disable expanded notification option when unsupported & provide informative toast

This commit is contained in:
Mike Chelen 2014-08-03 03:03:02 -04:00
parent baf980951e
commit b43037c958
2 changed files with 22 additions and 3 deletions

View File

@ -255,7 +255,7 @@
<string name="pref_expandNotify_sum">Always expand the notification to show playback buttons.</string>
<string name="pref_persistNotify_title">Persistent Notification</string>
<string name="pref_persistNotify_sum">Keep notification when playback is paused.</string>
<string name="pref_expand_notify_unsupport_toast">Android versions before 4.1 do not support expanded notifications.</string>
<!-- Auto-Flattr dialog -->
<string name="auto_flattr_enable">Enable automatic flattring</string>

View File

@ -9,6 +9,7 @@ import android.content.res.Resources.Theme;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Build;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@ -59,6 +60,9 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
private static final String PREF_GPODNET_LOGOUT = "pref_gpodnet_logout";
private static final String PREF_GPODNET_HOSTNAME = "pref_gpodnet_hostname";
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
private CheckBoxPreference[] selectedNetworks;
@SuppressLint("NewApi")
@ -76,6 +80,23 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
}
addPreferencesFromResource(R.xml.preferences);
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
// disable expanded notification option on unsupported android versions
findPreference(PREF_EXPANDED_NOTIFICATION).setEnabled(false);
findPreference(PREF_EXPANDED_NOTIFICATION).setOnPreferenceClickListener(
new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Toast toast = Toast.makeText(PreferenceActivity.this, R.string.pref_expand_notify_unsupport_toast, Toast.LENGTH_SHORT);
toast.show();
return true;
}
}
);
}
findPreference(PREF_FLATTR_THIS_APP).setOnPreferenceClickListener(
new OnPreferenceClickListener() {
@ -271,8 +292,6 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
buildAutodownloadSelectedNetworsPreference();
setSelectedNetworksEnabled(UserPreferences
.isEnableAutodownloadWifiFilter());
}
private void updateGpodnetPreferenceScreen() {