Skip to content

Commit

Permalink
disable LC activation checkbox when GC is not active (fix cgeo#10477)
Browse files Browse the repository at this point in the history
  • Loading branch information
moving-bits committed May 1, 2021
1 parent 936b8ab commit d9e9781
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main/src/cgeo/geocaching/settings/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ private void initServicePreferences() {
getPreference(R.string.pref_connectorLCActive).setOnPreferenceChangeListener(this);
setWebsite(R.string.pref_fakekey_lc_website, LCConnector.getInstance().getHost());
getPreference(R.string.preference_screen_lc).setSummary(getServiceSummary(Settings.isLCConnectorActive()));
initLCServicePreference(Settings.isGCConnectorActive());

getPreference(R.string.pref_connectorSUActive).setOnPreferenceChangeListener(this);
setWebsite(R.string.pref_fakekey_su_website, SuConnector.getInstance().getHost());
Expand All @@ -301,6 +302,10 @@ private void initServicePreferences() {
getPreference(R.string.preference_screen_sendtocgeo).setSummary(getServiceSummary(Settings.isRegisteredForSend2cgeo()));
}

private void initLCServicePreference(final boolean gcConnectorActive) {
getPreference(R.string.pref_connectorLCActive).setEnabled(gcConnectorActive && Settings.isGCPremiumMember());
}

private void setWebsite(final int preferenceKey, final String urlOrHost) {
final Preference preference = getPreference(preferenceKey);
preference.setOnPreferenceClickListener(preference1 -> {
Expand Down Expand Up @@ -855,6 +860,7 @@ protected void onActivityResult(final int requestCode, final int resultCode, fin
setConnectedUsernameTitle(requestCode, GCConnector.getInstance());
redrawScreen(R.string.preference_screen_gc);
initBasicMemberPreferences();
initLCServicePreference(Settings.isGCConnectorActive());
break;
case R.string.pref_fakekey_ec_authorization:
setAuthTitle(requestCode, ECConnector.getInstance());
Expand Down Expand Up @@ -933,6 +939,7 @@ public boolean onPreferenceChange(final Preference preference, final Object valu
preference.getPreferenceManager().findPreference(getKey(prefKey.prefScreenId)).setSummary(summary);
} else if (isPreference(preference, R.string.pref_connectorGCActive)) {
preference.getPreferenceManager().findPreference(getKey(R.string.preference_screen_gc)).setSummary(summary);
initLCServicePreference(boolVal);
} else if (isPreference(preference, R.string.pref_connectorECActive)) {
preference.getPreferenceManager().findPreference(getKey(R.string.preference_screen_ec)).setSummary(summary);
} else if (isPreference(preference, R.string.pref_connectorLCActive)) {
Expand Down

0 comments on commit d9e9781

Please sign in to comment.