Merge "Adds the lightning badge for Instant Apps" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ef64404f44
33
res/drawable/ic_instant_apps_badge.xml
Normal file
33
res/drawable/ic_instant_apps_badge.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2017 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
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="48"
|
||||||
|
android:viewportHeight="48">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M 24.5 2.7 C 35.5456949966 2.7 44.5 11.6543050034 44.5 22.7 C 44.5 33.7456949966 35.5456949966 42.7 24.5 42.7 C 13.4543050034 42.7 4.5 33.7456949966 4.5 22.7 C 4.5 11.6543050034 13.4543050034 2.7 24.5 2.7 Z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#757575"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M 33.3 19.1 L 26.4 19.1 L 26.4 5.8 L 16.6 26.4 L 23.5 26.3 L 23.5 39.6 Z" />
|
||||||
|
<path
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M 0.5 0 H 48.5 V 48 H 0.5 V 0 Z" />
|
||||||
|
</vector>
|
23
res/drawable/ic_instant_apps_badge_bg.xml
Normal file
23
res/drawable/ic_instant_apps_badge_bg.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2017 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
|
||||||
|
-->
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<gradient android:type="radial"
|
||||||
|
android:startColor="#4d000000"
|
||||||
|
android:endColor="#00000000"
|
||||||
|
android:gradientRadius="12dp"/>
|
||||||
|
</shape>
|
@@ -34,13 +34,26 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="8dp">
|
android:paddingStart="8dp">
|
||||||
|
|
||||||
|
<FrameLayout android:id="@+id/app_icon_frame"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="80dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/app_detail_icon"
|
android:id="@+id/app_detail_icon"
|
||||||
android:layout_width="80dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:antialias="true"/>
|
android:antialias="true"/>
|
||||||
|
<ImageView android:id="@+id/app_icon_instant_apps_badge"
|
||||||
|
android:layout_width="22dp"
|
||||||
|
android:layout_height="22dp"
|
||||||
|
android:layout_gravity="end|bottom"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:elevation="20dp"
|
||||||
|
android:background="@drawable/ic_instant_apps_badge_bg"
|
||||||
|
android:src="@drawable/ic_instant_apps_badge" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/app_detail_links"
|
android:id="@+id/app_detail_links"
|
||||||
@@ -71,7 +84,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toEndOf="@id/app_detail_icon"
|
android:layout_toEndOf="@id/app_icon_frame"
|
||||||
android:layout_toStartOf="@id/app_detail_links"
|
android:layout_toStartOf="@id/app_detail_links"
|
||||||
android:paddingStart="24dp"
|
android:paddingStart="24dp"
|
||||||
android:paddingEnd="24dp"
|
android:paddingEnd="24dp"
|
||||||
|
@@ -212,6 +212,10 @@ public class AppHeaderController {
|
|||||||
ImageView iconView = (ImageView) mAppHeader.findViewById(R.id.app_detail_icon);
|
ImageView iconView = (ImageView) mAppHeader.findViewById(R.id.app_detail_icon);
|
||||||
if (iconView != null) {
|
if (iconView != null) {
|
||||||
iconView.setImageDrawable(mIcon);
|
iconView.setImageDrawable(mIcon);
|
||||||
|
ImageView badgeView = mAppHeader.findViewById(R.id.app_icon_instant_apps_badge);
|
||||||
|
if (badgeView != null) {
|
||||||
|
badgeView.setVisibility(mIsInstantApp ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setText(R.id.app_detail_title, mLabel);
|
setText(R.id.app_detail_title, mLabel);
|
||||||
setText(R.id.app_detail_summary, mSummary);
|
setText(R.id.app_detail_summary, mSummary);
|
||||||
|
@@ -28,6 +28,7 @@ import android.os.UserHandle;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -276,6 +277,17 @@ public class AppHeaderControllerTest {
|
|||||||
.isEqualTo(View.GONE);
|
.isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the instant app label does not show up when we haven't told the controller the
|
||||||
|
// app is instant.
|
||||||
|
@Test
|
||||||
|
public void instantApps_normalAppsDontGetInstantAppsBadge() {
|
||||||
|
final View appHeader = mLayoutInflater.inflate(R.layout.app_details, null /* root */);
|
||||||
|
mController = new AppHeaderController(mContext, mFragment, appHeader);
|
||||||
|
mController.done();
|
||||||
|
assertThat(appHeader.findViewById(R.id.app_icon_instant_apps_badge).getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
// Test that the "instant apps" label is present in the header when we have an instant app.
|
// Test that the "instant apps" label is present in the header when we have an instant app.
|
||||||
@Test
|
@Test
|
||||||
public void instantApps_expectedHeaderItem() {
|
public void instantApps_expectedHeaderItem() {
|
||||||
@@ -284,6 +296,8 @@ public class AppHeaderControllerTest {
|
|||||||
mController.setIsInstantApp(true);
|
mController.setIsInstantApp(true);
|
||||||
mController.done();
|
mController.done();
|
||||||
TextView label = (TextView)appHeader.findViewById(R.id.install_type);
|
TextView label = (TextView)appHeader.findViewById(R.id.install_type);
|
||||||
|
ImageView badgeView = appHeader.findViewById(R.id.app_icon_instant_apps_badge);
|
||||||
|
assertThat(badgeView.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
assertThat(label.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(label.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
assertThat(label.getText()).isEqualTo(
|
assertThat(label.getText()).isEqualTo(
|
||||||
appHeader.getResources().getString(R.string.install_type_instant));
|
appHeader.getResources().getString(R.string.install_type_instant));
|
||||||
|
Reference in New Issue
Block a user