greedy google patch (#717)
This commit is contained in:
parent
ada5261773
commit
4b8ccdd2b1
3 changed files with 22 additions and 11 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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));
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue