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 {
static final String NAME = "donate_link";
private final PreferencesActivity activity;
private final boolean isVisible;
ItemDonate(Preference preference, PreferencesActivity activity) {
ItemDonate(Preference preference, PreferencesActivity activity, boolean isTT9On) {
super(preference);
this.activity = activity;
this.isVisible = false;
}
public ItemDonate populate() {
if (item != null) {
if (item == null) {
return this;
}
if (isVisible) {
String appName = activity.getString(R.string.app_name_short);
String url = activity.getString(R.string.donate_url_short);
item.setSummary(activity.getString(R.string.donate_summary, appName, url));
}
item.setVisible(isVisible);
return this;
}

View file

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

View file

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