mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 03:09:00 +00:00
improve reminder rescheduling
This commit is contained in:
parent
05a4c88921
commit
2666fc4ece
5 changed files with 27 additions and 7 deletions
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="129"
|
||||
android:versionName="0.0.34.2"
|
||||
android:versionCode="131"
|
||||
android:versionName="0.0.34.3"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
||||
|
|
@ -138,7 +138,9 @@
|
|||
android:screenOrientation="portrait" />
|
||||
<receiver android:process=":remote" android:name=".NotificationPublisher" />
|
||||
|
||||
<receiver android:process=":remote" android:name=".receivers.TaskReceiver"></receiver>
|
||||
<receiver
|
||||
android:process=":remote"
|
||||
android:name=".receivers.TaskReceiver"/>
|
||||
|
||||
<receiver android:name=".receivers.LocalNotificationActionReceiver">
|
||||
<intent-filter>
|
||||
|
|
@ -150,7 +152,7 @@
|
|||
</receiver>
|
||||
<receiver android:name=".receivers.TaskAlarmBootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action._BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
|
|
|||
|
|
@ -288,4 +288,4 @@ apply plugin: 'com.getkeepsafe.dexcount'
|
|||
apply plugin: 'com.android.application' //or apply plugin: 'java'
|
||||
apply plugin: 'me.tatarka.retrolambda'
|
||||
apply plugin: 'com.jakewharton.hugo'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import android.app.AlarmManager;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
|
@ -109,6 +111,10 @@ public class TaskAlarmManager {
|
|||
for (Task task : tasks) {
|
||||
this.setAlarmsForTask(task);
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||
editor.putLong("lastReminderSchedule", new Date().getTime());
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private RemindersItem setTimeForDailyReminder(RemindersItem remindersItem, Task task) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,16 @@ import com.habitrpg.android.habitica.helpers.TaskAlarmManager;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TaskAlarmBootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context arg0, Intent arg1) {
|
||||
TaskAlarmManager taskAlarmManager = TaskAlarmManager.getInstance(arg0);
|
||||
public void onReceive(Context context, Intent arg1) {
|
||||
TaskAlarmManager taskAlarmManager = TaskAlarmManager.getInstance(context);
|
||||
taskAlarmManager.scheduleAllSavedAlarms();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ import com.habitrpg.android.habitica.events.commands.UnlockPathCommand;
|
|||
import com.habitrpg.android.habitica.events.commands.UpdateUserCommand;
|
||||
import com.habitrpg.android.habitica.helpers.AmplitudeManager;
|
||||
import com.habitrpg.android.habitica.helpers.LanguageHelper;
|
||||
import com.habitrpg.android.habitica.helpers.TaskAlarmManager;
|
||||
import com.habitrpg.android.habitica.helpers.notifications.PushNotificationManager;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
||||
|
|
@ -183,6 +184,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
public HabitRPGUser user;
|
||||
@Inject
|
||||
protected HostConfig hostConfig;
|
||||
@Inject
|
||||
protected SharedPreferences sharedPreferences;
|
||||
@BindView(R.id.floating_menu_wrapper)
|
||||
FrameLayout floatingMenuWrapper;
|
||||
@BindView(R.id.toolbar)
|
||||
|
|
@ -303,6 +306,11 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}
|
||||
}
|
||||
|
||||
if (this.sharedPreferences.getLong("lastReminderSchedule", 0) > new Date().getTime() - 86400000) {
|
||||
TaskAlarmManager taskAlarmManager = TaskAlarmManager.getInstance(this);
|
||||
taskAlarmManager.scheduleAllSavedAlarms();
|
||||
}
|
||||
|
||||
//after the activity has been stopped and is thereafter resumed,
|
||||
//a state can arise in which the active fragment no longer has a
|
||||
//reference to the tabLayout (and all its adapters are null).
|
||||
|
|
|
|||
Loading…
Reference in a new issue