summaryrefslogtreecommitdiffstats
path: root/java/src/com
diff options
context:
space:
mode:
authorKurt Partridge <kep@google.com>2012-07-22 19:31:39 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-22 19:31:40 -0700
commita4f762ff98a5024cf265b6f45880eed29b10dcbd (patch)
treef959989dc49c2d37fc97269afa224ff5159e0028 /java/src/com
parent74c95d6d18331e80e35f0417c5204a0a050b3890 (diff)
parent4fa6e5726041a22db4f15d99521ea06419401946 (diff)
downloadandroid_packages_inputmethods_LatinIME-a4f762ff98a5024cf265b6f45880eed29b10dcbd.tar.gz
android_packages_inputmethods_LatinIME-a4f762ff98a5024cf265b6f45880eed29b10dcbd.tar.bz2
android_packages_inputmethods_LatinIME-a4f762ff98a5024cf265b6f45880eed29b10dcbd.zip
Merge "ResearchLogging indicator"
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java9
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java51
2 files changed, 55 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 6d9f0139c..f751fa53c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -43,6 +43,8 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.StringUtils;
+import com.android.inputmethod.latin.define.ProductionFlag;
+import com.android.inputmethod.research.ResearchLogger;
import java.util.HashSet;
@@ -518,6 +520,13 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
+ // ResearchLogging indicator.
+ // TODO: Reimplement using a keyboard background image specific to the ResearchLogger,
+ // and remove this call.
+ if (ProductionFlag.IS_EXPERIMENTAL) {
+ ResearchLogger.getInstance().paintIndicator(this, paint, canvas, width, height);
+ }
+
mInvalidatedKeys.clear();
mInvalidatedKeysRect.setEmpty();
mInvalidateAllKeys = false;
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index a4234a940..d097ea436 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -28,6 +28,10 @@ import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.inputmethodservice.InputMethodService;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Style;
import android.os.Build;
import android.os.IBinder;
import android.text.TextUtils;
@@ -48,6 +52,7 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
+import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.LatinIME;
@@ -87,7 +92,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final String FILENAME_SUFFIX = ".txt";
private static final SimpleDateFormat TIMESTAMP_DATEFORMAT =
new SimpleDateFormat("yyyyMMddHHmmssS", Locale.US);
- private static final boolean IS_SHOWING_INDICATOR = false;
+ private static final boolean IS_SHOWING_INDICATOR = true;
+ private static final boolean IS_SHOWING_INDICATOR_CLEARLY = false;
// constants related to specific log points
private static final String WHITESPACE_SEPARATORS = " \t\n\r";
@@ -528,11 +534,46 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
public void requestIndicatorRedraw() {
- // invalidate any existing graphics
- if (IS_SHOWING_INDICATOR) {
- if (mKeyboardSwitcher != null) {
- mKeyboardSwitcher.getKeyboardView().invalidateAllKeys();
+ if (!IS_SHOWING_INDICATOR) {
+ return;
+ }
+ if (mKeyboardSwitcher == null) {
+ return;
+ }
+ final KeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
+ if (keyboardView == null) {
+ return;
+ }
+ keyboardView.invalidateAllKeys();
+ }
+
+
+ public void paintIndicator(KeyboardView view, Paint paint, Canvas canvas, int width,
+ int height) {
+ // TODO: Reimplement using a keyboard background image specific to the ResearchLogger
+ // and remove this method.
+ // The check for LatinKeyboardView ensures that a red border is only placed around
+ // the main keyboard, not every keyboard.
+ if (IS_SHOWING_INDICATOR && isAllowedToLog() && view instanceof LatinKeyboardView) {
+ final int savedColor = paint.getColor();
+ paint.setColor(Color.RED);
+ final Style savedStyle = paint.getStyle();
+ paint.setStyle(Style.STROKE);
+ final float savedStrokeWidth = paint.getStrokeWidth();
+ if (IS_SHOWING_INDICATOR_CLEARLY) {
+ paint.setStrokeWidth(5);
+ canvas.drawRect(0, 0, width, height, paint);
+ } else {
+ // Put a tiny red dot on the screen so a knowledgeable user can check whether
+ // it is enabled. The dot is actually a zero-width, zero-height rectangle,
+ // placed at the lower-right corner of the canvas, painted with a non-zero border
+ // width.
+ paint.setStrokeWidth(3);
+ canvas.drawRect(width, height, width, height, paint);
}
+ paint.setColor(savedColor);
+ paint.setStyle(savedStyle);
+ paint.setStrokeWidth(savedStrokeWidth);
}
}