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

Commit 8956dbbc authored by Daniel Sandler's avatar Daniel Sandler Committed by Daniel Sandler
Browse files

On-screen navigation bar (separate from the status bar).

In Honeycomb we introduced navigation controls in the status
bar, for xlarge devices without physical buttons. What about
phones? The status bar is pretty cramped already, and
besides, it's at the top of the display most of the time,
not at the bottom where your thumb is likely to be.

Enter the navigation bar. It's a new window type that
appears atop almost everything (including the keyguard); the
window manager subtracts its rectangle from the default
visible rectangle of other windows (including the status bar
and notification shade).

However, it behaves (on phones) like the status bar in that
applications that request fullscreen windows can get access
to those pixels. Well, almost; they need cooperation from
the navigation bar implementation to make the navbar
disappear, just like the status bar.

The current SystemUI implementation of the navigation bar on
phones is still rough, but it has the basics:

 + back, home, and menu keys (NB: we're showing menu all the
   time right now because checking the api level of the
   package owning the top window is currently a poor
   indicator of whether the app requires the menu key)
 + it tries to stick to the same physical end of the device,
   regardless of device orientation (on a phone, this is
   the strip of land closest to the microphone)

Change-Id: Ic613a3351220af0bbfbdef63e1d99cbefd5ed1c2
parent 6d8a98af
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -387,6 +387,12 @@ public interface WindowManager extends ViewManager {
         */
        public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;

        /**
         * Window type: Navigation bar (when distinct from status bar)
         * @hide
         */
        public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;

        /**
         * End of types of system windows.
         */
+124 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* apps/common/assets/default/default/skins/StatusBar.xml
**
** Copyright 2011, 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.
*/
-->

<com.android.systemui.statusbar.phone.NavigationBarView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    >

    <LinearLayout android:id="@+id/rot0"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:paddingLeft="8dip"
        android:paddingRight="8dip"
        android:background="#FF000000"
        android:orientation="horizontal"
        >

        <!-- navigation controls -->
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/ic_sysbar_back"
            systemui:keyCode="4"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/ic_sysbar_home"
            systemui:keyCode="3"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/ic_sysbar_menu"
            systemui:keyCode="82"
            android:layout_weight="1"
            />
    </LinearLayout>

    <LinearLayout android:id="@+id/rot90"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#FF000000"
        android:orientation="vertical"
        android:visibility="gone"
        >

        <!-- navigation controls -->
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_menu"
            systemui:keyCode="82"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_home"
            systemui:keyCode="3"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_back"
            systemui:keyCode="4"
            android:layout_weight="1"
            />
    </LinearLayout>

    <LinearLayout android:id="@+id/rot270"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#FF000000"
        android:orientation="vertical"
        android:visibility="gone"
        >

        <!-- navigation controls -->
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_back"
            systemui:keyCode="4"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_home"
            systemui:keyCode="3"
            android:layout_weight="1"
            />
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_sysbar_menu"
            systemui:keyCode="82"
            android:layout_weight="1"
            />
    </LinearLayout>
</com.android.systemui.statusbar.phone.NavigationBarView>
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2011, 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>
    <!-- thickness (width) of the navigation bar on phones that require it -->
    <dimen name="navigation_bar_size">42dp</dimen>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -31,5 +31,7 @@
    <!-- Width of scrollable area in recents -->
    <dimen name="status_bar_recents_width">356dp</dimen>

    <!-- thickness (height) of the navigation bar on phones that require it -->
    <dimen name="navigation_bar_size">42dp</dimen>
</resources>
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 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.phone;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.Surface;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.content.res.Configuration;

import com.android.systemui.R;

public class NavigationBarView extends LinearLayout {
    final Display mDisplay;
    View[] mRotatedViews = new View[4];

    public NavigationBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mDisplay = ((WindowManager)context.getSystemService(
                Context.WINDOW_SERVICE)).getDefaultDisplay();
    }

    public void onFinishInflate() {
        mRotatedViews[Surface.ROTATION_0] = 
        mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);

        mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
        
        mRotatedViews[Surface.ROTATION_270] = findViewById(R.id.rot270);
    }

    public void reorient() {
        final int rot = mDisplay.getRotation();
        for (int i=0; i<4; i++) {
            mRotatedViews[i].setVisibility(View.GONE);
        }
        mRotatedViews[rot].setVisibility(View.VISIBLE);

        android.util.Log.d("NavigationBarView", "reorient(): rot=" + mDisplay.getRotation());
    }
}
Loading