From 773e978cb71a6c18137204c6db436ff7ef2ffa19 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 10 Nov 2021 06:40:32 -0800 Subject: [PATCH 01/21] initial setup for export | import feature --- .idea/misc.xml | 1 + .../noah/timely/exports/TMLFileGenerator.java | 15 +++ .../exports/TimeLYDataGeneratorDialog.java | 61 +++++++++++ .../com/noah/timely/main/MainActivity.java | 13 ++- .../drawable/ic_baseline_import_export_24.xml | 5 + .../main/res/layout/bottomsheet_chooser.xml | 6 ++ app/src/main/res/layout/dialog_generate.xml | 100 ++++++++++++++++++ app/src/main/res/menu/nav_menu.xml | 8 +- app/src/main/res/values/strings.xml | 3 +- app/src/main/res/xml/preferences.xml | 16 ++- app/src/main/res/xml/release_note.xml | 7 +- 11 files changed, 224 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/com/noah/timely/exports/TMLFileGenerator.java create mode 100644 app/src/main/java/com/noah/timely/exports/TimeLYDataGeneratorDialog.java create mode 100644 app/src/main/res/drawable/ic_baseline_import_export_24.xml create mode 100644 app/src/main/res/layout/bottomsheet_chooser.xml create mode 100644 app/src/main/res/layout/dialog_generate.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index aded2c10..57d3f874 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -34,6 +34,7 @@ + diff --git a/app/src/main/java/com/noah/timely/exports/TMLFileGenerator.java b/app/src/main/java/com/noah/timely/exports/TMLFileGenerator.java new file mode 100644 index 00000000..54fa0955 --- /dev/null +++ b/app/src/main/java/com/noah/timely/exports/TMLFileGenerator.java @@ -0,0 +1,15 @@ +package com.noah.timely.exports; + +import com.noah.timely.core.DataModel; + +import java.util.List; + +/** + * TimeLY's native .tml file generator + */ +public class TMLFileGenerator { + + public static boolean generate(List dataModelList) { + return false; + } +} diff --git a/app/src/main/java/com/noah/timely/exports/TimeLYDataGeneratorDialog.java b/app/src/main/java/com/noah/timely/exports/TimeLYDataGeneratorDialog.java new file mode 100644 index 00000000..225c0f5e --- /dev/null +++ b/app/src/main/java/com/noah/timely/exports/TimeLYDataGeneratorDialog.java @@ -0,0 +1,61 @@ +package com.noah.timely.exports; + +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.view.Window; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +import com.noah.timely.R; +import com.noah.timely.core.DataModel; + +import java.util.ArrayList; +import java.util.List; + +public class TimeLYDataGeneratorDialog extends DialogFragment implements View.OnClickListener { + @SuppressWarnings("FieldCanBeLocal") + public static final String TAG = "com.noah.timely.exports.TimeLYDataGeneratorDialog"; + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") // fixme: remove this + private final List dataModelList = new ArrayList<>(); + + public void show(Context context) { + FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager(); + show(manager, TAG); + } + + @Override + public void onClick(View v) { + boolean isGenerated = TMLFileGenerator.generate(dataModelList); + if (isGenerated) Toast.makeText(getContext(), "Error occurred", Toast.LENGTH_SHORT).show(); + } + + @NonNull + @Override + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { + return new DataGeneratorDialog(getContext()); + } + + private static class DataGeneratorDialog extends Dialog { + + public DataGeneratorDialog(@NonNull Context context) { + super(context, R.style.Dialog_Closeable); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().requestFeature(Window.FEATURE_NO_TITLE); + getWindow().setBackgroundDrawableResource(R.drawable.bg_rounded_edges_8); + setContentView(R.layout.dialog_generate); + + } + + } +} diff --git a/app/src/main/java/com/noah/timely/main/MainActivity.java b/app/src/main/java/com/noah/timely/main/MainActivity.java index fa3c8731..55c9da05 100644 --- a/app/src/main/java/com/noah/timely/main/MainActivity.java +++ b/app/src/main/java/com/noah/timely/main/MainActivity.java @@ -23,6 +23,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.navigation.NavigationView; import com.noah.timely.R; import com.noah.timely.about.TimelyBasicInfoDialog; @@ -230,11 +231,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { new TimelyUpdateInfoDialog().show(this); - }/* else if (menuItemId == R.id.generate) { + } else if (menuItemId == R.id.generate) { - Toast.makeText(this, "No action yet", Toast.LENGTH_LONG).show(); + displaySelectionBottomSheet(); - }*/ else if (menuItemId == R.id.report) { + } else if (menuItemId == R.id.report) { new AlertDialog.Builder(this) .setTitle(R.string.report_title) @@ -254,6 +255,12 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { return true; } + private void displaySelectionBottomSheet(){ + BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this); + bottomSheetDialog.setContentView(R.layout.bottomsheet_chooser); + bottomSheetDialog.show(); + } + private void reportAction(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { // send message with emojis diff --git a/app/src/main/res/drawable/ic_baseline_import_export_24.xml b/app/src/main/res/drawable/ic_baseline_import_export_24.xml new file mode 100644 index 00000000..44929b76 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_import_export_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/bottomsheet_chooser.xml b/app/src/main/res/layout/bottomsheet_chooser.xml new file mode 100644 index 00000000..ef6183d5 --- /dev/null +++ b/app/src/main/res/layout/bottomsheet_chooser.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_generate.xml b/app/src/main/res/layout/dialog_generate.xml new file mode 100644 index 00000000..a4b32570 --- /dev/null +++ b/app/src/main/res/layout/dialog_generate.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/nav_menu.xml b/app/src/main/res/menu/nav_menu.xml index 6a2e6bce..4c5090f4 100644 --- a/app/src/main/res/menu/nav_menu.xml +++ b/app/src/main/res/menu/nav_menu.xml @@ -74,10 +74,10 @@ android:icon="@drawable/ic_whats_new" android:title="@string/whats_new" /> - + No Images Attached Image add course - Generate and Share + Export | Import Check for updates Good Morning Good Afternoon @@ -117,6 +117,7 @@ Yes v1.0.0 Use dialogs to add new task and reminders. This won\'t work for smaller screen sizes + Use dialogs to show data to be exported/imported. This won\'t work for smaller screen sizes Add timetable add exams Good Night diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index f96a7fe6..debf92af 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -39,7 +39,7 @@ external:icon="@drawable/ic_baseline_build_24" external:key="prefer_dialog" external:summary="@string/dialog_pref" - external:title="Prefer dialogs" /> + external:title="Prefer dialogs for input" /> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/release_note.xml b/app/src/main/res/xml/release_note.xml index e736e505..0a051dd4 100644 --- a/app/src/main/res/xml/release_note.xml +++ b/app/src/main/res/xml/release_note.xml @@ -1,9 +1,12 @@ - Fixed bugs in Todo list. + Added export/import data feature. - Added select-all feature + Improved introduction page; added skip and improved naviagation + + + Working on full support for Android 12 (S) From 770c3fe5c4298ddd7f8b6bf8a6acf28b537dd540 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 10 Nov 2021 06:43:01 -0800 Subject: [PATCH 02/21] initial setup for export | import feature --- app/src/main/java/com/noah/timely/main/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/noah/timely/main/MainActivity.java b/app/src/main/java/com/noah/timely/main/MainActivity.java index 55c9da05..e1d1bfe1 100644 --- a/app/src/main/java/com/noah/timely/main/MainActivity.java +++ b/app/src/main/java/com/noah/timely/main/MainActivity.java @@ -295,7 +295,7 @@ private void reportAction(DialogInterface dialog, int which) { } // Get intent actions and update UI - private void doUpdateFragment(Intent intent) { + private void doUpdateFragment(Intent intent) { final String reqAction = intent.getAction(); if (reqAction != null) { switch (reqAction) { From 8d3b60e8ffc4ae16391701cdd93c6e6a298b99e7 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 10 Nov 2021 06:46:04 -0800 Subject: [PATCH 03/21] fixed deprecated VIBRATOR_SERVICE on Android 12 --- .../alarms/AlarmNotificationService.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/noah/timely/alarms/AlarmNotificationService.java b/app/src/main/java/com/noah/timely/alarms/AlarmNotificationService.java index 80ddf892..b9d00732 100644 --- a/app/src/main/java/com/noah/timely/alarms/AlarmNotificationService.java +++ b/app/src/main/java/com/noah/timely/alarms/AlarmNotificationService.java @@ -20,6 +20,7 @@ import android.os.Process; import android.os.VibrationEffect; import android.os.Vibrator; +import android.os.VibratorManager; import android.text.TextUtils; import androidx.preference.PreferenceManager; @@ -73,7 +74,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { .build(); String type = PreferenceManager.getDefaultSharedPreferences(aCtxt) - .getString("Alarm Ringtone", "TimeLY's Default"); + .getString("Alarm Ringtone", "TimeLY's Default"); final Uri DEFAULT_URI = type.equals("TimeLY's Default") || SYSTEM_DEFAULT == null ? APP_DEFAULT : SYSTEM_DEFAULT; @@ -93,11 +94,18 @@ public int onStartCommand(Intent intent, int flags, int startId) { } - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + // retrive the default vibrator + VibratorManager vManager = (VibratorManager) getSystemService(Context.VIBRATOR_MANAGER_SERVICE); + vibrator = vManager.getDefaultVibrator(); + } else { + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + } + if (isAlarmVibrate) { final int DELAY = 0, VIBRATE = 1000, SLEEP = 1000, START = 0; - long[] vibratePattern = {DELAY, VIBRATE, SLEEP}; + long[] vibratePattern = { DELAY, VIBRATE, SLEEP }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { vibrator.vibrate(VibrationEffect.createWaveform(vibratePattern, START)); @@ -157,14 +165,14 @@ public void run() { String ss = preferences.getString("snoozeOnStop", "Snooze"); if (ss.equals("Snooze")) sendBroadcast(new Intent(this, NotificationActionReceiver.class) - .putExtra("action", "Snooze") - .putExtra(ID, NOTIFICATION_ID) - .putExtra(ALARM_POS, alarmPos)); + .putExtra("action", "Snooze") + .putExtra(ID, NOTIFICATION_ID) + .putExtra(ALARM_POS, alarmPos)); else sendBroadcast(new Intent(this, NotificationActionReceiver.class) - .putExtra("action", "Dismiss") - .putExtra(ID, NOTIFICATION_ID) - .putExtra(ALARM_POS, alarmPos)); + .putExtra("action", "Dismiss") + .putExtra(ID, NOTIFICATION_ID) + .putExtra(ALARM_POS, alarmPos)); stopSelf(); } From 124a7919b2bf100075d1cd6273036c834bd89268 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 10 Nov 2021 10:02:24 -0800 Subject: [PATCH 04/21] updated code :) --- .idea/misc.xml | 3 +- app/src/main/AndroidManifest.xml | 4 + .../com/noah/timely/main/MainActivity.java | 21 ++- .../main/res/drawable/bg_buy_me_coffee.xml | 21 +++ app/src/main/res/drawable/ic_bmc_logo.xml | 17 +++ app/src/main/res/font/cookie.xml | 7 + .../main/res/layout/bottomsheet_chooser.xml | 6 - app/src/main/res/layout/dialog_about.xml | 25 +++- app/src/main/res/layout/dialog_generate.xml | 137 +++++++++--------- app/src/main/res/menu/nav_menu.xml | 9 +- app/src/main/res/values-560dpi/dimens.xml | 1 + app/src/main/res/values-sw320dp/dimens.xml | 1 + app/src/main/res/values-sw360dp/dimens.xml | 1 + app/src/main/res/values-sw411dp/dimens.xml | 1 + app/src/main/res/values-sw440dp/dimens.xml | 1 + app/src/main/res/values-sw480dp/dimens.xml | 1 + app/src/main/res/values-sw533dp/dimens.xml | 1 + app/src/main/res/values-sw560dp/dimens.xml | 1 + app/src/main/res/values-sw600dp/dimens.xml | 1 + app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/font_certs.xml | 17 +++ app/src/main/res/values/preloaded_fonts.xml | 6 + app/src/main/res/values/strings.xml | 5 +- 23 files changed, 193 insertions(+), 95 deletions(-) create mode 100644 app/src/main/res/drawable/bg_buy_me_coffee.xml create mode 100644 app/src/main/res/drawable/ic_bmc_logo.xml create mode 100644 app/src/main/res/font/cookie.xml delete mode 100644 app/src/main/res/layout/bottomsheet_chooser.xml create mode 100644 app/src/main/res/values/font_certs.xml create mode 100644 app/src/main/res/values/preloaded_fonts.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 57d3f874..f6555e77 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -61,9 +61,10 @@ - + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3917a53d..f2219b8c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -239,6 +239,10 @@ + + \ No newline at end of file diff --git a/app/src/main/java/com/noah/timely/main/MainActivity.java b/app/src/main/java/com/noah/timely/main/MainActivity.java index e1d1bfe1..3d7e8e55 100644 --- a/app/src/main/java/com/noah/timely/main/MainActivity.java +++ b/app/src/main/java/com/noah/timely/main/MainActivity.java @@ -9,6 +9,7 @@ import android.provider.Settings; import android.view.Menu; import android.view.MenuItem; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; @@ -23,7 +24,6 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.navigation.NavigationView; import com.noah.timely.R; import com.noah.timely.about.TimelyBasicInfoDialog; @@ -34,6 +34,7 @@ import com.noah.timely.core.SchoolDatabase; import com.noah.timely.courses.CoursesFragment; import com.noah.timely.exam.ExamFragment; +import com.noah.timely.exports.TimeLYDataGeneratorDialog; import com.noah.timely.scheduled.ScheduledTimetableFragment; import com.noah.timely.settings.SettingsActivity; import com.noah.timely.timetable.TimetableFragment; @@ -231,11 +232,15 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { new TimelyUpdateInfoDialog().show(this); - } else if (menuItemId == R.id.generate) { + } else if (menuItemId == R.id.__export) { - displaySelectionBottomSheet(); + new TimeLYDataGeneratorDialog().show(this); - } else if (menuItemId == R.id.report) { + } else if (menuItemId == R.id.__import) { + + Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); + + } else if (menuItemId == R.id.report) { new AlertDialog.Builder(this) .setTitle(R.string.report_title) @@ -255,12 +260,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { return true; } - private void displaySelectionBottomSheet(){ - BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this); - bottomSheetDialog.setContentView(R.layout.bottomsheet_chooser); - bottomSheetDialog.show(); - } - private void reportAction(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { // send message with emojis @@ -295,7 +294,7 @@ private void reportAction(DialogInterface dialog, int which) { } // Get intent actions and update UI - private void doUpdateFragment(Intent intent) { + private void doUpdateFragment(Intent intent) { final String reqAction = intent.getAction(); if (reqAction != null) { switch (reqAction) { diff --git a/app/src/main/res/drawable/bg_buy_me_coffee.xml b/app/src/main/res/drawable/bg_buy_me_coffee.xml new file mode 100644 index 00000000..c8abb7e4 --- /dev/null +++ b/app/src/main/res/drawable/bg_buy_me_coffee.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bmc_logo.xml b/app/src/main/res/drawable/ic_bmc_logo.xml new file mode 100644 index 00000000..15405a21 --- /dev/null +++ b/app/src/main/res/drawable/ic_bmc_logo.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/font/cookie.xml b/app/src/main/res/font/cookie.xml new file mode 100644 index 00000000..4e3c7032 --- /dev/null +++ b/app/src/main/res/font/cookie.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/layout/bottomsheet_chooser.xml b/app/src/main/res/layout/bottomsheet_chooser.xml deleted file mode 100644 index ef6183d5..00000000 --- a/app/src/main/res/layout/bottomsheet_chooser.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_about.xml b/app/src/main/res/layout/dialog_about.xml index 5dbc74cd..95ffc21e 100644 --- a/app/src/main/res/layout/dialog_about.xml +++ b/app/src/main/res/layout/dialog_about.xml @@ -1,9 +1,8 @@ @@ -89,8 +88,8 @@ android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="0dp" - external:layout_constraintTop_toBottomOf="@+id/textView4" - tools:layout_editor_absoluteX="16dp"> + external:layout_constraintBottom_toTopOf="@+id/bmc" + external:layout_constraintTop_toBottomOf="@+id/textView4"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_generate.xml b/app/src/main/res/layout/dialog_generate.xml index a4b32570..458e5d86 100644 --- a/app/src/main/res/layout/dialog_generate.xml +++ b/app/src/main/res/layout/dialog_generate.xml @@ -2,99 +2,96 @@ - - - - - - - - - - + external:layout_constraintTop_toTopOf="parent" /> + external:layout_constraintTop_toBottomOf="@id/title"> + android:orientation="vertical"> + + + + + + + + + + + + +