New design for instant apps in app details header

Bug: 35098444
Test: make RunSettingsRoboTests

In the previous design for instant apps, some metadata about the app
such as developer title, maturity rating, etc. was going to be shown
in the app header. In the latest design, we instead are just showing
a little label that says "Instant app".

The two CL's for this topic work together to change this:

frameworks/base : adds code to work around the problem that
robolectric doesn't know about the new isInstantApp method of the
ApplicationInfo class, so we need to avoid calling it during tests.

pacakges/apps/Settings: removes the code that previously displayed
the instant app metadata, and instead just insert the "Instant app"
label.

Change-Id: I2cbc70bf4827c401e862c58ea4ca7f8f9ba1cf58
This commit is contained in:
Antony Sargent
2017-02-28 10:57:45 -08:00
parent bee2554f13
commit d06aaa8fd0
9 changed files with 39 additions and 375 deletions

View File

@@ -37,7 +37,6 @@ import android.widget.TextView;
import com.android.settings.AppHeader;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.instantapps.InstantAppDetails;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.ApplicationsState;
@@ -81,7 +80,7 @@ public class AppHeaderController {
@ActionType
private int mRightAction;
private InstantAppDetails mInstantAppDetails;
private boolean mIsInstantApp;
public AppHeaderController(Context context, Fragment fragment, View appHeader) {
mContext = context;
@@ -154,8 +153,8 @@ public class AppHeaderController {
return this;
}
public AppHeaderController setInstantAppDetails(InstantAppDetails instantAppDetails) {
mInstantAppDetails = instantAppDetails;
public AppHeaderController setIsInstantApp(boolean isInstantApp) {
this.mIsInstantApp = isInstantApp;
return this;
}
@@ -220,26 +219,9 @@ public class AppHeaderController {
bindAppHeaderButtons();
}
if (mInstantAppDetails != null) {
setText(R.id.instant_app_developer_title, mInstantAppDetails.developerTitle);
View maturity = mAppHeader.findViewById(R.id.instant_app_maturity);
if (maturity != null) {
String maturityText = mInstantAppDetails.maturityRatingString;
Drawable maturityIcon = mInstantAppDetails.maturityRatingIcon;
if (!TextUtils.isEmpty(maturityText) || maturityIcon != null) {
maturity.setVisibility(View.VISIBLE);
}
setText(R.id.instant_app_maturity_text, maturityText);
if (maturityIcon != null) {
ImageView maturityIconView = (ImageView) mAppHeader.findViewById(
R.id.instant_app_maturity_icon);
if (maturityIconView != null) {
maturityIconView.setImageDrawable(maturityIcon);
}
}
}
setText(R.id.instant_app_monetization, mInstantAppDetails.monetizationNotice);
if (mIsInstantApp) {
setText(R.id.install_type,
mAppHeader.getResources().getString(R.string.install_type_instant));
}
return mAppHeader;

View File

@@ -23,6 +23,7 @@ import android.util.Log;
import com.android.settings.AppHeader;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.AppUtils;
import static com.android.settings.applications.AppHeaderController.ActionType;
@@ -52,6 +53,7 @@ public abstract class AppInfoWithHeader extends AppInfoBase {
.setIcon(mPackageInfo.applicationInfo.loadIcon(mPm))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
.setPackageName(mPackageName)
.setUid(mPackageInfo.applicationInfo.uid)
.setButtonActions(ActionType.ACTION_APP_INFO, ActionType.ACTION_NONE)

View File

@@ -563,6 +563,7 @@ public class InstalledAppDetails extends AppInfoBase
.setLabel(mAppEntry)
.setIcon(mAppEntry)
.setSummary(getString(getInstallationStatus(mAppEntry.info)))
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
.done(false /* rebindActions */);
mVersionPreference.setSummary(getString(R.string.version_text, pkgInfo.versionName));
} else {

View File

@@ -1,110 +0,0 @@
/*
* 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.
*/
package com.android.settings.applications.instantapps;
import android.graphics.drawable.Drawable;
import java.net.URL;
/**
* Encapsulates state about instant apps that is provided by an app store implementation.
*/
public class InstantAppDetails {
// Most of these members are self-explanatory; the one that may not be is
// monetizationNotice, which is a string alerting users that the app contains ads and/or uses
// in-app purchases (this may eventually become two separate members).
public final Drawable maturityRatingIcon;
public final String maturityRatingString;
public final String monetizationNotice;
public final String developerTitle;
public final URL privacyPolicy;
public final URL developerWebsite;
public final String developerEmail;
public final String developerMailingAddress;
public static class Builder {
private Drawable mMaturityRatingIcon;
private String mMaturityRatingString;
private String mMonetizationNotice;
private String mDeveloperTitle;
private URL mPrivacyPolicy;
private URL mDeveloperWebsite;
private String mDeveloperEmail;
private String mDeveloperMailingAddress;
public Builder maturityRatingIcon(Drawable maturityRatingIcon) {
this.mMaturityRatingIcon = maturityRatingIcon;
return this;
}
public Builder maturityRatingString(String maturityRatingString) {
mMaturityRatingString = maturityRatingString;
return this;
}
public Builder monetizationNotice(String monetizationNotice) {
mMonetizationNotice = monetizationNotice;
return this;
}
public Builder developerTitle(String developerTitle) {
mDeveloperTitle = developerTitle;
return this;
}
public Builder privacyPolicy(URL privacyPolicy) {
mPrivacyPolicy = privacyPolicy;
return this;
}
public Builder developerWebsite(URL developerWebsite) {
mDeveloperWebsite = developerWebsite;
return this;
}
public Builder developerEmail(String developerEmail) {
mDeveloperEmail = developerEmail;
return this;
}
public Builder developerMailingAddress(String developerMailingAddress) {
mDeveloperMailingAddress = developerMailingAddress;
return this;
}
public InstantAppDetails build() {
return new InstantAppDetails(mMaturityRatingIcon, mMaturityRatingString,
mMonetizationNotice, mDeveloperTitle, mPrivacyPolicy, mDeveloperWebsite,
mDeveloperEmail, mDeveloperMailingAddress);
}
}
public static Builder builder() { return new Builder(); }
private InstantAppDetails(Drawable maturityRatingIcon, String maturityRatingString,
String monetizationNotice, String developerTitle, URL privacyPolicy,
URL developerWebsite, String developerEmail, String developerMailingAddress) {
this.maturityRatingIcon = maturityRatingIcon;
this.maturityRatingString = maturityRatingString;
this.monetizationNotice = monetizationNotice;
this.developerTitle = developerTitle;
this.privacyPolicy = privacyPolicy;
this.developerWebsite = developerWebsite;
this.developerEmail = developerEmail;
this.developerMailingAddress = developerMailingAddress;
}
}