Hide debug mode
- Tap feedback option 10 times, then debug mode will be enabled. - Change default value of KeyboardMode to avoid NPE - Update version code Change-Id: I3a4e64db0d3aa9a08f0e3b3ad1669e728e32cddfmain
parent
518643a2c5
commit
8edbaf0433
|
@ -1,7 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.inputmethod.latin"
|
||||
android:versionCode="9"
|
||||
android:versionName="0.14">
|
||||
android:versionName="0.15">
|
||||
|
||||
<uses-sdk android:minSdkVersion="8"></uses-sdk>
|
||||
|
||||
|
|
|
@ -107,5 +107,4 @@
|
|||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -74,7 +74,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
private KeyboardId mCurrentId;
|
||||
private Map<KeyboardId, LatinKeyboard> mKeyboards;
|
||||
|
||||
private int mMode; /** One of the MODE_XXX values */
|
||||
private int mMode = MODE_TEXT; /** One of the MODE_XXX values */
|
||||
private int mImeOptions;
|
||||
private int mTextMode = MODE_TEXT_QWERTY;
|
||||
private boolean mIsSymbols;
|
||||
|
|
|
@ -24,13 +24,13 @@ import android.app.Dialog;
|
|||
import android.app.backup.BackupManager;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.speech.SpeechRecognizer;
|
||||
import android.text.AutoText;
|
||||
import android.util.Log;
|
||||
|
@ -43,11 +43,9 @@ public class LatinIMESettings extends PreferenceActivity
|
|||
DialogInterface.OnDismissListener {
|
||||
|
||||
private static final String QUICK_FIXES_KEY = "quick_fixes";
|
||||
private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
|
||||
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
||||
private static final String VOICE_SETTINGS_KEY = "voice_mode";
|
||||
private static final String VOICE_ON_PRIMARY_KEY = "voice_on_main";
|
||||
private static final String VOICE_SERVER_KEY = "voice_server_url";
|
||||
private static final String DEBUG_MODE_KEY = "debug_mode";
|
||||
|
||||
private static final String TAG = "LatinIMESettings";
|
||||
|
||||
|
@ -55,7 +53,7 @@ public class LatinIMESettings extends PreferenceActivity
|
|||
private static final int VOICE_INPUT_CONFIRM_DIALOG = 0;
|
||||
|
||||
private CheckBoxPreference mQuickFixes;
|
||||
private CheckBoxPreference mShowSuggestions;
|
||||
private CheckBoxPreference mDebugMode;
|
||||
private ListPreference mVoicePreference;
|
||||
private boolean mVoiceOn;
|
||||
|
||||
|
@ -69,7 +67,6 @@ public class LatinIMESettings extends PreferenceActivity
|
|||
super.onCreate(icicle);
|
||||
addPreferencesFromResource(R.xml.prefs);
|
||||
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
|
||||
mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
|
||||
mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY);
|
||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
@ -77,6 +74,9 @@ public class LatinIMESettings extends PreferenceActivity
|
|||
mVoiceModeOff = getString(R.string.voice_mode_off);
|
||||
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
||||
mLogger = VoiceInputLogger.getLogger(this);
|
||||
|
||||
mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY);
|
||||
updateDebugMode(mDebugMode.isChecked());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,11 +110,35 @@ public class LatinIMESettings extends PreferenceActivity
|
|||
.equals(mVoiceModeOff)) {
|
||||
showVoiceConfirmation();
|
||||
}
|
||||
} else if (key.equals(DEBUG_MODE_KEY)) {
|
||||
updateDebugMode(prefs.getBoolean(DEBUG_MODE_KEY, false));
|
||||
}
|
||||
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
||||
updateVoiceModeSummary();
|
||||
}
|
||||
|
||||
private void updateDebugMode(boolean isDebugMode) {
|
||||
if (mDebugMode == null) {
|
||||
return;
|
||||
}
|
||||
String version = "";
|
||||
try {
|
||||
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
version = "Version " + info.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "Could not find version info.");
|
||||
}
|
||||
if (!isDebugMode) {
|
||||
mDebugMode.setEnabled(false);
|
||||
mDebugMode.setTitle(version);
|
||||
mDebugMode.setSummary("");
|
||||
} else {
|
||||
mDebugMode.setEnabled(true);
|
||||
mDebugMode.setTitle(getResources().getString(R.string.prefs_debug_mode));
|
||||
mDebugMode.setSummary(version);
|
||||
}
|
||||
}
|
||||
|
||||
private void showVoiceConfirmation() {
|
||||
mOkClicked = false;
|
||||
showDialog(VOICE_INPUT_CONFIRM_DIALOG);
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
|
||||
public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = "LatinIMELogs";
|
||||
private static final boolean DBG = true;
|
||||
private static boolean sDBG = false;
|
||||
private static boolean sLOGPRINT = false;
|
||||
// SUPPRESS_EXCEPTION should be true when released to public.
|
||||
private static final boolean SUPPRESS_EXCEPTION = true;
|
||||
|
@ -77,6 +77,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
/* package */ static String sLastAutoSuggestAfter;
|
||||
/* package */ static String sLastAutoSuggestSeparator;
|
||||
private static HashMap<String, Integer> sSuggestDicMap = new HashMap<String, Integer>();
|
||||
private static DebugKeyEnabler sDebugKeyEnabler = new DebugKeyEnabler();
|
||||
|
||||
private ArrayList<LogEntry> mLogBuffer = null;
|
||||
private ArrayList<LogEntry> mPrivacyLogBuffer = null;
|
||||
|
@ -142,6 +143,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mThemeId = prefs.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
|
||||
KeyboardSwitcher.DEFAULT_LAYOUT_ID);
|
||||
sLOGPRINT = prefs.getBoolean(PREF_DEBUG_MODE, sLOGPRINT);
|
||||
sDBG = sLOGPRINT;
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
@ -165,7 +167,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
* Check if the input string is safe as an entry or not.
|
||||
*/
|
||||
private static boolean checkStringDataSafe(String s) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.d(TAG, "Check String safety: " + s);
|
||||
}
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
|
@ -295,7 +297,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
++mWordCount;
|
||||
String[] dataStrings = (String[]) data;
|
||||
if (dataStrings.length < 2) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "The length of logged string array is invalid.");
|
||||
}
|
||||
break;
|
||||
|
@ -305,7 +307,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mPrivacyLogBuffer.add(
|
||||
new LogEntry (System.currentTimeMillis(), tag, dataStrings));
|
||||
} else {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.d(TAG, "Skipped to add an entry because data is unsafe.");
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +316,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
--mWordCount;
|
||||
dataStrings = (String[]) data;
|
||||
if (dataStrings.length < 2) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "The length of logged string array is invalid.");
|
||||
}
|
||||
break;
|
||||
|
@ -324,7 +326,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mPrivacyLogBuffer.add(
|
||||
new LogEntry (System.currentTimeMillis(), tag, dataStrings));
|
||||
} else {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.d(TAG, "Skipped to add an entry because data is unsafe.");
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +334,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
case ID_EXCEPTION:
|
||||
dataStrings = (String[]) data;
|
||||
if (dataStrings.length < 2) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "The length of logged string array is invalid.");
|
||||
}
|
||||
break;
|
||||
|
@ -340,7 +342,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
addExceptionEntry(System.currentTimeMillis(), dataStrings);
|
||||
break;
|
||||
default:
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "Log Tag is not entried.");
|
||||
}
|
||||
break;
|
||||
|
@ -370,7 +372,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
private void commitInternalAndStopSelf() {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "Exception was thrown and let's die.");
|
||||
}
|
||||
commitInternal();
|
||||
|
@ -381,7 +383,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
|
||||
private synchronized void sendLogToDropBox(int tag, Object s) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
String out = "";
|
||||
if (s instanceof String[]) {
|
||||
for (String str: ((String[]) s)) {
|
||||
|
@ -414,12 +416,16 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
} else {
|
||||
sLogEnabled = false;
|
||||
}
|
||||
if (sDebugKeyEnabler.check()) {
|
||||
sharedPreferences.edit().putBoolean(PREF_DEBUG_MODE, true).commit();
|
||||
}
|
||||
} else if (KeyboardSwitcher.PREF_KEYBOARD_LAYOUT.equals(key)) {
|
||||
mThemeId = sharedPreferences.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
|
||||
KeyboardSwitcher.DEFAULT_LAYOUT_ID);
|
||||
addThemeIdEntry(mLastTimeActive);
|
||||
} else if (PREF_DEBUG_MODE.equals(key)) {
|
||||
sLOGPRINT = sharedPreferences.getBoolean(PREF_DEBUG_MODE, sLOGPRINT);
|
||||
sDBG = sLOGPRINT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,14 +452,14 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION, new String[] {
|
||||
before, after, String.valueOf(position), ""});
|
||||
} else if (!sSuggestDicMap.containsKey(after)) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "logOnManualSuggestion was cancelled: came from unknown source.");
|
||||
}
|
||||
} else {
|
||||
int dicTypeId = sSuggestDicMap.get(after);
|
||||
sLatinImeLogger.mManualSuggestCountPerDic[dicTypeId]++;
|
||||
if (dicTypeId != Suggest.DIC_MAIN) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.d(TAG, "logOnManualSuggestion was cancelled: didn't come from main dic.");
|
||||
}
|
||||
} else {
|
||||
|
@ -479,7 +485,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static void logOnAutoSuggestion(String before, String after) {
|
||||
if (sLogEnabled) {
|
||||
if (!sSuggestDicMap.containsKey(after)) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "logOnAutoSuggestion was cancelled: came from unknown source.");
|
||||
}
|
||||
return;
|
||||
|
@ -488,7 +494,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
sLatinImeLogger.mAutoSuggestCountPerDic[dicId]++;
|
||||
sSuggestDicMap.clear();
|
||||
if (dicId != Suggest.DIC_MAIN) {
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.d(TAG, "logOnAutoSuggestion was cancelled: didn't come from main dic.");
|
||||
}
|
||||
return;
|
||||
|
@ -552,7 +558,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
Math.min(EXCEPTION_MAX_LENGTH, baos.size()));
|
||||
sLatinImeLogger.sendLogToDropBox(
|
||||
ID_EXCEPTION, new String[] {metaData, exceptionString});
|
||||
if (DBG) {
|
||||
if (sDBG) {
|
||||
Log.e(TAG, "Exception: " + new String(baos.toByteArray()));
|
||||
}
|
||||
if (SUPPRESS_EXCEPTION) {
|
||||
|
@ -659,4 +665,18 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static class DebugKeyEnabler {
|
||||
private int mCounter = 0;
|
||||
private long mLastTime = 0;
|
||||
public boolean check() {
|
||||
if (System.currentTimeMillis() - mLastTime > 10 * 1000) {
|
||||
mCounter = 0;
|
||||
mLastTime = System.currentTimeMillis();
|
||||
} else if (++mCounter >= 10) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue