Loading res/layout/homepage_condition_full_tile.xml 0 → 100644 +78 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 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. --> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/ContextualCardStyle"> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="@dimen/homepage_condition_full_card_height" android:paddingStart="@dimen/homepage_card_padding_start" android:paddingEnd="@dimen/homepage_card_padding_end" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:id="@android:id/icon" android:layout_width="@dimen/suggestion_card_icon_size" android:layout_height="@dimen/suggestion_card_icon_size" android:tint="?android:attr/colorAccent"/> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:paddingStart="@dimen/homepage_condition_full_card_padding_start" android:paddingEnd="@dimen/homepage_condition_full_card_padding_end" android:orientation="vertical"> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom" style="@style/TextAppearance.ConditionCardTitle"/> <TextView android:id="@android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TextAppearance.ConditionCardSummary"/> </LinearLayout> <View android:id="@+id/divider" android:layout_width="@dimen/homepage_condition_full_card_divider_width" android:layout_height="match_parent" android:layout_marginTop="@dimen/homepage_condition_full_card_divider_padding_top" android:layout_marginBottom="@dimen/homepage_condition_full_card_divider_padding_bottom" android:background="?android:attr/dividerVertical" /> <Button android:id="@+id/first_action" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/ConditionFullCardBorderlessButton"/> </LinearLayout> </androidx.cardview.widget.CardView> res/layout/homepage_condition_tile.xml→res/layout/homepage_condition_half_tile.xml +63 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 The Android Open Source Project Loading @@ -17,80 +18,45 @@ <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="@dimen/homepage_condition_half_card_height" style="@style/ContextualCardStyle"> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="@dimen/homepage_card_padding_start" android:paddingEnd="@dimen/homepage_card_padding_end" android:paddingTop="@dimen/homepage_condition_half_card_padding_top" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/condition_header_height" android:background="?android:attr/selectableItemBackground" android:orientation="horizontal"> <ImageView android:id="@android:id/icon" android:layout_width="@dimen/suggestion_card_icon_size" android:layout_height="@dimen/suggestion_card_icon_size" android:layout_marginTop="12dp" android:layout_marginStart="14dp" android:layout_marginEnd="24dp" android:tint="?android:attr/colorAccent"/> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="14dp" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorPrimary"/> </LinearLayout> android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top" android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom" style="@style/TextAppearance.ConditionCardTitle"/> <TextView android:id="@android:id/summary" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="62dp" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingBottom="8dp" android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:alpha=".7" android:textColor="?android:attr/textColorPrimary"/> style="@style/TextAppearance.ConditionCardSummary"/> <androidx.appcompat.widget.ButtonBarLayout android:id="@+id/buttonBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="62dp" android:paddingBottom="1dp" style="?android:attr/buttonBarStyle" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> <include layout="@layout/horizontal_divider"/> <Button android:id="@+id/first_action" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:paddingStart="0dp" android:alpha=".8" android:textAlignment="viewStart" android:textColor="?android:attr/textColorPrimary" style="?android:attr/buttonBarButtonStyle"/> <Space android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </androidx.appcompat.widget.ButtonBarLayout> <include layout="@layout/horizontal_divider"/> style="@style/ConditionHalfCardBorderlessButton"/> </LinearLayout> Loading res/values/dimens.xml +11 −1 Original line number Diff line number Diff line Loading @@ -346,6 +346,16 @@ <!-- Signal icon in NetworkSelectSetting --> <dimen name="signal_strength_icon_size">24dp</dimen> <!-- Condition cards size and padding --> <dimen name="homepage_condition_card_title_margin_bottom">2dp</dimen> <dimen name="homepage_condition_half_card_height">150dp</dimen> <dimen name="homepage_condition_half_card_padding_top">12dp</dimen> <dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen> <dimen name="homepage_condition_full_card_height">72dp</dimen> <dimen name="homepage_condition_full_card_padding_start">24dp</dimen> <dimen name="homepage_condition_full_card_padding_end">24dp</dimen> <dimen name="homepage_condition_full_card_divider_width">.75dp</dimen> <dimen name="homepage_condition_full_card_divider_padding_top">12dp</dimen> <dimen name="homepage_condition_full_card_divider_padding_bottom">12dp</dimen> </resources> res/values/styles.xml +30 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,16 @@ <item name="android:textColor">?android:attr/colorAccent</item> </style> <style name="TextAppearance.ConditionCardTitle" parent="@android:style/TextAppearance.Material.Body2"> <item name="android:textSize">16sp</item> </style> <style name="TextAppearance.ConditionCardSummary" parent="@android:style/TextAppearance.Material.Body1"> <item name="android:textColor">?android:attr/textColorSecondary</item> </style> <style name="TextAppearance.EntityHeaderTitle" parent="@android:style/TextAppearance.Material.Subhead"> <item name="android:textColor">?android:attr/textColorPrimary</item> Loading Loading @@ -463,4 +473,24 @@ <item name="cardElevation">@dimen/homepage_card_elevation</item> </style> <style name="ConditionCardBorderlessButton" parent="android:Widget.DeviceDefault.Button.Borderless"> <item name="android:textColor">?android:attr/colorAccent</item> <item name="android:textSize">14sp</item> <item name="android:textAllCaps">false</item> <item name="android:fontFamily">sans-serif-medium</item> </style> <style name="ConditionHalfCardBorderlessButton" parent="@style/ConditionCardBorderlessButton"> <item name="android:textAlignment">viewStart</item> <item name="android:paddingStart">0dp</item> </style> <style name="ConditionFullCardBorderlessButton" parent="@style/ConditionCardBorderlessButton"> <item name="android:textAlignment">viewEnd</item> <item name="android:paddingEnd">0dp</item> </style> </resources> src/com/android/settings/homepage/contextualcards/ContextualCard.java +25 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class ContextualCard { int CONDITIONAL = 3; } private final Builder mBuilder; private final String mName; @CardType private final int mCardType; Loading Loading @@ -142,7 +143,12 @@ public class ContextualCard { return TextUtils.isEmpty(mSliceUri); } public Builder mutate() { return mBuilder; } public ContextualCard(Builder builder) { mBuilder = builder; mName = builder.mName; mCardType = builder.mCardType; mRankingScore = builder.mRankingScore; Loading @@ -164,28 +170,47 @@ public class ContextualCard { } ContextualCard(Cursor c) { mBuilder = new Builder(); mName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.NAME)); mBuilder.setName(mName); mCardType = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.TYPE)); mBuilder.setCardType(mCardType); mRankingScore = c.getDouble(c.getColumnIndex(CardDatabaseHelper.CardColumns.SCORE)); mBuilder.setRankingScore(mRankingScore); mSliceUri = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.SLICE_URI)); mBuilder.setSliceUri(Uri.parse(mSliceUri)); mCategory = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CATEGORY)); mBuilder.setCategory(mCategory); mLocalizedToLocale = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.LOCALIZED_TO_LOCALE)); mBuilder.setLocalizedToLocale(mLocalizedToLocale); mPackageName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.PACKAGE_NAME)); mBuilder.setPackageName(mPackageName); mAppVersion = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.APP_VERSION)); mBuilder.setAppVersion(mAppVersion); mTitleResName = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_RES_NAME)); mBuilder.setTitleResName(mTitleResName); mTitleText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_TEXT)); mBuilder.setTitleText(mTitleText); mSummaryResName = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_RES_NAME)); mBuilder.setSummaryResName(mSummaryResName); mSummaryText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_TEXT)); mBuilder.setSummaryText(mSummaryText); mIconResName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_NAME)); mBuilder.setIconResName(mIconResName); mIconResId = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_ID)); mBuilder.setIconResId(mIconResId); mCardAction = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CARD_ACTION)); mBuilder.setCardAction(mCardAction); mExpireTimeMS = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.EXPIRE_TIME_MS)); mBuilder.setExpireTimeMS(mExpireTimeMS); mIsHalfWidth = (c.getInt( c.getColumnIndex(CardDatabaseHelper.CardColumns.SUPPORT_HALF_WIDTH)) == 1); mBuilder.setIsHalfWidth(mIsHalfWidth); mIconDrawable = null; mBuilder.setIconDrawable(mIconDrawable); } @Override Loading Loading
res/layout/homepage_condition_full_tile.xml 0 → 100644 +78 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 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. --> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/ContextualCardStyle"> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="@dimen/homepage_condition_full_card_height" android:paddingStart="@dimen/homepage_card_padding_start" android:paddingEnd="@dimen/homepage_card_padding_end" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:id="@android:id/icon" android:layout_width="@dimen/suggestion_card_icon_size" android:layout_height="@dimen/suggestion_card_icon_size" android:tint="?android:attr/colorAccent"/> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:paddingStart="@dimen/homepage_condition_full_card_padding_start" android:paddingEnd="@dimen/homepage_condition_full_card_padding_end" android:orientation="vertical"> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom" style="@style/TextAppearance.ConditionCardTitle"/> <TextView android:id="@android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TextAppearance.ConditionCardSummary"/> </LinearLayout> <View android:id="@+id/divider" android:layout_width="@dimen/homepage_condition_full_card_divider_width" android:layout_height="match_parent" android:layout_marginTop="@dimen/homepage_condition_full_card_divider_padding_top" android:layout_marginBottom="@dimen/homepage_condition_full_card_divider_padding_bottom" android:background="?android:attr/dividerVertical" /> <Button android:id="@+id/first_action" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/ConditionFullCardBorderlessButton"/> </LinearLayout> </androidx.cardview.widget.CardView>
res/layout/homepage_condition_tile.xml→res/layout/homepage_condition_half_tile.xml +63 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 The Android Open Source Project Loading @@ -17,80 +18,45 @@ <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="@dimen/homepage_condition_half_card_height" style="@style/ContextualCardStyle"> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="@dimen/homepage_card_padding_start" android:paddingEnd="@dimen/homepage_card_padding_end" android:paddingTop="@dimen/homepage_condition_half_card_padding_top" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/condition_header_height" android:background="?android:attr/selectableItemBackground" android:orientation="horizontal"> <ImageView android:id="@android:id/icon" android:layout_width="@dimen/suggestion_card_icon_size" android:layout_height="@dimen/suggestion_card_icon_size" android:layout_marginTop="12dp" android:layout_marginStart="14dp" android:layout_marginEnd="24dp" android:tint="?android:attr/colorAccent"/> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="14dp" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorPrimary"/> </LinearLayout> android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top" android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom" style="@style/TextAppearance.ConditionCardTitle"/> <TextView android:id="@android:id/summary" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="62dp" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingBottom="8dp" android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:alpha=".7" android:textColor="?android:attr/textColorPrimary"/> style="@style/TextAppearance.ConditionCardSummary"/> <androidx.appcompat.widget.ButtonBarLayout android:id="@+id/buttonBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="62dp" android:paddingBottom="1dp" style="?android:attr/buttonBarStyle" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> <include layout="@layout/horizontal_divider"/> <Button android:id="@+id/first_action" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:paddingStart="0dp" android:alpha=".8" android:textAlignment="viewStart" android:textColor="?android:attr/textColorPrimary" style="?android:attr/buttonBarButtonStyle"/> <Space android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </androidx.appcompat.widget.ButtonBarLayout> <include layout="@layout/horizontal_divider"/> style="@style/ConditionHalfCardBorderlessButton"/> </LinearLayout> Loading
res/values/dimens.xml +11 −1 Original line number Diff line number Diff line Loading @@ -346,6 +346,16 @@ <!-- Signal icon in NetworkSelectSetting --> <dimen name="signal_strength_icon_size">24dp</dimen> <!-- Condition cards size and padding --> <dimen name="homepage_condition_card_title_margin_bottom">2dp</dimen> <dimen name="homepage_condition_half_card_height">150dp</dimen> <dimen name="homepage_condition_half_card_padding_top">12dp</dimen> <dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen> <dimen name="homepage_condition_full_card_height">72dp</dimen> <dimen name="homepage_condition_full_card_padding_start">24dp</dimen> <dimen name="homepage_condition_full_card_padding_end">24dp</dimen> <dimen name="homepage_condition_full_card_divider_width">.75dp</dimen> <dimen name="homepage_condition_full_card_divider_padding_top">12dp</dimen> <dimen name="homepage_condition_full_card_divider_padding_bottom">12dp</dimen> </resources>
res/values/styles.xml +30 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,16 @@ <item name="android:textColor">?android:attr/colorAccent</item> </style> <style name="TextAppearance.ConditionCardTitle" parent="@android:style/TextAppearance.Material.Body2"> <item name="android:textSize">16sp</item> </style> <style name="TextAppearance.ConditionCardSummary" parent="@android:style/TextAppearance.Material.Body1"> <item name="android:textColor">?android:attr/textColorSecondary</item> </style> <style name="TextAppearance.EntityHeaderTitle" parent="@android:style/TextAppearance.Material.Subhead"> <item name="android:textColor">?android:attr/textColorPrimary</item> Loading Loading @@ -463,4 +473,24 @@ <item name="cardElevation">@dimen/homepage_card_elevation</item> </style> <style name="ConditionCardBorderlessButton" parent="android:Widget.DeviceDefault.Button.Borderless"> <item name="android:textColor">?android:attr/colorAccent</item> <item name="android:textSize">14sp</item> <item name="android:textAllCaps">false</item> <item name="android:fontFamily">sans-serif-medium</item> </style> <style name="ConditionHalfCardBorderlessButton" parent="@style/ConditionCardBorderlessButton"> <item name="android:textAlignment">viewStart</item> <item name="android:paddingStart">0dp</item> </style> <style name="ConditionFullCardBorderlessButton" parent="@style/ConditionCardBorderlessButton"> <item name="android:textAlignment">viewEnd</item> <item name="android:paddingEnd">0dp</item> </style> </resources>
src/com/android/settings/homepage/contextualcards/ContextualCard.java +25 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class ContextualCard { int CONDITIONAL = 3; } private final Builder mBuilder; private final String mName; @CardType private final int mCardType; Loading Loading @@ -142,7 +143,12 @@ public class ContextualCard { return TextUtils.isEmpty(mSliceUri); } public Builder mutate() { return mBuilder; } public ContextualCard(Builder builder) { mBuilder = builder; mName = builder.mName; mCardType = builder.mCardType; mRankingScore = builder.mRankingScore; Loading @@ -164,28 +170,47 @@ public class ContextualCard { } ContextualCard(Cursor c) { mBuilder = new Builder(); mName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.NAME)); mBuilder.setName(mName); mCardType = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.TYPE)); mBuilder.setCardType(mCardType); mRankingScore = c.getDouble(c.getColumnIndex(CardDatabaseHelper.CardColumns.SCORE)); mBuilder.setRankingScore(mRankingScore); mSliceUri = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.SLICE_URI)); mBuilder.setSliceUri(Uri.parse(mSliceUri)); mCategory = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CATEGORY)); mBuilder.setCategory(mCategory); mLocalizedToLocale = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.LOCALIZED_TO_LOCALE)); mBuilder.setLocalizedToLocale(mLocalizedToLocale); mPackageName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.PACKAGE_NAME)); mBuilder.setPackageName(mPackageName); mAppVersion = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.APP_VERSION)); mBuilder.setAppVersion(mAppVersion); mTitleResName = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_RES_NAME)); mBuilder.setTitleResName(mTitleResName); mTitleText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_TEXT)); mBuilder.setTitleText(mTitleText); mSummaryResName = c.getString( c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_RES_NAME)); mBuilder.setSummaryResName(mSummaryResName); mSummaryText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_TEXT)); mBuilder.setSummaryText(mSummaryText); mIconResName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_NAME)); mBuilder.setIconResName(mIconResName); mIconResId = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_ID)); mBuilder.setIconResId(mIconResId); mCardAction = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CARD_ACTION)); mBuilder.setCardAction(mCardAction); mExpireTimeMS = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.EXPIRE_TIME_MS)); mBuilder.setExpireTimeMS(mExpireTimeMS); mIsHalfWidth = (c.getInt( c.getColumnIndex(CardDatabaseHelper.CardColumns.SUPPORT_HALF_WIDTH)) == 1); mBuilder.setIsHalfWidth(mIsHalfWidth); mIconDrawable = null; mBuilder.setIconDrawable(mIconDrawable); } @Override Loading