diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0d7e2d2..4b01236 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,11 +15,6 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning">
-
+
+
= Build.VERSION_CODES.M) {
- window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
- window.setStatusBarColor(ContextCompat.getColor(this, R.color.background));
- window.setNavigationBarColor(ContextCompat.getColor(this, R.color.background));
- } else {
- window.setStatusBarColor(ContextCompat.getColor(this, R.color.background));
- window.setNavigationBarColor(ContextCompat.getColor(this, R.color.background));
- }
- 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.background));
- 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);
-
- helpCourses.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alertDialog;
- alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight);
- View dialogView = LayoutInflater.from(context).inflate(R.layout.simple_dialog, null);
- TextView title = dialogView.findViewById(R.id.textviewtitle);
- title.setText(R.string.helpCoursesTitle);
- TextView dialogText = dialogView.findViewById(R.id.dialogtext);
- dialogText.setText(getString(R.string.helpCourses));
- alertDialog.setView(dialogView);
- alertDialog.show();
- }
- });
-
- helpClasses.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alertDialog;
- alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight);
- View dialogView = LayoutInflater.from(context).inflate(R.layout.simple_dialog, null);
- TextView title = dialogView.findViewById(R.id.textviewtitle);
- title.setText(R.string.helpClassesTitle);
- TextView dialogText = dialogView.findViewById(R.id.dialogtext);
- dialogText.setText(getString(R.string.helpClasses));
- alertDialog.setView(dialogView);
- alertDialog.show();
- }
- });
-
- 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/FirstTime.kt b/app/src/main/java/com/denizd/substitutionplan/FirstTime.kt
new file mode 100644
index 0000000..cbdca6f
--- /dev/null
+++ b/app/src/main/java/com/denizd/substitutionplan/FirstTime.kt
@@ -0,0 +1,144 @@
+package com.denizd.substitutionplan
+
+import android.app.ActivityManager
+import android.content.Context
+import android.content.Intent
+import android.content.SharedPreferences
+import android.graphics.BitmapFactory
+import android.graphics.drawable.Animatable
+import android.graphics.drawable.AnimatedVectorDrawable
+import android.graphics.drawable.AnimationDrawable
+import android.os.Build
+import android.os.Bundle
+import android.os.Handler
+import android.preference.PreferenceManager
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewAnimationUtils
+import android.view.WindowManager
+import android.view.animation.Animation
+import android.view.animation.AnimationUtils
+import android.widget.*
+import androidx.appcompat.app.AlertDialog
+import androidx.appcompat.app.AppCompatActivity
+import androidx.coordinatorlayout.widget.CoordinatorLayout
+import androidx.core.content.ContextCompat
+import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
+import java.util.*
+
+class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
+
+ lateinit var context: Context
+ lateinit var prefs: SharedPreferences
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ val window = this.window
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
+ window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
+ window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
+ }
+ val bm = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
+ val taskDesc = ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.background))
+ setTaskDescription(taskDesc)
+
+ context = this
+
+ prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences
+ val edit = prefs.edit()
+
+ val fab = findViewById(R.id.efab)
+
+ val start = Intent(this, Main::class.java)
+
+ val name = findViewById(R.id.txtName)
+ val grade = findViewById(R.id.txtClasses)
+ val courses = findViewById(R.id.txtCourses)
+ val notif = findViewById(R.id.cbNotif)
+ val dark = findViewById(R.id.cbDark)
+ val pers = findViewById(R.id.cbPersonalised)
+ val helpClasses = findViewById(R.id.chipHelpClasses)
+ val helpCourses = findViewById(R.id.chipHelpCourses)
+
+ helpClasses.setOnClickListener {
+ createDialog(getString(R.string.helpClassesTitle), getString(R.string.helpClasses))
+ }
+ helpCourses.setOnClickListener {
+ createDialog(getString(R.string.helpCoursesTitle), getString(R.string.helpCourses))
+ }
+
+ val inflater = this.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+
+ fab.setOnClickListener {
+ fab.isClickable = false
+
+ edit.putString("firstTimeDev", Calendar.getInstance().time.toString())
+ .putString("username", name.text.toString())
+ .putString("classes", grade.text.toString())
+ .putString("courses", courses.text.toString())
+ if (dark.isChecked) {
+ edit.putInt("themeInt", 1)
+ } else {
+ edit.putInt("themeInt", 0)
+ }
+ edit.putBoolean("notif", notif.isChecked)
+ .putBoolean("defaultPersonalised", pers.isChecked)
+ .putBoolean("firstTime", false)
+ .apply()
+
+ val cLayout = findViewById(R.id.coordinatorLayout)
+ val linearInflation = findViewById(R.id.linearInflation)
+
+ val x: Int = fab.right - fab.width / 2
+ val y: Int = fab.bottom- fab.height / 2
+ val endRadius = Math.hypot(cLayout.width.toDouble(), cLayout.height.toDouble()).toInt()
+ inflater.inflate(R.layout.welcome_screen, linearInflation, true)
+ val anim = ViewAnimationUtils.createCircularReveal(linearInflation, x, y, 0F, endRadius.toFloat())
+ val handler = Handler()
+ val animOut = AnimationUtils.loadAnimation(context, R.anim.fade_out_short)
+ anim.duration = 600
+ val colour = findViewById(R.id.colourLayout)
+ linearInflation.visibility = View.VISIBLE
+ anim.start()
+
+ handler.postDelayed({
+ colour.startAnimation(animOut)
+ }, 400)
+ animOut.setAnimationListener(object: Animation.AnimationListener {
+ override fun onAnimationStart(arg0: Animation) {}
+
+ override fun onAnimationRepeat(arg0: Animation) {}
+
+ override fun onAnimationEnd(arg0: Animation) {
+ colour.visibility = View.GONE
+ }
+ })
+ handler.postDelayed({
+ val mImgCheck = findViewById(R.id.imageView).drawable as AnimatedVectorDrawable
+ mImgCheck.start()
+ }, 1000)
+ handler.postDelayed({
+ startActivity(start)
+ finish()
+ }, 2000)
+ }
+ }
+
+ private fun createDialog(title: String, text: String) {
+ val alertDialog = if (prefs.getInt("themeInt", 0) == 1) {
+ AlertDialog.Builder(context, R.style.AlertDialogCustomDark)
+ } else {
+ AlertDialog.Builder(context, R.style.AlertDialogCustomLight)
+ }
+ val dialogView = LayoutInflater.from(context).inflate(R.layout.simple_dialog, null)
+ val dialogTitle = dialogView.findViewById(R.id.textviewtitle)
+ val dialogText = dialogView.findViewById(R.id.dialogtext)
+ dialogTitle.text = title
+ dialogText.text = text
+ alertDialog.setView(dialogView).show()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/denizd/substitutionplan/SettingsFragment.kt b/app/src/main/java/com/denizd/substitutionplan/SettingsFragment.kt
index 53c41ee..ec606bf 100644
--- a/app/src/main/java/com/denizd/substitutionplan/SettingsFragment.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/SettingsFragment.kt
@@ -38,7 +38,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
private val builder = CustomTabsIntent.Builder()
private val customTabsIntent = builder.build() as CustomTabsIntent
private var cs: Int = 7
- var window: Window? = null
+ private var window: Window? = null
override fun onAttach(context: Context) {
super.onAttach(context)
@@ -46,7 +46,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
edit = prefs.edit()
- window = activity?.window
+ window = activity?.window
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -131,6 +131,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
})
btnVersion.setOnLongClickListener {
+ Toast.makeText(mContext, getString(R.string.devby), Toast.LENGTH_LONG).show()
debugMenu()
}
}
@@ -244,7 +245,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
R.id.btnVersion -> {
if (cs > 0) {
cs--
- Toast.makeText(mContext, getString(R.string.devby), Toast.LENGTH_LONG).show()
} else {
try {
cs = 7
@@ -467,6 +467,10 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
edit.putString("time", "").apply()
Toast.makeText(mContext, "Notification time cleared", Toast.LENGTH_LONG).show()
} // TODO add option to clear database
+ "@FIRSTTIME" -> {
+ edit.putBoolean("firstTime", true).apply()
+ Toast.makeText(mContext, "First time flag cleared", Toast.LENGTH_LONG).show()
+ }
else -> Toast.makeText(mContext, getString(R.string.nothinghappened), Toast.LENGTH_LONG).show()
}
}
@@ -475,11 +479,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
return true
}
-// override fun onDetach() {
-// super.onDetach()
-// edit.apply()
-// }
-
private fun getDiagnosticsText(prefs: SharedPreferences): String {
return "First Launch: " + prefs.getString("firstTimeDev", "") +
"\n\nApp launched: " + prefs.getInt("launchDev", 0) +