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

Commit 9d9294cc authored by Andrei Stingaceanu's avatar Andrei Stingaceanu
Browse files

Keyboard shortcuts: initial view.

Initial view and functionality for showing/hiding it.

Change-Id: I0e365ecc3ba19110b87b020ff53a6318a7304ce8
parent 76774af1
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 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
  -->
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyboard_shortcuts_wrapper"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="40dp"
    android:focusable="true">
</RelativeLayout>
+15 −8
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar;

import static  android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_MAX;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
@@ -80,11 +78,8 @@ import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AnimationUtils;
import android.widget.DateTimeView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

@@ -116,6 +111,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_MAX;
import static com.android.keyguard.KeyguardHostView.OnDismissAction;

public abstract class BaseStatusBar extends SystemUI implements
@@ -237,6 +233,8 @@ public abstract class BaseStatusBar extends SystemUI implements

    private TimeInterpolator mLinearOutSlowIn, mFastOutLinearIn;

    private KeyboardShortcuts mKeyboardShortcuts;

    /**
     * The {@link StatusBarState} of the status bar.
     */
@@ -1142,7 +1140,7 @@ public abstract class BaseStatusBar extends SystemUI implements
         return new H();
    }

    static void sendCloseSystemWindows(Context context, String reason) {
    protected void sendCloseSystemWindows(String reason) {
        if (ActivityManagerNative.isSystemReady()) {
            try {
                ActivityManagerNative.getDefault().closeSystemDialogs(reason);
@@ -1177,7 +1175,7 @@ public abstract class BaseStatusBar extends SystemUI implements

    protected void showRecents(boolean triggeredFromAltTab) {
        if (mRecents != null) {
            sendCloseSystemWindows(mContext, SYSTEM_DIALOG_REASON_RECENT_APPS);
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
            mRecents.showRecents(triggeredFromAltTab, getStatusBarView());
        }
    }
@@ -1200,8 +1198,9 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    // TODO: this (and maybe a few layers above) should be called toggle instead of show.
    protected void showKeyboardShortcuts() {
        Toast.makeText(mContext, "Show keyboard shortcuts screen", Toast.LENGTH_LONG).show();
        getKeyboardShortcuts().toggleKeyboardShortcuts(mContext);
    }

    protected void cancelPreloadingRecents() {
@@ -1531,6 +1530,14 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    protected KeyboardShortcuts getKeyboardShortcuts() {
        if (mKeyboardShortcuts == null) {
            mKeyboardShortcuts = new KeyboardShortcuts();
        }

        return mKeyboardShortcuts;
    }

    public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
        if (!isDeviceProvisioned()) return;

+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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
 */

package com.android.systemui.statusbar;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.android.systemui.R;

/**
 * Contains functionality for handling keyboard shortcuts.
 */
public class KeyboardShortcuts {
    private Dialog mKeyboardShortcutsDialog;

    public KeyboardShortcuts() {}

    public void toggleKeyboardShortcuts(Context context) {
        if (mKeyboardShortcutsDialog == null) {
            // Create dialog.
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            final View keyboardShortcutsView = inflater.inflate(
                    R.layout.keyboard_shortcuts_view, null);

            populateKeyboardShortcuts(keyboardShortcutsView.findViewById(
                    R.id.keyboard_shortcuts_wrapper));
            dialogBuilder.setView(keyboardShortcutsView);
            mKeyboardShortcutsDialog = dialogBuilder.create();
            mKeyboardShortcutsDialog.setCanceledOnTouchOutside(true);

            // Setup window.
            Window keyboardShortcutsWindow = mKeyboardShortcutsDialog.getWindow();
            keyboardShortcutsWindow.setType(
                    WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
            keyboardShortcutsWindow.setBackgroundDrawable(
                    new ColorDrawable(android.graphics.Color.TRANSPARENT));
            keyboardShortcutsWindow.setGravity(Gravity.TOP);
            mKeyboardShortcutsDialog.show();
        } else {
            dismissKeyboardShortcutsDialog();
        }
    }

    public void dismissKeyboardShortcutsDialog() {
        if (mKeyboardShortcutsDialog != null) {
            mKeyboardShortcutsDialog.dismiss();
            mKeyboardShortcutsDialog = null;
        }
    }

    /**
     * @return {@code true} if the keyboard shortcuts have been successfully populated.
     */
    private boolean populateKeyboardShortcuts(View keyboardShortcutsLayout) {
        // TODO: Populate shortcuts.
        return true;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -2987,6 +2987,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            if (DEBUG) Log.v(TAG, "onReceive: " + intent);
            String action = intent.getAction();
            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
                getKeyboardShortcuts().dismissKeyboardShortcutsDialog();
                if (isCurrentProfile(getSendingUserId())) {
                    int flags = CommandQueue.FLAG_EXCLUDE_NONE;
                    String reason = intent.getStringExtra("reason");