diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-07-12 16:14:38 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-07-12 16:14:38 +0200 |
commit | 5b57490f60582d38c8e95c28860cdd0db32ae8a4 (patch) | |
tree | e9cba7406a5e9e660341cb4949b099db52c74d0a | |
parent | f3c19b6da20dadc3b93b6e1d2fd8481f9afb561b (diff) | |
download | AntennaPod-5b57490f60582d38c8e95c28860cdd0db32ae8a4.zip |
Added item visibility check and 'revoke access'-item
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/preferences.xml | 5 | ||||
-rw-r--r-- | src/de/podfetcher/activity/PreferenceActivity.java | 35 |
3 files changed, 32 insertions, 10 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 739c651fc..1d9141851 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -116,5 +116,7 @@ <string name="flattr_click_success">Successfully flattred this thing!</string> <string name="pref_flattr_this_app_title">Flattr this app</string> <string name="pref_flattr_this_app_sum">Support the development of Antennacast by flattring it. Thanks!</string> + <string name="pref_revokeAccess_title">Revoke access</string> + <string name="pref_revokeAccess_sum">Revoke the access permission to your flattr account for this app.</string> </resources>
\ No newline at end of file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 2521d3c83..daf6511df 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -34,9 +34,10 @@ <PreferenceCategory android:title="@string/flattr_settings_label" > <PreferenceScreen android:summary="@string/pref_flattr_auth_sum" - android:title="@string/pref_flattr_auth_title" > + android:title="@string/pref_flattr_auth_title" android:key="pref_flattr_authenticate"> <intent android:action=".activities.FlattrAuthActivity" /> - </PreferenceScreen> + + </PreferenceScreen><Preference android:key="prefRevokeAccess" android:title="@string/pref_revokeAccess_title" android:summary="@string/pref_revokeAccess_sum"/> <Preference android:summary="@string/pref_flattr_this_app_sum" android:title="@string/pref_flattr_this_app_title" android:key="prefFlattrThisApp"> diff --git a/src/de/podfetcher/activity/PreferenceActivity.java b/src/de/podfetcher/activity/PreferenceActivity.java index 1fa85940e..4a76a871c 100644 --- a/src/de/podfetcher/activity/PreferenceActivity.java +++ b/src/de/podfetcher/activity/PreferenceActivity.java @@ -10,25 +10,44 @@ import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; import de.podfetcher.R; +import de.podfetcher.util.FlattrUtils; public class PreferenceActivity extends SherlockPreferenceActivity { private static final String TAG = "PreferenceActivity"; - + private static final String PREF_FLATTR_THIS_APP = "prefFlattrThisApp"; - + private static final String PREF_FLATTR_AUTH = "pref_flattr_authenticate"; + private static final String PREF_FLATTR_REVOKE = "prefRevokeAccess"; + @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setDisplayHomeAsUpEnabled(true); addPreferencesFromResource(R.xml.preferences); - findPreference(PREF_FLATTR_THIS_APP).setOnPreferenceClickListener(new OnPreferenceClickListener() { + findPreference(PREF_FLATTR_THIS_APP).setOnPreferenceClickListener( + new OnPreferenceClickListener() { + + @Override + public boolean onPreferenceClick(Preference preference) { + Log.d(TAG, "Flattring this app"); + return true; + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + checkItemVisibility(); + } + + @SuppressWarnings("deprecation") + private void checkItemVisibility() { + boolean hasFlattrToken = FlattrUtils.hasToken(); + findPreference(PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken); + findPreference(PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken); - @Override - public boolean onPreferenceClick(Preference preference) { - Log.d(TAG, "Flattring this app"); - return true; - }}); } @Override |