Merge "[Rlog36z] Pass LatinIME instance to logger as LatinIME class"

main
Kurt Partridge 2012-12-23 10:37:30 -08:00 committed by Android (Google) Code Review
commit 5e9a5ca998
1 changed files with 16 additions and 17 deletions

View File

@ -34,7 +34,6 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.inputmethodservice.InputMethodService;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
@ -141,7 +140,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
// used to check whether words are not unique // used to check whether words are not unique
private Suggest mSuggest; private Suggest mSuggest;
private MainKeyboardView mMainKeyboardView; private MainKeyboardView mMainKeyboardView;
private InputMethodService mInputMethodService; private LatinIME mLatinIME;
private final Statistics mStatistics; private final Statistics mStatistics;
private Intent mUploadIntent; private Intent mUploadIntent;
@ -156,12 +155,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
return sInstance; return sInstance;
} }
public void init(final InputMethodService ims, final SharedPreferences prefs) { public void init(final LatinIME latinIME, final SharedPreferences prefs) {
assert ims != null; assert latinIME != null;
if (ims == null) { if (latinIME == null) {
Log.w(TAG, "IMS is null; logging is off"); Log.w(TAG, "IMS is null; logging is off");
} else { } else {
mFilesDir = ims.getFilesDir(); mFilesDir = latinIME.getFilesDir();
if (mFilesDir == null || !mFilesDir.exists()) { if (mFilesDir == null || !mFilesDir.exists()) {
Log.w(TAG, "IME storage directory does not exist."); Log.w(TAG, "IME storage directory does not exist.");
} }
@ -186,12 +185,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
e.apply(); e.apply();
} }
} }
mInputMethodService = ims; mLatinIME = latinIME;
mPrefs = prefs; mPrefs = prefs;
mUploadIntent = new Intent(mInputMethodService, UploaderService.class); mUploadIntent = new Intent(mLatinIME, UploaderService.class);
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {
scheduleUploadingService(mInputMethodService); scheduleUploadingService(mLatinIME);
} }
} }
@ -250,7 +249,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
if (windowToken == null) { if (windowToken == null) {
return; return;
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(mInputMethodService) final AlertDialog.Builder builder = new AlertDialog.Builder(mLatinIME)
.setTitle(R.string.research_splash_title) .setTitle(R.string.research_splash_title)
.setMessage(R.string.research_splash_content) .setMessage(R.string.research_splash_content)
.setPositiveButton(android.R.string.yes, .setPositiveButton(android.R.string.yes,
@ -265,12 +264,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
final String packageName = mInputMethodService.getPackageName(); final String packageName = mLatinIME.getPackageName();
final Uri packageUri = Uri.parse("package:" + packageName); final Uri packageUri = Uri.parse("package:" + packageName);
final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE,
packageUri); packageUri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mInputMethodService.startActivity(intent); mLatinIME.startActivity(intent);
} }
}) })
.setCancelable(true) .setCancelable(true)
@ -278,7 +277,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
new OnCancelListener() { new OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
mInputMethodService.requestHideSelf(0); mLatinIME.requestHideSelf(0);
} }
}); });
mSplashDialog = builder.create(); mSplashDialog = builder.create();
@ -322,10 +321,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
} }
private void checkForEmptyEditor() { private void checkForEmptyEditor() {
if (mInputMethodService == null) { if (mLatinIME == null) {
return; return;
} }
final InputConnection ic = mInputMethodService.getCurrentInputConnection(); final InputConnection ic = mLatinIME.getCurrentInputConnection();
if (ic == null) { if (ic == null) {
return; return;
} }
@ -585,7 +584,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "calling uploadNow()"); Log.d(TAG, "calling uploadNow()");
} }
mInputMethodService.startService(mUploadIntent); mLatinIME.startService(mUploadIntent);
} }
public void onLeavingSendFeedbackDialog() { public void onLeavingSendFeedbackDialog() {
@ -834,7 +833,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|| InputTypeUtils.isVisiblePasswordInputType(editorInfo.inputType); || InputTypeUtils.isVisiblePasswordInputType(editorInfo.inputType);
getInstance().setIsPasswordView(isPassword); getInstance().setIsPasswordView(isPassword);
researchLogger.start(); researchLogger.start();
final Context context = researchLogger.mInputMethodService; final Context context = researchLogger.mLatinIME;
try { try {
final PackageInfo packageInfo; final PackageInfo packageInfo;
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),