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

Commit 8861cb00 authored by Andrei Stingaceanu's avatar Andrei Stingaceanu
Browse files

Keyboard Shortcuts UI - add shortcuts to dialog.

This is the first UI iteration which contains elements for
displaying the keyboard shortcuts. Is is by no means final,
the following items (and maybe more) still need to be actioned:

* no UI for phone
* no view for system shortcuts (which contain icons)
* the shortcut items container needs a custom layout which
  needs to wrap and right align elements (prototype done)
* find or build an util which can produce human readable
  names of the baseCharacter and the modifiers (so far I
  found a few functions, none of them good)
* not pixel-perfect
* the scrollbar does not show
* the last separator (before the DONE button) is not
  visible

Change-Id: I0d191e9516ab8f4728f40b3eefe9d854249ee7a8
parent f1fa7908
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import static com.android.internal.util.Preconditions.checkNotNull;
public final class KeyboardShortcutGroup implements Parcelable {
    private final CharSequence mLabel;
    private final List<KeyboardShortcutInfo> mItems;
    // The system group looks different UI wise.
    private boolean mSystemGroup;

    /**
     * @param label The title to be used for this group, or null if there is none.
@@ -50,10 +52,33 @@ public final class KeyboardShortcutGroup implements Parcelable {
        this(label, Collections.<KeyboardShortcutInfo>emptyList());
    }

    /**
     * @param label The title to be used for this group, or null if there is none.
     * @param items The set of items to be included.
     * @param isSystemGroup Set this to {@code true} if this is s system group.
     * @hide
     */
    public KeyboardShortcutGroup(@Nullable CharSequence label,
            @NonNull List<KeyboardShortcutInfo> items, boolean isSystemGroup) {
        mLabel = label;
        mItems = new ArrayList<>(checkNotNull(items));
        mSystemGroup = isSystemGroup;
    }

    /**
     * @param label The title to be used for this group, or null if there is none.
     * @param isSystemGroup Set this to {@code true} if this is s system group.
     * @hide
     */
    public KeyboardShortcutGroup(@Nullable CharSequence label, boolean isSystemGroup) {
        this(label, Collections.<KeyboardShortcutInfo>emptyList(), isSystemGroup);
    }

    private KeyboardShortcutGroup(Parcel source) {
        mItems = new ArrayList<>();
        mLabel = source.readCharSequence();
        source.readTypedList(mItems, KeyboardShortcutInfo.CREATOR);
        mSystemGroup = source.readInt() == 1;
    }

    /**
@@ -70,6 +95,11 @@ public final class KeyboardShortcutGroup implements Parcelable {
        return mItems;
    }

    /** @hide **/
    public boolean isSystemGroup() {
        return mSystemGroup;
    }

    /**
     * Adds an item to the existing list.
     *
@@ -88,6 +118,7 @@ public final class KeyboardShortcutGroup implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeCharSequence(mLabel);
        dest.writeTypedList(mItems);
        dest.writeInt(mSystemGroup ? 1 : 0);
    }

    public static final Creator<KeyboardShortcutGroup> CREATOR =
+55 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/keyboard_shortcuts_keyword_wrapper"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingStart="24dp"
        android:paddingEnd="24dp"
        android:paddingBottom="8dp">
    <TextView
            android:id="@+id/keyboard_shortcuts_keyword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingEnd="12dp"
            android:background="@android:color/white"
            android:textColor="#D9000000"
            android:textSize="16sp"
            android:maxLines="5"
            android:singleLine="false"
            android:scrollHorizontally="false"
            android:layout_alignParentStart="true"
            android:minWidth="100dp"
            android:maxWidth="260dp"/>
    <!--TODO: introduce and use a layout that allows wrapping and right align -->
    <LinearLayout
            android:id="@+id/keyboard_shortcuts_item_container"
            android:layout_toEndOf="@+id/keyboard_shortcuts_keyword"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_alignParentEnd="true"
            android:gravity="end"
            android:textSize="14sp"
            android:paddingStart="0dp"
            android:paddingEnd="0dp"
            android:scrollHorizontally="false"
            android:minWidth="100dp"
            android:maxWidth="260dp"/>
</RelativeLayout>
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ 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
  -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:textSize="14sp"
          android:paddingStart="24dp"
          android:paddingTop="20dp"
          android:paddingEnd="24dp"
          android:paddingBottom="13dp" />
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">
</LinearLayout>
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginStart="4dp"
          android:padding="4dp"
          android:background="#EEEEEE"
          android:textColor="#8C000000"
          android:singleLine="true"
          android:textSize="14sp"/>
Loading