aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-06-20 14:20:01 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-06-20 14:20:01 +0000
commit354529ca8892b503ac667f0dd7ad93d13fbfdbfe (patch)
treec087d9f633411b16d9af9430b2ea2486489261a5 /app/src/main
parentdce5777fbbaa7d8611c819fe3a75ab7f85a9a09d (diff)
downloadinfinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar.gz
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar.bz2
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar.lz
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar.xz
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.tar.zst
infinity-for-reddit-354529ca8892b503ac667f0dd7ad93d13fbfdbfe.zip
Add 2 options for notification interval: 15 minutes and 30 minutes.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java17
-rw-r--r--app/src/main/res/values/arrays.xml4
2 files changed, 13 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 69b52cfb..d1e9af09 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -64,6 +64,10 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
@@ -73,10 +77,6 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
@@ -321,7 +321,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true);
- String notificationInterval = mSharedPreferences.getString(SharedPreferencesUtils.NOTIFICATION_INTERVAL_KEY, "1");
+ long notificationInterval = Long.parseLong(mSharedPreferences.getString(SharedPreferencesUtils.NOTIFICATION_INTERVAL_KEY, "1"));
+ TimeUnit timeUnit = notificationInterval == 15 || notificationInterval == 30 ? TimeUnit.MINUTES : TimeUnit.HOURS;
WorkManager workManager = WorkManager.getInstance(this);
@@ -349,7 +350,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
PeriodicWorkRequest pullNotificationRequest =
new PeriodicWorkRequest.Builder(PullNotificationWorker.class,
- Long.parseLong(notificationInterval), TimeUnit.HOURS)
+ notificationInterval, timeUnit)
.setConstraints(constraints)
.build();
@@ -375,7 +376,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
PeriodicWorkRequest pullNotificationRequest =
new PeriodicWorkRequest.Builder(PullNotificationWorker.class,
- Long.parseLong(notificationInterval), TimeUnit.HOURS)
+ notificationInterval, timeUnit)
.setConstraints(constraints)
.build();
@@ -405,7 +406,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
PeriodicWorkRequest pullNotificationRequest =
new PeriodicWorkRequest.Builder(PullNotificationWorker.class,
- Long.parseLong(notificationInterval), TimeUnit.HOURS)
+ notificationInterval, timeUnit)
.setConstraints(constraints)
.build();
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 878bf61b..3efd7c75 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -1,5 +1,7 @@
<resources>
<string-array name="settings_notification_interval">
+ <item>15 minutes</item>
+ <item>30 minutes</item>
<item>1 hour</item>
<item>2 hours</item>
<item>3 hours</item>
@@ -10,6 +12,8 @@
</string-array>
<string-array name="settings_notification_interval_values">
+ <item>15</item>
+ <item>30</item>
<item>1</item>
<item>2</item>
<item>3</item>