new debugging tools
* added a device make and model section on the Debug screen * input field details at startup are now logged at 'info' instead of 'debug' level
This commit is contained in:
parent
4d69eb750d
commit
3cb495ea22
6 changed files with 90 additions and 74 deletions
|
|
@ -74,7 +74,7 @@ abstract class KeyPadHandler extends AbstractHandler {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onStartInput(EditorInfo inputField, boolean restarting) {
|
public void onStartInput(EditorInfo inputField, boolean restarting) {
|
||||||
Logger.d(
|
Logger.i(
|
||||||
"KeyPadHandler",
|
"KeyPadHandler",
|
||||||
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " actionId: " + inputField.actionId + " imeOptions: " + inputField.imeOptions + " privateImeOptions: " + inputField.privateImeOptions + " extras: " + inputField.extras
|
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " actionId: " + inputField.actionId + " imeOptions: " + inputField.imeOptions + " privateImeOptions: " + inputField.privateImeOptions + " extras: " + inputField.extras
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package io.github.sspanak.tt9.preferences.items;
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import io.github.sspanak.tt9.R;
|
||||||
|
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||||
|
import io.github.sspanak.tt9.ui.UI;
|
||||||
|
|
||||||
|
public class ItemText extends ItemClickable {
|
||||||
|
private PreferencesActivity activity;
|
||||||
|
public ItemText(PreferencesActivity activity, Preference preference) {
|
||||||
|
super(preference);
|
||||||
|
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onClick(Preference p) {
|
||||||
|
if (activity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
String label = activity.getString(R.string.app_name_short) + " / " + item.getTitle();
|
||||||
|
clipboard.setPrimaryClip(ClipData.newPlainText(label , p.getSummary()));
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
||||||
|
UI.toast(activity, "Text copied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemText populate(String text) {
|
||||||
|
if (item != null) {
|
||||||
|
item.setSummary(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,17 @@
|
||||||
package io.github.sspanak.tt9.preferences.screens;
|
package io.github.sspanak.tt9.preferences.screens;
|
||||||
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.db.SlowQueryStats;
|
import io.github.sspanak.tt9.db.SlowQueryStats;
|
||||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||||
import io.github.sspanak.tt9.ui.UI;
|
import io.github.sspanak.tt9.preferences.items.ItemText;
|
||||||
|
|
||||||
public class UsageStatsScreen extends BaseScreenFragment {
|
public class UsageStatsScreen extends BaseScreenFragment {
|
||||||
final public static String NAME = "UsageStats";
|
final public static String NAME = "UsageStats";
|
||||||
final private static String RESET_BUTTON = "pref_slow_queries_reset_stats";
|
final private static String RESET_BUTTON = "pref_slow_queries_reset_stats";
|
||||||
final private static String SUMMARY_CONTAINER = "summary_container";
|
final private static String SUMMARY_CONTAINER = "summary_container";
|
||||||
final private static String QUERY_LIST_CONTAINER = "query_list_container";
|
private ItemText queryListContainer;
|
||||||
|
|
||||||
public UsageStatsScreen() { init(); }
|
public UsageStatsScreen() { init(); }
|
||||||
public UsageStatsScreen(PreferencesActivity activity) { init(activity); }
|
public UsageStatsScreen(PreferencesActivity activity) { init(activity); }
|
||||||
|
|
@ -29,7 +24,6 @@ public class UsageStatsScreen extends BaseScreenFragment {
|
||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
printSummary();
|
printSummary();
|
||||||
printSlowQueries();
|
printSlowQueries();
|
||||||
enableLogsCopy();
|
|
||||||
|
|
||||||
Preference resetButton = findPreference(RESET_BUTTON);
|
Preference resetButton = findPreference(RESET_BUTTON);
|
||||||
if (resetButton != null) {
|
if (resetButton != null) {
|
||||||
|
|
@ -50,27 +44,12 @@ public class UsageStatsScreen extends BaseScreenFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printSlowQueries() {
|
private void printSlowQueries() {
|
||||||
Preference queryListContainer = findPreference(QUERY_LIST_CONTAINER);
|
if (queryListContainer == null) {
|
||||||
if (queryListContainer != null) {
|
queryListContainer = new ItemText(activity, findPreference("query_list_container"));
|
||||||
String slowQueries = SlowQueryStats.getList();
|
queryListContainer.enableClickHandler();
|
||||||
queryListContainer.setSummary(slowQueries.isEmpty() ? "No slow queries." : slowQueries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void enableLogsCopy() {
|
|
||||||
Preference queryListContainer = findPreference(QUERY_LIST_CONTAINER);
|
|
||||||
if (activity == null || queryListContainer == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
String slowQueries = SlowQueryStats.getList();
|
||||||
queryListContainer.setOnPreferenceClickListener((Preference p) -> {
|
queryListContainer.populate(slowQueries.isEmpty() ? "No slow queries." : slowQueries);
|
||||||
clipboard.setPrimaryClip(ClipData.newPlainText("TT9 debug log", p.getSummary()));
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
|
||||||
UI.toast(activity, "Logs copied.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,26 @@
|
||||||
package io.github.sspanak.tt9.preferences.screens.debug;
|
package io.github.sspanak.tt9.preferences.screens.debug;
|
||||||
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.SwitchPreferenceCompat;
|
import androidx.preference.SwitchPreferenceCompat;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||||
|
import io.github.sspanak.tt9.preferences.items.ItemText;
|
||||||
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
|
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
|
||||||
import io.github.sspanak.tt9.ui.UI;
|
import io.github.sspanak.tt9.util.DeviceInfo;
|
||||||
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
|
|
||||||
public class DebugScreen extends BaseScreenFragment {
|
public class DebugScreen extends BaseScreenFragment {
|
||||||
final public static String NAME = "Debug";
|
public static final String NAME = "Debug";
|
||||||
final private static String LOG_TAG = NAME + "Screen";
|
|
||||||
final private static String SYSTEM_LOGS_SWITCH = "pref_enable_system_logs";
|
private static final String DEVICE_INFO_CONTAINER = "pref_device_info";
|
||||||
final private static String LOGS_CONTAINER = "debug_logs_container";
|
private static final String SYSTEM_LOGS_SWITCH = "pref_enable_system_logs";
|
||||||
|
|
||||||
|
|
||||||
|
private ItemText logsContainer;
|
||||||
|
|
||||||
public DebugScreen() { init(); }
|
public DebugScreen() { init(); }
|
||||||
public DebugScreen(PreferencesActivity activity) { init(activity); }
|
public DebugScreen(PreferencesActivity activity) { init(activity); }
|
||||||
|
|
@ -35,8 +33,8 @@ public class DebugScreen extends BaseScreenFragment {
|
||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
(new ItemLogLevel(findPreference(ItemLogLevel.NAME))).populate().preview().enableClickHandler();
|
(new ItemLogLevel(findPreference(ItemLogLevel.NAME))).populate().preview().enableClickHandler();
|
||||||
(new ItemInputHandlingMode(findPreference(ItemInputHandlingMode.NAME), activity.getSettings())).populate().preview().enableClickHandler();
|
(new ItemInputHandlingMode(findPreference(ItemInputHandlingMode.NAME), activity.getSettings())).populate().preview().enableClickHandler();
|
||||||
|
(new ItemText(activity, findPreference(DEVICE_INFO_CONTAINER))).populate(new DeviceInfo().toString()).enableClickHandler();
|
||||||
initSystemLogsSwitch();
|
initSystemLogsSwitch();
|
||||||
enableLogsCopy();
|
|
||||||
|
|
||||||
SwitchPreferenceCompat systemLogs = findPreference(SYSTEM_LOGS_SWITCH);
|
SwitchPreferenceCompat systemLogs = findPreference(SYSTEM_LOGS_SWITCH);
|
||||||
boolean includeSystemLogs = systemLogs != null && systemLogs.isChecked();
|
boolean includeSystemLogs = systemLogs != null && systemLogs.isChecked();
|
||||||
|
|
@ -54,12 +52,6 @@ public class DebugScreen extends BaseScreenFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printLogs(boolean includeSystemLogs) {
|
private void printLogs(boolean includeSystemLogs) {
|
||||||
Preference logsContainer = findPreference(LOGS_CONTAINER);
|
|
||||||
if (logsContainer == null) {
|
|
||||||
Logger.w(LOG_TAG, "Logs container not found. Cannot print logs");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
Process process = Runtime.getRuntime().exec("logcat -d -v threadtime io.github.sspanak.tt9:D");
|
Process process = Runtime.getRuntime().exec("logcat -d -v threadtime io.github.sspanak.tt9:D");
|
||||||
|
|
@ -80,28 +72,10 @@ public class DebugScreen extends BaseScreenFragment {
|
||||||
log.append("No Logs");
|
log.append("No Logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
logsContainer.setSummary(log.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableLogsCopy() {
|
|
||||||
if (activity == null) {
|
|
||||||
Logger.w(LOG_TAG, "Activity is missing. Copying the logs will not be possible.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Preference logsContainer = findPreference(LOGS_CONTAINER);
|
|
||||||
if (logsContainer == null) {
|
if (logsContainer == null) {
|
||||||
Logger.w(LOG_TAG, "Logs container not found. Copying the logs will not be possible.");
|
logsContainer = new ItemText(activity, findPreference("debug_logs_container"));
|
||||||
return;
|
logsContainer.enableClickHandler();
|
||||||
}
|
}
|
||||||
|
logsContainer.populate(log.toString());
|
||||||
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
logsContainer.setOnPreferenceClickListener((Preference p) -> {
|
|
||||||
clipboard.setPrimaryClip(ClipData.newPlainText("TT9 debug log", p.getSummary()));
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
|
||||||
UI.toast(activity, "Logs copied.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,17 @@
|
||||||
package io.github.sspanak.tt9.util;
|
package io.github.sspanak.tt9.util;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
public class DeviceInfo {
|
public class DeviceInfo {
|
||||||
public static boolean isQinF21() {
|
public static boolean isQinF21() {
|
||||||
return android.os.Build.MANUFACTURER.equals("DuoQin") && android.os.Build.MODEL.contains("F21");
|
return Build.MANUFACTURER.equals("DuoQin") && Build.MODEL.contains("F21");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "\"" + Build.MANUFACTURER + "\" " + "\"" + Build.MODEL + "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto" app:orderingFromXml="true">
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto" app:orderingFromXml="true">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<Preference
|
||||||
app:fragment="io.github.sspanak.tt9.preferences.UsageStatsScreen"
|
app:key="pref_device_info"
|
||||||
app:key="pref_slow_queries"
|
|
||||||
app:layout="@layout/pref_text"
|
app:layout="@layout/pref_text"
|
||||||
app:title="@string/pref_category_usage_stats" />
|
app:title="Device Info" />
|
||||||
|
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
|
|
@ -13,6 +12,12 @@
|
||||||
app:layout="@layout/pref_dropdown"
|
app:layout="@layout/pref_dropdown"
|
||||||
app:title="Keypad Handling Mode" />
|
app:title="Keypad Handling Mode" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:fragment="io.github.sspanak.tt9.preferences.UsageStatsScreen"
|
||||||
|
app:key="pref_slow_queries"
|
||||||
|
app:layout="@layout/pref_text"
|
||||||
|
app:title="@string/pref_category_usage_stats" />
|
||||||
|
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="pref_log_level"
|
app:key="pref_log_level"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue