Remove daily reminder on Android 8.0+

This commit is contained in:
Trevor Slocum 2019-04-26 06:59:05 -07:00
parent e71978ce2f
commit cdacf1ff50
7 changed files with 45 additions and 24 deletions

View File

@ -1,8 +1,10 @@
1.5.4:
- Past sessions may now be edited
- Add prompt to disable battery optimizations on Android 8.0+ (fixes sounds not playing reliably)
- Add long press shortcut to calendar buttons moving one year forward/backward
- Improve calculation of meditation streak window (streak buffer was not being applied consistently)
- Session start, length, end and message are now editable
- Fix tapping home screen widget asking to sign in to MediNET
- Remove daily reminder on Android 8.0+ (Google's new background execution policy no longer allows this behavior)
1.5.3:
- Fix tapping widget always causing MediNET sign in dialog to be shown

View File

@ -22,6 +22,9 @@ public class DailyReminderReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return;
}
try {
ma = (MeditationAssistant) context.getApplicationContext();
} catch (Exception e) {

View File

@ -1020,13 +1020,15 @@ public class MeditationAssistant extends Application {
db = DatabaseHandler.getInstance(getApplicationContext());
reminderAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
reminderAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
/* Send the daily notification updated intent just in case the receiver hasn't been called yet */
Log.d("MeditationAssistant", "Sending initial daily notification updated intent");
Intent intent = new Intent();
intent.setAction(MeditationAssistant.ACTION_UPDATED);
sendBroadcast(intent);
/* Send the daily notification updated intent just in case the receiver hasn't been called yet */
Log.d("MeditationAssistant", "Sending initial daily notification updated intent");
Intent intent = new Intent();
intent.setAction(MeditationAssistant.ACTION_UPDATED);
sendBroadcast(intent);
}
}
public String getPostDataString(HashMap<String, String> params) throws UnsupportedEncodingException {

View File

@ -489,9 +489,11 @@ public class SettingsActivity extends PreferenceActivity {
reminderPreferenceFragment = (ReminderPreferenceFragment) preferenceFragment;
}
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder_text") : preferenceFragment.findPreference("pref_daily_reminder_text"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder_time") : preferenceFragment.findPreference("pref_daily_reminder_time"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder") : preferenceFragment.findPreference("pref_daily_reminder"));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder_text") : preferenceFragment.findPreference("pref_daily_reminder_text"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder_time") : preferenceFragment.findPreference("pref_daily_reminder_time"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_daily_reminder") : preferenceFragment.findPreference("pref_daily_reminder"));
}
}
if (pref_type.equals("all") || pref_type.equals("meditation")) {
if (preferenceFragment != null) {
@ -595,10 +597,12 @@ public class SettingsActivity extends PreferenceActivity {
addPreferencesFromResource(R.xml.pref_session);
// Add 'Daily Reminder' preferences
fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_daily_reminder);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_reminder);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_daily_reminder);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_reminder);
}
// Add 'Meditation' preferences
fakeHeader = new PreferenceCategory(this);
@ -632,6 +636,10 @@ public class SettingsActivity extends PreferenceActivity {
public void onBuildHeaders(List<Header> target) {
if (!isSimplePreferences(this)) {
loadHeadersFromResource(R.xml.pref_headers, target);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
loadHeadersFromResource(R.xml.pref_headers_pre26, target);
}
loadHeadersFromResource(R.xml.pref_headers_footer, target);
}
}

View File

@ -1,15 +1,9 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<!-- These settings headers are only used on tablets. -->
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$SessionPreferenceFragment"
android:title="@string/session"/>
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$ReminderPreferenceFragment"
android:title="@string/pref_daily_reminder"/>
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$MeditationPreferenceFragment"
android:title="@string/meditation"/>
@ -18,8 +12,4 @@
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$MediNETPreferenceFragment"
android:title="@string/mediNET"/>
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$MiscellaneousPreferenceFragment"
android:title="@string/miscellaneous"/>
</preference-headers>

View File

@ -0,0 +1,7 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$MiscellaneousPreferenceFragment"
android:title="@string/miscellaneous"/>
</preference-headers>

View File

@ -0,0 +1,9 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<!-- These headers are only used pre-8.0 -->
<header
android:fragment="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity$ReminderPreferenceFragment"
android:title="@string/pref_daily_reminder"/>
</preference-headers>