diff options
author | Dianne Hackborn <hackbod@google.com> | 2015-07-17 18:04:14 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2015-07-20 12:49:10 -0700 |
commit | 17f693520da8977c4a60f5b4be3be035cba7146c (patch) | |
tree | 6e3fcf5d6adb3d72ab5b7c2300f3bb8ebe8bc550 /tests/VoiceInteraction | |
parent | 5aff3b5489262ccff4b6f9e18e0d990ebfe4d7bc (diff) | |
download | frameworks_base-17f693520da8977c4a60f5b4be3be035cba7146c.zip frameworks_base-17f693520da8977c4a60f5b4be3be035cba7146c.tar.gz frameworks_base-17f693520da8977c4a60f5b4be3be035cba7146c.tar.bz2 |
Fix issue #22531747: Assist info should declare if user has disabled...
...context and/or screenshot
Added new API to find out what contextual data has been globally disabled.
Also updated various documentation to make it clear what kind of contextual
data you will get (and when it will be null).
Also added a new Activity.showAssist() API because... well, I was already
in there, it was easy to do, it is safe, and maybe people will build cool
things with it.
Change-Id: Ia553d6bcdd098dc0fce4b9237fbfaca9652fc74b
Diffstat (limited to 'tests/VoiceInteraction')
5 files changed, 23 insertions, 25 deletions
diff --git a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml index dc4e31b..b106437 100644 --- a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml +++ b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml @@ -80,6 +80,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Disallow screenshot" /> + <TextView android:id="@+id/options_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> </LinearLayout> diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java index 8381aa1..f1dd1de 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java @@ -74,21 +74,6 @@ public class MainInteractionService extends VoiceInteractionService { "Hello There", Locale.forLanguageTag("en-US"), mHotwordCallback); } - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - if (isActiveService(this, new ComponentName(this, getClass()))) { - Bundle args = new Bundle(); - args.putParcelable("intent", new Intent(this, TestInteractionActivity.class)); - args.putBundle("assist", intent.getExtras()); - showSession(args, VoiceInteractionSession.SHOW_WITH_ASSIST - | VoiceInteractionSession.SHOW_WITH_SCREENSHOT); - } else { - Log.w(TAG, "Not starting -- not current voice interaction service"); - } - stopSelf(startId); - return START_NOT_STICKY; - } - private void hotwordAvailabilityChangeHelper(int availability) { Log.i(TAG, "Hotword availability = " + availability); switch (availability) { diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java index 8796c9f..c0a67c1 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java @@ -50,6 +50,7 @@ public class MainInteractionSession extends VoiceInteractionSession View mOptionsContainer; CheckBox mDisallowAssist; CheckBox mDisallowScreenshot; + TextView mOptionsText; ImageView mScreenshot; ImageView mFullScreenshot; Button mConfirmButton; @@ -86,8 +87,9 @@ public class MainInteractionSession extends VoiceInteractionSession @Override public void onShow(Bundle args, int showFlags) { super.onShow(args, showFlags); + Log.i(TAG, "onShow: flags=0x" + Integer.toHexString(showFlags) + " args=" + args); mState = STATE_IDLE; - mStartIntent = args.getParcelable("intent"); + mStartIntent = args != null ? (Intent)args.getParcelable("intent") : null; if (mStartIntent == null) { mStartIntent = new Intent(getContext(), TestInteractionActivity.class); } @@ -96,6 +98,7 @@ public class MainInteractionSession extends VoiceInteractionSession } onHandleScreenshot(null); updateState(); + refreshOptions(); } @Override @@ -134,6 +137,7 @@ public class MainInteractionSession extends VoiceInteractionSession mDisallowAssist.setOnClickListener(this); mDisallowScreenshot = (CheckBox)mContentView.findViewById(R.id.disallow_screenshot); mDisallowScreenshot.setOnClickListener(this); + mOptionsText = (TextView)mContentView.findViewById(R.id.options_text); mConfirmButton = (Button)mContentView.findViewById(R.id.confirm); mConfirmButton.setOnClickListener(this); mCompleteButton = (Button)mContentView.findViewById(R.id.complete); @@ -145,13 +149,17 @@ public class MainInteractionSession extends VoiceInteractionSession } void refreshOptions() { - if (mOptionsCheck.isChecked()) { - mOptionsContainer.setVisibility(View.VISIBLE); - int flags = getDisabledShowContext(); - mDisallowAssist.setChecked((flags & SHOW_WITH_ASSIST) != 0); - mDisallowScreenshot.setChecked((flags & SHOW_WITH_SCREENSHOT) != 0); - } else { - mOptionsContainer.setVisibility(View.GONE); + if (mOptionsContainer != null) { + if (mOptionsCheck.isChecked()) { + mOptionsContainer.setVisibility(View.VISIBLE); + int flags = getDisabledShowContext(); + mDisallowAssist.setChecked((flags & SHOW_WITH_ASSIST) != 0); + mDisallowScreenshot.setChecked((flags & SHOW_WITH_SCREENSHOT) != 0); + int disabled = getUserDisabledShowContext(); + mOptionsText.setText("Disabled: 0x" + Integer.toHexString(disabled)); + } else { + mOptionsContainer.setVisibility(View.GONE); + } } } diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java index b0d6b39..e10d89f 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java @@ -16,7 +16,6 @@ package com.android.test.voiceinteraction; -import android.annotation.Nullable; import android.app.Activity; import android.app.VoiceInteractor; import android.content.ComponentName; diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/VoiceInteractionMain.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/VoiceInteractionMain.java index a7636c3..ee75f28 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/VoiceInteractionMain.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/VoiceInteractionMain.java @@ -49,7 +49,7 @@ public class VoiceInteractionMain extends Activity { View.OnClickListener mStartListener = new View.OnClickListener() { public void onClick(View v) { - startService(new Intent(VoiceInteractionMain.this, MainInteractionService.class)); + showAssist(null); } }; } |