Commit 4de233a7 authored by Lennart Bader's avatar Lennart Bader
Browse files

Added information to AboutFragment, added App Icon, Added Plan Menu functionality

parent b66767c2
......@@ -9,7 +9,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher_mytfg_text"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.Base">
......
......@@ -27,6 +27,7 @@ import de.mytfg.apps.vplan.toolbar.ToolbarManager;
public class AboutFragment extends Fragment {
private View view;
private final String githubUrl = "https://github.com/MyTFG/mytfg-vplan-app";
public AboutFragment() {
......@@ -42,13 +43,15 @@ public class AboutFragment extends Fragment {
.setExpandable(true, true)
.setTabs(false);
/*Vplan plan = new Vplan(getContext(), "today");
plan.load(new SuccessCallback() {
ImageView github = (ImageView) view.findViewById(R.id.github);
github.setOnClickListener(new View.OnClickListener() {
@Override
public void callback(boolean success) {
public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(githubUrl));
startActivity(i);
}
});*/
});
return view;
}
......@@ -57,10 +60,4 @@ public class AboutFragment extends Fragment {
public void onResume() {
super.onResume();
}
private void openUrl(String url) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
}
......@@ -2,12 +2,16 @@ package de.mytfg.apps.vplan.fragments;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
......@@ -61,6 +65,65 @@ public class PlanFragment extends Fragment {
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
TabLayout tabLayout = context.getToolbarManager().getTabs();
Vplan plan = tabLayout.getSelectedTabPosition() == 0 ? todayPlan : tomorrowPlan;
if (!plan.isLoaded()) {
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) context.findViewById(R.id.coordinator_layout);
Snackbar snackbar = Snackbar
.make(coordinatorLayout,
getString(R.string.plan_not_loaded),
Snackbar.LENGTH_LONG);
snackbar.show();
return true;
}
switch (item.getItemId()) {
case R.id.show_absent:
AlertDialog.Builder absentDialog = new AlertDialog.Builder(context);
absentDialog.setTitle(getString(R.string.plan_absent));
String absent = null;
for (String msg : plan.getAbsentStrings()) {
if (absent == null) {
absent = msg;
} else {
absent += "\n\n" + msg;
}
}
absentDialog.setMessage(absent);
absentDialog.setIcon(R.drawable.ic_menu_absent);
AlertDialog abs = absentDialog.create();
abs.show();
return true;
case R.id.show_marquee:
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle(getString(R.string.plan_marquee));
String message = null;
for (String msg : plan.getMarquee()) {
if (message == null) {
message = msg;
} else {
message += "\n" + msg;
}
}
alertDialog.setMessage(message);
alertDialog.setIcon(R.drawable.ic_menu_about);
AlertDialog alert = alertDialog.create();
alert.show();
return true;
case R.id.show_time:
AlertDialog.Builder timeDialog = new AlertDialog.Builder(context);
timeDialog.setTitle(getString(R.string.plan_time));
String time = plan.getChanged();
timeDialog.setMessage(time);
timeDialog.setIcon(R.drawable.ic_menu_clock);
AlertDialog timeDlg = timeDialog.create();
timeDlg.show();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onResume() {
super.onResume();
......
......@@ -30,8 +30,9 @@ public class Vplan extends MytfgObject {
private String cls_string;
private String day_str;
private String changed;
private String marquee;
private List<String> marquee = new LinkedList<>();
private List<Pair<String, String>> absent_teachers = new LinkedList<>();
private List<String> absent_strings = new LinkedList<>();
private int lastCode;
private boolean loaded;
......@@ -77,7 +78,9 @@ public class Vplan extends MytfgObject {
private boolean parse(JSONObject result) {
this.entries = new LinkedList<>();
this.marquee = new LinkedList<>();
this.absent_teachers = new LinkedList<>();
this.absent_strings = new LinkedList<>();
try {
JSONObject plan = result.getJSONObject("plan");
this.day_str = plan.getString("day_str");
......@@ -87,6 +90,18 @@ public class Vplan extends MytfgObject {
vplanEntry.load(this, entries.getJSONObject(i));
this.entries.add(vplanEntry);
}
JSONArray marquee = plan.getJSONArray("marquee");
for (int i = 0; i < marquee.length(); ++i) {
this.marquee.add(marquee.getString(i));
}
JSONArray absent = plan.getJSONArray("absent_teachers");
JSONArray absentlessons = plan.getJSONArray("absent_lessons");
for (int i = 0; i < absent.length(); ++i) {
Pair<String, String> p = new Pair<>(absent.getString(i), absentlessons.getString(i));
this.absent_teachers.add(p);
this.absent_strings.add(p.first + ": " + p.second);
}
changed = plan.getString("changed");
} catch (JSONException ex) {
ex.printStackTrace();
return false;
......@@ -102,6 +117,18 @@ public class Vplan extends MytfgObject {
return day;
}
public List<String> getMarquee() {
return marquee;
}
public List<String> getAbsentStrings() {
return absent_strings;
}
public String getChanged() {
return changed;
}
public List<VplanEntry> getEntries() {
return entries;
}
......
......@@ -40,12 +40,48 @@
android:layout_gravity="end"
android:layout_height="60dp"
android:layout_marginEnd="@dimen/cardview_default_radius"
android:scaleType="centerInside"
android:scaleType="fitEnd"
android:src="@mipmap/mytfg"
android:layout_marginRight="@dimen/cardview_default_radius" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/cardview_spacing"
android:layout_marginBottom="@dimen/defaultPadding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/cardview_spacing"
android:background="@color/colorPrimaryLight">
<TextView
android:textSize="@dimen/textTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about_opensource" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textDefault"
android:text="@string/about_opensource_text" />
<ImageView
android:layout_width="200dp"
android:layout_gravity="end"
android:layout_height="60dp"
android:layout_marginEnd="@dimen/cardview_default_radius"
android:scaleType="fitEnd"
android:id="@+id/github"
android:src="@mipmap/github"
android:layout_marginRight="@dimen/cardview_default_radius" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
......@@ -9,4 +9,8 @@
android:icon="@drawable/ic_show_marquee"
android:title="@string/plan_show_marquee"
app:showAsAction="ifRoom" />
<item android:id="@+id/show_time"
android:icon="@drawable/ic_show_time"
android:title="@string/plan_show_time"
app:showAsAction="ifRoom" />
</menu>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment