added Demo Mode for enabling all preferences when TT9 is disabled
This commit is contained in:
parent
e0839bc923
commit
5e1d2b64db
12 changed files with 98 additions and 28 deletions
|
|
@ -9,10 +9,6 @@ import android.view.KeyEvent;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.github.sspanak.tt9.db.exporter.LogcatExporter;
|
||||
|
||||
public class DeviceInfo {
|
||||
private static Boolean isRobo = null;
|
||||
|
||||
|
|
@ -39,17 +35,6 @@ public class DeviceInfo {
|
|||
return Build.MANUFACTURER.equals("DuoQin") && Build.MODEL.contains("F21");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isRobo() {
|
||||
if (isRobo == null) {
|
||||
Pattern roboLog = Pattern.compile("\\d+\\s+\\d+\\s+\\|\\s+Robo\\W");
|
||||
isRobo = roboLog.matcher(LogcatExporter.getLogs(false)).find();
|
||||
}
|
||||
|
||||
return isRobo;
|
||||
}
|
||||
|
||||
public static boolean isSonim() {
|
||||
return Build.MANUFACTURER.equals("Sonimtech");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ public class TraditionalT9 extends MainViewHandler {
|
|||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
settings.setDemoMode(false);
|
||||
Logger.setLevel(settings.getLogLevel());
|
||||
WordStoreAsync.init(this);
|
||||
super.onInit();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import io.github.sspanak.tt9.db.WordStoreAsync;
|
|||
import io.github.sspanak.tt9.ime.helpers.InputModeValidator;
|
||||
import io.github.sspanak.tt9.preferences.helpers.Hotkeys;
|
||||
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
|
||||
import io.github.sspanak.tt9.preferences.screens.MainSettingsScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.UsageStatsScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.appearance.AppearanceScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.debug.DebugScreen;
|
||||
|
|
@ -27,6 +26,7 @@ import io.github.sspanak.tt9.preferences.screens.deleteWords.DeleteWordsScreen;
|
|||
import io.github.sspanak.tt9.preferences.screens.hotkeys.HotkeysScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.keypad.KeyPadScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.languages.LanguagesScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.main.MainSettingsScreen;
|
||||
import io.github.sspanak.tt9.preferences.screens.setup.SetupScreen;
|
||||
import io.github.sspanak.tt9.ui.ActivityWithNavigation;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
|
|
@ -171,6 +171,11 @@ public class PreferencesActivity extends ActivityWithNavigation implements Prefe
|
|||
}
|
||||
|
||||
|
||||
public void displayScreen(@NonNull String screenName) {
|
||||
displayScreen(getScreen(screenName), true);
|
||||
}
|
||||
|
||||
|
||||
private void buildLayout() {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class DebugScreen extends BaseScreenFragment {
|
|||
(new ItemInputHandlingMode(findPreference(ItemInputHandlingMode.NAME), activity.getSettings())).populate().preview().enableClickHandler();
|
||||
(new ItemText(activity, findPreference(DEVICE_INFO_CONTAINER))).populate(new DeviceInfo().toString()).enableClickHandler();
|
||||
(new ItemExportLogcat(findPreference(ItemExportLogcat.NAME), activity)).enableClickHandler();
|
||||
(new ItemDemoMode(findPreference(ItemDemoMode.NAME), activity)).populate().enableClickHandler();
|
||||
initSystemLogsSwitch();
|
||||
|
||||
SwitchPreferenceCompat systemLogs = findPreference(SYSTEM_LOGS_SWITCH);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package io.github.sspanak.tt9.preferences.screens.debug;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemClickable;
|
||||
|
||||
class ItemDemoMode extends ItemClickable {
|
||||
public static final String NAME = "pref_demo_mode";
|
||||
|
||||
private final PreferencesActivity activity;
|
||||
|
||||
ItemDemoMode(Preference item, PreferencesActivity activity) {
|
||||
super(item);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onClick(Preference p) {
|
||||
activity.getSettings().setDemoMode(((SwitchPreferenceCompat) p).isChecked());
|
||||
activity.onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemDemoMode populate() {
|
||||
if (item != null) {
|
||||
((SwitchPreferenceCompat) item).setChecked(activity.getSettings().getDemoMode());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package io.github.sspanak.tt9.preferences.screens.main;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import io.github.sspanak.tt9.BuildConfig;
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemClickable;
|
||||
import io.github.sspanak.tt9.preferences.screens.debug.DebugScreen;
|
||||
|
||||
class ItemVersionInfo extends ItemClickable {
|
||||
static final String NAME = "version_info";
|
||||
|
||||
private final PreferencesActivity activity;
|
||||
|
||||
ItemVersionInfo(Preference item, PreferencesActivity activity) {
|
||||
super(item);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onClick(Preference p) {
|
||||
if (!activity.getSettings().getDemoMode()) {
|
||||
activity.displayScreen(DebugScreen.NAME);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemVersionInfo populate() {
|
||||
if (item != null) {
|
||||
item.setSummary(BuildConfig.VERSION_FULL);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.sspanak.tt9.preferences.screens;
|
||||
package io.github.sspanak.tt9.preferences.screens.main;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
|
@ -11,8 +11,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
import io.github.sspanak.tt9.BuildConfig;
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.hacks.DeviceInfo;
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
import io.github.sspanak.tt9.util.SystemSettings;
|
||||
|
||||
|
|
@ -71,17 +71,15 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
|
||||
|
||||
private void createAboutSection() {
|
||||
Preference vi = findPreference("version_info");
|
||||
if (vi != null) {
|
||||
vi.setSummary(BuildConfig.VERSION_FULL);
|
||||
}
|
||||
|
||||
Preference donate = findPreference("donate_link");
|
||||
if (donate != null) {
|
||||
String appName = getString(R.string.app_name_short);
|
||||
String url = getString(R.string.donate_url_short);
|
||||
donate.setSummary(getString(R.string.donate_summary, appName, url));
|
||||
}
|
||||
|
||||
ItemVersionInfo debugOptions = new ItemVersionInfo(findPreference(ItemVersionInfo.NAME), activity);
|
||||
debugOptions.populate().enableClickHandler();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -101,7 +99,7 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
|
||||
for (Preference goToScreen : screens) {
|
||||
if (goToScreen != null) {
|
||||
goToScreen.setEnabled(isTT9On || DeviceInfo.isRobo());
|
||||
goToScreen.setEnabled(isTT9On || activity.getSettings().getDemoMode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package io.github.sspanak.tt9.preferences.screens.setup;
|
|||
import androidx.preference.Preference;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.hacks.DeviceInfo;
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
|
||||
import io.github.sspanak.tt9.util.SystemSettings;
|
||||
|
|
@ -21,7 +20,7 @@ public class SetupScreen extends BaseScreenFragment {
|
|||
public void onCreate() {
|
||||
boolean isTT9On = SystemSettings.isTT9Enabled(activity);
|
||||
createKeyboardSection(isTT9On);
|
||||
createHacksSection(isTT9On | DeviceInfo.isRobo());
|
||||
createHacksSection(isTT9On | activity.getSettings().getDemoMode());
|
||||
resetFontSize(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,20 @@ import io.github.sspanak.tt9.preferences.screens.debug.ItemInputHandlingMode;
|
|||
import io.github.sspanak.tt9.util.Logger;
|
||||
|
||||
class SettingsHacks extends BaseSettings {
|
||||
private boolean demoMode = false;
|
||||
|
||||
SettingsHacks(Context context) { super(context); }
|
||||
|
||||
/************* debugging settings *************/
|
||||
|
||||
public boolean getDemoMode() {
|
||||
return demoMode;
|
||||
}
|
||||
|
||||
public void setDemoMode(boolean demoMode) {
|
||||
this.demoMode = demoMode;
|
||||
}
|
||||
|
||||
public int getLogLevel() {
|
||||
return getStringifiedInt("pref_log_level", Logger.LEVEL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
android:id="@+id/preferences_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:context=".preferences.screens.MainSettingsScreen"
|
||||
tools:context=".preferences.screens.main.MainSettingsScreen"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@
|
|||
</Preference>
|
||||
|
||||
<Preference
|
||||
app:fragment="io.github.sspanak.tt9.preferences.DebugScreen"
|
||||
app:key="version_info"
|
||||
app:title="@string/app_name" />
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
app:key="pref_input_handling_mode"
|
||||
app:title="Keypad Handling Mode" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="pref_demo_mode"
|
||||
app:title="Demo Mode" />
|
||||
|
||||
<Preference
|
||||
app:fragment="io.github.sspanak.tt9.preferences.UsageStatsScreen"
|
||||
app:key="pref_slow_queries"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue