ResearchLogger clean up splash screen

- simpler text
- AlertDialog implementation
- declining users are redirected to regular IME

Bug: 6188932
Change-Id: Ifb983c3511125f8919f4a8b25aeee7de66dbb0cb
main
Kurt Partridge 2012-07-26 15:27:57 -07:00
parent 58eb4d9f27
commit 25405eafb0
4 changed files with 63 additions and 129 deletions

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/research_splash_screen_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.android.internal.widget.DialogTitle
style="?android:attr/windowTitleStyle"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="64dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip"
android:gravity="center_vertical|left"
android:text="@string/research_splash_title" />
<View android:layout_width="match_parent"
android:layout_height="2dip"
android:background="@android:color/holo_blue_light" />
</LinearLayout>
<TextView
android:text="@string/research_splash_content"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:layout_gravity="fill_horizontal|center_vertical"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip"
android:layout_marginBottom="16dip"
android:layout_marginTop="16dip"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="beginning"
android:dividerPadding="0dip">
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:measureWithLargestChild="true">
<Button
android:layout_width="0dip"
android:layout_gravity="left"
android:layout_weight="1"
android:maxLines="2"
stype="?android:attr/buttonBarButtonStyle"
android:textSize="14sp"
android:text="@string/research_dont_send_usage_info"
android:layout_height="wrap_content"
android:id="@+id/research_do_not_log_button" />
<Button
android:layout_width="0dip"
android:layout_gravity="right"
android:layout_weight="1"
android:maxLines="2"
style="?android:attr/buttonBarButtonStyle"
android:textSize="14sp"
android:text="@string/research_send_usage_info"
android:layout_height="wrap_content"
android:id="@+id/research_do_log_button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Contents of note explaining what data is collected and how. -->
<!-- TODO: remove translatable=false attribute once text is stable -->
<string name="research_splash_content" translatable="false"></string>
</resources>

View File

@ -278,16 +278,11 @@
<!-- Title of dialog shown at start informing users about contributing research usage data-->
<!-- TODO: remove translatable=false attribute once text is stable -->
<string name="research_splash_title" translatable="false">Usage Participation</string>
<!-- Contents of note explaining what data is collected and how. -->
<string name="research_splash_title" translatable="false">Warning</string>
<!-- Toast message informing users that logging has been disabled -->
<!-- TODO: remove translatable=false attribute once text is stable -->
<string name="research_splash_content" translatable="false">Thank you for dogfooding this keyboard.\n\nIf you like it, please help us make it better by sending us usage information. When enabled, the keyboard uploads general statistics, such as how fast you type, and also occasional samples of how you type words.\n\nNo passwords or non-dictionary words are ever automatically uploaded, and words are sampled infrequently enough so that reconstructing the meaning of what you typed is highly unlikely.\n\nYou can disable and reenable logging through the RLog menu by long-pressing on the microphone or settings key.\n</string>
<!-- Button label text for opting out of research usage data collection [CHAR LIMIT=50] -->
<!-- TODO: remove translatable=false attribute once text is stable -->
<string name="research_dont_send_usage_info" translatable="false">Do not send\nusage info</string>
<!-- Button label text for opting into research usage data collection [CHAR LIMIT=50] -->
<!-- TODO: remove translatable=false attribute once text is stable -->
<string name="research_send_usage_info" translatable="false">Send usage info</string>
<string name="research_logging_disabled" translatable="false">Logging Disabled</string>
<!-- Name for the research uploading service to be displayed to users. [CHAR LIMIT=50] -->
<!-- TODO: remove translatable=false attribute once text is stable -->

View File

@ -35,6 +35,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.os.SystemClock;
@ -43,15 +44,12 @@ import android.text.format.DateUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.Button;
import android.widget.Toast;
import com.android.inputmethod.keyboard.Key;
@ -251,44 +249,49 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
if (windowToken == null) {
return;
}
mSplashDialog = new Dialog(mInputMethodService, android.R.style.Theme_Holo_Dialog);
mSplashDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSplashDialog.setContentView(R.layout.research_splash);
mSplashDialog.setCancelable(true);
final AlertDialog.Builder builder = new AlertDialog.Builder(mInputMethodService)
.setTitle(R.string.research_splash_title)
.setMessage(R.string.research_splash_content)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onUserLoggingConsent();
mSplashDialog.dismiss();
}
})
.setNegativeButton(android.R.string.no,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String packageName = mInputMethodService.getPackageName();
final Uri packageUri = Uri.parse("package:" + packageName);
final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE,
packageUri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mInputMethodService.startActivity(intent);
}
})
.setCancelable(true)
.setOnCancelListener(
new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mInputMethodService.requestHideSelf(0);
}
});
mSplashDialog = builder.create();
final Window w = mSplashDialog.getWindow();
final WindowManager.LayoutParams lp = w.getAttributes();
lp.token = windowToken;
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
w.setAttributes(lp);
w.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
mSplashDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mInputMethodService.requestHideSelf(0);
}
});
final Button doNotLogButton = (Button) mSplashDialog.findViewById(
R.id.research_do_not_log_button);
doNotLogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onUserLoggingElection(false);
mSplashDialog.dismiss();
}
});
final Button doLogButton = (Button) mSplashDialog.findViewById(R.id.research_do_log_button);
doLogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onUserLoggingElection(true);
mSplashDialog.dismiss();
}
});
mSplashDialog.show();
}
public void onUserLoggingElection(final boolean enableLogging) {
setLoggingAllowed(enableLogging);
public void onUserLoggingConsent() {
setLoggingAllowed(true);
if (mPrefs == null) {
return;
}