commit a45e5cdfa08f86ad71febebe3c9db1a7d3fe6512 Author: Deniz Düzgören Date: Mon Apr 29 19:27:51 2019 +0200 Initial Push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..f75e2dc --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,59 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' + +android { +// signingConfigs { +// release { +// keyAlias 'key0' +// keyPassword 'Cinemassacre' +// storeFile file('C:/Users/kduez/git/substKey.jks') +// storePassword 'Cinemassacre' +// } +// } + compileSdkVersion 28 + defaultConfig { + applicationId "com.denizd.substitutionplan" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 9 + versionName "1.2.4" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' +// signingConfig signingConfigs.release + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'androidx.appcompat:appcompat:1.1.0-alpha04' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.2.0-alpha03' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha03' + implementation 'org.jsoup:jsoup:1.11.3' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04' + implementation 'com.google.android.material:material:1.1.0-alpha05' + implementation 'com.android.support:customtabs:28.0.0' + implementation 'com.jaredrummler:android-device-names:1.1.8' + implementation 'com.github.mukeshsolanki:easypreferences:1.0.6' + + def lifecycle_version = "2.0.0" + implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" + annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" + + def room_version = "2.1.0-alpha04" + implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$room_version" + + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/release/app.aab b/app/release/app.aab new file mode 100644 index 0000000..746fc67 Binary files /dev/null and b/app/release/app.aab differ diff --git a/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java new file mode 100644 index 0000000..a16d79b --- /dev/null +++ b/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.denizd.substitutionplan; + +import android.content.Context; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.denizd.substitutionplan", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c413e71 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..6c330e9 Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/denizd/substitutionplan/CardAdapter.java b/app/src/main/java/com/denizd/substitutionplan/CardAdapter.java new file mode 100644 index 0000000..c8c136b --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/CardAdapter.java @@ -0,0 +1,73 @@ +package com.denizd.substitutionplan; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class CardAdapter extends RecyclerView.Adapter { + private List mSubst; + + public static class CardViewHolder extends RecyclerView.ViewHolder { + public ImageView mImageView; + public TextView mGroup, mDate, mTime, mCourse, mRoom, mAdditional; + + public CardViewHolder(@NonNull View itemView) { + super(itemView); + mImageView = itemView.findViewById(R.id.iconView); + mGroup = itemView.findViewById(R.id.group); + mDate = itemView.findViewById(R.id.date); + mTime = itemView.findViewById(R.id.time); + mCourse = itemView.findViewById(R.id.course); + mRoom = itemView.findViewById(R.id.room); + mAdditional = itemView.findViewById(R.id.additional); + } + } + + public CardAdapter(ArrayList subst) { + mSubst = subst; + } + + @NonNull + @Override + public CardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.course_card, parent, false); + CardViewHolder cvh = new CardViewHolder(v); + return cvh; + } + + public Subst getSubstAt(int i) { + return mSubst.get(i); + } + + @Override + public void onBindViewHolder(@NonNull CardViewHolder holder, int position) { + Subst currentItem = mSubst.get(position); + + + holder.mImageView.setImageResource(currentItem.getIcon()); + holder.mGroup.setText(currentItem.getGroup()); + holder.mDate.setText(currentItem.getDate()); + holder.mTime.setText(currentItem.getTime()); + holder.mCourse.setText(currentItem.getCourse()); + holder.mRoom.setText(currentItem.getRoom()); + holder.mAdditional.setText(currentItem.getAdditional()); + } + + @Override + public int getItemCount() { + return mSubst.size(); + } + + public void setSubst(List subst) { + mSubst = subst; + notifyDataSetChanged(); + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FirstTime.java b/app/src/main/java/com/denizd/substitutionplan/FirstTime.java new file mode 100644 index 0000000..38f03e1 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FirstTime.java @@ -0,0 +1,235 @@ +package com.denizd.substitutionplan; + +import android.animation.Animator; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.Animatable; +import android.os.Build; +import android.os.Handler; +import android.preference.PreferenceManager; + +import androidx.annotation.ColorInt; +import androidx.appcompat.app.AppCompatActivity; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.content.ContextCompat; + +import android.os.Bundle; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewAnimationUtils; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; +import com.jaredrummler.android.device.DeviceName; + +import java.util.Calendar; + +public class FirstTime extends AppCompatActivity { + + private String manufacturer; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_first_time); + setTheme(R.style.AppTheme0); + + Window window = this.getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + window.setStatusBarColor(ContextCompat.getColor(this, R.color.white)); + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.white)); + } else { + window.setStatusBarColor(ContextCompat.getColor(this, R.color.black)); + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.black)); + } + window.setBackgroundDrawable(getDrawable(R.drawable.white)); + Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); + ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.white)); + setTaskDescription(taskDesc); + + final Context context = this; + + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); + final SharedPreferences.Editor edit = prefs.edit(); + + final ExtendedFloatingActionButton fab = findViewById(R.id.efab); + + final Intent start = new Intent(this, MainActivity.class); + + final EditText name = findViewById(R.id.txtName); + final EditText grade = findViewById(R.id.txtClasses); + final EditText courses = findViewById(R.id.txtCourses); + final CheckBox notif = findViewById(R.id.cbNotif); + final CheckBox dark = findViewById(R.id.cbDark); + final CheckBox pers = findViewById(R.id.cbPersonalised); + final ImageButton helpClasses = findViewById(R.id.chipHelpClasses); + final ImageButton helpCourses = findViewById(R.id.chipHelpCourses); + + // TODO Huawei + +// DeviceName.with(context).request(new DeviceName.Callback() { +// @Override +// public void onFinished(DeviceName.DeviceInfo info, Exception error) { +// manufacturer = info.manufacturer; +// if (manufacturer.contains("Huawei") || +// manufacturer.contains("Honor")) { +//// if (true) { +// notif.setEnabled(false); +// +// @ColorInt int color; +// +// TypedValue typedValue = new TypedValue(); +// Resources.Theme theme = context.getTheme(); +// theme.resolveAttribute(R.attr.colorHint, typedValue, true); +// color = typedValue.data; +// +// notif.setTextColor(color); +// edit.putBoolean("notif", false); +// edit.putBoolean("autoRefresh", true); +// edit.apply(); +// } +// } +// }); + + helpCourses.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder alertDialog; + alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight); + alertDialog.setTitle(getString(R.string.helpCoursesTitle)); + View dialogView = LayoutInflater.from(context).inflate(R.layout.simple_dialog, null); + 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; + alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight); + alertDialog.setTitle(getString(R.string.helpClassesTitle)); + View dialogView = LayoutInflater.from(context).inflate(R.layout.simple_dialog, null); + TextView dialogText = dialogView.findViewById(R.id.dialogtext); + dialogText.setText(getString(R.string.helpClasses)); + alertDialog.setView(dialogView); + alertDialog.show(); + } + }); + + final LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + fab.setClickable(false); + + edit.putString("firstTimeDev", String.valueOf(Calendar.getInstance().getTime())); + edit.putString("username", name.getText().toString()); + edit.putString("classes", grade.getText().toString()); + edit.putString("courses", courses.getText().toString()); + if (dark.isChecked()) { + edit.putInt("themeInt", 1); + } else { + edit.putInt("themeInt", 0); + } + if (notif.isChecked()) { + edit.putBoolean("notif", true); + } else { + edit.putBoolean("notif", false); + } + if (pers.isChecked()) { + edit.putBoolean("defaultPersonalised", true); + } else { + edit.putBoolean("defaultPersonalised", false); + } + + edit.putBoolean("firstTime", false); + edit.apply(); + + final CoordinatorLayout cLayout = findViewById(R.id.coordinatorLayout); + final LinearLayout linearInflation = findViewById(R.id.linearInflation); + + int x = fab.getRight() - fab.getWidth() / 2; + int y = fab.getBottom() - fab.getHeight() / 2; + + int startRadius = 0; + int endRadius = (int) Math.hypot(cLayout.getWidth(), cLayout.getHeight()); + + inflater.inflate(R.layout.welcome_screen, linearInflation, true); + + Animator anim = ViewAnimationUtils.createCircularReveal(linearInflation, x, y, startRadius, endRadius); + anim.setDuration(600); + + final LinearLayout colour = findViewById(R.id.colourLayout); + + linearInflation.setVisibility(View.VISIBLE); + anim.start(); + + final Animation animationOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out_short); + + final Handler handlerZero = new Handler(); + handlerZero.postDelayed(new Runnable() { + @Override + public void run() { + colour.startAnimation(animationOut); + } + }, 400); + + animationOut.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) {} + + @Override + public void onAnimationEnd(Animation animation) { + colour.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(Animation animation) {} + }); + + final Handler handlerOne = new Handler(); + handlerOne.postDelayed(new Runnable() { + @Override + public void run() { + ImageView mImgCheck = findViewById(R.id.imageView); + ((Animatable) mImgCheck.getDrawable()).start(); + } + }, 1000); + + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + startActivity(start); + finish(); + } + }, 2000); + + } + }); + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/Food.java b/app/src/main/java/com/denizd/substitutionplan/Food.java new file mode 100644 index 0000000..03f0a12 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/Food.java @@ -0,0 +1,17 @@ +package com.denizd.substitutionplan; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +public class Food { + + private String food; + + public Food(String food) { + this.food = food; + } + + public String getFood() { + return food; + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FoodAdapter.java b/app/src/main/java/com/denizd/substitutionplan/FoodAdapter.java new file mode 100644 index 0000000..df0b730 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FoodAdapter.java @@ -0,0 +1,59 @@ +package com.denizd.substitutionplan; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class FoodAdapter extends RecyclerView.Adapter { + private List 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) { + 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) { + mFood = food; + notifyDataSetChanged(); + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FoodFragment.kt b/app/src/main/java/com/denizd/substitutionplan/FoodFragment.kt new file mode 100644 index 0000000..c5671c1 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FoodFragment.kt @@ -0,0 +1,4 @@ +package com.denizd.substitutionplan + +class FoodFragment { +} \ No newline at end of file diff --git a/app/src/main/java/com/denizd/substitutionplan/FragmentFood.java b/app/src/main/java/com/denizd/substitutionplan/FragmentFood.java new file mode 100644 index 0000000..9ce31e5 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FragmentFood.java @@ -0,0 +1,254 @@ +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.view.animation.LayoutAnimationController; +import android.widget.ProgressBar; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import java.io.IOException; +import java.util.ArrayList; + +import static android.content.Context.LAYOUT_INFLATER_SERVICE; +import static com.google.android.material.snackbar.Snackbar.make; + +public class FragmentFood extends Fragment { + + private RecyclerView recyclerView; + private FoodAdapter mAdapter; + private RecyclerView.LayoutManager layoutManager; + private ArrayList 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.pullToRefreshFood); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + final SharedPreferences.Editor edit = prefs.edit(); + final LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_animation_fall_down); + final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE); + + EasyPrefrences easyPrefs = new EasyPrefrences(getContext()); + ArrayList 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); + +// try { +// recyclerView.removeAllViews(); +// } catch (NullPointerException e) { +// +// } + + 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 { + + boolean attempt = false, npe = false; + Elements foodElements; + Document docFood; + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + final SharedPreferences.Editor edit = prefs.edit(); + final SwipeRefreshLayout pullToRefresh = getView().findViewById(R.id.pullToRefreshFood); + + protected fetcher() { + } + + @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()); +// progressBar.incrementProgressBy(paragraphs[0].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 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 foodListPopulation = new ArrayList<>(easyPrefs.getListString("foodListPrefs")); + + final LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_animation_fall_down); + final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE); + + for (int i = 0; i < foodListPopulation.size(); i++) { + foodArrayList.add(new Food(foodListPopulation.get(i))); + mAdapter.setFood(foodArrayList); + 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) { +// 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(); + } + + } + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FragmentPersonal.java b/app/src/main/java/com/denizd/substitutionplan/FragmentPersonal.java new file mode 100644 index 0000000..bc78b5d --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FragmentPersonal.java @@ -0,0 +1,377 @@ +package com.denizd.substitutionplan; + +import android.content.Context; +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 androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProviders; +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 android.content.Context.LAYOUT_INFLATER_SERVICE; +import static com.google.android.material.snackbar.Snackbar.make; + +public class FragmentPersonal extends Fragment { + + private RecyclerView recyclerView; + private CardAdapter mAdapter; + private RecyclerView.LayoutManager layoutManager; + private ArrayList planCardList; + private TextView bottomSheetText; + private SubstViewModel substViewModel; + private boolean persPlanEmpty; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.plan, null); + } + + @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); + layoutManager = new LinearLayoutManager(getContext()); + recyclerView.setHasFixedSize(true); + 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>() { + @Override + public void onChanged(List 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() { + @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.setRefreshing(true); +// new fetcher().execute(); + + 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 { + + 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, emptyIcon; + 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); + + int drawable = icons(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; + } + + private int icons(String course) { + emptyIcon = false; + if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) { + return R.drawable.ic_german; + } else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) { + return R.drawable.ic_maths; + } else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) { + return R.drawable.ic_english; + } else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) { + return R.drawable.ic_pe; + } else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) { + return R.drawable.ic_politics; + } else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) { + return R.drawable.ic_drama; + } else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) { + return R.drawable.ic_physics; + } else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) { + return R.drawable.ic_biology; + } else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) { + return R.drawable.ic_chemistry; + } else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) { + return R.drawable.ic_philosophy; + } else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) { + return R.drawable.ic_latin; + } else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) { + return R.drawable.ic_spanish; + } else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) { + return R.drawable.ic_french; + } else if (course.toLowerCase().contains("inf")) { + return R.drawable.ic_compsci; + } else if (course.toLowerCase().contains("ges")) { + return R.drawable.ic_history; + } else if (course.toLowerCase().contains("rel")) { + return R.drawable.ic_religion; + } else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) { + return R.drawable.ic_geography; + } else if (course.toLowerCase().contains("kun")) { + return R.drawable.ic_arts; + } else if (course.toLowerCase().contains("mus")) { + return R.drawable.ic_music; + } else if (course.toLowerCase().contains("tue")) { + return R.drawable.ic_turkish; + } else if (course.toLowerCase().contains("chi")) { + return R.drawable.ic_chinese; + } else if (course.toLowerCase().contains("gll")) { + return R.drawable.ic_gll; + } else if (course.toLowerCase().contains("wat")) { + return R.drawable.ic_wat; + } else if (course.toLowerCase().contains("för")) { + return R.drawable.ic_help; + } else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) { + return R.drawable.ic_pencil; + } else { + emptyIcon = true; + return R.drawable.ic_empty; + } + } + + @Override + protected void onPostExecute(Void result) { + try { + if (attempt) { + final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.fade_out); + + 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 e) { + + } + } + + + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FragmentPlan.java b/app/src/main/java/com/denizd/substitutionplan/FragmentPlan.java new file mode 100644 index 0000000..1edba50 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FragmentPlan.java @@ -0,0 +1,316 @@ +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 androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProviders; +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.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; + private ArrayList 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 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); + layoutManager = new LinearLayoutManager(getContext()); + recyclerView.setHasFixedSize(true); + 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 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>() { + @Override + public void onChanged(List substs) { +// LayoutAnimationController animationOut = AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_animation_fall_down_out); +// LayoutAnimationController animationIn = AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_animation_fall_down); +// recyclerView.setLayoutAnimation(animationOut); +// recyclerView.scheduleLayoutAnimation(); + mAdapter.setSubst(substs); +// recyclerView.setLayoutAnimation(animationIn); + recyclerView.scheduleLayoutAnimation(); + bottomSheetText.setText(prefs.getString("informational", getString(R.string.noinfo))); + } + }); + + + 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 { + + 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, emptyIcon; + 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); + + int drawable = icons(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; + } + + private int icons(String course) { + emptyIcon = false; + if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) { + return R.drawable.ic_german; + } else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) { + return R.drawable.ic_maths; + } else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) { + return R.drawable.ic_english; + } else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) { + return R.drawable.ic_pe; + } else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) { + return R.drawable.ic_politics; + } else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) { + return R.drawable.ic_drama; + } else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) { + return R.drawable.ic_physics; + } else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) { + return R.drawable.ic_biology; + } else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) { + return R.drawable.ic_chemistry; + } else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) { + return R.drawable.ic_philosophy; + } else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) { + return R.drawable.ic_latin; + } else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) { + return R.drawable.ic_spanish; + } else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) { + return R.drawable.ic_french; + } else if (course.toLowerCase().contains("inf")) { + return R.drawable.ic_compsci; + } else if (course.toLowerCase().contains("ges")) { + return R.drawable.ic_history; + } else if (course.toLowerCase().contains("rel")) { + return R.drawable.ic_religion; + } else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) { + return R.drawable.ic_geography; + } else if (course.toLowerCase().contains("kun")) { + return R.drawable.ic_arts; + } else if (course.toLowerCase().contains("mus")) { + return R.drawable.ic_music; + } else if (course.toLowerCase().contains("tue")) { + return R.drawable.ic_turkish; + } else if (course.toLowerCase().contains("chi")) { + return R.drawable.ic_chinese; + } else if (course.toLowerCase().contains("gll")) { + return R.drawable.ic_gll; + } else if (course.toLowerCase().contains("wat")) { + return R.drawable.ic_wat; + } else if (course.toLowerCase().contains("för")) { + return R.drawable.ic_help; + } else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) { + return R.drawable.ic_pencil; + } else { + emptyIcon = true; + return R.drawable.ic_empty; + } + } + + @Override + protected void onPostExecute(Void result) { + try { + if (attempt) { + final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.fade_out); + + 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 e) { + + } + } + + + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FragmentSearch.java b/app/src/main/java/com/denizd/substitutionplan/FragmentSearch.java new file mode 100644 index 0000000..f8d58d3 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FragmentSearch.java @@ -0,0 +1,318 @@ +package com.denizd.substitutionplan; + +import android.content.SharedPreferences; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.google.android.material.snackbar.Snackbar; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProviders; +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.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static com.google.android.material.snackbar.Snackbar.make; + +public class FragmentSearch extends Fragment { + + ConstraintLayout constraintLayout; + + private RecyclerView recyclerView; + private CardAdapter mAdapter; + private RecyclerView.LayoutManager layoutManager; + private ArrayList 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>() { + @Override + public void onChanged(List substs) { + planCardList.removeAll(substs); + new search(substs).searchSth(); + } + }); + + } + }); + + } + + private class search extends AsyncTask { + + private List substs; + + protected search(List 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).getDate().toLowerCase().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { + search = true; + } + if (substs.get(i).getTime().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { + search = true; + } + if (substs.get(i).getCourse().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { + search = true; + } + 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; + } + } + } + } + +// private class fetcher extends AsyncTask { +// +// private int count = 0, iconColour; +// String[] groupS, dateS, timeS, courseS, roomS, additionalS; +// boolean attempt = false, search = false, first = false, npe = false, emptyIcon; +// Elements rows; +// Document doc; +// final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); +// private RecyclerView recyclerView; +// private CardAdapter mAdapter; +// private RecyclerView.LayoutManager layoutManager; +// private ArrayList planCardList; +// +// protected fetcher() {} +// +// @Override +// protected Void doInBackground(Void... params) { +// +// if (!first) { +// try { +// doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get(); +// rows = doc.select("tr"); +// count = rows.size(); +// attempt = true; +// +// } catch (IOException e1) { +// npe = true; +// } +// +// groupS = new String[count]; +// dateS = new String[count]; +// timeS = new String[count]; +// courseS = new String[count]; +// roomS = new String[count]; +// additionalS = new String[count]; +// +// if (attempt) { +// for (int i = 0; i < count; i++) { +// Element row = rows.get(i); +// Elements cols = row.select("th"); +// groupS[i] = cols.get(0).text(); +// dateS[i] = cols.get(1).text(); +// timeS[i] = cols.get(2).text(); +// courseS[i] = cols.get(3).text(); +// roomS[i] = cols.get(4).text(); +// additionalS[i] = cols.get(5).text(); +// } +// } +// +// if (prefs.getInt("themeInt", 0) == 0) { +// iconColour = Color.parseColor("#212121"); +// } +// if (prefs.getInt("themeInt", 0) == 1) { +// iconColour = Color.parseColor("#e0e0e0"); +// } +// first = true; +// } +// +// return null; +// } +// +// private int icons(String[] courseS, int i) { +// emptyIcon = false; +// if (courseS[i].toLowerCase().contains("deu") || courseS[i].toLowerCase().contains("dep") || courseS[i].toLowerCase().contains("daz")) { +// return R.drawable.ic_german; +// } else if (courseS[i].toLowerCase().contains("mat") || courseS[i].toLowerCase().contains("map")) { +// return R.drawable.ic_maths; +// } else if (courseS[i].toLowerCase().contains("eng") || courseS[i].toLowerCase().contains("enp") || courseS[i].toLowerCase().contains("ena")) { +// return R.drawable.ic_english; +// } else if (courseS[i].toLowerCase().contains("spo") || courseS[i].toLowerCase().contains("spp") || courseS[i].toLowerCase().contains("spth")) { +// return R.drawable.ic_pe; +// } else if (courseS[i].toLowerCase().contains("pol") || courseS[i].toLowerCase().contains("pop")) { +// return R.drawable.ic_politics; +// } else if (courseS[i].toLowerCase().contains("dar") || courseS[i].toLowerCase().contains("dap")) { +// return R.drawable.ic_drama; +// } else if (courseS[i].toLowerCase().contains("phy") || courseS[i].toLowerCase().contains("php")) { +// return R.drawable.ic_physics; +// } else if (courseS[i].toLowerCase().contains("bio") || courseS[i].toLowerCase().contains("bip") || courseS[i].toLowerCase().contains("nw")) { +// return R.drawable.ic_biology; +// } else if (courseS[i].toLowerCase().contains("che") || courseS[i].toLowerCase().contains("chp")) { +// return R.drawable.ic_chemistry; +// } else if (courseS[i].toLowerCase().contains("phi") || courseS[i].toLowerCase().contains("psp")) { +// return R.drawable.ic_philosophy; +// } else if (courseS[i].toLowerCase().contains("laa") || courseS[i].toLowerCase().contains("laf") || courseS[i].toLowerCase().contains("lat")) { +// return R.drawable.ic_latin; +// } else if (courseS[i].toLowerCase().contains("spa") || courseS[i].toLowerCase().contains("spf")) { +// return R.drawable.ic_spanish; +// } else if (courseS[i].toLowerCase().contains("fra") || courseS[i].toLowerCase().contains("frf") || courseS[i].toLowerCase().contains("frz")) { +// return R.drawable.ic_french; +// } else if (courseS[i].toLowerCase().contains("inf")) { +// return R.drawable.ic_compsci; +// } else if (courseS[i].toLowerCase().contains("ges")) { +// return R.drawable.ic_history; +// } else if (courseS[i].toLowerCase().contains("rel")) { +// return R.drawable.ic_religion; +// } else if (courseS[i].toLowerCase().contains("geg") || courseS[i].toLowerCase().contains("wuk")) { +// return R.drawable.ic_geography; +// } else if (courseS[i].toLowerCase().contains("kun")) { +// return R.drawable.ic_arts; +// } else if (courseS[i].toLowerCase().contains("mus")) { +// return R.drawable.ic_music; +// } else if (courseS[i].toLowerCase().contains("tue")) { +// return R.drawable.ic_turkish; +// } else if (courseS[i].toLowerCase().contains("chi")) { +// return R.drawable.ic_chinese; +// } else if (courseS[i].toLowerCase().contains("gll")) { +// return R.drawable.ic_gll; +// } else if (courseS[i].toLowerCase().contains("wat")) { +// return R.drawable.ic_wat; +// } else if (courseS[i].toLowerCase().contains("för")) { +// return R.drawable.ic_help; +// } else if (courseS[i].toLowerCase().contains("wp") || courseS[i].toLowerCase().contains("met")) { +// return R.drawable.ic_pencil; +// } else { +// emptyIcon = true; +// return R.drawable.ic_empty; +// } +// } +// +// @Override +// protected void onPostExecute(Void result) { +// if (attempt) { +// +// try { +// +// planCardList = new ArrayList<>(); +// recyclerView = getView().findViewById(R.id.linearRecyclerSearch); +// layoutManager = new LinearLayoutManager(getContext()); +// recyclerView.setHasFixedSize(true); +// recyclerView.setLayoutManager(layoutManager); +// mAdapter = new CardAdapter(planCardList); +// recyclerView.setAdapter(mAdapter); +// } catch (NullPointerException e) { +// return; +// } +// recyclerView.removeAllViews(); +// EditText searchfield = getView().findViewById(R.id.searchbar); +// final Animation animationIn = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in); +// +// for (int i = 0; i < count; i++) { +// if (groupS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } if (dateS[i].toLowerCase().toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } if (timeS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } if (courseS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } if (roomS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } if (additionalS[i].toLowerCase().contains(searchfield.getText().toString().toLowerCase())) { +// search = true; +// } +// +// if (search) { +// Drawable drawable = getResources().getDrawable(icons(courseS, i)); +// if (!emptyIcon) { +// drawable.setTint(iconColour); +// } +// planCardList.add(new Subst(0, groupS[i], dateS[i], timeS[i], courseS[i], roomS[i], additionalS[i], 0)); +// recyclerView.setAnimation(animationIn); +// search = false; +// } +// } +// } else if (npe) { +// View contextView = getView().getRootView().findViewById(R.id.coordination); +// Snackbar snackbar = make(contextView, getText(R.string.nointernet), Snackbar.LENGTH_LONG) +// .setAction("Action", null); +// snackbar.show(); +// } +// } +// } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/FragmentSettings.java b/app/src/main/java/com/denizd/substitutionplan/FragmentSettings.java new file mode 100644 index 0000000..28ccece --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/FragmentSettings.java @@ -0,0 +1,646 @@ +package com.denizd.substitutionplan; + +import android.app.AlertDialog; +import android.content.SharedPreferences; +import android.content.res.Resources; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.browser.customtabs.CustomTabsIntent; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.fragment.app.Fragment; + +import android.text.Editable; +import android.text.TextWatcher; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.Switch; +import android.widget.TextView; +import android.widget.Toast; + +import com.jaredrummler.android.device.DeviceName; + +import java.text.DecimalFormat; +import java.util.Random; + +public class FragmentSettings extends Fragment { + CoordinatorLayout coordinatorLayout; + private int cs = 7; + private String manufacturer, 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.white)); + final CustomTabsIntent customTabsIntent = builder.build(); + + final EditText txtName = getView().findViewById(R.id.txtName); + final Switch greeting = getView().findViewById(R.id.switchDisableGreeting); + final Switch darkmode = getView().findViewById(R.id.switchDark); + + final EditText txtClasses = getView().findViewById(R.id.txtClasses); + final EditText 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); + + final TextView notif1 = getView().findViewById(R.id.txtNotifications); + final TextView auto1 = getView().findViewById(R.id.txtAutoRefresh); + final TextView notif2 = getView().findViewById(R.id.txtNotifiedAbout); + final TextView auto2 = getView().findViewById(R.id.txtAutoRefreshTwo); + + helpCourses.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + 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); + } + alertDialog.setTitle(getString(R.string.helpCoursesTitle)); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null); + 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); + } + alertDialog.setTitle(getString(R.string.helpClassesTitle)); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null); + 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(); + } + }); + + 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(); + } + }); + + // TODO check whether Huawei devices actually support background services + +// DeviceName.with(getContext()).request(new DeviceName.Callback() { +// @Override +// public void onFinished(DeviceName.DeviceInfo info, Exception error) { +// manufacturer = info.manufacturer; +// if (manufacturer.contains("Huawei") || +// manufacturer.contains("Honor")) { +//// if (true) { +// notifswitch.setChecked(false); +// autoRefresh.setChecked(true); +// notifswitch.setEnabled(false); +// autoRefresh.setEnabled(false); +// +// @ColorInt int color; +// if (prefs.getInt("themeInt", 0) == 1) { +// TypedValue typedValue = new TypedValue(); +// Resources.Theme theme = getContext().getTheme(); +// theme.resolveAttribute(R.attr.colorHintDark, typedValue, true); +// color = typedValue.data; +// notif2.setTextColor(color); +// auto2.setTextColor(color); +// } else { +// TypedValue typedValue = new TypedValue(); +// Resources.Theme theme = getContext().getTheme(); +// theme.resolveAttribute(R.attr.colorHint, typedValue, true); +// color = typedValue.data; +// } +// +// notif1.setTextColor(color); +// auto1.setTextColor(color); +// edit.putBoolean("notif", false); +// edit.putBoolean("autoRefresh", true); +// edit.apply(); +// notif2.setText(R.string.chinaNotif); +// auto2.setText(R.string.chinaAuto); +// } +// } +// }); + + website.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + customTabsIntent.launchUrl(getContext(), Uri.parse("http://307.joomla.schule.bremen.de")); + } + }); + + 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); + } + alertDialog.setTitle("Licences"); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null); + TextView dialogText = dialogView.findViewById(R.id.dialogtext); + dialogText.setText("Libraries:\n • Android Device Names © 2015 Jared Rummler, licensed under the Apache License, Version 2.0" + + "\n • EasyPreferences © 2018 Mukesh Solanki, licensed under the MIT License" + + "\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT License" + + "\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font License 1.1" + + "\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); + } + alertDialog.setTitle("Terms & Conditions"); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null); + 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); + } + alertDialog.setTitle("Privacy Policy"); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null); + 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 { + Toast.makeText(getContext(), getString(R.string.donttell), Toast.LENGTH_LONG).show(); + cs = 7; + customTabsIntent.launchUrl(getContext(), Uri.parse("http://www.flussufer.de/gerd/person.htm")); + } + } + }); + + + +// 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); + } + alertDialog.setTitle(getString(R.string.experimentalmenu)); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.edittext_dialog, null); + 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) { + if (dialogEditText.getText().toString().equals("@DEV_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); + } + alertDialogDev.setTitle(getString(R.string.diagnosticsmenu)); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.diagnostics_dialog, null); + 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(); + + } else if (dialogEditText.getText().toString().equals("Tim Bergling")) { + Toast.makeText(getActivity(), "◢◤", + Toast.LENGTH_LONG).show(); + + } else if (dialogEditText.getText().toString().equals("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); + } + alertDialogDev.setTitle(getString(R.string.dating)); + View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dating_dialog, null); + + Button datingBtn = dialogView.findViewById(R.id.dating_btn); + final EditText boyT = dialogView.findViewById(R.id.dating_txt1); + final EditText girlT = dialogView.findViewById(R.id.dating_txt2); + final 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(names.boy[gen.nextInt(names.boy.length)]); + } + if (girlT.getText().toString().isEmpty() || girl.isChecked()) { + girlT.setText(names.girl[gen.nextInt(names.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(); + } + } + }); + alertDialogDev.setView(dialogView); + alertDialogDev.show(); + + } else { + Toast.makeText(getActivity(), getString(R.string.nothinghappened), + Toast.LENGTH_LONG).show(); + } + } + }); + alertDialog.setView(dialogView); + alertDialog.show(); + return true; + } + }); + } + + 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); + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/MainActivity.java b/app/src/main/java/com/denizd/substitutionplan/MainActivity.java new file mode 100644 index 0000000..4cf8e99 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/MainActivity.java @@ -0,0 +1,462 @@ +package com.denizd.substitutionplan; + +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.app.SearchManager; +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.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 android.view.MenuItem; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.Button; +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; + private String marketName; + + 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)) { +// if (true) { + startActivity(firstTime); + finish(); + } + + 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); +// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); +// window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + + final BottomNavigationView bottomNav = findViewById(R.id.bottom_nav); + final Chip chip = findViewById(R.id.chip); + + 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) { + + } + }); + + 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) { + + } + } + + final Context context = this; + + // TODO Huawei dialog + + if (prefs.getBoolean("huaweiDeviceDialog", true)) { +// if (true) { + DeviceName.with(this).request(new DeviceName.Callback() { + @Override + public void onFinished(DeviceName.DeviceInfo info, Exception error) { + manufacturer = info.manufacturer; + marketName = info.marketName; + if (manufacturer.contains("Huawei") || + manufacturer.contains("Honor") || + manufacturer.contains("Xiaomi")) { +// if (true) { + + AlertDialog.Builder alertDialog; + View dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null); + TextView secretText = dialogView.findViewById(R.id.secrettext); + if (prefs.getInt("themeInt", 0) == 1) { + secretText.setTextColor(getResources().getColor(R.color.hintdark)); + alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomDark); + } else { + secretText.setTextColor(getResources().getColor(R.color.hint)); + alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight); + } + alertDialog.setTitle(R.string.chinaTitle); + TextView dialogText = dialogView.findViewById(R.id.dialogtext); + dialogText.setText(R.string.chinaDialog); + secretText.setText(R.string.orbuy); + Button searchbtn = dialogView.findViewById(R.id.searchbtn); + searchbtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); + intent.putExtra(SearchManager.QUERY, marketName + " disable power optimisation"); + startActivity(intent); + } + }); + alertDialog.setView(dialogView); + alertDialog.show(); + + 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); + } + }); + + // theme change + if (prefs.getInt("themeInt", 0) == 0) { + setTheme(R.style.AppTheme0); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + window.setStatusBarColor(ContextCompat.getColor(this, R.color.white)); + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.white)); + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.white)); + } else { + window.setStatusBarColor(ContextCompat.getColor(this, R.color.black)); + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.black)); + } + + toolbarTxt.setTextColor(ContextCompat.getColor(this, R.color.accent)); + bottomNav.setBackgroundColor(ContextCompat.getColor(this, R.color.white)); + chip.setChipBackgroundColor(getResources().getColorStateList(R.color.chip_state_list)); + chip.setTextColor(ContextCompat.getColor(this, R.color.lessdark)); + bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.white)); + bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.lessdark)); + bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.lessdark)); + bottomNavDivider.setBackgroundColor(ContextCompat.getColor(this, R.color.lightgrey)); + + Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); + ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.white)); + 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.accent)); + bottomNav.setBackgroundColor(ContextCompat.getColor(this, R.color.dark)); + window.setNavigationBarColor(getResources().getColor(R.color.background)); + chip.setChipBackgroundColor(getResources().getColorStateList(R.color.chip_state_list_dark)); + chip.setTextColor(ContextCompat.getColor(this, R.color.lightgrey)); + bottomSheet.setBackgroundColor(ContextCompat.getColor(this, R.color.dark)); + bottomSheetHeader.setTextColor(ContextCompat.getColor(this, R.color.lightgrey)); + bottomSheetText.setTextColor(ContextCompat.getColor(this, R.color.lightgrey)); + bottomNavDivider.setBackgroundColor(ContextCompat.getColor(this, R.color.darkdivider)); + + 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) { +// if (true) { + 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; + + switch (item.getItemId()) { + case R.id.plan: + fragment = new FragmentPlan(); + toolbarTxt.setText(getString(R.string.app_name)); + break; + case R.id.personal: + 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)); + } + break; +// case R.id.search: +// fragment = new FragmentSearch(); +// toolbarTxt.setText(getString(R.string.search)); +// break; + case R.id.menu: + fragment = new FragmentFood(); + toolbarTxt.setText(getString(R.string.foodmenu)); + break; + case R.id.settings: + fragment = new FragmentSettings(); + toolbarTxt.setText(getString(R.string.settings)); + break; + } + appbarlayout.setExpanded(true); + bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_COLLAPSED); + return loadFragment(fragment); + } + + }); + } + + 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(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/denizd/substitutionplan/PlanCard.java b/app/src/main/java/com/denizd/substitutionplan/PlanCard.java new file mode 100644 index 0000000..f106402 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/PlanCard.java @@ -0,0 +1,46 @@ +package com.denizd.substitutionplan; + +import android.graphics.drawable.Drawable; + +public class PlanCard { + private Drawable mIcon; + private String mGroup, mDate, mTime, mCourse, mRoom, mAdditional; + + public PlanCard(Drawable icon, String group, String date, String time, String course, String room, String additional) { + mIcon = icon; + mGroup = group; + mDate = date; + mTime = time; + mCourse = course; + mRoom = room; + mAdditional = additional; + } + + public Drawable getImageResource() { + return mIcon; + } + + public String getGroup() { + return mGroup; + } + + public String getDate() { + return mDate; + } + + public String getTime() { + return mTime; + } + + public String getCourse() { + return mCourse; + } + + public String getRoom() { + return mRoom; + } + + public String getAdditional() { + return mAdditional; + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/ScheduledJobService.java b/app/src/main/java/com/denizd/substitutionplan/ScheduledJobService.java new file mode 100644 index 0000000..90b9593 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/ScheduledJobService.java @@ -0,0 +1,354 @@ +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.os.AsyncTask; +import android.os.Build; +import android.preference.PreferenceManager; + +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; +import java.util.HashSet; +import java.util.Set; + +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()); +// substViewModel = ViewModelProviders.of().get(SubstViewModel.class); +// substViewModel.getAllSubst().observe(this, new Observer>() { +// @Override +// public void onChanged(List substs) { + new Thread(new Runnable() { + @Override + public void run() { + if (jobCancelled) { + return; + } + if (prefs.getBoolean("notif", false)) { + edit.putInt("notificationTestNumberDev", prefs.getInt("notificationTestNumberDev", 0) + 1); + edit.apply(); + URL url; + URLConnection connection = null; + try { + url = new URL("https://djd4rkn355.github.io/subst"); + connection = url.openConnection(); + } catch (MalformedURLException e) {} + catch (IOException e) {} + try { + if ((!connection.getHeaderField("Last-Modified").equals(prefs.getString("time", "")))) { +// if (true) { + new fetcher(context).execute(); + edit.putString("time", connection.getHeaderField("Last-Modified")); + edit.apply(); + } + } catch (NullPointerException e1) { + } + } + jobFinished(params, false); + } + }).start(); +// } +// }); + } + + @Override + public boolean onStopJob(JobParameters params) { + jobCancelled = true; + return true; + } + + private class fetcher extends AsyncTask { + + private int count = 0, columns = 0, pCount = 0, priority = 200; + Context mContext; + String notifText = "", foodInfo = "", informational = ""; + String[] groupS, dateS, timeS, courseS, roomS, additionalS; + boolean attempt = false, emptyIcon; + URL url; + URLConnection connection; + String modified; + Elements rows, paragraphs; + Elements[] paragraphsFood = new Elements[2]; + Elements foodElements; + Element[] dateFood = new Element[2], blockFood = new Element[2]; + Document doc, docFood; + NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + String channelId = "general"; + 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 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(); + + int drawable = icons(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); + + if (!notifText.isEmpty()) { + Notification notification = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + notification = new NotificationCompat.Builder(mContext) + .setContentTitle(getString(R.string.subst)) + .setStyle(new NotificationCompat.BigTextStyle() + .bigText(notifText)) + .setSmallIcon(R.drawable.ic_avh) + .setChannelId(channelId) + .setContentIntent(openAppPending) + .setAutoCancel(true) + .build(); + } else { + notification = new NotificationCompat.Builder(mContext) + .setContentTitle(getString(R.string.subst)) + .setStyle(new NotificationCompat.BigTextStyle() + .bigText(notifText)) + .setSmallIcon(R.drawable.ic_avh) + .setContentIntent(openAppPending) + .setAutoCancel(true) + .build(); + } + manager.notify(1, notification); + } + + } + return null; + } + + private int icons(String course) { + emptyIcon = false; + if (course.toLowerCase().contains("deu") || course.toLowerCase().contains("dep") || course.toLowerCase().contains("daz")) { + return R.drawable.ic_german; + } else if (course.toLowerCase().contains("mat") || course.toLowerCase().contains("map")) { + return R.drawable.ic_maths; + } else if (course.toLowerCase().contains("eng") || course.toLowerCase().contains("enp") || course.toLowerCase().contains("ena")) { + return R.drawable.ic_english; + } else if (course.toLowerCase().contains("spo") || course.toLowerCase().contains("spp") || course.toLowerCase().contains("spth")) { + return R.drawable.ic_pe; + } else if (course.toLowerCase().contains("pol") || course.toLowerCase().contains("pop")) { + return R.drawable.ic_politics; + } else if (course.toLowerCase().contains("dar") || course.toLowerCase().contains("dap")) { + return R.drawable.ic_drama; + } else if (course.toLowerCase().contains("phy") || course.toLowerCase().contains("php")) { + return R.drawable.ic_physics; + } else if (course.toLowerCase().contains("bio") || course.toLowerCase().contains("bip") || course.toLowerCase().contains("nw")) { + return R.drawable.ic_biology; + } else if (course.toLowerCase().contains("che") || course.toLowerCase().contains("chp")) { + return R.drawable.ic_chemistry; + } else if (course.toLowerCase().contains("phi") || course.toLowerCase().contains("psp")) { + return R.drawable.ic_philosophy; + } else if (course.toLowerCase().contains("laa") || course.toLowerCase().contains("laf") || course.toLowerCase().contains("lat")) { + return R.drawable.ic_latin; + } else if (course.toLowerCase().contains("spa") || course.toLowerCase().contains("spf")) { + return R.drawable.ic_spanish; + } else if (course.toLowerCase().contains("fra") || course.toLowerCase().contains("frf") || course.toLowerCase().contains("frz")) { + return R.drawable.ic_french; + } else if (course.toLowerCase().contains("inf")) { + return R.drawable.ic_compsci; + } else if (course.toLowerCase().contains("ges")) { + return R.drawable.ic_history; + } else if (course.toLowerCase().contains("rel")) { + return R.drawable.ic_religion; + } else if (course.toLowerCase().contains("geg") || course.toLowerCase().contains("wuk")) { + return R.drawable.ic_geography; + } else if (course.toLowerCase().contains("kun")) { + return R.drawable.ic_arts; + } else if (course.toLowerCase().contains("mus")) { + return R.drawable.ic_music; + } else if (course.toLowerCase().contains("tue")) { + return R.drawable.ic_turkish; + } else if (course.toLowerCase().contains("chi")) { + return R.drawable.ic_chinese; + } else if (course.toLowerCase().contains("gll")) { + return R.drawable.ic_gll; + } else if (course.toLowerCase().contains("wat")) { + return R.drawable.ic_wat; + } else if (course.toLowerCase().contains("för")) { + return R.drawable.ic_help; + } else if (course.toLowerCase().contains("wp") || course.toLowerCase().contains("met")) { + return R.drawable.ic_pencil; + } else { + emptyIcon = true; + return R.drawable.ic_empty; + } + } + + @Override + protected void onPostExecute(Void result) {} + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/Subst.java b/app/src/main/java/com/denizd/substitutionplan/Subst.java new file mode 100644 index 0000000..3b11184 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/Subst.java @@ -0,0 +1,68 @@ +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; + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/SubstDao.java b/app/src/main/java/com/denizd/substitutionplan/SubstDao.java new file mode 100644 index 0000000..9b1b4b1 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/SubstDao.java @@ -0,0 +1,29 @@ +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> getAllSubst(); +} diff --git a/app/src/main/java/com/denizd/substitutionplan/SubstDatabase.java b/app/src/main/java/com/denizd/substitutionplan/SubstDatabase.java new file mode 100644 index 0000000..c2f3681 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/SubstDatabase.java @@ -0,0 +1,52 @@ +package com.denizd.substitutionplan; + +import android.content.Context; +import android.os.AsyncTask; + +import androidx.annotation.NonNull; +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; +import androidx.sqlite.db.SupportSQLiteDatabase; + +@Database(entities = {Subst.class}, version = 2, exportSchema = false) +public abstract class SubstDatabase extends RoomDatabase { + + 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; + } + +// private static RoomDatabase.Callback roomCallback = new RoomDatabase.Callback() { // initial population +// @Override +// public void onCreate(@NonNull SupportSQLiteDatabase db) { +// super.onCreate(db); +// new PopulateDBAsync(instance).execute(); +// } +// }; +// +// private static class PopulateDBAsync extends AsyncTask { +// +// private SubstDao substDao; +// +// private PopulateDBAsync(SubstDatabase db) { +// substDao = db.substDao(); +// } +// +// @Override +// protected Void doInBackground(Void... voids) { +// substDao.insert(new Subst(R.drawable.ic_avh,"Group", "Date", "Time", "Course", "Room", "Additional", 0)); +// return null; +// } +// } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/SubstRepository.java b/app/src/main/java/com/denizd/substitutionplan/SubstRepository.java new file mode 100644 index 0000000..360d72a --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/SubstRepository.java @@ -0,0 +1,96 @@ +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> 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> getAllSubst() { + return allSubst; + } + + private static class InsertSubstAsync extends AsyncTask { + + 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 { + + 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 { + + 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 { + + private SubstDao substDao; + private DeleteAllSubstAsync(SubstDao substDao) { + this.substDao = substDao; + } + + @Override + protected Void doInBackground(Void... voids) { + substDao.deleteAllSubst(); + return null; + } + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/SubstViewModel.java b/app/src/main/java/com/denizd/substitutionplan/SubstViewModel.java new file mode 100644 index 0000000..e885c20 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/SubstViewModel.java @@ -0,0 +1,41 @@ +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> 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> getAllSubst() { + return allSubst; + } +} diff --git a/app/src/main/java/com/denizd/substitutionplan/names.java b/app/src/main/java/com/denizd/substitutionplan/names.java new file mode 100644 index 0000000..bb24619 --- /dev/null +++ b/app/src/main/java/com/denizd/substitutionplan/names.java @@ -0,0 +1,26 @@ +package com.denizd.substitutionplan; + +public class names { + protected static String boy[] = { "Cedric Grislawski", // excluded are most boys from Physical Education + // profile (no offense) and me + "Dawid Kniola", "Jonas Köstergarten", "Jakob Moerschner", "Siamak Nemati", "Hendrik Plönnings", + "Jan Rohmann", "Anton Rosenberger", "Christoph Senft", "Jan Mika Sieckendieck", "Alexander Sinaj", + "Nico Tischer", "Nhat Vinh Tran", "Leon Becker", "Youssef Beltagi", "Erich Kerkesner", "Alex Lick", + "Oskar Piskorz", "Theo Recktor", "Eray Vatansever", "Dennis Wojciechowski", "Übeydullah Alkan", + "Yahya Almarashli", "Sinan Aydin", "Rick Büteröwe", "Levin Dropp", "Silvester Jermolajew", "Tolgay Kekilli", + "Dennis Lange", "Aras Mahmoud", "Batuhan Özcan", "Michael Rek", "Khabat Sharif", "Anbinh Tran", + "Bastian Westerboer", "Abdulwahab Alshebli", "Kelechi Gaius", "Armin Großmann", "Anes Halep", + "Marco Jankowski", "Emirhan Kaplan", "Alexander Kofmann", "Tobi Derek Köhler", "Vasilije Nedeljkovic", + "Batu Öcal", "Paul Rehbohm" }; + protected static String girl[] = { "Mayra Dronia", // excluded are the girls from Physical Education profile + // (no offense) + "Shalin Ramadan", "Nigina Amin", "Mariya Kheder", "Niegen Khosrawi", "Dayana Osipova", + "Julia Petri", "Laura Pister", "Dana Alyoussef", "Ilkem Kahramanoglu", "Rozita Amiri", "Mirja Arneke", + "Nastasja Banik", "Anni Kienke", "Benedite Mateta", "Leonie Pohl", "Cecillia Sawires", "Patrycja Smółka", + "Elif Zencirkiran", "Nusyba Al Semadi", "Vivien Bruns", "Yasemin Dal", "Svenja Demuth", "Nina Groß", + "Kim Lahmeyer", "Luca Minschke", "Kim Reschke", "Amélie Schnellecke", "Delal Secer", "Xenia Segijanski", + "Melisa Tas", "Kim Völker", "Banu Yari", "Zeinab Ali", "Mariam Bannout", "Stefanie Fahl", "Yamaty Gaye", + "Anna-Sophia Haeberle", "Finja Hastedt", "Viktoria Hammermeister", "Isabel Horn", "Laura Kern", + "Melanie Kleinermann", "Målin Kollhoff", "Darja Maier", "Lisa Maier", "Naura Nadzifah", "Janina Roelfs", + "Vanessa Scheifler", "Mara Thies", "Lieli Umar", "Leonie Welk", "Betraben Yacoub" }; +} diff --git a/app/src/main/res/anim/check_animation.xml b/app/src/main/res/anim/check_animation.xml new file mode 100644 index 0000000..77b70da --- /dev/null +++ b/app/src/main/res/anim/check_animation.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/chip_slide_in.xml b/app/src/main/res/anim/chip_slide_in.xml new file mode 100644 index 0000000..680f133 --- /dev/null +++ b/app/src/main/res/anim/chip_slide_in.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/chip_slide_out.xml b/app/src/main/res/anim/chip_slide_out.xml new file mode 100644 index 0000000..c840530 --- /dev/null +++ b/app/src/main/res/anim/chip_slide_out.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml new file mode 100644 index 0000000..f13c2bd --- /dev/null +++ b/app/src/main/res/anim/fade_in.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml new file mode 100644 index 0000000..301f935 --- /dev/null +++ b/app/src/main/res/anim/fade_out.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_out_short.xml b/app/src/main/res/anim/fade_out_short.xml new file mode 100644 index 0000000..30b3304 --- /dev/null +++ b/app/src/main/res/anim/fade_out_short.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/item_animation_fall_down.xml b/app/src/main/res/anim/item_animation_fall_down.xml new file mode 100644 index 0000000..2e03fc7 --- /dev/null +++ b/app/src/main/res/anim/item_animation_fall_down.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/item_animation_fall_down_out.xml b/app/src/main/res/anim/item_animation_fall_down_out.xml new file mode 100644 index 0000000..630a64e --- /dev/null +++ b/app/src/main/res/anim/item_animation_fall_down_out.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/item_animation_fall_down_quick.xml b/app/src/main/res/anim/item_animation_fall_down_quick.xml new file mode 100644 index 0000000..836b5bc --- /dev/null +++ b/app/src/main/res/anim/item_animation_fall_down_quick.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/layout_animation_fall_down.xml b/app/src/main/res/anim/layout_animation_fall_down.xml new file mode 100644 index 0000000..6eb9447 --- /dev/null +++ b/app/src/main/res/anim/layout_animation_fall_down.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/layout_animation_fall_down_out.xml b/app/src/main/res/anim/layout_animation_fall_down_out.xml new file mode 100644 index 0000000..3ff66be --- /dev/null +++ b/app/src/main/res/anim/layout_animation_fall_down_out.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/layout_animation_fall_down_quick.xml b/app/src/main/res/anim/layout_animation_fall_down_quick.xml new file mode 100644 index 0000000..963e232 --- /dev/null +++ b/app/src/main/res/anim/layout_animation_fall_down_quick.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/layout_fade_in.xml b/app/src/main/res/anim/layout_fade_in.xml new file mode 100644 index 0000000..9c2f18b --- /dev/null +++ b/app/src/main/res/anim/layout_fade_in.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/color/bottom_nav_color_avhblue.xml b/app/src/main/res/color/bottom_nav_color_avhblue.xml new file mode 100644 index 0000000..f0a529b --- /dev/null +++ b/app/src/main/res/color/bottom_nav_color_avhblue.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/chip_state_list.xml b/app/src/main/res/color/chip_state_list.xml new file mode 100644 index 0000000..7f7f90c --- /dev/null +++ b/app/src/main/res/color/chip_state_list.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/chip_state_list_dark.xml b/app/src/main/res/color/chip_state_list_dark.xml new file mode 100644 index 0000000..f428437 --- /dev/null +++ b/app/src/main/res/color/chip_state_list_dark.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/ic_avh.png b/app/src/main/res/drawable-hdpi/ic_avh.png new file mode 100644 index 0000000..b0e2b8e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_avh.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_avh.png b/app/src/main/res/drawable-mdpi/ic_avh.png new file mode 100644 index 0000000..1cb6db8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_avh.png differ diff --git a/app/src/main/res/drawable-v21/avhbmp.png b/app/src/main/res/drawable-v21/avhbmp.png new file mode 100644 index 0000000..813e902 Binary files /dev/null and b/app/src/main/res/drawable-v21/avhbmp.png differ diff --git a/app/src/main/res/drawable-v21/launch_screen.xml b/app/src/main/res/drawable-v21/launch_screen.xml new file mode 100644 index 0000000..2ceee59 --- /dev/null +++ b/app/src/main/res/drawable-v21/launch_screen.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v23/launch_screen.xml b/app/src/main/res/drawable-v23/launch_screen.xml new file mode 100644 index 0000000..9621d97 --- /dev/null +++ b/app/src/main/res/drawable-v23/launch_screen.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-xhdpi/ic_avh.png b/app/src/main/res/drawable-xhdpi/ic_avh.png new file mode 100644 index 0000000..9cd66e4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_avh.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_avh.png b/app/src/main/res/drawable-xxhdpi/ic_avh.png new file mode 100644 index 0000000..11d5569 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_avh.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_avh.png b/app/src/main/res/drawable-xxxhdpi/ic_avh.png new file mode 100644 index 0000000..3223846 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_avh.png differ diff --git a/app/src/main/res/drawable/animated_check.xml b/app/src/main/res/drawable/animated_check.xml new file mode 100644 index 0000000..5f57bfd --- /dev/null +++ b/app/src/main/res/drawable/animated_check.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/check_mark.xml b/app/src/main/res/drawable/check_mark.xml new file mode 100644 index 0000000..6852473 --- /dev/null +++ b/app/src/main/res/drawable/check_mark.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arts.xml b/app/src/main/res/drawable/ic_arts.xml new file mode 100644 index 0000000..33f625e --- /dev/null +++ b/app/src/main/res/drawable/ic_arts.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_avhlogo.xml b/app/src/main/res/drawable/ic_avhlogo.xml new file mode 100644 index 0000000..84b8e44 --- /dev/null +++ b/app/src/main/res/drawable/ic_avhlogo.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_biology.xml b/app/src/main/res/drawable/ic_biology.xml new file mode 100644 index 0000000..b71545c --- /dev/null +++ b/app/src/main/res/drawable/ic_biology.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_chemistry.xml b/app/src/main/res/drawable/ic_chemistry.xml new file mode 100644 index 0000000..d4c52d0 --- /dev/null +++ b/app/src/main/res/drawable/ic_chemistry.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_chinese.xml b/app/src/main/res/drawable/ic_chinese.xml new file mode 100644 index 0000000..30494ab --- /dev/null +++ b/app/src/main/res/drawable/ic_chinese.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cogwheel.xml b/app/src/main/res/drawable/ic_cogwheel.xml new file mode 100644 index 0000000..dc48532 --- /dev/null +++ b/app/src/main/res/drawable/ic_cogwheel.xml @@ -0,0 +1,5 @@ + + + + diff --git a/app/src/main/res/drawable/ic_compsci.xml b/app/src/main/res/drawable/ic_compsci.xml new file mode 100644 index 0000000..5900312 --- /dev/null +++ b/app/src/main/res/drawable/ic_compsci.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_drama.xml b/app/src/main/res/drawable/ic_drama.xml new file mode 100644 index 0000000..bb0655c --- /dev/null +++ b/app/src/main/res/drawable/ic_drama.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_empty.xml b/app/src/main/res/drawable/ic_empty.xml new file mode 100644 index 0000000..0bf6ead --- /dev/null +++ b/app/src/main/res/drawable/ic_empty.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_english.xml b/app/src/main/res/drawable/ic_english.xml new file mode 100644 index 0000000..380ec1a --- /dev/null +++ b/app/src/main/res/drawable/ic_english.xml @@ -0,0 +1,5 @@ + + + + diff --git a/app/src/main/res/drawable/ic_french.xml b/app/src/main/res/drawable/ic_french.xml new file mode 100644 index 0000000..a7e28a0 --- /dev/null +++ b/app/src/main/res/drawable/ic_french.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_geography.xml b/app/src/main/res/drawable/ic_geography.xml new file mode 100644 index 0000000..94cb978 --- /dev/null +++ b/app/src/main/res/drawable/ic_geography.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_german.xml b/app/src/main/res/drawable/ic_german.xml new file mode 100644 index 0000000..f478e4d --- /dev/null +++ b/app/src/main/res/drawable/ic_german.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_gll.xml b/app/src/main/res/drawable/ic_gll.xml new file mode 100644 index 0000000..a75395b --- /dev/null +++ b/app/src/main/res/drawable/ic_gll.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_help.xml b/app/src/main/res/drawable/ic_help.xml new file mode 100644 index 0000000..799be2a --- /dev/null +++ b/app/src/main/res/drawable/ic_help.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_history.xml b/app/src/main/res/drawable/ic_history.xml new file mode 100644 index 0000000..2d4fa89 --- /dev/null +++ b/app/src/main/res/drawable/ic_history.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_idea.xml b/app/src/main/res/drawable/ic_idea.xml new file mode 100644 index 0000000..27d1b91 --- /dev/null +++ b/app/src/main/res/drawable/ic_idea.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_latin.xml b/app/src/main/res/drawable/ic_latin.xml new file mode 100644 index 0000000..e054482 --- /dev/null +++ b/app/src/main/res/drawable/ic_latin.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_maths.xml b/app/src/main/res/drawable/ic_maths.xml new file mode 100644 index 0000000..661d21e --- /dev/null +++ b/app/src/main/res/drawable/ic_maths.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_music.xml b/app/src/main/res/drawable/ic_music.xml new file mode 100644 index 0000000..3b8cfd5 --- /dev/null +++ b/app/src/main/res/drawable/ic_music.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_pe.xml b/app/src/main/res/drawable/ic_pe.xml new file mode 100644 index 0000000..b4c661c --- /dev/null +++ b/app/src/main/res/drawable/ic_pe.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_pencil.xml b/app/src/main/res/drawable/ic_pencil.xml new file mode 100644 index 0000000..3323522 --- /dev/null +++ b/app/src/main/res/drawable/ic_pencil.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_philosophy.xml b/app/src/main/res/drawable/ic_philosophy.xml new file mode 100644 index 0000000..7636111 --- /dev/null +++ b/app/src/main/res/drawable/ic_philosophy.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_physics.xml b/app/src/main/res/drawable/ic_physics.xml new file mode 100644 index 0000000..fe80a81 --- /dev/null +++ b/app/src/main/res/drawable/ic_physics.xml @@ -0,0 +1,5 @@ + + + + diff --git a/app/src/main/res/drawable/ic_politics.xml b/app/src/main/res/drawable/ic_politics.xml new file mode 100644 index 0000000..c1793fe --- /dev/null +++ b/app/src/main/res/drawable/ic_politics.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_qmark.xml b/app/src/main/res/drawable/ic_qmark.xml new file mode 100644 index 0000000..afb0404 --- /dev/null +++ b/app/src/main/res/drawable/ic_qmark.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_religion.xml b/app/src/main/res/drawable/ic_religion.xml new file mode 100644 index 0000000..ea8cf27 --- /dev/null +++ b/app/src/main/res/drawable/ic_religion.xml @@ -0,0 +1,5 @@ + + + + diff --git a/app/src/main/res/drawable/ic_spanish.xml b/app/src/main/res/drawable/ic_spanish.xml new file mode 100644 index 0000000..61f9190 --- /dev/null +++ b/app/src/main/res/drawable/ic_spanish.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_tick.xml b/app/src/main/res/drawable/ic_tick.xml new file mode 100644 index 0000000..b18d5cb --- /dev/null +++ b/app/src/main/res/drawable/ic_tick.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_tomato.xml b/app/src/main/res/drawable/ic_tomato.xml new file mode 100644 index 0000000..1320cd3 --- /dev/null +++ b/app/src/main/res/drawable/ic_tomato.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_turkish.xml b/app/src/main/res/drawable/ic_turkish.xml new file mode 100644 index 0000000..aa17741 --- /dev/null +++ b/app/src/main/res/drawable/ic_turkish.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_wat.xml b/app/src/main/res/drawable/ic_wat.xml new file mode 100644 index 0000000..b877813 --- /dev/null +++ b/app/src/main/res/drawable/ic_wat.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_writing.xml b/app/src/main/res/drawable/ic_writing.xml new file mode 100644 index 0000000..075e108 --- /dev/null +++ b/app/src/main/res/drawable/ic_writing.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/app/src/main/res/drawable/white.xml b/app/src/main/res/drawable/white.xml new file mode 100644 index 0000000..662a2fd --- /dev/null +++ b/app/src/main/res/drawable/white.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/font/manrope_bold.otf b/app/src/main/res/font/manrope_bold.otf new file mode 100644 index 0000000..f2e3bba Binary files /dev/null and b/app/src/main/res/font/manrope_bold.otf differ diff --git a/app/src/main/res/font/manrope_medium.otf b/app/src/main/res/font/manrope_medium.otf new file mode 100644 index 0000000..be87523 Binary files /dev/null and b/app/src/main/res/font/manrope_medium.otf differ diff --git a/app/src/main/res/font/manrope_regular.otf b/app/src/main/res/font/manrope_regular.otf new file mode 100644 index 0000000..d87c7b4 Binary files /dev/null and b/app/src/main/res/font/manrope_regular.otf differ diff --git a/app/src/main/res/font/manrope_semibold.otf b/app/src/main/res/font/manrope_semibold.otf new file mode 100644 index 0000000..e06b60f Binary files /dev/null and b/app/src/main/res/font/manrope_semibold.otf differ diff --git a/app/src/main/res/layout/activity_first_time.xml b/app/src/main/res/layout/activity_first_time.xml new file mode 100644 index 0000000..036a18d --- /dev/null +++ b/app/src/main/res/layout/activity_first_time.xml @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..5d45f84 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml new file mode 100644 index 0000000..3dad9fa --- /dev/null +++ b/app/src/main/res/layout/app_bar_main.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/bottom_sheet.xml b/app/src/main/res/layout/bottom_sheet.xml new file mode 100644 index 0000000..5c66acd --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..c6f767d --- /dev/null +++ b/app/src/main/res/layout/content_main.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_settings.xml b/app/src/main/res/layout/content_settings.xml new file mode 100644 index 0000000..1c0322c --- /dev/null +++ b/app/src/main/res/layout/content_settings.xml @@ -0,0 +1,589 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/course_card.xml b/app/src/main/res/layout/course_card.xml new file mode 100644 index 0000000..0f37ac8 --- /dev/null +++ b/app/src/main/res/layout/course_card.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dating_dialog.xml b/app/src/main/res/layout/dating_dialog.xml new file mode 100644 index 0000000..ba7411f --- /dev/null +++ b/app/src/main/res/layout/dating_dialog.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +