Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:

#	Habitica/src/main/java/com/habitrpg/android/habitica/helpers/TaskAlarmManager.java
This commit is contained in:
Phillip Thelen 2016-10-26 20:25:01 +02:00
commit 3a41d0226e
5 changed files with 26 additions and 7 deletions

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica" package="com.habitrpg.android.habitica"
android:versionCode="129" android:versionCode="132"
android:versionName="0.0.34.2" android:versionName="0.0.34.3"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:installLocation="auto" > android:installLocation="auto" >
@ -138,7 +138,9 @@
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<receiver android:process=":remote" android:name=".NotificationPublisher" /> <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"> <receiver android:name=".receivers.LocalNotificationActionReceiver">
<intent-filter> <intent-filter>
@ -150,7 +152,7 @@
</receiver> </receiver>
<receiver android:name=".receivers.TaskAlarmBootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> <receiver android:name=".receivers.TaskAlarmBootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter> <intent-filter>
<action android:name="android.intent.action._BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>

View file

@ -288,4 +288,4 @@ apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application' //or apply plugin: 'java' apply plugin: 'com.android.application' //or apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda' apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo' apply plugin: 'com.jakewharton.hugo'
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

View file

@ -17,6 +17,8 @@ import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.preference.PreferenceManager; import android.support.v7.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -113,6 +115,9 @@ public class TaskAlarmManager {
} }
scheduleDailyReminder(context); scheduleDailyReminder(context);
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
editor.putLong("lastReminderSchedule", new Date().getTime());
editor.apply();
} }
private RemindersItem setTimeForDailyReminder(RemindersItem remindersItem, Task task) { private RemindersItem setTimeForDailyReminder(RemindersItem remindersItem, Task task) {

View file

@ -5,12 +5,16 @@ import com.habitrpg.android.habitica.helpers.TaskAlarmManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.preference.PreferenceManager;
import java.util.Date;
public class TaskAlarmBootReceiver extends BroadcastReceiver { public class TaskAlarmBootReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context arg0, Intent arg1) { public void onReceive(Context context, Intent arg1) {
TaskAlarmManager taskAlarmManager = TaskAlarmManager.getInstance(arg0); TaskAlarmManager taskAlarmManager = TaskAlarmManager.getInstance(context);
taskAlarmManager.scheduleAllSavedAlarms(); taskAlarmManager.scheduleAllSavedAlarms();
} }

View file

@ -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.events.commands.UpdateUserCommand;
import com.habitrpg.android.habitica.helpers.AmplitudeManager; import com.habitrpg.android.habitica.helpers.AmplitudeManager;
import com.habitrpg.android.habitica.helpers.LanguageHelper; 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.helpers.notifications.PushNotificationManager;
import com.habitrpg.android.habitica.ui.AvatarView; import com.habitrpg.android.habitica.ui.AvatarView;
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel; import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
@ -183,6 +184,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
public HabitRPGUser user; public HabitRPGUser user;
@Inject @Inject
protected HostConfig hostConfig; protected HostConfig hostConfig;
@Inject
protected SharedPreferences sharedPreferences;
@BindView(R.id.floating_menu_wrapper) @BindView(R.id.floating_menu_wrapper)
FrameLayout floatingMenuWrapper; FrameLayout floatingMenuWrapper;
@BindView(R.id.toolbar) @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, //after the activity has been stopped and is thereafter resumed,
//a state can arise in which the active fragment no longer has a //a state can arise in which the active fragment no longer has a
//reference to the tabLayout (and all its adapters are null). //reference to the tabLayout (and all its adapters are null).