1
0
Fork 0

greedy google patch (#717)

This commit is contained in:
Dimo Karaivanov 2025-01-31 23:23:28 +02:00 committed by GitHub
parent ada5261773
commit 4b8ccdd2b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 11 deletions

View file

@ -13,18 +13,26 @@ import io.github.sspanak.tt9.util.Logger;
class ItemDonate extends ItemClickable { class ItemDonate extends ItemClickable {
static final String NAME = "donate_link"; static final String NAME = "donate_link";
private final PreferencesActivity activity; private final PreferencesActivity activity;
private final boolean isVisible;
ItemDonate(Preference preference, PreferencesActivity activity) { ItemDonate(Preference preference, PreferencesActivity activity, boolean isTT9On) {
super(preference); super(preference);
this.activity = activity; this.activity = activity;
this.isVisible = false;
} }
public ItemDonate populate() { public ItemDonate populate() {
if (item != null) { if (item == null) {
return this;
}
if (isVisible) {
String appName = activity.getString(R.string.app_name_short); String appName = activity.getString(R.string.app_name_short);
String url = activity.getString(R.string.donate_url_short); String url = activity.getString(R.string.donate_url_short);
item.setSummary(activity.getString(R.string.donate_summary, appName, url)); item.setSummary(activity.getString(R.string.donate_summary, appName, url));
} }
item.setVisible(isVisible);
return this; return this;
} }

View file

@ -24,8 +24,9 @@ public class MainSettingsScreen extends BaseScreenFragment {
@Override @Override
public void onCreate() { public void onCreate() {
createSettingsSection(); boolean isTT9On = SystemSettings.isTT9Enabled(activity);
createAboutSection(); createSettingsSection(isTT9On);
createAboutSection(isTT9On);
updateHelpButtonDescription(); updateHelpButtonDescription();
resetFontSize(false); resetFontSize(false);
} }
@ -35,13 +36,16 @@ public class MainSettingsScreen extends BaseScreenFragment {
public void onResume() { public void onResume() {
init(); // changing the theme recreates the PreferencesActivity, making "this.activity" NULL, so we reinitialize it. init(); // changing the theme recreates the PreferencesActivity, making "this.activity" NULL, so we reinitialize it.
super.onResume(); super.onResume();
createSettingsSection();
boolean isTT9On = SystemSettings.isTT9Enabled(activity);
createSettingsSection(isTT9On);
createAboutSection(isTT9On);
resetFontSize(false); resetFontSize(false);
} }
private void createAboutSection() { private void createAboutSection(boolean isTT9On) {
(new ItemDonate(findPreference(ItemDonate.NAME), activity)).populate().enableClickHandler(); (new ItemDonate(findPreference(ItemDonate.NAME), activity, isTT9On)).populate().enableClickHandler();
(new ItemVersionInfo(findPreference(ItemVersionInfo.NAME), activity)).populate().enableClickHandler(); (new ItemVersionInfo(findPreference(ItemVersionInfo.NAME), activity)).populate().enableClickHandler();
} }
@ -57,9 +61,7 @@ public class MainSettingsScreen extends BaseScreenFragment {
} }
private void createSettingsSection() { private void createSettingsSection(boolean isTT9On) {
boolean isTT9On = SystemSettings.isTT9Enabled(activity);
Preference gotoSetup = findPreference("screen_setup"); Preference gotoSetup = findPreference("screen_setup");
if (gotoSetup != null) { if (gotoSetup != null) {
gotoSetup.setSummary(isTT9On ? "" : activity.getString(R.string.setup_click_here_to_enable)); gotoSetup.setSummary(isTT9On ? "" : activity.getString(R.string.setup_click_here_to_enable));

View file

@ -38,7 +38,8 @@
<Preference <Preference
app:key="donate_link" app:key="donate_link"
app:title="@string/donate_title" /> app:title="@string/donate_title"
app:isPreferenceVisible="false" />
<Preference <Preference
app:key="version_info" app:key="version_info"