Version 1.3.0 (little design overhaul) with additional fixes

This commit is contained in:
Deniz Düzgören
2019-05-09 07:48:17 +02:00
parent 4c3d011c6f
commit 907a746b55
35 changed files with 392 additions and 1167 deletions
@@ -198,9 +198,9 @@ public class CardAdapter extends RecyclerView.Adapter<CardAdapter.CardViewHolder
} finally {
if (colour == 0) {
if (prefs.getInt("themeInt", 0) == 1) {
colour = R.color.lightgrey;
colour = R.color.textLight;
} else {
colour = R.color.lessdark;
colour = R.color.textDark;
}
}
holder.mImageView.getDrawable().setTint(ContextCompat.getColor(holder.mImageView.getContext(), colour));
@@ -0,0 +1,79 @@
package com.denizd.substitutionplan;
public class DataGetter {
protected static int getIcon(String course) {
if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) {
return R.drawable.ic_german;
} else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) {
return R.drawable.ic_maths;
} else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) {
return R.drawable.ic_english;
} else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) {
return R.drawable.ic_pe;
} else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) {
return R.drawable.ic_politics;
} else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) {
return R.drawable.ic_drama;
} else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) {
return R.drawable.ic_physics;
} else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) {
return R.drawable.ic_biology;
} else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) {
return R.drawable.ic_chemistry;
} else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) {
return R.drawable.ic_philosophy;
} else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) {
return R.drawable.ic_latin;
} else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) {
return R.drawable.ic_spanish;
} else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) {
return R.drawable.ic_french;
} else if (course.toLowerCase().contains("inf")) {
return R.drawable.ic_compsci;
} else if (course.toLowerCase().contains("ges")) {
return R.drawable.ic_history;
} else if (course.toLowerCase().contains("rel")) {
return R.drawable.ic_religion;
} else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) {
return R.drawable.ic_geography;
} else if (course.toLowerCase().contains("kun")) {
return R.drawable.ic_arts;
} else if (course.toLowerCase().contains("mus")) {
return R.drawable.ic_music;
} else if (course.toLowerCase().contains("tue")) {
return R.drawable.ic_turkish;
} else if (course.toLowerCase().contains("chi")) {
return R.drawable.ic_chinese;
} else if (course.toLowerCase().contains("gll")) {
return R.drawable.ic_gll;
} else if (course.toLowerCase().contains("wat")) {
return R.drawable.ic_wat;
} else if (course.toLowerCase().contains("för")) {
return R.drawable.ic_help;
} else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) {
return R.drawable.ic_pencil;
} else {
return R.drawable.ic_empty;
}
}
protected static String[] boy = {"Cedric Grislawski", "Dawid Kniola", "Jonas Köstergarten", "Jakob Moerschner", "Siamak Nemati", "Hendrik Plönnings",
"Jan Rohmann", "Anton Rosenberger", "Christoph Senft", "Jan Mika Sieckendieck", "Alexander Sinaj",
"Nico Tischer", "Nhat Vinh Tran", "Leon Becker", "Youssef Beltagi", "Erich Kerkesner", "Alex Lick",
"Oskar Piskorz", "Theo Recktor", "Eray Vatansever", "Dennis Wojciechowski", "Übeydullah Alkan",
"Yahya Almarashli", "Sinan Aydin", "Rick Büteröwe", "Levin Dropp", "Silvester Jermolajew", "Tolgay Kekilli",
"Dennis Lange", "Aras Mahmoud", "Batuhan Özcan", "Michael Rek", "Khabat Sharif", "Anbinh Tran",
"Bastian Westerboer", "Abdulwahab Alshebli", "Kelechi Gaius", "Armin Großmann", "Anes Halep",
"Marco Jankowski", "Emirhan Kaplan", "Alexander Kofmann", "Tobi Derek Köhler", "Vasilije Nedeljkovic",
"Batu Öcal", "Paul Rehbohm"};
protected static String[] girl = {"Mayra Dronia", "Shalin Ramadan", "Nigina Amin", "Mariya Kheder", "Niegen Khosrawi", "Dayana Osipova",
"Julia Petri", "Laura Pister", "Dana Alyoussef", "Ilkem Kahramanoglu", "Rozita Amiri", "Mirja Arneke",
"Nastasja Banik", "Anni Kienke", "Benedite Mateta", "Leonie Pohl", "Cecillia Sawires", "Patrycja Smółka",
"Elif Zencirkiran", "Nusyba Al Semadi", "Vivien Bruns", "Yasemin Dal", "Svenja Demuth", "Nina Groß",
"Kim Lahmeyer", "Luca Minschke", "Kim Reschke", "Amélie Schnellecke", "Delal Secer", "Xenia Segijanski",
"Melisa Tas", "Kim Völker", "Banu Yari", "Zeinab Ali", "Mariam Bannout", "Stefanie Fahl", "Yamaty Gaye",
"Anna-Sophia Haeberle", "Finja Hastedt", "Viktoria Hammermeister", "Isabel Horn", "Laura Kern",
"Melanie Kleinermann", "Målin Kollhoff", "Darja Maier", "Lisa Maier", "Naura Nadzifah", "Janina Roelfs",
"Vanessa Scheifler", "Mara Thies", "Lieli Umar", "Leonie Welk", "Betraben Yacoub"};
}
@@ -6,7 +6,6 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Animatable;
@@ -14,13 +13,11 @@ import android.os.Build;
import android.os.Handler;
import android.preference.PreferenceManager;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewAnimationUtils;
@@ -36,14 +33,11 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.jaredrummler.android.device.DeviceName;
import java.util.Calendar;
public class FirstTime extends AppCompatActivity {
private String manufacturer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -85,32 +79,6 @@ public class FirstTime extends AppCompatActivity {
final ImageButton helpClasses = findViewById(R.id.chipHelpClasses);
final ImageButton helpCourses = findViewById(R.id.chipHelpCourses);
// TODO Huawei
// DeviceName.with(context).request(new DeviceName.Callback() {
// @Override
// public void onFinished(DeviceName.DeviceInfo info, Exception error) {
// manufacturer = info.manufacturer;
// if (manufacturer.contains("Huawei") ||
// manufacturer.contains("Honor")) {
//// if (true) {
// notif.setEnabled(false);
//
// @ColorInt int color;
//
// TypedValue typedValue = new TypedValue();
// Resources.Theme theme = context.getTheme();
// theme.resolveAttribute(R.attr.colorHint, typedValue, true);
// color = typedValue.data;
//
// notif.setTextColor(color);
// edit.putBoolean("notif", false);
// edit.putBoolean("autoRefresh", true);
// edit.apply();
// }
// }
// });
helpCourses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -1,8 +1,5 @@
package com.denizd.substitutionplan;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
public class Food {
private String food;
@@ -3,7 +3,6 @@ package com.denizd.substitutionplan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
@@ -3,9 +3,7 @@ package com.denizd.substitutionplan
import android.content.SharedPreferences
import android.os.Bundle
import android.preference.PreferenceManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@@ -22,19 +22,15 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
import static com.google.android.material.snackbar.Snackbar.make;
public class FragmentFood extends Fragment {
@@ -55,9 +51,6 @@ public class FragmentFood extends Fragment {
super.onViewCreated(view, savedInstanceState);
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefreshFood);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
final SharedPreferences.Editor edit = prefs.edit();
final LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_animation_fall_down);
final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
EasyPrefrences easyPrefs = new EasyPrefrences(getContext());
ArrayList<String> foodListPopulation = new ArrayList<>(easyPrefs.getListString("foodListPrefs"));
@@ -70,12 +63,6 @@ public class FragmentFood extends Fragment {
mAdapter = new FoodAdapter(foodArrayList);
recyclerView.setAdapter(mAdapter);
// try {
// recyclerView.removeAllViews();
// } catch (NullPointerException e) {
//
// }
for (int i = 0; i < foodListPopulation.size(); i++) {
foodArrayList.add(new Food(foodListPopulation.get(i)));
mAdapter.setFood(foodArrayList);
@@ -104,8 +91,6 @@ public class FragmentFood extends Fragment {
boolean attempt = false, npe = false;
Elements foodElements;
Document docFood;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
final SharedPreferences.Editor edit = prefs.edit();
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefreshFood);
protected fetcher() {
@@ -122,7 +107,6 @@ public class FragmentFood extends Fragment {
progressBar.setProgress(0);
progressBar.setMax(foodElements.size());
// progressBar.incrementProgressBy(paragraphs[0].size());
} catch (IOException e1) {
npe = true;
} catch (NullPointerException e1) {
@@ -197,9 +181,6 @@ public class FragmentFood extends Fragment {
ArrayList<String> foodListPopulation = new ArrayList<>(easyPrefs.getListString("foodListPrefs"));
final LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_animation_fall_down);
final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
for (int i = 0; i < foodListPopulation.size(); i++) {
foodArrayList.add(new Food(foodListPopulation.get(i)));
mAdapter.setFood(foodArrayList);
@@ -240,7 +221,6 @@ public class FragmentFood extends Fragment {
}
} catch (NullPointerException e) {
// pullToRefresh.setRefreshing(false);
}
} else if (npe) {
pullToRefresh.setRefreshing(false);
@@ -1,6 +1,5 @@
package com.denizd.substitutionplan;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -11,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
import com.madapps.prefrences.EasyPrefrences;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
@@ -43,7 +43,6 @@ import java.util.Comparator;
import java.util.Date;
import java.util.List;
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
import static com.google.android.material.snackbar.Snackbar.make;
public class FragmentPersonal extends Fragment {
@@ -55,6 +54,7 @@ public class FragmentPersonal extends Fragment {
private TextView bottomSheetText;
private SubstViewModel substViewModel;
private boolean persPlanEmpty;
private EasyPrefrences easyPrefs;
@Nullable
@Override
@@ -69,6 +69,7 @@ public class FragmentPersonal extends Fragment {
bottomSheetText = getView().getRootView().findViewById(R.id.bottom_sheet_text);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
final SharedPreferences.Editor edit = prefs.edit();
easyPrefs = new EasyPrefrences(getContext());
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
@@ -144,6 +145,7 @@ public class FragmentPersonal extends Fragment {
recyclerView.scheduleLayoutAnimation();
mAdapter.setSubst(planCardList);
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
@@ -163,9 +165,6 @@ public class FragmentPersonal extends Fragment {
}
});
// pullToRefresh.setRefreshing(true);
// new fetcher().execute();
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
@@ -180,9 +179,9 @@ public class FragmentPersonal extends Fragment {
private int count = 0, pCount = 0, priority = 200;
final String OLD_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz", NEW_FORMAT = "yyyy-MM-dd, HH:mm:ss";
String newDateString, informational;
String newDateString;
String[] groupS, dateS, timeS, courseS, roomS, additionalS;
boolean attempt = false, npe = false, emptyIcon;
boolean attempt = false, npe = false;
URL url;
URLConnection connection;
String modified;
@@ -194,6 +193,7 @@ public class FragmentPersonal extends Fragment {
ProgressBar progressBar;
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
Date d;
private ArrayList<String> informationalList = new ArrayList<>();
protected fetcher() {
}
@@ -214,16 +214,6 @@ public class FragmentPersonal extends Fragment {
pCount = paragraphs.size();
attempt = true;
for (int i = 0; i < pCount; i++) {
if (i == 0) {
informational = paragraphs.get(i).text();
} else {
informational += "\n\n" + paragraphs.get(i).text();
}
}
edit.putString("informational", informational);
edit.apply();
groupS = new String[count];
dateS = new String[count];
timeS = new String[count];
@@ -249,13 +239,23 @@ public class FragmentPersonal extends Fragment {
additionalS[i] = cols.get(5).text();
progressBar.incrementProgressBy(1);
int drawable = icons(courseS[i]);
int drawable = DataGetter.getIcon(courseS[i]);
Subst subst = new Subst(drawable, groupS[i], dateS[i], timeS[i], courseS[i], roomS[i], additionalS[i], priority);
substViewModel.insert(subst);
priority--;
}
}
for (int i = 0; i < pCount; i++) {
if (i == 0) {
informationalList.add(paragraphs.get(i).text());
} else {
informationalList.add("\n\n" + paragraphs.get(i).text());
}
}
easyPrefs.putListString("informationalList", informationalList);
} catch (IOException e1) {
npe = true;
} catch (NullPointerException e1) {
@@ -265,110 +265,48 @@ public class FragmentPersonal extends Fragment {
return null;
}
private int icons(String course) {
emptyIcon = false;
if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) {
return R.drawable.ic_german;
} else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) {
return R.drawable.ic_maths;
} else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) {
return R.drawable.ic_english;
} else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) {
return R.drawable.ic_pe;
} else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) {
return R.drawable.ic_politics;
} else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) {
return R.drawable.ic_drama;
} else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) {
return R.drawable.ic_physics;
} else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) {
return R.drawable.ic_biology;
} else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) {
return R.drawable.ic_chemistry;
} else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) {
return R.drawable.ic_philosophy;
} else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) {
return R.drawable.ic_latin;
} else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) {
return R.drawable.ic_spanish;
} else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) {
return R.drawable.ic_french;
} else if (course.toLowerCase().contains("inf")) {
return R.drawable.ic_compsci;
} else if (course.toLowerCase().contains("ges")) {
return R.drawable.ic_history;
} else if (course.toLowerCase().contains("rel")) {
return R.drawable.ic_religion;
} else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) {
return R.drawable.ic_geography;
} else if (course.toLowerCase().contains("kun")) {
return R.drawable.ic_arts;
} else if (course.toLowerCase().contains("mus")) {
return R.drawable.ic_music;
} else if (course.toLowerCase().contains("tue")) {
return R.drawable.ic_turkish;
} else if (course.toLowerCase().contains("chi")) {
return R.drawable.ic_chinese;
} else if (course.toLowerCase().contains("gll")) {
return R.drawable.ic_gll;
} else if (course.toLowerCase().contains("wat")) {
return R.drawable.ic_wat;
} else if (course.toLowerCase().contains("för")) {
return R.drawable.ic_help;
} else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) {
return R.drawable.ic_pencil;
} else {
emptyIcon = true;
return R.drawable.ic_empty;
}
}
@Override
protected void onPostExecute(Void result) {
try {
if (attempt) {
final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.fade_out);
if (attempt) {
final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.fade_out);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
progressBar.startAnimation(fadeOut);
}
}, 200);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
progressBar.startAnimation(fadeOut);
}
}, 200);
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
progressBar.setProgress(0);
}
});
@Override
public void onAnimationEnd(Animation arg0) {
progressBar.setProgress(0);
}
});
sdf.applyPattern(NEW_FORMAT);
newDateString = sdf.format(d);
View contextView = getView().getRootView().findViewById(R.id.coordination);
Snackbar snackbar = make(contextView, getText(R.string.lastupdated) + ": " + newDateString, Snackbar.LENGTH_LONG)
.setAction("Action", null);
snackbar.show();
pullToRefresh.setRefreshing(false);
} else if (npe) {
pullToRefresh.setRefreshing(false);
View contextView = getView().getRootView().findViewById(R.id.coordination);
Snackbar snackbar = make(contextView, getText(R.string.nointernet), Snackbar.LENGTH_LONG)
.setAction("Action", null);
snackbar.show();
}
} catch (NullPointerException e) {
sdf.applyPattern(NEW_FORMAT);
newDateString = sdf.format(d);
View contextView = getView().getRootView().findViewById(R.id.coordination);
Snackbar snackbar = make(contextView, getText(R.string.lastupdated) + ": " + newDateString, Snackbar.LENGTH_LONG)
.setAction("Action", null);
snackbar.show();
pullToRefresh.setRefreshing(false);
} else if (npe) {
pullToRefresh.setRefreshing(false);
View contextView = getView().getRootView().findViewById(R.id.coordination);
Snackbar snackbar = make(contextView, getText(R.string.nointernet), Snackbar.LENGTH_LONG)
.setAction("Action", null);
snackbar.show();
}
}
@@ -23,7 +23,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -93,17 +92,7 @@ public class FragmentPlan extends Fragment {
substViewModel.getAllSubst().observe(this, new Observer<List<Subst>>() {
@Override
public void onChanged(List<Subst> substs) {
// LayoutAnimationController animationOut = AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_animation_fall_down_out);
// LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_animation_fall_down);
// recyclerView.setLayoutAnimation(animationOut);
// recyclerView.scheduleLayoutAnimation();
mAdapter.setSubst(substs);
for (int i = 0; i < mAdapter.getItemCount(); i++) {
}
// recyclerView.setLayoutAnimation(animationIn);
recyclerView.scheduleLayoutAnimation();
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
}
@@ -126,7 +115,7 @@ public class FragmentPlan extends Fragment {
final String OLD_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz", NEW_FORMAT = "yyyy-MM-dd, HH:mm:ss";
String newDateString, informational;
String[] groupS, dateS, timeS, courseS, roomS, additionalS;
boolean attempt = false, npe = false, emptyIcon;
boolean attempt = false, npe = false;
URL url;
URLConnection connection;
String modified;
@@ -193,7 +182,7 @@ public class FragmentPlan extends Fragment {
additionalS[i] = cols.get(5).text();
progressBar.incrementProgressBy(1);
int drawable = icons(courseS[i]);
int drawable = DataGetter.getIcon(courseS[i]);
Subst subst = new Subst(drawable, groupS[i], dateS[i], timeS[i], courseS[i], roomS[i], additionalS[i], priority);
substViewModel.insert(subst);
priority--;
@@ -209,64 +198,6 @@ public class FragmentPlan extends Fragment {
return null;
}
private int icons(String course) {
emptyIcon = false;
if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) {
return R.drawable.ic_german;
} else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) {
return R.drawable.ic_maths;
} else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) {
return R.drawable.ic_english;
} else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) {
return R.drawable.ic_pe;
} else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) {
return R.drawable.ic_politics;
} else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) {
return R.drawable.ic_drama;
} else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) {
return R.drawable.ic_physics;
} else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) {
return R.drawable.ic_biology;
} else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) {
return R.drawable.ic_chemistry;
} else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) {
return R.drawable.ic_philosophy;
} else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) {
return R.drawable.ic_latin;
} else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) {
return R.drawable.ic_spanish;
} else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) {
return R.drawable.ic_french;
} else if (course.toLowerCase().contains("inf")) {
return R.drawable.ic_compsci;
} else if (course.toLowerCase().contains("ges")) {
return R.drawable.ic_history;
} else if (course.toLowerCase().contains("rel")) {
return R.drawable.ic_religion;
} else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) {
return R.drawable.ic_geography;
} else if (course.toLowerCase().contains("kun")) {
return R.drawable.ic_arts;
} else if (course.toLowerCase().contains("mus")) {
return R.drawable.ic_music;
} else if (course.toLowerCase().contains("tue")) {
return R.drawable.ic_turkish;
} else if (course.toLowerCase().contains("chi")) {
return R.drawable.ic_chinese;
} else if (course.toLowerCase().contains("gll")) {
return R.drawable.ic_gll;
} else if (course.toLowerCase().contains("wat")) {
return R.drawable.ic_wat;
} else if (course.toLowerCase().contains("för")) {
return R.drawable.ic_help;
} else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) {
return R.drawable.ic_pencil;
} else {
emptyIcon = true;
return R.drawable.ic_empty;
}
}
@Override
protected void onPostExecute(Void result) {
try {
@@ -1,16 +1,11 @@
package com.denizd.substitutionplan;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.material.snackbar.Snackbar;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
@@ -22,23 +17,12 @@ import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.android.material.snackbar.Snackbar.make;
public class FragmentSearch extends Fragment {
ConstraintLayout constraintLayout;
@@ -119,12 +103,6 @@ public class FragmentSearch extends Fragment {
if (substs.get(i).getGroup().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
search = true;
}
if (substs.get(i).getDate().toLowerCase().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
search = true;
}
if (substs.get(i).getTime().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
search = true;
}
if (substs.get(i).getCourse().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
search = true;
}
@@ -140,179 +118,7 @@ public class FragmentSearch extends Fragment {
search = false;
}
}
recyclerView.scheduleLayoutAnimation();
}
}
// private class fetcher extends AsyncTask<Void, Void, Void> {
//
// private int count = 0, iconColour;
// String[] groupS, dateS, timeS, courseS, roomS, additionalS;
// boolean attempt = false, search = false, first = false, npe = false, emptyIcon;
// Elements rows;
// Document doc;
// final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
// private RecyclerView recyclerView;
// private CardAdapter mAdapter;
// private RecyclerView.LayoutManager layoutManager;
// private ArrayList<Subst> planCardList;
//
// protected fetcher() {}
//
// @Override
// protected Void doInBackground(Void... params) {
//
// if (!first) {
// try {
// doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get();
// rows = doc.select("tr");
// count = rows.size();
// attempt = true;
//
// } catch (IOException e1) {
// npe = true;
// }
//
// groupS = new String[count];
// dateS = new String[count];
// timeS = new String[count];
// courseS = new String[count];
// roomS = new String[count];
// additionalS = new String[count];
//
// if (attempt) {
// for (int i = 0; i < count; i++) {
// Element row = rows.get(i);
// Elements cols = row.select("th");
// groupS[i] = cols.get(0).text();
// dateS[i] = cols.get(1).text();
// timeS[i] = cols.get(2).text();
// courseS[i] = cols.get(3).text();
// roomS[i] = cols.get(4).text();
// additionalS[i] = cols.get(5).text();
// }
// }
//
// if (prefs.getInt("themeInt", 0) == 0) {
// iconColour = Color.parseColor("#212121");
// }
// if (prefs.getInt("themeInt", 0) == 1) {
// iconColour = Color.parseColor("#e0e0e0");
// }
// first = true;
// }
//
// return null;
// }
//
// private int icons(String[] courseS, int i) {
// emptyIcon = false;
// if (courseS[i].toLowerCase().contains("deu") || courseS[i].toLowerCase().contains("dep") || courseS[i].toLowerCase().contains("daz")) {
// return R.drawable.ic_german;
// } else if (courseS[i].toLowerCase().contains("mat") || courseS[i].toLowerCase().contains("map")) {
// return R.drawable.ic_maths;
// } else if (courseS[i].toLowerCase().contains("eng") || courseS[i].toLowerCase().contains("enp") || courseS[i].toLowerCase().contains("ena")) {
// return R.drawable.ic_english;
// } else if (courseS[i].toLowerCase().contains("spo") || courseS[i].toLowerCase().contains("spp") || courseS[i].toLowerCase().contains("spth")) {
// return R.drawable.ic_pe;
// } else if (courseS[i].toLowerCase().contains("pol") || courseS[i].toLowerCase().contains("pop")) {
// return R.drawable.ic_politics;
// } else if (courseS[i].toLowerCase().contains("dar") || courseS[i].toLowerCase().contains("dap")) {
// return R.drawable.ic_drama;
// } else if (courseS[i].toLowerCase().contains("phy") || courseS[i].toLowerCase().contains("php")) {
// return R.drawable.ic_physics;
// } else if (courseS[i].toLowerCase().contains("bio") || courseS[i].toLowerCase().contains("bip") || courseS[i].toLowerCase().contains("nw")) {
// return R.drawable.ic_biology;
// } else if (courseS[i].toLowerCase().contains("che") || courseS[i].toLowerCase().contains("chp")) {
// return R.drawable.ic_chemistry;
// } else if (courseS[i].toLowerCase().contains("phi") || courseS[i].toLowerCase().contains("psp")) {
// return R.drawable.ic_philosophy;
// } else if (courseS[i].toLowerCase().contains("laa") || courseS[i].toLowerCase().contains("laf") || courseS[i].toLowerCase().contains("lat")) {
// return R.drawable.ic_latin;
// } else if (courseS[i].toLowerCase().contains("spa") || courseS[i].toLowerCase().contains("spf")) {
// return R.drawable.ic_spanish;
// } else if (courseS[i].toLowerCase().contains("fra") || courseS[i].toLowerCase().contains("frf") || courseS[i].toLowerCase().contains("frz")) {
// return R.drawable.ic_french;
// } else if (courseS[i].toLowerCase().contains("inf")) {
// return R.drawable.ic_compsci;
// } else if (courseS[i].toLowerCase().contains("ges")) {
// return R.drawable.ic_history;
// } else if (courseS[i].toLowerCase().contains("rel")) {
// return R.drawable.ic_religion;
// } else if (courseS[i].toLowerCase().contains("geg") || courseS[i].toLowerCase().contains("wuk")) {
// return R.drawable.ic_geography;
// } else if (courseS[i].toLowerCase().contains("kun")) {
// return R.drawable.ic_arts;
// } else if (courseS[i].toLowerCase().contains("mus")) {
// return R.drawable.ic_music;
// } else if (courseS[i].toLowerCase().contains("tue")) {
// return R.drawable.ic_turkish;
// } else if (courseS[i].toLowerCase().contains("chi")) {
// return R.drawable.ic_chinese;
// } else if (courseS[i].toLowerCase().contains("gll")) {
// return R.drawable.ic_gll;
// } else if (courseS[i].toLowerCase().contains("wat")) {
// return R.drawable.ic_wat;
// } else if (courseS[i].toLowerCase().contains("för")) {
// return R.drawable.ic_help;
// } else if (courseS[i].toLowerCase().contains("wp") || courseS[i].toLowerCase().contains("met")) {
// return R.drawable.ic_pencil;
// } else {
// emptyIcon = true;
// return R.drawable.ic_empty;
// }
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (attempt) {
//
// try {
//
// planCardList = new ArrayList<>();
// recyclerView = getView().findViewById(R.id.linearRecyclerSearch);
// layoutManager = new LinearLayoutManager(getContext());
// recyclerView.setHasFixedSize(true);
// recyclerView.setLayoutManager(layoutManager);
// mAdapter = new CardAdapter(planCardList);
// recyclerView.setAdapter(mAdapter);
// } catch (NullPointerException e) {
// return;
// }
// recyclerView.removeAllViews();
// EditText searchfield = getView().findViewById(R.id.searchbar);
// final Animation animationIn = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in);
//
// for (int i = 0; i < count; i++) {
// if (groupS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// } if (dateS[i].toLowerCase().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// } if (timeS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// } if (courseS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// } if (roomS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// } if (additionalS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
// search = true;
// }
//
// if (search) {
// Drawable drawable = getResources().getDrawable(icons(courseS, i));
// if (!emptyIcon) {
// drawable.setTint(iconColour);
// }
// planCardList.add(new Subst(0, groupS[i], dateS[i], timeS[i], courseS[i], roomS[i], additionalS[i], 0));
// recyclerView.setAnimation(animationIn);
// search = false;
// }
// }
// } else if (npe) {
// View contextView = getView().getRootView().findViewById(R.id.coordination);
// Snackbar snackbar = make(contextView, getText(R.string.nointernet), Snackbar.LENGTH_LONG)
// .setAction("Action", null);
// snackbar.show();
// }
// }
// }
}
@@ -2,16 +2,13 @@ package com.denizd.substitutionplan;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
@@ -21,7 +18,6 @@ import androidx.fragment.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,17 +34,16 @@ import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.jaredrummler.android.device.DeviceName;
import org.w3c.dom.Text;
import java.text.DecimalFormat;
import java.util.Random;
public class FragmentSettings extends Fragment implements View.OnClickListener {
CoordinatorLayout coordinatorLayout;
private int cs = 7, i = 0;
private String manufacturer, name, model;
private String name, model;
@Nullable
@Override
@@ -75,14 +70,14 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
builder.setToolbarColor(getResources().getColor(R.color.white));
final CustomTabsIntent customTabsIntent = builder.build();
final EditText txtName = getView().findViewById(R.id.txtName);
final TextInputEditText txtName = getView().findViewById(R.id.txtName);
final Switch greeting = getView().findViewById(R.id.switchDisableGreeting);
final Switch darkmode = getView().findViewById(R.id.switchDark);
final Switch showinfo = getView().findViewById(R.id.switchHideInfo);
final LinearLayout customiseColours = getView().findViewById(R.id.btnCustomiseColours);
final EditText txtClasses = getView().findViewById(R.id.txtClasses);
final EditText txtCourses = getView().findViewById(R.id.txtCourses);
final TextInputEditText txtClasses = getView().findViewById(R.id.txtClasses);
final TextInputEditText txtCourses = getView().findViewById(R.id.txtCourses);
final ImageButton helpClasses = getView().findViewById(R.id.chipHelpClasses);
final ImageButton helpCourses = getView().findViewById(R.id.chipHelpCourses);
@@ -99,11 +94,6 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
final LinearLayout privacy = getView().findViewById(R.id.btnPrivacyP);
final LinearLayout version = getView().findViewById(R.id.btnVersion);
final TextView notif1 = getView().findViewById(R.id.txtNotifications);
final TextView auto1 = getView().findViewById(R.id.txtAutoRefresh);
final TextView notif2 = getView().findViewById(R.id.txtNotifiedAbout);
final TextView auto2 = getView().findViewById(R.id.txtAutoRefreshTwo);
helpCourses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -246,7 +236,6 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
} else {
colourCustomiserBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
}
// colourCustomiserBuilder.setTitle(getString(R.string.customisecolor1));
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.empty_dialog, null);
TextView titleText = dialogView.findViewById(R.id.empty_textviewtitle);
titleText.setText(R.string.customisecolor1);
@@ -276,7 +265,6 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
} else {
colourPickerBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
}
// colourPickerBuilder.setTitle(title);
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.empty_dialog, null);
TextView titleText = dialogView.findViewById(R.id.empty_textviewtitle);
titleText.setText(title);
@@ -336,7 +324,6 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
colourCustomiserDialog.cancel();
}
});
// alertDialog.setPositiveButton(R.string.finish, null);
colourCustomiserDialog.show();
}
});
@@ -456,46 +443,6 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
}
});
// TODO check whether Huawei devices actually support background services
// DeviceName.with(getContext()).request(new DeviceName.Callback() {
// @Override
// public void onFinished(DeviceName.DeviceInfo info, Exception error) {
// manufacturer = info.manufacturer;
// if (manufacturer.contains("Huawei") ||
// manufacturer.contains("Honor")) {
//// if (true) {
// notifswitch.setChecked(false);
// autoRefresh.setChecked(true);
// notifswitch.setEnabled(false);
// autoRefresh.setEnabled(false);
//
// @ColorInt int color;
// if (prefs.getInt("themeInt", 0) == 1) {
// TypedValue typedValue = new TypedValue();
// Resources.Theme theme = getContext().getTheme();
// theme.resolveAttribute(R.attr.colorHintDark, typedValue, true);
// color = typedValue.data;
// notif2.setTextColor(color);
// auto2.setTextColor(color);
// } else {
// TypedValue typedValue = new TypedValue();
// Resources.Theme theme = getContext().getTheme();
// theme.resolveAttribute(R.attr.colorHint, typedValue, true);
// color = typedValue.data;
// }
//
// notif1.setTextColor(color);
// auto1.setTextColor(color);
// edit.putBoolean("notif", false);
// edit.putBoolean("autoRefresh", true);
// edit.apply();
// notif2.setText(R.string.chinaNotif);
// auto2.setText(R.string.chinaAuto);
// }
// }
// });
website.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -519,12 +466,12 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
}
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
TextView title = dialogView.findViewById(R.id.textviewtitle);
title.setText("Licenses");
title.setText("Licences");
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
dialogText.setText("Libraries:\n • Android Device Names © 2015 Jared Rummler, licensed under the Apache License, Version 2.0" +
"\n • EasyPreferences © 2018 Mukesh Solanki, licensed under the MIT License" +
"\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT License" +
"\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font License 1.1" +
dialogText.setText("Libraries:\n • Android Device Names © 2015 Jared Rummler, licensed under the Apache Licence, Version 2.0" +
"\n • EasyPreferences © 2018 Mukesh Solanki, licensed under the MIT Licence" +
"\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT Licence" +
"\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font Licence 1.1" +
"\n\nIcons:\n • bqlqn\n • fjstudio\n • Freepik\n • Smashicons\n • © 2013-2019 Freepik Company S.L., licensed under Creative Commons BY 3.0" +
"\n\nMarketing & Publishing:\n • Leon Becker\n • Alex Lick\n • Batuhan Özcan\n • Erich Kerkesner");
alertDialog.setView(dialogView);
@@ -758,8 +705,8 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
title.setText(R.string.dating);
Button datingBtn = dialogView.findViewById(R.id.dating_btn);
final EditText boyT = dialogView.findViewById(R.id.dating_txt1);
final EditText girlT = dialogView.findViewById(R.id.dating_txt2);
final TextInputEditText boyT = dialogView.findViewById(R.id.dating_txt1);
final TextInputEditText girlT = dialogView.findViewById(R.id.dating_txt2);
final CheckBox boy = dialogView.findViewById(R.id.cb1);
final CheckBox girl = dialogView.findViewById(R.id.cb2);
final TextView percentage = dialogView.findViewById(R.id.dating_txtp);
@@ -769,10 +716,10 @@ public class FragmentSettings extends Fragment implements View.OnClickListener {
try {
double boyP = 0, girlP = 0, perc = 0;
if (boyT.getText().toString().isEmpty() || boy.isChecked()) {
boyT.setText(names.boy[gen.nextInt(names.boy.length)]);
boyT.setText(DataGetter.boy[gen.nextInt(DataGetter.boy.length)]);
}
if (girlT.getText().toString().isEmpty() || girl.isChecked()) {
girlT.setText(names.girl[gen.nextInt(names.girl.length)]);
girlT.setText(DataGetter.girl[gen.nextInt(DataGetter.girl.length)]);
}
for (int i = 0; i < boyT.getText().length(); i++) {
boyP++;
@@ -43,6 +43,7 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -57,7 +58,6 @@ public class MainActivity extends AppCompatActivity {
BottomSheetBehavior bottomSheetBehaviour;
private String manufacturer;
private String marketName;
protected void job() {
ComponentName componentName = new ComponentName(this, ScheduledJobService.class);
@@ -77,7 +77,6 @@ public class MainActivity extends AppCompatActivity {
final SharedPreferences.Editor edit = prefs.edit();
final Intent firstTime = new Intent(this, FirstTime.class);
if (prefs.getBoolean("firstTime", true)) {
// if (true) {
startActivity(firstTime);
finish();
}
@@ -104,9 +103,6 @@ public class MainActivity extends AppCompatActivity {
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
final BottomNavigationView bottomNav = findViewById(R.id.bottom_nav);
final Chip chip = findViewById(R.id.chip);
@@ -160,19 +156,14 @@ public class MainActivity extends AppCompatActivity {
}
}
// TODO Huawei dialog
if (prefs.getBoolean("huaweiDeviceDialog", true)) {
// if (true) {
DeviceName.with(this).request(new DeviceName.Callback() {
@Override
public void onFinished(DeviceName.DeviceInfo info, Exception error) {
manufacturer = info.manufacturer;
marketName = info.marketName;
if (manufacturer.contains("Huawei") ||
manufacturer.contains("Honor") ||
manufacturer.contains("Xiaomi")) {
// if (true) {
AlertDialog.Builder alertDialog;
View dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null);
@@ -185,15 +176,6 @@ public class MainActivity extends AppCompatActivity {
}
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
dialogText.setText(R.string.chinaDialog);
// Button searchbtn = dialogView.findViewById(R.id.searchbtn);
// searchbtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
// intent.putExtra(SearchManager.QUERY, marketName + " disable power optimisation");
// startActivity(intent);
// }
// });
alertDialog.setView(dialogView);
alertDialog.show();
@@ -220,31 +202,36 @@ public class MainActivity extends AppCompatActivity {
}
});
ImageView iconinfo = findViewById(R.id.info_icon);
// theme change
if (prefs.getInt("themeInt", 0) == 0) {
setTheme(R.style.AppTheme0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.setStatusBarColor(ContextCompat.getColor(this, R.color.white));
window.setStatusBarColor(ContextCompat.getColor(this, R.color.darkwhite));
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.white));
toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.darkwhite));
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.darkwhite));
} else {
window.setStatusBarColor(ContextCompat.getColor(this, R.color.black));
window.setNavigationBarColor(ContextCompat.getColor(this, R.color.black));
}
toolbarTxt.setTextColor(ContextCompat.getColor(this, R.color.accent));
bottomNav.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
bottomNav.setBackgroundColor(ContextCompat.getColor(this, R.color.darkwhite));
bottomNav.setItemIconTintList(ContextCompat.getColorStateList(this, R.color.tintlist_light));
bottomNav.setItemTextColor(ContextCompat.getColorStateList(this, R.color.tintlist_light));
chip.setChipBackgroundColor(getResources().getColorStateList(R.color.chip_state_list));
chip.setTextColor(ContextCompat.getColor(this, R.color.lessdark));
bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.darkwhite));
bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.lessdark));
bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.lessdark));
bottomNavDivider.setBackgroundColor(ContextCompat.getColor(this, R.color.lightgrey));
iconinfo.setColorFilter(ContextCompat.getColor(context, R.color.lessdark), android.graphics.PorterDuff.Mode.SRC_IN);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.white));
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.darkwhite));
setTaskDescription(taskDesc);
}
if (prefs.getInt("themeInt", 0) == 1) {
@@ -252,8 +239,10 @@ public class MainActivity extends AppCompatActivity {
window.setStatusBarColor(ContextCompat.getColor(this, R.color.background));
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.dark));
toolbarTxt.setTextColor(ContextCompat.getColor(this, R.color.accent));
toolbarTxt.setTextColor(ContextCompat.getColor(this, R.color.accentPastel));
bottomNav.setBackgroundColor(ContextCompat.getColor(this, R.color.dark));
bottomNav.setItemIconTintList(ContextCompat.getColorStateList(this, R.color.tintlist_dark));
bottomNav.setItemTextColor(ContextCompat.getColorStateList(this, R.color.tintlist_dark));
window.setNavigationBarColor(getResources().getColor(R.color.background));
chip.setChipBackgroundColor(getResources().getColorStateList(R.color.chip_state_list_dark));
chip.setTextColor(ContextCompat.getColor(this, R.color.lightgrey));
@@ -261,6 +250,7 @@ public class MainActivity extends AppCompatActivity {
bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.lightgrey));
bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.lightgrey));
bottomNavDivider.setBackgroundColor(ContextCompat.getColor(this, R.color.darkdivider));
iconinfo.setColorFilter(ContextCompat.getColor(context, R.color.lightgrey), android.graphics.PorterDuff.Mode.SRC_IN);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, getResources().getColor(R.color.background));
@@ -345,7 +335,6 @@ public class MainActivity extends AppCompatActivity {
}
if (prefs.getInt("firstTimeOpening", 0) < 2) {
// if (true) {
final Handler bsbIn = new Handler();
bsbIn.postDelayed(new Runnable() {
@Override
@@ -449,10 +438,6 @@ public class MainActivity extends AppCompatActivity {
switcher = true;
}
break;
// case R.id.search:
// fragment = new FragmentSearch();
// toolbarTxt.setText(getString(R.string.search));
// break;
case R.id.menu:
if (getCurrentFragment().toString().contains("FragmentFood")) {
final RecyclerView recyclerView = findViewById(R.id.linear_food);
@@ -1,46 +0,0 @@
package com.denizd.substitutionplan;
import android.graphics.drawable.Drawable;
public class PlanCard {
private Drawable mIcon;
private String mGroup, mDate, mTime, mCourse, mRoom, mAdditional;
public PlanCard(Drawable icon, String group, String date, String time, String course, String room, String additional) {
mIcon = icon;
mGroup = group;
mDate = date;
mTime = time;
mCourse = course;
mRoom = room;
mAdditional = additional;
}
public Drawable getImageResource() {
return mIcon;
}
public String getGroup() {
return mGroup;
}
public String getDate() {
return mDate;
}
public String getTime() {
return mTime;
}
public String getCourse() {
return mCourse;
}
public String getRoom() {
return mRoom;
}
public String getAdditional() {
return mAdditional;
}
}
@@ -10,11 +10,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;
import android.widget.RemoteViews;
import android.widget.TextView;
import com.madapps.prefrences.EasyPrefrences;
@@ -30,8 +30,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class ScheduledJobService extends JobService {
@@ -50,41 +48,34 @@ public class ScheduledJobService extends JobService {
final SharedPreferences.Editor edit = prefs.edit();
substViewModel = new SubstViewModel(getApplication());
// substViewModel = ViewModelProviders.of().get(SubstViewModel.class);
// substViewModel.getAllSubst().observe(this, new Observer<List<Subst>>() {
// @Override
// public void onChanged(List<Subst> substs) {
new Thread(new Runnable() {
@Override
public void run() {
if (jobCancelled) {
return;
}
if (prefs.getBoolean("notif", false)) {
edit.putInt("notificationTestNumberDev", prefs.getInt("notificationTestNumberDev", 0) + 1);
new Thread(new Runnable() {
@Override
public void run() {
if (jobCancelled) {
return;
}
if (prefs.getBoolean("notif", false)) {
edit.putInt("notificationTestNumberDev", prefs.getInt("notificationTestNumberDev", 0) + 1);
edit.apply();
URL url;
URLConnection connection = null;
try {
url = new URL("https://djd4rkn355.github.io/subst");
connection = url.openConnection();
} catch (MalformedURLException e) {}
catch (IOException e) {}
try {
if ((!connection.getHeaderField("Last-Modified").equals(prefs.getString("time", "")))) {
new fetcher(context).execute();
edit.putString("time", connection.getHeaderField("Last-Modified"));
edit.apply();
URL url;
URLConnection connection = null;
try {
url = new URL("https://djd4rkn355.github.io/subst");
connection = url.openConnection();
} catch (MalformedURLException e) {}
catch (IOException e) {}
try {
if ((!connection.getHeaderField("Last-Modified").equals(prefs.getString("time", "")))) {
// if (true) {
new fetcher(context).execute();
edit.putString("time", connection.getHeaderField("Last-Modified"));
edit.apply();
}
} catch (NullPointerException e1) {
}
}
jobFinished(params, false);
} catch (NullPointerException e1) {
}
}).start();
// }
// });
}
jobFinished(params, false);
}
}).start();
}
@Override
@@ -95,18 +86,16 @@ public class ScheduledJobService extends JobService {
private class fetcher extends AsyncTask<Void, Void, Void> {
private int count = 0, columns = 0, pCount = 0, priority = 200;
private int count = 0, pCount = 0, priority = 200;
Context mContext;
String notifText = "", foodInfo = "", informational = "";
String notifText = "", informational = "";
String[] groupS, dateS, timeS, courseS, roomS, additionalS;
boolean attempt = false, emptyIcon;
URL url;
URLConnection connection;
String modified;
Elements rows, paragraphs;
Elements[] paragraphsFood = new Elements[2];
Elements foodElements;
Element[] dateFood = new Element[2], blockFood = new Element[2];
Document doc, docFood;
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "general";
@@ -228,7 +217,7 @@ public class ScheduledJobService extends JobService {
roomS[i] = cols.get(4).text();
additionalS[i] = cols.get(5).text();
int drawable = icons(courseS[i]);
int drawable = DataGetter.getIcon(courseS[i]);
Subst subst = new Subst(drawable, groupS[i], dateS[i], timeS[i], courseS[i], roomS[i], additionalS[i], priority);
priority--;
substViewModel.insert(subst);
@@ -267,97 +256,34 @@ public class ScheduledJobService extends JobService {
notificationLayout.setTextViewText(R.id.notification_title, getString(R.string.subst));
notificationLayout.setTextViewText(R.id.notification_textview, notifText);
if (!notifText.isEmpty()) {
Notification notification = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = new NotificationCompat.Builder(mContext) // TODO switch out the deprecated notification delivery method
// .setContentTitle(getString(R.string.subst))
// .setStyle(new NotificationCompat.BigTextStyle()
// .bigText(notifText))
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setChannelId(channelId)
.setContentIntent(openAppPending)
.setAutoCancel(true)
.build();
} else {
notification = new NotificationCompat.Builder(mContext)
// .setContentTitle(getString(R.string.subst))
// .setStyle(new NotificationCompat.BigTextStyle()
// .bigText(notifText))
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setContentIntent(openAppPending)
.setAutoCancel(true)
.build();
}
manager.notify(1, notification);
if (!notifText.isEmpty()) {
Notification notification;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = new NotificationCompat.Builder(mContext) // TODO switch out the deprecated notification delivery method
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setChannelId(channelId)
.setContentIntent(openAppPending)
.setAutoCancel(true)
.build();
} else {
notification = new NotificationCompat.Builder(mContext)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setContentIntent(openAppPending)
.setAutoCancel(true)
.build();
}
notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
manager.notify(1, notification);
}
}
return null;
}
private int icons(String course) {
emptyIcon = false;
if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) {
return R.drawable.ic_german;
} else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) {
return R.drawable.ic_maths;
} else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) {
return R.drawable.ic_english;
} else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) {
return R.drawable.ic_pe;
} else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) {
return R.drawable.ic_politics;
} else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) {
return R.drawable.ic_drama;
} else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) {
return R.drawable.ic_physics;
} else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) {
return R.drawable.ic_biology;
} else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) {
return R.drawable.ic_chemistry;
} else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) {
return R.drawable.ic_philosophy;
} else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) {
return R.drawable.ic_latin;
} else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) {
return R.drawable.ic_spanish;
} else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) {
return R.drawable.ic_french;
} else if (course.toLowerCase().contains("inf")) {
return R.drawable.ic_compsci;
} else if (course.toLowerCase().contains("ges")) {
return R.drawable.ic_history;
} else if (course.toLowerCase().contains("rel")) {
return R.drawable.ic_religion;
} else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) {
return R.drawable.ic_geography;
} else if (course.toLowerCase().contains("kun")) {
return R.drawable.ic_arts;
} else if (course.toLowerCase().contains("mus")) {
return R.drawable.ic_music;
} else if (course.toLowerCase().contains("tue")) {
return R.drawable.ic_turkish;
} else if (course.toLowerCase().contains("chi")) {
return R.drawable.ic_chinese;
} else if (course.toLowerCase().contains("gll")) {
return R.drawable.ic_gll;
} else if (course.toLowerCase().contains("wat")) {
return R.drawable.ic_wat;
} else if (course.toLowerCase().contains("för")) {
return R.drawable.ic_help;
} else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) {
return R.drawable.ic_pencil;
} else {
emptyIcon = true;
return R.drawable.ic_empty;
}
}
@Override
protected void onPostExecute(Void result) {}
}
@@ -1,13 +1,9 @@
package com.denizd.substitutionplan;
import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteDatabase;
@Database(entities = {Subst.class}, version = 2, exportSchema = false)
public abstract class SubstDatabase extends RoomDatabase {
@@ -26,27 +22,4 @@ public abstract class SubstDatabase extends RoomDatabase {
}
return instance;
}
// private static RoomDatabase.Callback roomCallback = new RoomDatabase.Callback() { // initial population
// @Override
// public void onCreate(@NonNull SupportSQLiteDatabase db) {
// super.onCreate(db);
// new PopulateDBAsync(instance).execute();
// }
// };
//
// private static class PopulateDBAsync extends AsyncTask<Void, Void, Void> {
//
// private SubstDao substDao;
//
// private PopulateDBAsync(SubstDatabase db) {
// substDao = db.substDao();
// }
//
// @Override
// protected Void doInBackground(Void... voids) {
// substDao.insert(new Subst(R.drawable.ic_avh,"Group", "Date", "Time", "Course", "Room", "Additional", 0));
// return null;
// }
// }
}
@@ -1,26 +1,5 @@
package com.denizd.substitutionplan;
public class names {
protected static String boy[] = { "Cedric Grislawski", // excluded are most boys from Physical Education
// profile (no offense) and me
"Dawid Kniola", "Jonas Köstergarten", "Jakob Moerschner", "Siamak Nemati", "Hendrik Plönnings",
"Jan Rohmann", "Anton Rosenberger", "Christoph Senft", "Jan Mika Sieckendieck", "Alexander Sinaj",
"Nico Tischer", "Nhat Vinh Tran", "Leon Becker", "Youssef Beltagi", "Erich Kerkesner", "Alex Lick",
"Oskar Piskorz", "Theo Recktor", "Eray Vatansever", "Dennis Wojciechowski", "Übeydullah Alkan",
"Yahya Almarashli", "Sinan Aydin", "Rick Büteröwe", "Levin Dropp", "Silvester Jermolajew", "Tolgay Kekilli",
"Dennis Lange", "Aras Mahmoud", "Batuhan Özcan", "Michael Rek", "Khabat Sharif", "Anbinh Tran",
"Bastian Westerboer", "Abdulwahab Alshebli", "Kelechi Gaius", "Armin Großmann", "Anes Halep",
"Marco Jankowski", "Emirhan Kaplan", "Alexander Kofmann", "Tobi Derek Köhler", "Vasilije Nedeljkovic",
"Batu Öcal", "Paul Rehbohm" };
protected static String girl[] = { "Mayra Dronia", // excluded are the girls from Physical Education profile
// (no offense)
"Shalin Ramadan", "Nigina Amin", "Mariya Kheder", "Niegen Khosrawi", "Dayana Osipova",
"Julia Petri", "Laura Pister", "Dana Alyoussef", "Ilkem Kahramanoglu", "Rozita Amiri", "Mirja Arneke",
"Nastasja Banik", "Anni Kienke", "Benedite Mateta", "Leonie Pohl", "Cecillia Sawires", "Patrycja Smółka",
"Elif Zencirkiran", "Nusyba Al Semadi", "Vivien Bruns", "Yasemin Dal", "Svenja Demuth", "Nina Groß",
"Kim Lahmeyer", "Luca Minschke", "Kim Reschke", "Amélie Schnellecke", "Delal Secer", "Xenia Segijanski",
"Melisa Tas", "Kim Völker", "Banu Yari", "Zeinab Ali", "Mariam Bannout", "Stefanie Fahl", "Yamaty Gaye",
"Anna-Sophia Haeberle", "Finja Hastedt", "Viktoria Hammermeister", "Isabel Horn", "Laura Kern",
"Melanie Kleinermann", "Målin Kollhoff", "Darja Maier", "Lisa Maier", "Naura Nadzifah", "Janina Roelfs",
"Vanessa Scheifler", "Mara Thies", "Lieli Umar", "Leonie Welk", "Betraben Yacoub" };
}