Skip to content
Snippets Groups Projects
Unverified Commit cd7aaa47 authored by mueller-ma's avatar mueller-ma Committed by GitHub
Browse files

Show shortcut to notification settings for Oreo and above (#1167)


Closes #1156

Signed-off-by: default avatarmueller-ma <mueller-ma@users.noreply.github.com>
parent c7e182d2
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
......@@ -235,6 +236,8 @@ public class PreferencesActivity extends AppCompatActivity {
final Preference ringtonePref = findPreference(Constants.PREFERENCE_TONE);
final Preference vibrationPref =
findPreference(Constants.PREFERENCE_NOTIFICATION_VIBRATION);
final Preference ringtoneVibrationPref =
findPreference(Constants.PREFERENCE_NOTIFICATION_TONE_VIBRATION);
final Preference viewLogPref = findPreference(Constants.PREFERENCE_LOG);
final SharedPreferences prefs = getPreferenceScreen().getSharedPreferences();
......@@ -308,6 +311,14 @@ public class PreferencesActivity extends AppCompatActivity {
return true;
});
ringtoneVibrationPref.setOnPreferenceClickListener(preference -> {
Intent i = new Intent(android.provider.Settings.ACTION_SETTINGS);
i.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
i.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
startActivity(i);
return true;
});
viewLogPref.setOnPreferenceClickListener(preference -> {
Intent logIntent = new Intent(preference.getContext(), LogActivity.class);
startActivity(logIntent);
......@@ -322,11 +333,20 @@ public class PreferencesActivity extends AppCompatActivity {
getParent(fullscreenPreference).removePreference(fullscreenPreference);
}
if (!CloudMessagingHelper.isSupported()
|| Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.d(TAG, "Removing notification prefs");
if (CloudMessagingHelper.isSupported()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.d(TAG, "Removing notification prefs for < 25");
getParent(ringtonePref).removePreference(ringtonePref);
getParent(vibrationPref).removePreference(vibrationPref);
} else {
Log.d(TAG, "Removing notification prefs for >= 25");
getParent(ringtoneVibrationPref).removePreference(ringtoneVibrationPref);
}
} else {
Log.d(TAG, "Removing all notification prefs");
getParent(ringtonePref).removePreference(ringtonePref);
getParent(vibrationPref).removePreference(vibrationPref);
getParent(ringtoneVibrationPref).removePreference(ringtoneVibrationPref);
}
final ServerProperties props =
......
......@@ -26,6 +26,8 @@ public class Constants {
public static final String PREFERENCE_TONE = "default_openhab_alertringtone";
public static final String PREFERENCE_NOTIFICATION_VIBRATION =
"default_openhab_notification_vibration";
public static final String PREFERENCE_NOTIFICATION_TONE_VIBRATION =
"default_openhab_alertringtone_vibration";
public static final String PREFERENCE_CLEAR_CACHE = "default_openhab_cleacache";
public static final String PREFERENCE_SSLCLIENTCERT = "default_openhab_sslclientcert";
public static final String PREFERENCE_DEBUG_MESSAGES = "default_openhab_debug_messages";
......
......@@ -68,6 +68,7 @@
<string name="settings_notification_vibration_value_short" translatable="false">short</string>
<string name="settings_notification_vibration_value_long" translatable="false">long</string>
<string name="settings_notification_vibration_value_twice" translatable="false">twice</string>
<string name="settings_notification_ringtone_vibration">Notification settings</string>
<string name="settings_connection_summary">Connected to %s</string>
<string name="settings_insecure_connection_summary">Insecurely connected to %s</string>
<string name="beta">Beta</string>
......
......@@ -96,6 +96,11 @@
android:entries="@array/notificationVibration"
android:entryValues="@array/notificationVibrationValues"
android:icon="@drawable/ic_vibration_grey_24dp" />
<Preference
android:clickable="true"
android:key="default_openhab_alertringtone_vibration"
android:title="@string/settings_notification_ringtone_vibration"
android:icon="@drawable/ic_notifications_active_grey_24dp" />
<SwitchPreference
android:defaultValue="false"
android:key="default_openhab_debug_messages"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment