Added item visibility check and 'revoke access'-item
This commit is contained in:
parent
f3c19b6da2
commit
5b57490f60
|
@ -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>
|
|
@ -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">
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue