Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc8b467c authored by Bryce Lee's avatar Bryce Lee
Browse files

Add voice assist action for global actions.

Bug: 18919886
Change-Id: Idd74cf6980207deabfb312732a0316a2edf3c176
parent 2a114737
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@

    <!-- Only show settings item due to smaller real estate. -->
    <string-array translatable="false" name="config_globalActionsList">
        <item>settings</item>
        <item>voiceassist</item>
    </string-array>

    <!-- Base "touch slop" value used by ViewConfiguration as a
+3 −0
Original line number Diff line number Diff line
@@ -482,6 +482,9 @@
    <!-- label for item that launches settings in phone options dialog [CHAR LIMIT=15]-->
    <string name="global_action_settings">Settings</string>

    <!-- label for item that launches voice assist in phone options dialog [CHAR LIMIT=15]-->
    <string name="global_action_voice_assist">Voice Assist</string>

    <!-- label for item that locks the phone and enforces that it can't be unlocked without entering a credential. [CHAR LIMIT=15] -->
    <string name="global_action_lockdown">Lock now</string>

+2 −0
Original line number Diff line number Diff line
@@ -1527,6 +1527,7 @@
  <java-symbol type="string" name="global_action_silent_mode_on_status" />
  <java-symbol type="string" name="global_action_toggle_silent_mode" />
  <java-symbol type="string" name="global_action_lockdown" />
  <java-symbol type="string" name="global_action_voice_assist" />
  <java-symbol type="string" name="invalidPuk" />
  <java-symbol type="string" name="lockscreen_carrier_default" />
  <java-symbol type="style" name="Animation.LockScreen" />
@@ -1614,6 +1615,7 @@
  <java-symbol type="drawable" name="ic_notification_ime_default" />
  <java-symbol type="drawable" name="ic_menu_refresh" />
  <java-symbol type="drawable" name="ic_settings" />
  <java-symbol type="drawable" name="ic_voice_search" />
  <java-symbol type="drawable" name="stat_notify_car_mode" />
  <java-symbol type="drawable" name="stat_notify_disabled_data" />
  <java-symbol type="drawable" name="stat_notify_disk_full" />
+25 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
    private static final String GLOBAL_ACTION_KEY_USERS = "users";
    private static final String GLOBAL_ACTION_KEY_SETTINGS = "settings";
    private static final String GLOBAL_ACTION_KEY_LOCKDOWN = "lockdown";
    private static final String GLOBAL_ACTION_KEY_VOICEASSIST = "voiceassist";

    private final Context mContext;
    private final WindowManagerFuncs mWindowManagerFuncs;
@@ -291,6 +292,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                mItems.add(getSettingsAction());
            } else if (GLOBAL_ACTION_KEY_LOCKDOWN.equals(actionKey)) {
                mItems.add(getLockdownAction());
            } else if (GLOBAL_ACTION_KEY_VOICEASSIST.equals(actionKey)) {
                mItems.add(getVoiceAssistAction());
            } else {
                Log.e(TAG, "Invalid global action key " + actionKey);
            }
@@ -436,6 +439,28 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        };
    }

    private Action getVoiceAssistAction() {
        return new SinglePressAction(com.android.internal.R.drawable.ic_voice_search,
                R.string.global_action_voice_assist) {
            @Override
            public void onPress() {
                Intent intent = new Intent(Intent.ACTION_VOICE_ASSIST);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                mContext.startActivity(intent);
            }

            @Override
            public boolean showDuringKeyguard() {
                return true;
            }

            @Override
            public boolean showBeforeProvisioning() {
                return true;
            }
        };
    }

    private Action getLockdownAction() {
        return new SinglePressAction(com.android.internal.R.drawable.ic_lock_lock,
                R.string.global_action_lockdown) {