Add suggestions to settings

Use an XML to define the categories that Settings will look for,
and surface enabled activities under those categories as suggestions.

When clicked on the activity will be started for result.  If the result
is not cancelled, then the operation is assumed successful and the
suggestion is disabled.  Users can also use an overflow -> remove
flow to get rid of unwanted suggestions.

Change-Id: I767abf8efe103af0509bc6b6b55888ae82643512
This commit is contained in:
Jason Monk
2016-01-07 16:25:34 -05:00
parent c24d360328
commit d4f03ec86f
14 changed files with 340 additions and 56 deletions

View File

@@ -15,15 +15,14 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dashboard_category_padding_start"
android:paddingEnd="@dimen/dashboard_category_padding_end"
android:orientation="vertical"
android:paddingBottom="8dip"
android:background="@color/card_background"
android:elevation="@dimen/dashboard_category_elevation" >
android:id="@+id/category"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_height"
android:paddingStart="@dimen/dashboard_category_padding_start"
android:paddingEnd="@dimen/dashboard_category_padding_end"
android:orientation="vertical"
android:paddingBottom="8dip"
android:background="@color/card_background" >
<View
android:layout_width="match_parent"
@@ -31,14 +30,14 @@
android:background="?android:attr/listDivider" />
<TextView android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_title_height"
android:paddingStart="@dimen/dashboard_category_title_margin_start"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.CategoryTitle"
android:textAlignment="viewStart"
/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="@dimen/dashboard_category_title_margin_start"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.CategoryTitle"
android:textAlignment="viewStart"
/>
</LinearLayout>

View File

@@ -21,8 +21,7 @@
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height"
android:clickable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation" >
android:background="@drawable/selectable_card" >
<ImageView
android:id="@android:id/icon"

View File

@@ -16,7 +16,7 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_title_height"
android:layout_height="@dimen/dashboard_category_height"
android:paddingStart="@dimen/search_title_padding_start"
android:singleLine="true"
android:ellipsize="marquee"

View File

@@ -16,7 +16,7 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_title_height"
android:layout_height="@dimen/dashboard_category_height"
android:paddingStart="@dimen/search_title_padding_start"
android:singleLine="true"
android:ellipsize="marquee"

View File

@@ -21,8 +21,7 @@
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height"
android:clickable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation">
android:background="@drawable/selectable_card">
<View
android:layout_width="@dimen/dashboard_tile_image_size"

View File

@@ -0,0 +1,45 @@
<?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:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_height"
android:clickable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation"
android:gravity="center_vertical" >
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="@dimen/suggestion_arrow_margin"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:textColor="?android:attr/colorAccent"
android:alpha=".87"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<ImageView android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:layout_marginStart="@dimen/suggestion_arrow_margin"
android:layout_marginEnd="@dimen/suggestion_arrow_margin"
android:src="@drawable/ic_expand_more" />
</LinearLayout>

View File

@@ -0,0 +1,86 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:scaleType="centerInside"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/overflow"
android:layout_width="44dp"
android:layout_height="44dp"
android:paddingStart="16dp"
android:paddingBottom="16dp"
android:paddingTop="12dp"
android:paddingEnd="12dp"
android:gravity="top"
style="?android:attr/actionOverflowButtonStyle" />
</FrameLayout>
</LinearLayout>
</LinearLayout>