diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-09-10 07:23:48 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-09-10 07:23:48 +0000 |
commit | 24261df3dbc4cfd0843c871b8570587344a4001a (patch) | |
tree | 9716fa49b88ab6ea8a137654732ba73661e3c931 | |
parent | 2df26c3faa65dff62aa2c550991fa363331b7e98 (diff) | |
download | infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar.gz infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar.bz2 infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar.lz infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar.xz infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.tar.zst infinity-for-reddit-24261df3dbc4cfd0843c871b8570587344a4001a.zip |
Delete PullNotificationAlarmReceiver because it seems no notification bug is finally fixed (Wrong TimeUnit in NotificationPreferenceFragment).
Diffstat (limited to '')
4 files changed, 0 insertions, 116 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fd4695f7..a35853b4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -347,8 +347,6 @@ android:name=".Service.SubmitPostService" android:enabled="true" android:exported="false" /> - - <receiver android:process=":remote" android:name=".PullNotificationAlarmReceiver" /> </application> </manifest>
\ No newline at end of file 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 d8904a69..d86168ee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -335,7 +335,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } if (enableNotification) { - //PullNotificationAlarmReceiver.setNotificationAlarm(this, notificationInterval); Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build(); @@ -349,7 +348,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb workManager.enqueueUniquePeriodicWork(PullNotificationWorker.UNIQUE_WORKER_NAME, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - //PullNotificationAlarmReceiver.cancelAlarm(this); workManager.cancelUniqueWork(PullNotificationWorker.UNIQUE_WORKER_NAME); } @@ -363,7 +361,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb mKarma = account.getKarma(); if (enableNotification) { - //PullNotificationAlarmReceiver.setNotificationAlarm(this, notificationInterval); Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build(); @@ -377,7 +374,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb workManager.enqueueUniquePeriodicWork(PullNotificationWorker.UNIQUE_WORKER_NAME, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - //PullNotificationAlarmReceiver.cancelAlarm(this); workManager.cancelUniqueWork(PullNotificationWorker.UNIQUE_WORKER_NAME); } @@ -395,7 +391,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } if (enableNotification) { - //PullNotificationAlarmReceiver.setNotificationAlarm(this, notificationInterval); Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build(); @@ -409,7 +404,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb workManager.enqueueUniquePeriodicWork(PullNotificationWorker.UNIQUE_WORKER_NAME, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - //PullNotificationAlarmReceiver.cancelAlarm(this); workManager.cancelUniqueWork(PullNotificationWorker.UNIQUE_WORKER_NAME); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index 606d9d2c..34695608 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -197,6 +197,4 @@ public interface AppComponent { void inject(DownloadLocationPreferenceFragment downloadLocationPreferenceFragment); void inject(SubmitCrosspostActivity submitCrosspostActivity); - - void inject(PullNotificationAlarmReceiver pullNotificationAlarmReceiver); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationAlarmReceiver.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationAlarmReceiver.java deleted file mode 100644 index 2a12f7a1..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationAlarmReceiver.java +++ /dev/null @@ -1,106 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.os.PowerManager; -import android.util.Log; - -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; -import androidx.work.Constraints; -import androidx.work.ExistingWorkPolicy; -import androidx.work.NetworkType; -import androidx.work.OneTimeWorkRequest; -import androidx.work.WorkManager; - -import javax.inject.Inject; -import javax.inject.Named; - -import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.Utils.NotificationUtils; -import retrofit2.Retrofit; - -public class PullNotificationAlarmReceiver extends BroadcastReceiver { - - @Inject - @Named("oauth_without_authenticator") - Retrofit mOauthWithoutAuthenticatorRetrofit; - @Inject - @Named("no_oauth") - Retrofit mRetrofit; - @Inject - RedditDataRoomDatabase mRedditDataRoomDatabase; - @Inject - @Named("default") - SharedPreferences mSharedPreferences; - @Inject - CustomThemeWrapper mCustomThemeWrapper; - - @Override - public void onReceive(Context context, Intent receivedIntent) { - ((Infinity) context.getApplicationContext()).getAppComponent().inject(this); - - PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - PowerManager.WakeLock wl = null; - if (pm != null) { - wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ml.docilealligator.infinityforreddit:notification"); - wl.acquire(2*60*1000L /*2 minutes*/); - } - - Log.i("asasdfsdaf", "time: " + System.currentTimeMillis()); - - NotificationManagerCompat testNotificationManager = NotificationUtils.getNotificationManager(context); - - NotificationCompat.Builder testSummaryBuilder = NotificationUtils.buildSummaryNotification(context, - testNotificationManager, "test", - Long.toString(System.currentTimeMillis()), - NotificationUtils.CHANNEL_ID_NEW_MESSAGES, NotificationUtils.CHANNEL_NEW_MESSAGES, - NotificationUtils.getAccountGroupName("test"), Color.BLACK); - testNotificationManager.notify(NotificationUtils.getSummaryIdUnreadMessage(12), testSummaryBuilder.build()); - - WorkManager workManager = WorkManager.getInstance(context); - - Constraints constraints = new Constraints.Builder() - .setRequiredNetworkType(NetworkType.CONNECTED) - .build(); - - OneTimeWorkRequest pullNotificationRequest = - new OneTimeWorkRequest.Builder(PullNotificationWorker.class) - .setConstraints(constraints) - .build(); - - workManager.enqueueUniqueWork(PullNotificationWorker.UNIQUE_WORKER_NAME, - ExistingWorkPolicy.KEEP, pullNotificationRequest); - - if (wl != null) { - wl.release(); - } - } - - public static void setNotificationAlarm(Context context, long notificationInterval) { - AlarmManager am =(AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - if (am != null) { - Intent intent = new Intent(context, PullNotificationAlarmReceiver.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, NotificationUtils.PULL_NOTIFICATION_ALARM_RECEIVER_REQUEST_CODE, intent, 0); - if ((notificationInterval == 15 || notificationInterval == 30)) { - am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 60 * 1000, 1000 * 60 * notificationInterval, pendingIntent); // Millisec * Second * Minute - } else { - am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 60 * 1000, 1000 * 60 * 60 * notificationInterval, pendingIntent); // Millisec * Second * Minute - } - } - } - - public static void cancelAlarm(Context context) { - AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - if (alarmManager != null) { - Intent intent = new Intent(context, AlarmManager.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, NotificationUtils.PULL_NOTIFICATION_ALARM_RECEIVER_REQUEST_CODE, intent, 0); - alarmManager.cancel(pendingIntent); - } - } -} |