Archived
App is now fully converted to Kotlin
This commit is contained in:
+5
-2
@@ -1,6 +1,7 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
@@ -9,7 +10,7 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 12
|
||||
versionName "1.4.0"
|
||||
versionName "2.0.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
@@ -34,6 +35,8 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha06'
|
||||
implementation 'com.android.support:customtabs:28.0.0'
|
||||
|
||||
// implementation 'androidx.core:core-ktx:1.0.2'
|
||||
|
||||
implementation 'com.jaredrummler:android-device-names:1.1.8'
|
||||
implementation 'com.github.mukeshsolanki:easypreferences:1.0.6'
|
||||
|
||||
@@ -43,7 +46,7 @@ dependencies {
|
||||
|
||||
def room_version = "2.1.0-alpha04"
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
|
||||
|
||||
@@ -15,12 +15,6 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme0.Launcher"
|
||||
android:windowSoftInputMode="adjustPan"/>
|
||||
|
||||
<activity
|
||||
android:name=".FirstTime"
|
||||
@@ -36,8 +30,6 @@
|
||||
android:theme="@style/AppTheme0.Launcher"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -45,9 +37,6 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".ScheduledJobService"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
<service
|
||||
android:name=".NotificationService"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
public class Food {
|
||||
|
||||
private String food;
|
||||
|
||||
public Food(String food) {
|
||||
this.food = food;
|
||||
}
|
||||
|
||||
public String getFood() {
|
||||
return food;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
class Food(val food: String)
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.CardViewHolder> {
|
||||
private List<Food> mFood;
|
||||
|
||||
public static class CardViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView mFood;
|
||||
|
||||
public CardViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mFood = itemView.findViewById(R.id.cardInfoText);
|
||||
}
|
||||
}
|
||||
|
||||
public FoodAdapter(ArrayList<Food> food) {
|
||||
mFood = food;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.just_a_card, parent, false);
|
||||
CardViewHolder cvh = new CardViewHolder(v);
|
||||
return cvh;
|
||||
}
|
||||
|
||||
public Food getFoodAt(int i) {
|
||||
return mFood.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CardViewHolder holder, int position) {
|
||||
Food currentItem = mFood.get(position);
|
||||
|
||||
holder.mFood.setText(currentItem.getFood());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mFood.size();
|
||||
}
|
||||
|
||||
public void setFood(List<Food> food) {
|
||||
mFood = food;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
|
||||
import java.util.ArrayList
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class FoodAdapter(food: ArrayList<Food>) : RecyclerView.Adapter<FoodAdapter.CardViewHolder>() {
|
||||
private var mFood: List<Food>? = null
|
||||
|
||||
class CardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var mFood: TextView
|
||||
|
||||
init {
|
||||
mFood = itemView.findViewById(R.id.cardInfoText)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
mFood = food
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder {
|
||||
val v = LayoutInflater.from(parent.context).inflate(R.layout.just_a_card, parent, false)
|
||||
return CardViewHolder(v)
|
||||
}
|
||||
|
||||
fun getFoodAt(i: Int): Food {
|
||||
return mFood!![i]
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
|
||||
val currentItem = mFood!![position]
|
||||
|
||||
holder.mFood.text = currentItem.food
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mFood!!.size
|
||||
}
|
||||
|
||||
fun setFood(food: List<Food>) {
|
||||
mFood = food
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.ProgressBar
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.madapps.prefrences.EasyPrefrences
|
||||
import kotlinx.android.synthetic.main.plan.*
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.select.Elements
|
||||
@@ -49,7 +48,7 @@ class FoodFragment : Fragment(R.layout.food_layout) {
|
||||
try {
|
||||
recyclerView = view.findViewById(R.id.linear_food)
|
||||
recyclerView.hasFixedSize()
|
||||
recyclerView.layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL,false)
|
||||
recyclerView.layoutManager = GridLayoutManager(mContext, 1) // , RecyclerView.VERTICAL,false
|
||||
recyclerView.adapter = mAdapter
|
||||
|
||||
try {
|
||||
@@ -97,10 +96,6 @@ class FoodFragment : Fragment(R.layout.food_layout) {
|
||||
docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get()
|
||||
foodElements = docFood.select("th")
|
||||
|
||||
try {
|
||||
mFoodArrayList.removeAll(mFoodArrayList)
|
||||
} catch (ignored: NullPointerException) {}
|
||||
|
||||
progressBar = mRootView.findViewById(R.id.progressBar)
|
||||
|
||||
progressBar.max = foodElements.size
|
||||
@@ -165,10 +160,7 @@ class FoodFragment : Fragment(R.layout.food_layout) {
|
||||
|
||||
try {
|
||||
mRecyclerView.removeAllViews()
|
||||
} catch (ignored: NullPointerException) {}
|
||||
|
||||
try {
|
||||
mRecyclerView.removeAllViews()
|
||||
mFoodArrayList.removeAll(mFoodArrayList)
|
||||
} catch (ignored: NullPointerException) {}
|
||||
|
||||
val foodListPopulation = ArrayList(mEasyPrefs.getListString("foodListPrefs"))
|
||||
@@ -176,9 +168,9 @@ class FoodFragment : Fragment(R.layout.food_layout) {
|
||||
for (i in 0 until foodListPopulation.size) {
|
||||
mFoodArrayList.add(Food(foodListPopulation[i]))
|
||||
mAdapter.setFood(mFoodArrayList)
|
||||
mRecyclerView.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
mRecyclerView.scheduleLayoutAnimation()
|
||||
pullToRefresh.isRefreshing = false
|
||||
|
||||
handler.postDelayed({ progressBar.startAnimation(fadeOut) }, 200)
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
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.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
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.ProgressBar;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.android.material.snackbar.Snackbar.make;
|
||||
|
||||
public class FragmentFood extends Fragment {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private FoodAdapter mAdapter;
|
||||
private RecyclerView.LayoutManager layoutManager;
|
||||
private ArrayList<Food> foodArrayList;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.food_layout, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
EasyPrefrences easyPrefs = new EasyPrefrences(getContext());
|
||||
ArrayList<String> foodListPopulation = new ArrayList<>(easyPrefs.getListString("foodListPrefs"));
|
||||
try {
|
||||
foodArrayList = new ArrayList<>();
|
||||
recyclerView = getView().findViewById(R.id.linear_food);
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
mAdapter = new FoodAdapter(foodArrayList);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
for (int i = 0; i < foodListPopulation.size(); i++) {
|
||||
foodArrayList.add(new Food(foodListPopulation.get(i)));
|
||||
mAdapter.setFood(foodArrayList);
|
||||
recyclerView.scheduleLayoutAnimation();
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("autoRefresh", false)) {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new fetcher().execute();
|
||||
}
|
||||
|
||||
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new fetcher().execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class fetcher extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
boolean attempt = false, npe = false;
|
||||
Elements foodElements;
|
||||
Document docFood;
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
|
||||
protected fetcher() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
final ProgressBar progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
try {
|
||||
docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get();
|
||||
foodElements = docFood.select("th");
|
||||
|
||||
attempt = true;
|
||||
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setMax(foodElements.size());
|
||||
} catch (IOException e1) {
|
||||
npe = true;
|
||||
} catch (NullPointerException e1) {
|
||||
npe = true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (attempt) {
|
||||
|
||||
|
||||
try {
|
||||
|
||||
final ProgressBar progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
EasyPrefrences easyPrefs = new EasyPrefrences(getContext());
|
||||
|
||||
ArrayList<String> foodList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
recyclerView.removeAllViews();
|
||||
foodArrayList.removeAll(foodArrayList);
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
}
|
||||
|
||||
for (int foodInt = 0; foodInt < foodElements.size(); foodInt++) {
|
||||
|
||||
try {
|
||||
if (foodElements.get(foodInt).text().contains("Montag") ||
|
||||
foodElements.get(foodInt).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt).text().contains("Freitag")) {
|
||||
|
||||
if (foodElements.get(foodInt + 3).text().contains("Montag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Freitag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("von")) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text() + "\n" + foodElements.get(foodInt + 2).text());
|
||||
foodInt += 2;
|
||||
} else if (foodElements.get(foodInt + 2).text().contains("Montag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Freitag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("von")) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text());
|
||||
foodInt += 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
foodList.add(foodElements.get(foodInt).text());
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
try {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text() + "\n" + foodElements.get(foodInt + 2).text());
|
||||
break;
|
||||
} catch (IndexOutOfBoundsException e1) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text());
|
||||
break;
|
||||
}
|
||||
}
|
||||
progressBar.incrementProgressBy(1);
|
||||
}
|
||||
|
||||
easyPrefs.putListString("foodListPrefs", foodList);
|
||||
|
||||
ArrayList<String> foodListPopulation = new ArrayList<>(easyPrefs.getListString("foodListPrefs"));
|
||||
|
||||
for (int i = 0; i < foodListPopulation.size(); i++) {
|
||||
foodArrayList.add(new Food(foodListPopulation.get(i)));
|
||||
mAdapter.setFood(foodArrayList);
|
||||
recyclerView.scheduleLayoutAnimation();
|
||||
progressBar.incrementProgressBy(1);
|
||||
}
|
||||
|
||||
progressBar.setProgress(1000);
|
||||
|
||||
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);
|
||||
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation arg0) {
|
||||
progressBar.setProgress(0);
|
||||
}
|
||||
});
|
||||
try {
|
||||
pullToRefresh.setRefreshing(false);
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
}
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
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;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
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.LinearLayout;
|
||||
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.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.android.material.snackbar.Snackbar.make;
|
||||
|
||||
public class FragmentPersonal extends Fragment {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private CardAdapter mAdapter;
|
||||
private RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext()),
|
||||
linearLayoutManager = new LinearLayoutManager(getContext()),
|
||||
gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
private ArrayList<Subst> planCardList;
|
||||
private TextView bottomSheetText;
|
||||
private SubstViewModel substViewModel;
|
||||
private boolean persPlanEmpty;
|
||||
private EasyPrefrences easyPrefs;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.plan, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
layoutManager = linearLayoutManager;
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutManager = gridLayoutManager;
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
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)));
|
||||
|
||||
planCardList = new ArrayList<>();
|
||||
recyclerView = getView().findViewById(R.id.linearRecycler);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
layoutManager = linearLayoutManager;
|
||||
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutManager = gridLayoutManager;
|
||||
}
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
mAdapter = new CardAdapter(planCardList);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
final TextView smileydown = getView().findViewById(R.id.smileydown);
|
||||
final TextView smileydowntext = getView().findViewById(R.id.smileydowntext);
|
||||
final LinearLayout linearsmiley = getView().findViewById(R.id.linearsmiley);
|
||||
|
||||
if (prefs.getInt("firstTimeOpening", 0) == 2) {
|
||||
if (!prefs.getBoolean("notif", false)) {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new fetcher().execute();
|
||||
edit.putInt("firstTimeOpening", 3);
|
||||
edit.apply();
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("autoRefresh", false)) {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new fetcher().execute();
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
}
|
||||
substViewModel = ViewModelProviders.of(getActivity()).get(SubstViewModel.class);
|
||||
substViewModel.getAllSubst().observe(this, new Observer<List<Subst>>() {
|
||||
@Override
|
||||
public void onChanged(List<Subst> substs) {
|
||||
try {
|
||||
if (planCardList != null) {
|
||||
planCardList.clear();
|
||||
}
|
||||
smileydown.setVisibility(View.GONE);
|
||||
smileydowntext.setVisibility(View.GONE);
|
||||
linearsmiley.setVisibility(View.GONE);
|
||||
persPlanEmpty = true;
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
for (int i = 0; i < substs.size(); i++) {
|
||||
|
||||
if (prefs.getString("courses", "").isEmpty() && !prefs.getString("classes", "").isEmpty()) {
|
||||
if (!substs.get(i).getGroup().isEmpty() && !substs.get(i).getGroup().equals("")) {
|
||||
if (prefs.getString("classes", "").contains(substs.get(i).getGroup()) || substs.get(i).getGroup().contains(prefs.getString("classes", ""))) {
|
||||
planCardList.add(substs.get(i));
|
||||
persPlanEmpty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for seniors
|
||||
else if (!prefs.getString("courses", "").isEmpty() && !prefs.getString("classes", "").isEmpty()) {
|
||||
if (!substs.get(i).getGroup().equals("") && !substs.get(i).getCourse().equals("")) {
|
||||
if (prefs.getString("courses", "").contains(substs.get(i).getCourse())) {
|
||||
if (prefs.getString("classes", "").contains(substs.get(i).getGroup()) || substs.get(i).getGroup().contains(prefs.getString("classes", ""))) {
|
||||
planCardList.add(substs.get(i));
|
||||
persPlanEmpty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recyclerView.getAdapter().notifyDataSetChanged(); // TODO check whether this is necessary
|
||||
Collections.sort(planCardList, new Comparator<Subst>() {
|
||||
@Override
|
||||
public int compare(Subst lhs, Subst rhs) {
|
||||
return Integer.compare(rhs.getPriority(), lhs.getPriority());
|
||||
}
|
||||
});
|
||||
recyclerView.scheduleLayoutAnimation();
|
||||
mAdapter.setSubst(planCardList);
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (persPlanEmpty) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
smileydown.setVisibility(View.VISIBLE);
|
||||
smileydowntext.setVisibility(View.VISIBLE);
|
||||
linearsmiley.setVisibility(View.VISIBLE);
|
||||
linearsmiley.scheduleLayoutAnimation();
|
||||
}
|
||||
}
|
||||
}, 64);
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new fetcher().execute();
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class fetcher extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
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;
|
||||
String[] groupS, dateS, timeS, courseS, roomS, additionalS;
|
||||
boolean attempt = false, npe = false;
|
||||
URL url;
|
||||
URLConnection connection;
|
||||
String modified;
|
||||
Elements rows, paragraphs;
|
||||
Document doc;
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
ProgressBar progressBar;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
|
||||
Date d;
|
||||
private ArrayList<String> informationalList = new ArrayList<>();
|
||||
|
||||
protected fetcher() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
try {
|
||||
doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get();
|
||||
url = new URL("https://djd4rkn355.github.io/subst");
|
||||
connection = url.openConnection();
|
||||
rows = doc.select("tr");
|
||||
count = rows.size();
|
||||
modified = connection.getHeaderField("Last-Modified");
|
||||
d = new Date(connection.getHeaderField("Last-Modified"));
|
||||
edit.putString("time", connection.getHeaderField("Last-Modified"));
|
||||
paragraphs = doc.select("p");
|
||||
pCount = paragraphs.size();
|
||||
attempt = 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];
|
||||
|
||||
progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setMax(count);
|
||||
|
||||
substViewModel.deleteAllSubst();
|
||||
|
||||
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();
|
||||
progressBar.incrementProgressBy(1);
|
||||
|
||||
MiscData dg = new MiscData();
|
||||
int drawable = dg.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 | NullPointerException e1) {
|
||||
npe = true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
try {
|
||||
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);
|
||||
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation arg0) {
|
||||
}
|
||||
|
||||
@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 ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
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.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.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.android.material.snackbar.Snackbar.make;
|
||||
|
||||
public class FragmentPlan extends Fragment {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private CardAdapter mAdapter;
|
||||
private RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext()),
|
||||
linearLayoutManager = new LinearLayoutManager(getContext()),
|
||||
gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
private ArrayList<Subst> planCardList;
|
||||
private TextView bottomSheetText;
|
||||
private SubstViewModel substViewModel;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.plan, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
layoutManager = linearLayoutManager;
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutManager = gridLayoutManager;
|
||||
recyclerView.setLayoutManager(layoutManager); // TODO grid layout but change an integer value instead
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
bottomSheetText = getView().getRootView().findViewById(R.id.bottom_sheet_text);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
|
||||
planCardList = new ArrayList<>();
|
||||
recyclerView = getView().findViewById(R.id.linearRecycler);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
layoutManager = linearLayoutManager;
|
||||
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutManager = gridLayoutManager;
|
||||
}
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
mAdapter = new CardAdapter(planCardList);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
if (prefs.getInt("firstTimeOpening", 0) == 2) {
|
||||
if (!prefs.getBoolean("notif", false)) {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new DataFetcher(true, false, false, getContext(), getActivity().getApplication(), getView().getRootView()).execute();
|
||||
edit.putInt("firstTimeOpening", 3);
|
||||
edit.apply();
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("autoRefresh", false)) {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new DataFetcher(true, false, false, getContext(), getActivity().getApplication(), getView().getRootView()).execute();
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
}
|
||||
substViewModel = ViewModelProviders.of(getActivity()).get(SubstViewModel.class);
|
||||
substViewModel.getAllSubst().observe(this, new Observer<List<Subst>>() {
|
||||
@Override
|
||||
public void onChanged(List<Subst> substs) {
|
||||
mAdapter.setSubst(substs);
|
||||
recyclerView.scheduleLayoutAnimation();
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
pullToRefresh.setRefreshing(true);
|
||||
new DataFetcher(true, false, true, getContext(), getActivity().getApplication(), getView().getRootView()).execute(); // TODO test for notification
|
||||
bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class fetcher extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
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[] groupS, dateS, timeS, courseS, roomS, additionalS;
|
||||
boolean attempt = false, npe = false;
|
||||
URL url;
|
||||
URLConnection connection;
|
||||
String modified;
|
||||
Elements rows, paragraphs;
|
||||
Document doc;
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefresh);
|
||||
ProgressBar progressBar;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
|
||||
Date d;
|
||||
|
||||
protected fetcher() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
try {
|
||||
doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get();
|
||||
url = new URL("https://djd4rkn355.github.io/subst");
|
||||
connection = url.openConnection();
|
||||
rows = doc.select("tr");
|
||||
count = rows.size();
|
||||
modified = connection.getHeaderField("Last-Modified");
|
||||
d = new Date(connection.getHeaderField("Last-Modified"));
|
||||
edit.putString("time", connection.getHeaderField("Last-Modified"));
|
||||
paragraphs = doc.select("p");
|
||||
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];
|
||||
courseS = new String[count];
|
||||
roomS = new String[count];
|
||||
additionalS = new String[count];
|
||||
|
||||
progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setMax(count);
|
||||
|
||||
substViewModel.deleteAllSubst();
|
||||
|
||||
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();
|
||||
progressBar.incrementProgressBy(1);
|
||||
|
||||
MiscData dg = new MiscData();
|
||||
int drawable = dg.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--;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e1) {
|
||||
npe = true;
|
||||
} catch (NullPointerException e1) {
|
||||
npe = true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
try {
|
||||
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);
|
||||
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation arg0) {
|
||||
}
|
||||
|
||||
@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 ignored) {}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FragmentSearch extends Fragment {
|
||||
|
||||
ConstraintLayout constraintLayout;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private CardAdapter mAdapter;
|
||||
private RecyclerView.LayoutManager layoutManager;
|
||||
private ArrayList<Subst> planCardList;
|
||||
private SubstViewModel substViewModel;
|
||||
private boolean search = false;
|
||||
private EditText searchfield;
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.search, container, false);
|
||||
constraintLayout = rootView.findViewById(R.id.fragment_container);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final ProgressBar progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
progressBar.setProgress(0);
|
||||
|
||||
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);
|
||||
|
||||
searchfield = getView().findViewById(R.id.searchbar);
|
||||
searchfield.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
substViewModel = ViewModelProviders.of(getActivity()).get(SubstViewModel.class);
|
||||
substViewModel.getAllSubst().observe(getActivity(), new Observer<List<Subst>>() {
|
||||
@Override
|
||||
public void onChanged(List<Subst> substs) {
|
||||
planCardList.removeAll(substs);
|
||||
new search(substs).searchSth();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private class search extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private List<Subst> substs;
|
||||
|
||||
protected search(List<Subst> substs) {
|
||||
this.substs = substs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void searchSth() {
|
||||
for (int i = 0; i < substs.size(); i++) {
|
||||
if (substs.get(i).getGroup().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
|
||||
search = true;
|
||||
}
|
||||
if (substs.get(i).getCourse().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
|
||||
search = true;
|
||||
}
|
||||
if (substs.get(i).getRoom().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
|
||||
search = true;
|
||||
}
|
||||
if (substs.get(i).getAdditional().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) {
|
||||
search = true;
|
||||
}
|
||||
|
||||
if (search) {
|
||||
planCardList.add(substs.get(i));
|
||||
search = false;
|
||||
}
|
||||
}
|
||||
recyclerView.scheduleLayoutAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,801 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.browser.customtabs.CustomTabsIntent;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Switch;
|
||||
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 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 name, model;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.content_settings, container, false);
|
||||
coordinatorLayout = rootView.findViewById(R.id.fragment_container);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final ProgressBar progressBar = getView().getRootView().findViewById(R.id.progressBar);
|
||||
progressBar.setProgress(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
builder.setToolbarColor(getResources().getColor(R.color.background));
|
||||
final CustomTabsIntent customTabsIntent = builder.build();
|
||||
|
||||
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 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);
|
||||
|
||||
final Switch notifswitch = getView().findViewById(R.id.switchNotifications);
|
||||
|
||||
final Switch defaultPlan = getView().findViewById(R.id.switchDefaultPlan);
|
||||
final Switch openInfo = getView().findViewById(R.id.switchOpenInfo);
|
||||
final Switch autoRefresh = getView().findViewById(R.id.switchAutoRefresh);
|
||||
final LinearLayout website = getView().findViewById(R.id.btnWebsite);
|
||||
final LinearLayout licences = getView().findViewById(R.id.btnLicences);
|
||||
final TextView versionNumber = getView().findViewById(R.id.txtVersionTwo);
|
||||
|
||||
final LinearLayout tac = getView().findViewById(R.id.btnTerms);
|
||||
final LinearLayout privacy = getView().findViewById(R.id.btnPrivacyP);
|
||||
final LinearLayout version = getView().findViewById(R.id.btnVersion);
|
||||
|
||||
helpCourses.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder alertDialog;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText(R.string.helpCoursesTitle);
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
dialogText.setText(getString(R.string.helpCourses));
|
||||
alertDialog.setView(dialogView);
|
||||
alertDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
helpClasses.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder alertDialog;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText(R.string.helpClassesTitle);
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
dialogText.setText(getString(R.string.helpClasses));
|
||||
alertDialog.setView(dialogView);
|
||||
alertDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
txtName.setText(prefs.getString("username", ""));
|
||||
txtName.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
edit.putString("username", txtName.getText().toString());
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("greeting", false)) {
|
||||
greeting.setChecked(false);
|
||||
}
|
||||
if (prefs.getBoolean("greeting", false)) {
|
||||
greeting.setChecked(true);
|
||||
}
|
||||
|
||||
greeting.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("greeting", true);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putBoolean("greeting", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (prefs.getInt("themeInt", 0) == 0) {
|
||||
darkmode.setChecked(false);
|
||||
}
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
darkmode.setChecked(true);
|
||||
}
|
||||
|
||||
darkmode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putInt("themeInt", 1);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putInt("themeInt", 0);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (prefs.getBoolean("showinfotab", true)) {
|
||||
showinfo.setChecked(true);
|
||||
} else {
|
||||
showinfo.setChecked(false);
|
||||
}
|
||||
|
||||
showinfo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("showinfotab", true);
|
||||
} else if (!isChecked) {
|
||||
edit.putBoolean("showinfotab", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
final String[] coursesNoLang = {"German", "English", "French", "Spanish", "Latin", "Turkish", "Chinese", "Arts", "Music", "Theatre",
|
||||
"Geography", "History", "Politics", "Philosophy", "Religion",
|
||||
"Maths", "Biology", "Chemistry", "Physics", "CompSci",
|
||||
"PhysEd", "GLL", "WAT", "Forder", "WP"};
|
||||
final String[] courses = {getString(R.string.courseDeu), getString(R.string.courseEng), getString(R.string.courseFra),
|
||||
getString(R.string.courseSpa), getString(R.string.courseLat), getString(R.string.courseTue),
|
||||
getString(R.string.courseChi), getString(R.string.courseKun), getString(R.string.courseMus),
|
||||
getString(R.string.courseDar),
|
||||
getString(R.string.courseGeg), getString(R.string.courseGes), getString(R.string.coursePol),
|
||||
getString(R.string.coursePhi), getString(R.string.courseRel),
|
||||
getString(R.string.courseMat), getString(R.string.courseBio), getString(R.string.courseChe),
|
||||
getString(R.string.coursePhy), getString(R.string.courseInf),
|
||||
getString(R.string.courseSpo), getString(R.string.courseGll), getString(R.string.courseWat),
|
||||
getString(R.string.courseFor), getString(R.string.courseWp)};
|
||||
final int[] coursesIcons = {R.drawable.ic_german, R.drawable.ic_english,
|
||||
R.drawable.ic_french, R.drawable.ic_spanish, R.drawable.ic_latin, R.drawable.ic_turkish,
|
||||
R.drawable.ic_chinese, R.drawable.ic_arts, R.drawable.ic_music, R.drawable.ic_drama,
|
||||
R.drawable.ic_geography, R.drawable.ic_history, R.drawable.ic_politics, R.drawable.ic_philosophy,
|
||||
R.drawable.ic_religion,
|
||||
R.drawable.ic_maths, R.drawable.ic_biology, R.drawable.ic_chemistry, R.drawable.ic_physics,
|
||||
R.drawable.ic_compsci,
|
||||
R.drawable.ic_pe, R.drawable.ic_gll, R.drawable.ic_wat, R.drawable.ic_help, R.drawable.ic_pencil};
|
||||
customiseColours.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final AlertDialog.Builder colourCustomiserBuilder;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
colourCustomiserBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
colourCustomiserBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.empty_dialog, null);
|
||||
TextView titleText = dialogView.findViewById(R.id.empty_textviewtitle);
|
||||
titleText.setText(R.string.customisecolor1);
|
||||
LinearLayout emptyLayout = dialogView.findViewById(R.id.empty_linearlayout);
|
||||
for (i = 0; i < coursesNoLang.length; i++) {
|
||||
View item = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
|
||||
TextView itemText = item.findViewById(R.id.item_text);
|
||||
ImageView itemImage = item.findViewById(R.id.item_image);
|
||||
LinearLayout layout = item.findViewById(R.id.item_layout);
|
||||
itemText.setText(courses[i]);
|
||||
itemImage.setImageDrawable(getResources().getDrawable(coursesIcons[i]));
|
||||
|
||||
final String title = courses[i];
|
||||
final String titleNoLang = coursesNoLang[i];
|
||||
|
||||
if (prefs.getInt("col" + titleNoLang, 0) != 0) {
|
||||
itemText.setTextColor(ContextCompat.getColor(getContext(), prefs.getInt("col" + titleNoLang, 0)));
|
||||
itemImage.getDrawable().setTint(ContextCompat.getColor(getContext(), prefs.getInt("col" + titleNoLang, 0)));
|
||||
}
|
||||
|
||||
layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final AlertDialog.Builder colourPickerBuilder;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
colourPickerBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
colourPickerBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.empty_dialog, null);
|
||||
TextView titleText = dialogView.findViewById(R.id.empty_textviewtitle);
|
||||
titleText.setText(title);
|
||||
LinearLayout emptyLayout = dialogView.findViewById(R.id.empty_linearlayout);
|
||||
View picker = LayoutInflater.from(getContext()).inflate(R.layout.colour_picker, null);
|
||||
emptyLayout.addView(picker);
|
||||
colourPickerBuilder.setView(dialogView);
|
||||
final AlertDialog colourPickerDialog = colourPickerBuilder.create();
|
||||
|
||||
final MaterialButton[] buttons = {picker.findViewById(R.id.colourRed), picker.findViewById(R.id.colourPink),
|
||||
picker.findViewById(R.id.colourPurple), picker.findViewById(R.id.colourDeepPurple),
|
||||
picker.findViewById(R.id.colourLavender), picker.findViewById(R.id.colourIndigo),
|
||||
picker.findViewById(R.id.colourBlue), picker.findViewById(R.id.colourLightBlue),
|
||||
picker.findViewById(R.id.colourTeal), picker.findViewById(R.id.colourGreen),
|
||||
picker.findViewById(R.id.colourYellow), picker.findViewById(R.id.colourOrange),
|
||||
picker.findViewById(R.id.colourNeonRed), picker.findViewById(R.id.colourNeonPink),
|
||||
picker.findViewById(R.id.colourNeonPurple), picker.findViewById(R.id.colourNeonDeepPurple),
|
||||
picker.findViewById(R.id.colourNeonBlue), picker.findViewById(R.id.colourNeonGreen),
|
||||
picker.findViewById(R.id.colourNeonYellow), picker.findViewById(R.id.colourNeonOrange),
|
||||
picker.findViewById(R.id.colourNone)};
|
||||
final int[] colours = {R.color.red, R.color.pink, R.color.purple, R.color.deeppurple,
|
||||
R.color.lavender, R.color.indigo, R.color.blue, R.color.lightblue,
|
||||
R.color.teal, R.color.green, R.color.yellow, R.color.orange,
|
||||
R.color.neonred, R.color.neonpink, R.color.neonpurple, R.color.neondeeppurple,
|
||||
R.color.neonblue, R.color.neongreen, R.color.neonyellow, R.color.neonorange, 0};
|
||||
for (int i2 = 0; i2 < buttons.length; i2++) {
|
||||
final int colour = colours[i2];
|
||||
buttons[i2].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
edit.putInt("col" + titleNoLang, colour);
|
||||
edit.apply();
|
||||
colourPickerDialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
colourPickerDialog.show();
|
||||
}
|
||||
});
|
||||
emptyLayout.addView(item);
|
||||
}
|
||||
View button = LayoutInflater.from(getContext()).inflate(R.layout.forever_alone_button, null);
|
||||
MaterialButton buttonclearallcolours = button.findViewById(R.id.buttonclearallcolours);
|
||||
emptyLayout.addView(button);
|
||||
colourCustomiserBuilder.setView(dialogView);
|
||||
final AlertDialog colourCustomiserDialog = colourCustomiserBuilder.create();
|
||||
buttonclearallcolours.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
for (String courses : coursesNoLang) {
|
||||
edit.putInt("col" + courses, 0);
|
||||
}
|
||||
edit.apply();
|
||||
Toast.makeText(getActivity(), getString(R.string.allcolourscleared),
|
||||
Toast.LENGTH_LONG).show();
|
||||
colourCustomiserDialog.cancel();
|
||||
}
|
||||
});
|
||||
colourCustomiserDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// ------
|
||||
|
||||
txtClasses.setText(prefs.getString("classes", ""));
|
||||
txtCourses.setText(prefs.getString("courses", ""));
|
||||
|
||||
txtClasses.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
edit.putString("classes", txtClasses.getText().toString());
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
txtCourses.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
edit.putString("courses", txtCourses.getText().toString());
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("notif", false)) {
|
||||
notifswitch.setChecked(false);
|
||||
}
|
||||
if (prefs.getBoolean("notif", false)) {
|
||||
notifswitch.setChecked(true);
|
||||
}
|
||||
|
||||
notifswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("notif", true);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putBoolean("notif", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("defaultPersonalised", false)) {
|
||||
defaultPlan.setChecked(false);
|
||||
}
|
||||
if (prefs.getBoolean("defaultPersonalised", false)) {
|
||||
defaultPlan.setChecked(true);
|
||||
}
|
||||
|
||||
defaultPlan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("defaultPersonalised", true);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putBoolean("defaultPersonalised", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("openInfo", false)) {
|
||||
openInfo.setChecked(false);
|
||||
}
|
||||
if (prefs.getBoolean("openInfo", false)) {
|
||||
openInfo.setChecked(true);
|
||||
}
|
||||
|
||||
openInfo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("openInfo", true);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putBoolean("openInfo", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("autoRefresh", false)) {
|
||||
autoRefresh.setChecked(false);
|
||||
}
|
||||
if (prefs.getBoolean("autoRefresh", false)) {
|
||||
autoRefresh.setChecked(true);
|
||||
}
|
||||
|
||||
autoRefresh.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
edit.putBoolean("autoRefresh", true);
|
||||
}
|
||||
if (!isChecked) {
|
||||
edit.putBoolean("autoRefresh", false);
|
||||
}
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
website.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
try {
|
||||
customTabsIntent.launchUrl(getContext(), Uri.parse("http://307.joomla.schule.bremen.de"));
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getContext(), getString(R.string.chromecompatible), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
licences.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder alertDialog;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText("Licences");
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
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);
|
||||
alertDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
tac.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder alertDialog;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText("Terms & Conditions");
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
dialogText.setText("These terms automatically apply to anyone using this app - therefore, please make sure to read them carefully before using the app. Copying or modifying parts of the app or the entire app, as well as creating derivative versions, is prohibited without permission. This app is intellectual property of the developer.\n" +
|
||||
"\n" +
|
||||
"The developer reserves the right to make changes to the app at any given time and for any reason. The user will be informed of any changes made accordingly.\n" +
|
||||
"\n" +
|
||||
"Tampering with the end device, in the form of rooting or otherwise modifying the operating system may result in malfunction of the software. In this case, the developer does not provide support, as the user is responsible for keeping the device free of software that may compromise its security.\n" +
|
||||
"\n" +
|
||||
"Full functionality of the app relies on a steady internet connection. The developer does not take responsibility for malfunction of these services, nor for any errors caused by the end device. The user is responsible for ensuring that their device is fully updated and fully functioning.\n" +
|
||||
"\n" +
|
||||
"As the app relies on third-parties, information provided in-app may be delayed or incorrect at times. The developer accepts no liability for any information mistakenly provided in the app.\n" +
|
||||
"\n" +
|
||||
"The developer may wish to update the app at any point. Should such action arise, then the user is advised to update the app to ensure proper functionality. However, the developer does not promise that the app will be continuously updated, and may stop providing the app at any point. Unless told otherwise, upon any termination, (a) the rights and licenses granted to the user in these terms will end; (b) the user must stop using the app, and (if needed) delete it from their device.\n" +
|
||||
"\n" +
|
||||
"Changes to these Terms & Conditions\n" +
|
||||
"\n" +
|
||||
"The developer may update these Terms & Conditions from time to time. Thus, the user is advised to review this page periodically for any changes. Any changes are effective immediately after they are posted on this page.\n" +
|
||||
"\n" +
|
||||
"Contact Us\n" +
|
||||
"\n" +
|
||||
"In case of questions or suggestions regarding these Terms & Conditions, the user is advised to contact the developer of this app. Contact information is provided through the Play Store.\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"\n" +
|
||||
"These Terms & Conditions were modified upon the template provided by App Privacy Policy Generator. This service is in no way affiliated with AvH Plan or the developer.");
|
||||
alertDialog.setView(dialogView);
|
||||
alertDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
privacy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder alertDialog;
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
}
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText("Privacy Policy");
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
dialogText.setText("The app \"Alexander-von-Humboldt-Plan\", hereby abbreviated to AvH Plan, is provided as a free service by the developer for use as is.\n" +
|
||||
"\n" +
|
||||
"This page is used to inform visitors and users regarding policies with the collection, use, and disclosure of personal information, if they choose to make use of the service.\n" +
|
||||
"\n" +
|
||||
"AvH Plan does not collect, store, share, or in any other way use personal information retrieved from its users. Any information asked for within the app is only used to improve the user experience and as such, is stored locally and cannot be accessed by third-parties or be used to identify the user.\n" +
|
||||
"\n" +
|
||||
"Information Collection and Use\n" +
|
||||
"\n" +
|
||||
"At this moment, AvH Plan does not require personally identifiable information for its core functionality. Certain features do require entering information that may be personally identifiable, however, this data will be retained on the user's device and is therefore not accessible outside the app\n" +
|
||||
"\n" +
|
||||
"Log Data\n" +
|
||||
"\n" +
|
||||
"In the case of an error in the app, device-specific data may be collected and stored on your phone. This data is called Log Data. This Log Data may include information, such as your device's Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilising the service, the time and date when the last usage occured, and other statistics. This data can not be used to personally identify any user.\n" +
|
||||
"\n" +
|
||||
"Cookies\n" +
|
||||
"\n" +
|
||||
"Cookies are files with small amounts of data that are commonly used as anonymous unique identifiers on the web. AvH Plan strives to not make use of cookies for its functionality, however, as its functionality requires access to third-party-websites, cookies may be unintentionally collected by the device's web browser. AvH Plan does not make use of these cookies in any way.\n" +
|
||||
"\n" +
|
||||
"Service Providers\n" +
|
||||
"\n" +
|
||||
"No third-parties are employed for providing any functionality or services of the AvH Plan-app and as such, all functionality is accessible without directly sharing personal data with third-parties.\n" +
|
||||
"\n" +
|
||||
"Security\n" +
|
||||
"\n" +
|
||||
"While absolute security cannot be ensured due to the internet functionality the app employs, no information is shared over any transmission methods.\n" +
|
||||
"\n" +
|
||||
"Links to Other Sites\n" +
|
||||
"\n" +
|
||||
"This Service may contain links to other sites, which are not operated by the developer of AvH Plan. The user is advised to review the privacy policy of any webpage they may access through the app. No responsibility for the content of these third-party websites is provided by the app developer.\n" +
|
||||
"\n" +
|
||||
"Children’s Privacy\n" +
|
||||
"\n" +
|
||||
"The service does not address anyone under the age of 13. As the app does not collect any information from its users, no data is collected from users that may be under the age of 13.\n" +
|
||||
"\n" +
|
||||
"Changes to This Privacy Policy\n" +
|
||||
"\n" +
|
||||
"This privacy policy may be updated as the AvH Plan app is updated with new features. As such, the user is advised to review this page periodically for any changes. Any changes that may be made are effective immediately upon publishing.\n" +
|
||||
"\n" +
|
||||
"Contact Us\n" +
|
||||
"\n" +
|
||||
"In case of questions or suggestions regarding this privacy policy, the user is advised to contact the developer of this app. Contact information is provided through the Play Store.\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"\n" +
|
||||
"This privacy policy was modified upon the template provided by privacypolicytemplate.net and App Privacy Policy Generator. These services are in no way affiliated with AvH Plan or the developer.");
|
||||
alertDialog.setView(dialogView);
|
||||
alertDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
version.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (cs > 0) {
|
||||
cs--;
|
||||
} else {
|
||||
try {
|
||||
cs = 7;
|
||||
customTabsIntent.launchUrl(getContext(), Uri.parse("http://www.flussufer.de/gerd/person.htm"));
|
||||
Toast.makeText(getContext(), getString(R.string.donttell), Toast.LENGTH_LONG).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getContext(), getString(R.string.chromecompatible), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// versionNumber.setText(BuildConfig.VERSION_NAME + "-DEV_BUILD");
|
||||
// } else {
|
||||
versionNumber.setText(BuildConfig.VERSION_NAME);
|
||||
// }
|
||||
|
||||
// final LinearLayout hiddenBtn = getView().findViewById(R.id.btnHiddenENP);
|
||||
// hiddenBtn.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Toast.makeText(getActivity(), getString(R.string.bestclass),
|
||||
// Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// });
|
||||
// hiddenBtn.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
// @Override
|
||||
// public boolean onLongClick(View v) {
|
||||
// DeviceName.with(getContext()).request(new DeviceName.Callback() {
|
||||
// @Override
|
||||
// public void onFinished(DeviceName.DeviceInfo info, Exception error) {
|
||||
// name = info.marketName; // "Galaxy S8+"
|
||||
// model = info.model; // "SM-G955W"
|
||||
// }
|
||||
// });
|
||||
// AlertDialog.Builder alertDialog;
|
||||
// if (prefs.getInt("themeInt", 0) == 1) {
|
||||
// alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
// } else {
|
||||
// alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
// }
|
||||
// View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.edittext_dialog, null);
|
||||
// TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
// title.setText(R.string.experimentalmenu);
|
||||
// TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
// dialogText.setText(getString(R.string.fortest));
|
||||
// final EditText dialogEditText = dialogView.findViewById(R.id.dialog_edittext);
|
||||
// final Button dialogButton = dialogView.findViewById(R.id.dialog_button);
|
||||
// dialogButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// switch (dialogEditText.getText().toString()) {
|
||||
// case "@DIAGNOSTICS": {
|
||||
// AlertDialog.Builder alertDialogDev;
|
||||
// if (prefs.getInt("themeInt", 0) == 1) {
|
||||
// alertDialogDev = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
// } else {
|
||||
// alertDialogDev = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
// }
|
||||
// View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.diagnostics_dialog, null);
|
||||
// TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
// title.setText(R.string.diagnosticsmenu);
|
||||
// final TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
// setDiagnosticsText(dialogText, prefs);
|
||||
// Button launch = dialogView.findViewById(R.id.btnResetLaunch);
|
||||
// Button notif = dialogView.findViewById(R.id.btnResetNotif);
|
||||
// launch.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// edit.putInt("launchDev", 0);
|
||||
// edit.apply();
|
||||
// setDiagnosticsText(dialogText, prefs);
|
||||
// }
|
||||
// });
|
||||
// notif.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// edit.putInt("notificationTestNumberDev", 0);
|
||||
// edit.apply();
|
||||
// setDiagnosticsText(dialogText, prefs);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
// alertDialogDev.setView(dialogView);
|
||||
// alertDialogDev.show();
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// case "2018-04-20":
|
||||
// try {
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=u8tdT5pAE34")); // SOS
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// intent.setPackage("com.google.android.youtube");
|
||||
// startActivity(intent);
|
||||
// Toast.makeText(getActivity(), getEmojiByUnicode(0x1F494),
|
||||
// Toast.LENGTH_LONG).show();
|
||||
// } catch (ActivityNotFoundException e) {
|
||||
// Toast.makeText(getActivity(), R.string.noyoutube, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// break;
|
||||
// case "Q1 Matchmaker": {
|
||||
// final Random gen = new Random();
|
||||
// AlertDialog.Builder alertDialogDev;
|
||||
// if (prefs.getInt("themeInt", 0) == 1) {
|
||||
// alertDialogDev = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomDark);
|
||||
// } else {
|
||||
// alertDialogDev = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustomLight);
|
||||
// }
|
||||
// View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dating_dialog, null);
|
||||
// TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
// title.setText(R.string.dating);
|
||||
//
|
||||
// Button datingBtn = dialogView.findViewById(R.id.dating_btn);
|
||||
// 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);
|
||||
// datingBtn.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//// try {
|
||||
//// double boyP = 0, girlP = 0, perc = 0;
|
||||
//// if (boyT.getText().toString().isEmpty() || boy.isChecked()) {
|
||||
//// boyT.setText(MiscData.boy[gen.nextInt(MiscData.boy.length)]);
|
||||
//// }
|
||||
//// if (girlT.getText().toString().isEmpty() || girl.isChecked()) {
|
||||
//// girlT.setText(MiscData.girl[gen.nextInt(MiscData.girl.length)]);
|
||||
//// }
|
||||
//// for (int i = 0; i < boyT.getText().length(); i++) {
|
||||
//// boyP++;
|
||||
//// }
|
||||
//// for (int i = 0; i < girlT.getText().length(); i++) {
|
||||
//// girlP++;
|
||||
//// }
|
||||
//// if (girlP < boyP) {
|
||||
//// perc = (girlP / boyP) * 100;
|
||||
//// }
|
||||
//// if (girlP > boyP) {
|
||||
//// perc = (boyP / girlP) * 100;
|
||||
//// }
|
||||
//// char multiplyTempBoy = boyT.getText().charAt(boyT.getText().length() - 1);
|
||||
//// char multiplyTempGirl = girlT.getText().charAt(girlT.getText().length() - 1);
|
||||
//// double multiply = Character.getNumericValue(multiplyTempBoy) + Character.getNumericValue(multiplyTempGirl);
|
||||
//// multiply = multiply / 1.2;
|
||||
//// if (perc == 0) {
|
||||
//// perc += 30;
|
||||
//// }
|
||||
//// DecimalFormat df = new DecimalFormat("#.##");
|
||||
//// if (perc * (multiply / 40) > 100) {
|
||||
//// percentage.setText("100.00%");
|
||||
//// } else {
|
||||
//// percentage.setText(df.format(perc * (multiply / 40)) + "%");
|
||||
//// }
|
||||
//// } catch (NullPointerException e) {
|
||||
//// Toast.makeText(getActivity(), getString(R.string.error),
|
||||
//// Toast.LENGTH_SHORT).show();
|
||||
//// }
|
||||
// Toast.makeText(getActivity(), "Deprecated",
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
// });
|
||||
// alertDialogDev.setView(dialogView);
|
||||
// alertDialogDev.show();
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// case "@NOTIFICATION": {
|
||||
// edit.putString("time", "");
|
||||
// edit.apply();
|
||||
// Toast.makeText(getActivity(), "Notification time cleared",
|
||||
// Toast.LENGTH_LONG).show();
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// Toast.makeText(getActivity(), getString(R.string.nothinghappened),
|
||||
// Toast.LENGTH_LONG).show();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// alertDialog.setView(dialogView);
|
||||
// alertDialog.show();
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private String getEmojiByUnicode(int unicode){
|
||||
return new String(Character.toChars(unicode));
|
||||
}
|
||||
|
||||
private void setDiagnosticsText(TextView dialogText, SharedPreferences prefs) {
|
||||
dialogText.setText("First Launch: " + prefs.getString("firstTimeDev", "") +
|
||||
"\n\nApp launched: " + prefs.getInt("launchDev", 0) +
|
||||
"\n\nNotification Service fired: " + prefs.getInt("notificationTestNumberDev", 0) +
|
||||
"\n\nDevice Name: " + name +
|
||||
"\n\nDevice Model: " + model +
|
||||
"\n\nAndroid Version: " + Build.VERSION.RELEASE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,11 +144,10 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
if (info.manufacturer.contains("Huawei") ||
|
||||
info.manufacturer.contains("Honor") ||
|
||||
info.manufacturer.contains("Xiaomi")) {
|
||||
val alertDialog: AlertDialog.Builder = if (prefs.getInt("themeInt", 0) == 1) {
|
||||
AlertDialog.Builder(context, R.style.AlertDialogCustomDark)
|
||||
} else {
|
||||
AlertDialog.Builder(context, R.style.AlertDialogCustomLight)
|
||||
} // TODO dialogue theming
|
||||
val alertDialog = when (prefs.getInt("themeInt", 0)) {
|
||||
1 -> AlertDialog.Builder(context, R.style.AlertDialogCustomDark)
|
||||
else -> AlertDialog.Builder(context, R.style.AlertDialogCustomLight)
|
||||
}
|
||||
val dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null)
|
||||
val title = dialogView.findViewById<TextView>(R.id.textviewtitle)
|
||||
title.text = getString(R.string.chinaTitle)
|
||||
@@ -242,27 +241,28 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
} else {
|
||||
getString(R.string.personalplan)
|
||||
}
|
||||
|
||||
lateinit var fragment: Fragment
|
||||
if (prefs.getBoolean("defaultPersonalised", false)) {
|
||||
loadFragment(FragmentPersonal())
|
||||
fragment = mPlanFragment(true)
|
||||
bottomNav.selectedItemId = R.id.personal
|
||||
toolbarTxt.text = userPlan
|
||||
} else {
|
||||
loadFragment(FragmentPlan())
|
||||
fragment = mPlanFragment(false)
|
||||
bottomNav.selectedItemId = R.id.plan
|
||||
toolbarTxt.text = getString(R.string.app_name)
|
||||
}
|
||||
loadFragment(fragment)
|
||||
|
||||
bottomNav.setOnNavigationItemSelectedListener { item: MenuItem ->
|
||||
var fragmentLoading = true
|
||||
lateinit var fragment: Fragment
|
||||
when (item.itemId) {
|
||||
R.id.plan -> {
|
||||
fragment = PlanFragment(false)
|
||||
fragment = mPlanFragment(false)
|
||||
toolbarTxt.text = getString(R.string.app_name)
|
||||
}
|
||||
R.id.personal -> {
|
||||
fragment = PlanFragment(true)
|
||||
fragment = mPlanFragment(true)
|
||||
toolbarTxt.text = userPlan
|
||||
}
|
||||
R.id.menu -> {
|
||||
@@ -320,6 +320,14 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun mPlanFragment(ispersonal: Boolean): PlanFragment {
|
||||
val f = PlanFragment()
|
||||
val bdl = Bundle(1)
|
||||
bdl.putBoolean("ispersonal", ispersonal)
|
||||
f.arguments = bdl
|
||||
return f
|
||||
}
|
||||
|
||||
private fun loadFragment(fragment: Fragment): Boolean {
|
||||
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, fragment).commit()
|
||||
return true
|
||||
|
||||
@@ -1,521 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.job.JobInfo;
|
||||
import android.app.job.JobScheduler;
|
||||
import android.content.ComponentName;
|
||||
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.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.jaredrummler.android.device.DeviceName;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.MenuItem;
|
||||
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;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.google.android.material.snackbar.Snackbar.make;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
BottomSheetBehavior bottomSheetBehaviour;
|
||||
private String manufacturer;
|
||||
|
||||
protected void job() {
|
||||
ComponentName componentName = new ComponentName(this, ScheduledJobService.class);
|
||||
JobInfo info = new JobInfo.Builder(42, componentName)
|
||||
.setRequiresCharging(false)
|
||||
.setPersisted(true)
|
||||
.setPeriodic(900000)
|
||||
.build();
|
||||
JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
|
||||
scheduler.schedule(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
final Intent firstTime = new Intent(this, FirstTime.class);
|
||||
if (prefs.getBoolean("firstTime", true)) {
|
||||
startActivity(firstTime);
|
||||
finish();
|
||||
}
|
||||
|
||||
final Context context = this;
|
||||
|
||||
edit.putInt("launchDev", prefs.getInt("launchDev", 0) + 1);
|
||||
edit.apply();
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
final AppBarLayout appbarlayout = findViewById(R.id.appbarlayout);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
final TextView toolbarTxt = findViewById(R.id.toolbarTxt);
|
||||
|
||||
final LinearLayout bottomSheetRoot = findViewById(R.id.bottom_sheet);
|
||||
final LinearLayout bottomSheet = findViewById(R.id.bottom_sheet_linear);
|
||||
final TextView bottomSheetHeader = findViewById(R.id.bottom_sheet_header);
|
||||
final TextView bottomSheetText = findViewById(R.id.bottom_sheet_text);
|
||||
final View bottomNavDivider = findViewById(R.id.bottom_nav_divider);
|
||||
bottomSheetBehaviour = BottomSheetBehavior.from(bottomSheetRoot);
|
||||
|
||||
Window window = this.getWindow();
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
|
||||
final BottomNavigationView bottomNav = findViewById(R.id.bottom_nav);
|
||||
final Chip chip = findViewById(R.id.chip);
|
||||
|
||||
if (!prefs.getBoolean("showinfotab", true)) {
|
||||
bottomNav.getMenu().removeItem(R.id.openinfopanel);
|
||||
}
|
||||
|
||||
final CoordinatorLayout fragmentContainer = findViewById(R.id.fragment_container);
|
||||
fragmentContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
|
||||
final LinearLayout bottomSheetCloser = findViewById(R.id.bottom_sheet_closer);
|
||||
bottomSheetBehaviour.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
if (bottomSheetBehaviour.getState() == BottomSheetBehavior.STATE_EXPANDED) { // 2 = expanded, 4 = collapsed
|
||||
bottomSheetCloser.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
if (bottomSheetBehaviour.getState() == BottomSheetBehavior.STATE_COLLAPSED) { // 2 = expanded, 4 = collapsed
|
||||
bottomSheetCloser.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
||||
// bottomSheetCloser.setVisibility(View.VISIBLE);
|
||||
// bottomSheetCloser.setAlpha(slideOffset);
|
||||
}
|
||||
});
|
||||
|
||||
if (!prefs.getBoolean("autoRefresh", false) && prefs.getInt("firstTimeOpening", 0) > 1) {
|
||||
try {
|
||||
final String OLD_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz", NEW_FORMAT = "yyyy-MM-dd, HH:mm:ss";
|
||||
String newDateString;
|
||||
Date d = new Date(prefs.getString("time", ""));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
|
||||
sdf.applyPattern(NEW_FORMAT);
|
||||
newDateString = sdf.format(d);
|
||||
View contextView = findViewById(R.id.coordination);
|
||||
Snackbar snackbar = make(contextView, getText(R.string.lastupdated) + ": " + newDateString, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null);
|
||||
snackbar.show();
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("huaweiDeviceDialog", true)) {
|
||||
DeviceName.with(this).request(new DeviceName.Callback() {
|
||||
@Override
|
||||
public void onFinished(DeviceName.DeviceInfo info, Exception error) {
|
||||
manufacturer = info.manufacturer;
|
||||
if (manufacturer.contains("Huawei") ||
|
||||
manufacturer.contains("Honor") ||
|
||||
manufacturer.contains("Xiaomi")) {
|
||||
|
||||
AlertDialog.Builder alertDialog;
|
||||
View dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null);
|
||||
TextView title = dialogView.findViewById(R.id.textviewtitle);
|
||||
title.setText(R.string.chinaTitle);
|
||||
if (prefs.getInt("themeInt", 0) == 1) {
|
||||
alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomDark);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight);
|
||||
}
|
||||
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
|
||||
dialogText.setText(R.string.chinaDialog);
|
||||
alertDialog.setView(dialogView);
|
||||
alertDialog.show();
|
||||
|
||||
edit.putBoolean("huaweiDeviceDialog", false);
|
||||
edit.apply();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
|
||||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
|
||||
} else {
|
||||
View contextView = findViewById(R.id.coordination);
|
||||
Snackbar.make(contextView, getText(R.string.nointernet), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
bottomSheetCloser.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetCloser.setVisibility(View.GONE);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
|
||||
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.darkwhite));
|
||||
// window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
// 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.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.textDark));
|
||||
// bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.darkwhite));
|
||||
// bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.textDark));
|
||||
// bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.textDark));
|
||||
// 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.darkwhite));
|
||||
// setTaskDescription(taskDesc);
|
||||
// }
|
||||
// if (prefs.getInt("themeInt", 0) == 1) {
|
||||
// setTheme(R.style.AppTheme0Dark);
|
||||
// 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.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.textLight));
|
||||
// bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.dark));
|
||||
// bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.textLight));
|
||||
// bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.textLight));
|
||||
// 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));
|
||||
// setTaskDescription(taskDesc);
|
||||
// }
|
||||
|
||||
if (prefs.getBoolean("greeting", false)) {
|
||||
if (!prefs.getString("username", "").isEmpty()) {
|
||||
final Animation animationIn = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.chip_slide_in);
|
||||
final Animation animationOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.chip_slide_out);
|
||||
final Random generator = new Random();
|
||||
Resources res = getResources();
|
||||
String[] greetings = res.getStringArray(R.array.greeting8_array);
|
||||
Calendar rightNow = Calendar.getInstance();
|
||||
int currentHour = rightNow.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
switch (generator.nextInt(9)) {
|
||||
case 0:
|
||||
chip.setText(getString(R.string.greeting0, prefs.getString("username", "")));
|
||||
break;
|
||||
case 1:
|
||||
chip.setText(getString(R.string.greeting1, prefs.getString("username", "")));
|
||||
break;
|
||||
case 2:
|
||||
chip.setText(getString(R.string.greeting2, prefs.getString("username", "")));
|
||||
break;
|
||||
case 3:
|
||||
chip.setText(getString(R.string.greeting3, prefs.getString("username", "")));
|
||||
break;
|
||||
case 4:
|
||||
chip.setText(getString(R.string.greeting4, prefs.getString("username", "")));
|
||||
break;
|
||||
case 5:
|
||||
chip.setText(getString(R.string.greeting5, prefs.getString("username", "")));
|
||||
break;
|
||||
case 6:
|
||||
chip.setText(getString(R.string.greeting6, prefs.getString("username", "")));
|
||||
break;
|
||||
case 7:
|
||||
chip.setText(getString(R.string.greeting7, prefs.getString("username", "")));
|
||||
break;
|
||||
case 8:
|
||||
if (currentHour < 11) {
|
||||
chip.setText(greetings[0] + prefs.getString("username", "") + ".");
|
||||
} else if (currentHour > 10 && currentHour < 18) {
|
||||
chip.setText(greetings[1] + prefs.getString("username", "") + ".");
|
||||
} else if (currentHour > 17) {
|
||||
chip.setText(greetings[2] + prefs.getString("username", "") + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
final Handler chipIn = new Handler();
|
||||
chipIn.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chip.setVisibility(View.VISIBLE);
|
||||
chip.startAnimation(animationIn);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
final Handler chipOut = new Handler();
|
||||
chipOut.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chip.startAnimation(animationOut);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
animationOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation arg0) {}
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation arg0) {}
|
||||
@Override
|
||||
public void onAnimationEnd(Animation arg0) {
|
||||
chip.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.getInt("firstTimeOpening", 0) < 2) {
|
||||
final Handler bsbIn = new Handler();
|
||||
bsbIn.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
}, 600);
|
||||
|
||||
final Handler bsbOut = new Handler();
|
||||
bsbOut.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
edit.putInt("firstTimeOpening", prefs.getInt("firstTimeOpening", 0) + 1);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("openInfo", false)) {
|
||||
final Handler bsbIn = new Handler();
|
||||
bsbIn.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
}, 600);
|
||||
}
|
||||
|
||||
|
||||
if (prefs.getBoolean("defaultPersonalised", false)) {
|
||||
loadFragment(new FragmentPersonal());
|
||||
bottomNav.setSelectedItemId(R.id.personal);
|
||||
if (!prefs.getString("username", "").isEmpty()) {
|
||||
if (Character.toString(prefs.getString("username", "").charAt(prefs.getString("username", "").length() - 1)).toLowerCase().equals("s")
|
||||
|| Character.toString(prefs.getString("username", "").charAt(prefs.getString("username", "").length() - 1)).toLowerCase().equals("z")) {
|
||||
toolbarTxt.setText(prefs.getString("username", "") + getString(R.string.nosplan));
|
||||
} else {
|
||||
toolbarTxt.setText(prefs.getString("username", "") + getString(R.string.splan));
|
||||
}
|
||||
} else {
|
||||
toolbarTxt.setText(getString(R.string.personalplan));
|
||||
}
|
||||
} else if (!prefs.getBoolean("defaultPersonalised", false)) {
|
||||
loadFragment(new FragmentPlan());
|
||||
bottomNav.setSelectedItemId(R.id.plan);
|
||||
toolbarTxt.setText(getString(R.string.app_name));
|
||||
}
|
||||
|
||||
job();
|
||||
|
||||
bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
Fragment fragment = null;
|
||||
boolean switcher = false;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.plan:
|
||||
if (getCurrentFragment().toString().contains("FragmentPlan")) {
|
||||
final RecyclerView recyclerView = findViewById(R.id.linearRecycler);
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
recyclerView.smoothScrollToPosition(0);
|
||||
appbarlayout.setExpanded(true);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fragment = new FragmentPlan();
|
||||
toolbarTxt.setText(getString(R.string.app_name));
|
||||
switcher = true;
|
||||
}
|
||||
break;
|
||||
case R.id.personal:
|
||||
if (getCurrentFragment().toString().contains("FragmentPersonal")) {
|
||||
final RecyclerView recyclerView = findViewById(R.id.linearRecycler);
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
recyclerView.smoothScrollToPosition(0);
|
||||
appbarlayout.setExpanded(true);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fragment = new FragmentPersonal();
|
||||
if (!prefs.getString("username", "").isEmpty()) {
|
||||
if (Character.toString(prefs.getString("username", "").charAt(prefs.getString("username", "").length() - 1)).toLowerCase().equals("s")
|
||||
|| Character.toString(prefs.getString("username", "").charAt(prefs.getString("username", "").length() - 1)).toLowerCase().equals("x")
|
||||
|| Character.toString(prefs.getString("username", "").charAt(prefs.getString("username", "").length() - 1)).toLowerCase().equals("z")) {
|
||||
toolbarTxt.setText(prefs.getString("username", "") + getString(R.string.nosplan));
|
||||
} else {
|
||||
toolbarTxt.setText(prefs.getString("username", "") + getString(R.string.splan));
|
||||
}
|
||||
} else {
|
||||
toolbarTxt.setText(getString(R.string.personalplan));
|
||||
}
|
||||
switcher = true;
|
||||
}
|
||||
break;
|
||||
case R.id.menu:
|
||||
if (getCurrentFragment().toString().contains("FragmentFood")) {
|
||||
final RecyclerView recyclerView = findViewById(R.id.linear_food);
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
recyclerView.smoothScrollToPosition(0);
|
||||
appbarlayout.setExpanded(true);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fragment = new FragmentFood();
|
||||
toolbarTxt.setText(getString(R.string.foodmenu));
|
||||
switcher = true;
|
||||
}
|
||||
break;
|
||||
case R.id.settings:
|
||||
if (getCurrentFragment().toString().contains("FragmentSettings")) {
|
||||
final NestedScrollView nsv = findViewById(R.id.nsvsettings);
|
||||
nsv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// recyclerView.fling(0);
|
||||
nsv.smoothScrollTo(0, 0);
|
||||
appbarlayout.setExpanded(true);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fragment = new FragmentSettings();
|
||||
toolbarTxt.setText(getString(R.string.settings));
|
||||
switcher = true;
|
||||
}
|
||||
break;
|
||||
case R.id.openinfopanel:
|
||||
if (bottomSheetBehaviour.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
break;
|
||||
} else if (bottomSheetBehaviour.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (switcher) {
|
||||
appbarlayout.setExpanded(true);
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
return loadFragment(fragment);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private Fragment getCurrentFragment() {
|
||||
return getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||
}
|
||||
|
||||
private boolean loadFragment(Fragment fragment) {
|
||||
if (fragment != null) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
// .setCustomAnimations(R.anim.fade_in, R.anim.fade_out) // TODO add proper animations
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (bottomSheetBehaviour.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class PlanFragment(isPersonal: Boolean) : Fragment(R.layout.plan) {
|
||||
class PlanFragment() : Fragment(R.layout.plan) { // isPersonal: Boolean
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private lateinit var mAdapter: CardAdapter
|
||||
private lateinit var layoutManager: GridLayoutManager
|
||||
@@ -28,7 +28,7 @@ class PlanFragment(isPersonal: Boolean) : Fragment(R.layout.plan) {
|
||||
private lateinit var mContext: Context
|
||||
private lateinit var prefs: SharedPreferences
|
||||
private lateinit var edit: SharedPreferences.Editor
|
||||
private val personal = isPersonal
|
||||
private var personal = false
|
||||
|
||||
private lateinit var smileydown: TextView
|
||||
private lateinit var smileydowntext: TextView
|
||||
@@ -53,6 +53,11 @@ class PlanFragment(isPersonal: Boolean) : Fragment(R.layout.plan) {
|
||||
recyclerView.layoutManager = layoutManager
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
personal = arguments!!.getBoolean("ispersonal")
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val pullToRefresh = view.findViewById<SwipeRefreshLayout>(R.id.pullToRefresh)
|
||||
@@ -92,8 +97,8 @@ class PlanFragment(isPersonal: Boolean) : Fragment(R.layout.plan) {
|
||||
DataFetcher(true, false, false, mContext, activity!!.application, view.rootView).execute()
|
||||
bottomSheetText.text = prefs.getString("informational", getString(R.string.noinfo))
|
||||
}
|
||||
substViewModel = ViewModelProviders.of(activity!!).get(SubstViewModel::class.java)
|
||||
substViewModel.allSubst.observe(this, Observer<List<Subst>> {
|
||||
substViewModel = ViewModelProviders.of(this).get(SubstViewModel::class.java)
|
||||
substViewModel.allSubst?.observe(this, Observer<List<Subst>> {
|
||||
if (personal) {
|
||||
planCardList.clear()
|
||||
smileydown.visibility = View.GONE
|
||||
@@ -103,16 +108,16 @@ class PlanFragment(isPersonal: Boolean) : Fragment(R.layout.plan) {
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
for (i in 0 until it.size) {
|
||||
if (prefs.getString("courses", "").isEmpty() && prefs.getString("classes", "").isNotEmpty()) {
|
||||
if (it[i].group.toString().isNotEmpty() && !it[i].group.equals("")) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group.toString()) || it[i].group.toString().contains(prefs.getString("classes", "").toString())) {
|
||||
if (it[i].group.isNotEmpty() && !it[i].group.equals("")) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
}
|
||||
} else if (prefs.getString("classes", "").isNotEmpty() && prefs.getString("courses", "").isNotEmpty()) {
|
||||
if (!it[i].group.equals("") && !it[i].course.equals("")) {
|
||||
if (prefs.getString("courses", "").contains(it[i].course.toString())) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group.toString()) || it[i].group.toString().contains(prefs.getString("classes", "").toString())) {
|
||||
if (prefs.getString("courses", "").contains(it[i].course)) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.job.JobParameters;
|
||||
import android.app.job.JobService;
|
||||
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 com.madapps.prefrences.EasyPrefrences;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
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.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ScheduledJobService extends JobService {
|
||||
|
||||
private boolean jobCancelled = false;
|
||||
Context context = this;
|
||||
private SubstViewModel substViewModel;
|
||||
|
||||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
doBackgroundWork(params);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doBackgroundWork(final JobParameters params) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
|
||||
substViewModel = new SubstViewModel(getApplication());
|
||||
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();
|
||||
}
|
||||
} catch (NullPointerException e1) {
|
||||
}
|
||||
}
|
||||
jobFinished(params, false);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
jobCancelled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private class fetcher extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private int count = 0, pCount = 0, priority = 200;
|
||||
Context mContext;
|
||||
String notifText = "", informational = "";
|
||||
String[] groupS, dateS, timeS, courseS, roomS, additionalS;
|
||||
boolean attempt = false, emptyIcon;
|
||||
URL url;
|
||||
URLConnection connection;
|
||||
String modified;
|
||||
Elements rows, paragraphs;
|
||||
Elements foodElements;
|
||||
Document doc, docFood;
|
||||
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
String channelId = "general";
|
||||
CharSequence channelName = getText(R.string.general);
|
||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||
NotificationChannel channel;
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
final SharedPreferences.Editor edit = prefs.edit();
|
||||
|
||||
protected fetcher(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
channel = new NotificationChannel(channelId, channelName, importance);
|
||||
channel.enableLights(true);
|
||||
channel.setLightColor(Color.BLUE);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
try {
|
||||
doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get();
|
||||
url = new URL("https://djd4rkn355.github.io/subst");
|
||||
connection = url.openConnection();
|
||||
rows = doc.select("tr");
|
||||
count = rows.size();
|
||||
|
||||
docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get();
|
||||
foodElements = docFood.select("th");
|
||||
|
||||
paragraphs = doc.select("p");
|
||||
pCount = paragraphs.size();
|
||||
|
||||
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();
|
||||
|
||||
attempt = true;
|
||||
modified = connection.getHeaderField("Last-Modified");
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
EasyPrefrences easyPrefs = new EasyPrefrences(context);
|
||||
ArrayList<String> foodList = new ArrayList<>();
|
||||
for (int foodInt = 0; foodInt < foodElements.size(); foodInt++) {
|
||||
|
||||
try {
|
||||
if (foodElements.get(foodInt).text().contains("Montag") ||
|
||||
foodElements.get(foodInt).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt).text().contains("Freitag")) {
|
||||
|
||||
if (foodElements.get(foodInt + 3).text().contains("Montag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("Freitag") ||
|
||||
foodElements.get(foodInt + 3).text().contains("von")) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text() + "\n" + foodElements.get(foodInt + 2).text());
|
||||
foodInt += 2;
|
||||
} else if (foodElements.get(foodInt + 2).text().contains("Montag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Dienstag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Mittwoch") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Donnerstag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("Freitag") ||
|
||||
foodElements.get(foodInt + 2).text().contains("von")) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text());
|
||||
foodInt += 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
foodList.add(foodElements.get(foodInt).text());
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
try {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text() + "\n" + foodElements.get(foodInt + 2).text());
|
||||
break;
|
||||
} catch (IndexOutOfBoundsException e1) {
|
||||
foodList.add(foodElements.get(foodInt).text() + "\n" + foodElements.get(foodInt + 1).text());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
easyPrefs.putListString("foodListPrefs", foodList);
|
||||
|
||||
if (substViewModel != null) {
|
||||
substViewModel.deleteAllSubst();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
MiscData dg = new MiscData();
|
||||
int drawable = dg.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);
|
||||
|
||||
// for juniors
|
||||
if (prefs.getString("courses", "").isEmpty() && !prefs.getString("classes", "").isEmpty()) {
|
||||
if (!groupS[i].isEmpty() && !groupS[i].equals("")) {
|
||||
if (prefs.getString("classes", "").contains(groupS[i]) || groupS[i].contains(prefs.getString("classes", ""))) {
|
||||
if (!notifText.isEmpty()) {
|
||||
notifText += ", ";
|
||||
}
|
||||
notifText += courseS[i] + ": " + additionalS[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for seniors
|
||||
else if (!prefs.getString("courses", "").isEmpty() && !prefs.getString("classes", "").isEmpty()) {
|
||||
if (!groupS[i].equals("") && !courseS[i].equals("")) {
|
||||
if (prefs.getString("courses", "").contains(courseS[i])) {
|
||||
if (prefs.getString("classes", "").contains(groupS[i]) || groupS[i].contains(prefs.getString("classes", ""))) {
|
||||
if (!notifText.isEmpty()) {
|
||||
notifText += ", ";
|
||||
}
|
||||
notifText += courseS[i] + ": " + additionalS[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent openApp = new Intent(getApplicationContext(), MainActivity.class);
|
||||
openApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent openAppPending = PendingIntent.getActivity(mContext, 0, openApp, 0);
|
||||
|
||||
RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.notification);
|
||||
notificationLayout.setTextViewText(R.id.notification_title, getString(R.string.subst));
|
||||
notificationLayout.setTextViewText(R.id.notification_textview, notifText);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "subst_table")
|
||||
public class Subst {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
|
||||
private int icon;
|
||||
private String group, date, time, course, room, additional;
|
||||
private int priority;
|
||||
|
||||
public Subst(int icon, String group, String date, String time, String course, String room, String additional, int priority) {
|
||||
this.icon = icon;
|
||||
this.group = group;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
this.course = course;
|
||||
this.room = room;
|
||||
this.additional = additional;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public String getAdditional() {
|
||||
return additional;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "subst_table")
|
||||
public class Subst(val icon: Int, val group: String, val date: String, val time: String, val course: String, val room: String, val additional: String, val priority: Int) {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Int = 0
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
@Dao
|
||||
public interface SubstDao {
|
||||
|
||||
@Insert
|
||||
void insert(Subst subst);
|
||||
|
||||
@Update
|
||||
void update(Subst subst);
|
||||
|
||||
@Delete
|
||||
void delete(Subst subst);
|
||||
|
||||
@Query("DELETE FROM subst_table")
|
||||
void deleteAllSubst();
|
||||
|
||||
@Query("SELECT * FROM subst_table ORDER BY priority DESC")
|
||||
LiveData<List<Subst>> getAllSubst();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.*
|
||||
|
||||
@Dao
|
||||
public interface SubstDao {
|
||||
|
||||
@get:Query("SELECT * FROM subst_table ORDER BY priority DESC")
|
||||
val allSubst: LiveData<List<Subst>>
|
||||
|
||||
@Insert
|
||||
fun insert(subst: Subst)
|
||||
|
||||
@Update
|
||||
fun update(subst: Subst)
|
||||
|
||||
@Delete
|
||||
fun delete(subst: Subst)
|
||||
|
||||
@Query("DELETE FROM subst_table")
|
||||
fun deleteAllSubst()
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
@Database(entities = {Subst.class}, version = 2, exportSchema = false)
|
||||
public abstract class SubstDatabase extends RoomDatabase {
|
||||
|
||||
private static SubstDatabase instance;
|
||||
|
||||
public abstract SubstDao substDao();
|
||||
|
||||
public static synchronized SubstDatabase getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = Room.databaseBuilder(context.getApplicationContext(),
|
||||
SubstDatabase.class,
|
||||
"subst_database")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [Subst::class], version = 3, exportSchema = false)
|
||||
public abstract class SubstDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun substDao(): SubstDao
|
||||
|
||||
companion object {
|
||||
|
||||
private var instance: SubstDatabase? = null
|
||||
|
||||
fun getInstance(context: Context): SubstDatabase? {
|
||||
if (instance == null) {
|
||||
synchronized (SubstDatabase::class) {
|
||||
instance = Room.databaseBuilder(context.applicationContext,
|
||||
SubstDatabase::class.java,
|
||||
"subst_database")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
}
|
||||
return instance
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
public class SubstRepository {
|
||||
|
||||
private SubstDao substDao;
|
||||
private LiveData<List<Subst>> allSubst;
|
||||
|
||||
public SubstRepository(Application application) {
|
||||
SubstDatabase database = SubstDatabase.getInstance(application);
|
||||
substDao = database.substDao();
|
||||
allSubst = substDao.getAllSubst();
|
||||
}
|
||||
|
||||
public void insert(Subst subst) {
|
||||
new InsertSubstAsync(substDao).execute(subst);
|
||||
}
|
||||
|
||||
public void update(Subst subst) {
|
||||
new UpdateSubstAsync(substDao).execute(subst);
|
||||
}
|
||||
|
||||
public void delete(Subst subst) {
|
||||
new DeleteSubstAsync(substDao).execute(subst);
|
||||
}
|
||||
|
||||
public void deleteAllSubst() {
|
||||
new DeleteAllSubstAsync(substDao).execute();
|
||||
}
|
||||
|
||||
public LiveData<List<Subst>> getAllSubst() {
|
||||
return allSubst;
|
||||
}
|
||||
|
||||
private static class InsertSubstAsync extends AsyncTask<Subst, Void, Void> {
|
||||
|
||||
private SubstDao substDao;
|
||||
private InsertSubstAsync(SubstDao substDao) {
|
||||
this.substDao = substDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Subst... substs) {
|
||||
substDao.insert(substs[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UpdateSubstAsync extends AsyncTask<Subst, Void, Void> {
|
||||
|
||||
private SubstDao substDao;
|
||||
private UpdateSubstAsync(SubstDao substDao) {
|
||||
this.substDao = substDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Subst... substs) {
|
||||
substDao.update(substs[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteSubstAsync extends AsyncTask<Subst, Void, Void> {
|
||||
|
||||
private SubstDao substDao;
|
||||
private DeleteSubstAsync(SubstDao substDao) {
|
||||
this.substDao = substDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Subst... substs) {
|
||||
substDao.delete(substs[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteAllSubstAsync extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private SubstDao substDao;
|
||||
private DeleteAllSubstAsync(SubstDao substDao) {
|
||||
this.substDao = substDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
substDao.deleteAllSubst();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.app.Application
|
||||
import android.os.AsyncTask
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
|
||||
public class SubstRepository(application: Application) {
|
||||
|
||||
private val substDao: SubstDao?
|
||||
val allSubst: LiveData<List<Subst>>?
|
||||
|
||||
init {
|
||||
val database = SubstDatabase.getInstance(application)
|
||||
substDao = database?.substDao()
|
||||
allSubst = substDao?.allSubst
|
||||
}
|
||||
|
||||
fun insert(subst: Subst) {
|
||||
InsertSubstAsync(substDao).execute(subst)
|
||||
}
|
||||
|
||||
fun update(subst: Subst) {
|
||||
UpdateSubstAsync(substDao).execute(subst)
|
||||
}
|
||||
|
||||
fun delete(subst: Subst) {
|
||||
DeleteSubstAsync(substDao).execute(subst)
|
||||
}
|
||||
|
||||
fun deleteAllSubst() {
|
||||
DeleteAllSubstAsync(substDao).execute()
|
||||
}
|
||||
|
||||
class InsertSubstAsync(substDao: SubstDao?) : AsyncTask<Subst, Void, Void>() {
|
||||
val mSubstDao = substDao
|
||||
override fun doInBackground(vararg substs: Subst): Void? {
|
||||
mSubstDao?.insert(substs[0])
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateSubstAsync(substDao: SubstDao?) : AsyncTask<Subst, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg substs: Subst): Void? {
|
||||
mSubstDao?.update(substs[0])
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteSubstAsync(substDao: SubstDao?) : AsyncTask<Subst, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg substs: Subst): Void? {
|
||||
mSubstDao?.delete(substs[0])
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteAllSubstAsync(substDao: SubstDao?) : AsyncTask<Void, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg voids: Void): Void? {
|
||||
mSubstDao?.deleteAllSubst()
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
public class SubstViewModel extends AndroidViewModel {
|
||||
|
||||
private SubstRepository repository;
|
||||
private LiveData<List<Subst>> allSubst;
|
||||
|
||||
public SubstViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
repository = new SubstRepository(application);
|
||||
allSubst = repository.getAllSubst();
|
||||
}
|
||||
|
||||
public void insert(Subst subst) {
|
||||
repository.insert(subst);
|
||||
}
|
||||
|
||||
public void update(Subst subst) {
|
||||
repository.update(subst);
|
||||
}
|
||||
|
||||
public void delete(Subst subst) {
|
||||
repository.delete(subst);
|
||||
}
|
||||
|
||||
public void deleteAllSubst() {
|
||||
repository.deleteAllSubst();
|
||||
}
|
||||
|
||||
public LiveData<List<Subst>> getAllSubst() {
|
||||
return allSubst;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
|
||||
public class SubstViewModel(application: Application) : AndroidViewModel(application) {
|
||||
|
||||
private val repository: SubstRepository
|
||||
val allSubst: LiveData<List<Subst>>?
|
||||
|
||||
init {
|
||||
repository = SubstRepository(application)
|
||||
allSubst = repository.allSubst
|
||||
}
|
||||
|
||||
fun insert(subst: Subst) {
|
||||
repository.insert(subst)
|
||||
}
|
||||
|
||||
fun update(subst: Subst) {
|
||||
repository.update(subst)
|
||||
}
|
||||
|
||||
fun delete(subst: Subst) {
|
||||
repository.delete(subst)
|
||||
}
|
||||
|
||||
fun deleteAllSubst() {
|
||||
repository.deleteAllSubst()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.denizd.substitutionplan;
|
||||
|
||||
public class names {
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="300"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
|
||||
<alpha
|
||||
android:fromAlpha="0.0"
|
||||
android:toAlpha="1.0">
|
||||
</alpha>
|
||||
</set>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime">
|
||||
|
||||
<translate
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="-20%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<alpha
|
||||
android:fromAlpha="1"
|
||||
android:toAlpha="0"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<scale
|
||||
android:fromXScale="100%"
|
||||
android:fromYScale="100%"
|
||||
android:toXScale="105%"
|
||||
android:toYScale="105%"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
</set>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="125">
|
||||
|
||||
<translate
|
||||
android:fromYDelta="-20%"
|
||||
android:toYDelta="0"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<alpha
|
||||
android:fromAlpha="0"
|
||||
android:toAlpha="1"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<scale
|
||||
android:fromXScale="105%"
|
||||
android:fromYScale="105%"
|
||||
android:toXScale="100%"
|
||||
android:toYScale="100%"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
</set>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layoutAnimation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:animation="@anim/item_animation_fall_down_out"
|
||||
android:delay="15%"
|
||||
android:animationOrder="normal"/>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layoutAnimation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:animation="@anim/item_animation_fall_down_quick"
|
||||
android:delay="6%"
|
||||
android:animationOrder="normal"/>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layoutAnimation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:animation="@anim/fade_in"
|
||||
android:delay="15%"
|
||||
android:animationOrder="normal"/>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
|
||||
<item android:drawable="?attr/colorBackground"/>
|
||||
</layer-list>
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
tools:context=".Main">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbarlayout"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity"
|
||||
tools:context=".Main"
|
||||
tools:showIn="@layout/app_bar_main"
|
||||
android:id="@+id/content"
|
||||
android:background="@color/background"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
app:cardElevation="2dp">
|
||||
app:cardElevation="1dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView android:layout_width="match_parent"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:backgroundTint="@color/lightbackground"
|
||||
@@ -10,8 +12,7 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
app:cardElevation="2dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
app:cardElevation="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:focusable="false">
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/background"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="@string/keyphrase"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="@color/accent"
|
||||
android:textColorHint="@color/hintcolor"
|
||||
android:textSize="20sp"
|
||||
android:theme="@style/EditTextTheme"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/searchbar">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/linearRecyclerSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"/>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,7 +2,6 @@
|
||||
<resources>
|
||||
<string name="app_name">AvH-Plan</string>
|
||||
<string name="filter">Filter</string>
|
||||
<string name="lastupdated">Zuletzt aktualisiert</string>
|
||||
<string name="nointernet">Keine Internetverbindung</string>
|
||||
<string name="general">Allgemein</string>
|
||||
<string name="classes">Klasse</string>
|
||||
@@ -12,11 +11,9 @@
|
||||
<string name="settings">Einstellungen</string>
|
||||
<string name="plan">Plan</string>
|
||||
<string name="darkbg">Dunkler Hintergrund</string>
|
||||
<string name="restart">App-Neustart erforderlich</string>
|
||||
<string name="notifications">Aktiviere Benachrichtigungen</string>
|
||||
<string name="notifiedabout">Aktiviert ebenfalls Hintergrund-Sync</string>
|
||||
<string name="personalplan">Persönlicher Plan</string>
|
||||
<string name="keyphrase">Gib ein Stichwort ein</string>
|
||||
<string name="personalise">Personalisieren</string>
|
||||
<string name="misc">Diverses</string>
|
||||
<string name="defplan">Standardmäßig ansonsten normaler Plan</string>
|
||||
@@ -25,7 +22,6 @@
|
||||
<string name="butwhy">Falls nötig</string>
|
||||
<string name="menu">Menü</string>
|
||||
<string name="foodmenu">Speiseplan</string>
|
||||
<string name="bestclass">17a ist das beste Profil</string>
|
||||
<string name="letsgo">Los geht\'s!</string>
|
||||
<string name="welcome">Willkommen!</string>
|
||||
<string name="firstsomethings">Lass uns erst einige Sachen einrichten.</string>
|
||||
@@ -86,12 +82,8 @@
|
||||
<string name="error">Ein Fehler ist aufgetreten!</string>
|
||||
<string name="wantnotif">Benachrichtigungen und Hintergrund-Synchronisation aktivieren</string>
|
||||
<string name="nosubst">Kein Entfall für dich</string>
|
||||
<string name="chinaNotif">Auf diesem Gerät nicht unterstützt</string>
|
||||
<string name="chinaAuto">Auf diesem Gerät automatisch aktiviert</string>
|
||||
<string name="chinaDialog">Einige chinesische Hersteller, wie Huawei/Honor und Xiaomi, unterdrücken Hintergrund-Services, weshalb Benachrichtungen und Hintergrund-Synchronisation nicht funktionieren.\n\nIch habe feststellen müssen, dass es keine einfache Lösung dafür gibt, die ich einbauen könnte.\n\nStattdessen kannst du jedoch versuchen, App-Optimierungen für diese App zu deaktivieren:\n\nSchließe die App und öffne \"Einstellungen\" -> \"Apps\" -> \"AvH-Plan\" -> \"Akku\" -> \"App-Start\" -> \"Automatisch verwalten\" deaktivieren, \"Im Hintergrund ausführen\" aktivieren.\n\nDies kann unter Umständen keinen Einfluss haben.</string>
|
||||
<string name="orbuy">Oder kauf dir ein gutes Smartphone</string>
|
||||
<string name="chinaTitle">Informationen bezüglich deines Gerätes</string>
|
||||
<string name="searchonline">Suche online</string>
|
||||
<string name="customisecolor1">Benutzerdefinierte Farben</string>
|
||||
<string name="customisecolor2">Farben für jedes Fach einstellen</string>
|
||||
<string name="courseDeu">Deutsch (+ DAZ)</string>
|
||||
@@ -123,7 +115,6 @@
|
||||
<string name="clearall">Alle löschen</string>
|
||||
<string name="allcolourscleared">Farben für alle Kurse wurden gelöscht</string>
|
||||
<string name="clearcolour">Farbe löschen</string>
|
||||
<string name="finish">Fertigstellen</string>
|
||||
<string name="chromecompatible">Kein Chrome-kompatibler Browser gefunden</string>
|
||||
<string name="noyoutube">YouTube-App nicht gefunden</string>
|
||||
<string name="swipeindependent">Unabhängig von Wischgeste</string>
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme0.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,40 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<color name="background">#eeeeee</color>
|
||||
<color name="background">#e0e0e0</color>
|
||||
<color name="lightbackground">#f5f5f5</color>
|
||||
<color name="accent">#448aff</color>
|
||||
<color name="textcolor">#212121</color>
|
||||
<color name="hintcolor">#757575</color>
|
||||
<color name="lighthintcolor">#bdbdbd</color>
|
||||
|
||||
<!-- <color name="background">#FFFFFF</color>-->
|
||||
<!-- <color name="colorChipLight">#f5f5f5</color>-->
|
||||
<!-- <color name="colorChipDark">#1E1E1E</color>-->
|
||||
|
||||
<!-- <color name="white">#FFFFFF</color>-->
|
||||
<!-- <color name="black">#000000</color>-->
|
||||
<!-- <color name="accent">#448aff</color>-->
|
||||
<!-- <color name="accentPastel">#64b5f6</color>-->
|
||||
<!-- <color name="dark">#121212</color>-->
|
||||
<!-- <color name="lessdark">#1E1E1E</color>-->
|
||||
<!-- <color name="lightgrey">#bdbdbd</color>-->
|
||||
|
||||
<!-- <color name="textcolor">#212121</color>-->
|
||||
<!-- <color name="textLight">#e0e0e0</color>-->
|
||||
|
||||
<!-- <color name="darkdivider">#313131</color>-->
|
||||
|
||||
<!-- <color name="darkwhite">#eeeeee</color>-->
|
||||
<!-- <color name="lightwhite">#f5f5f5</color>-->
|
||||
|
||||
<color name="datingPink">#d81b60</color>
|
||||
|
||||
<!-- <color name="hint">#9e9e9e</color>-->
|
||||
<!-- <color name="hintdark">#757575</color>-->
|
||||
|
||||
<color name="slighttransparency">#42000000</color>
|
||||
|
||||
<color name="red">#e53935</color>
|
||||
<color name="pink">#E91E63</color>
|
||||
<color name="purple">#9C27B0</color>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<string name="app_name">AvH Plan</string>
|
||||
<string name="subst">Substitution Plan</string>
|
||||
<string name="filter">Filters</string>
|
||||
<string name="lastupdated">Last updated</string>
|
||||
<string name="nointernet">No internet connection</string>
|
||||
<string name="general">General</string>
|
||||
<string name="classes">Grade</string>
|
||||
@@ -14,12 +13,10 @@
|
||||
|
||||
<!-- for Settings fragment -->
|
||||
<string name="darkbg">Dark background</string>
|
||||
<string name="restart">App restart required</string>
|
||||
<string name="notifications">Enable notifications</string>
|
||||
<string name="notifiedabout">Also enables background sync</string>
|
||||
|
||||
<string name="personalplan">Personal Plan</string>
|
||||
<string name="keyphrase">Enter a keyphrase</string>
|
||||
<string name="personalise">Personalise</string>
|
||||
<string name="misc">Miscellaneous</string>
|
||||
<string name="personalised">Set personalised plan as default</string>
|
||||
@@ -28,7 +25,6 @@
|
||||
<string name="butwhy">In case you need to</string>
|
||||
<string name="menu">Menu</string>
|
||||
<string name="foodmenu">Food Menu</string>
|
||||
<string name="bestclass">17a is the best profile</string>
|
||||
<string name="letsgo">Let\'s Go!</string>
|
||||
<string name="welcome">Welcome!</string>
|
||||
<string name="firstsomethings">First, let\'s setup some things.</string>
|
||||
@@ -96,14 +92,8 @@
|
||||
<string name="error">An error occurred!</string>
|
||||
<string name="nosubst">No substitutions for you</string>
|
||||
|
||||
<string name="chinaNotif">Not supported this device</string>
|
||||
<string name="chinaAuto">Automatically enabled on your device</string>
|
||||
|
||||
<string name="chinaTitle">Information regarding your device</string>
|
||||
<string name="chinaDialog">Some Chinese manufacturers, such as Huawei/Honor and Xiaomi, heavily suppress background services, which results in notifications and background synchronisation not working.\n\nFrom my current research, I have determined that there\'s no easy workaround I can implement.\n\nYou can, however, try to disable power optimisation for this app in the settings:\n\nClose the app and open \"Settings\" -> \"Apps\" -> \"AvH Plan\" -> \"Battery\" -> \"Launch\" -> disable \"Manage automatically\", enable \"Run in background\"\n\nThis is not guaranteed to work.</string>
|
||||
<string name="orbuy">Or, you know, buy a good device</string>
|
||||
|
||||
<string name="searchonline">Search online</string>
|
||||
|
||||
<string name="customisecolor1">Customise colours</string>
|
||||
<string name="customisecolor2">Customise every subject individually</string>
|
||||
@@ -139,7 +129,6 @@
|
||||
<string name="clearall">Clear all</string>
|
||||
<string name="clearcolour">Clear colour</string>
|
||||
<string name="allcolourscleared">Colours for all courses have been cleared</string>
|
||||
<string name="finish">Finish</string>
|
||||
|
||||
<string name="chromecompatible">No Chrome-compatible browser found</string>
|
||||
<string name="noyoutube">YouTube app not found</string>
|
||||
|
||||
Reference in New Issue
Block a user