Update action bar style in app header UI.
- Update background color of actionbar - Remove elevation of actionbar so it appears to be the same entity as app header. - Add a shadow below app header view. We can't set elevation on app header unfortunately because that will add shadow all round the view, but we only want shadow below it. - Updated app icon size/text size per to match UI spec. Change-Id: I63d7fa42b859a008fa662aaf19848cd40529c2ff Fix: 37207527 Fix: 37079248 Test: visual && make RunSettingsRoboTests
This commit is contained in:
@@ -18,25 +18,25 @@ package com.android.settings.applications;
|
||||
|
||||
import android.annotation.IdRes;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.AppHeader;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
@@ -69,7 +69,6 @@ public class AppHeaderController {
|
||||
private final Fragment mFragment;
|
||||
private final int mMetricsCategory;
|
||||
private final View mAppHeader;
|
||||
private final int mIconElevation;
|
||||
|
||||
private Drawable mIcon;
|
||||
private CharSequence mLabel;
|
||||
@@ -96,8 +95,6 @@ public class AppHeaderController {
|
||||
mAppHeader = LayoutInflater.from(fragment.getContext())
|
||||
.inflate(R.layout.app_details, null /* root */);
|
||||
}
|
||||
mIconElevation = mContext.getResources()
|
||||
.getDimensionPixelSize(R.dimen.launcher_icon_elevation);
|
||||
}
|
||||
|
||||
public AppHeaderController setIcon(Drawable icon) {
|
||||
@@ -163,58 +160,23 @@ public class AppHeaderController {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds app header view and data from {@code PackageInfo} and {@code AppEntry}.
|
||||
*/
|
||||
public void bindAppHeader(PackageInfo packageInfo, ApplicationsState.AppEntry appEntry) {
|
||||
final String versionName = packageInfo == null ? null : packageInfo.versionName;
|
||||
final Resources res = mAppHeader.getResources();
|
||||
|
||||
// Set Icon
|
||||
final ImageView iconView = (ImageView) mAppHeader.findViewById(R.id.app_detail_icon);
|
||||
if (appEntry.icon != null) {
|
||||
iconView.setImageDrawable(appEntry.icon.getConstantState().newDrawable(res));
|
||||
}
|
||||
|
||||
// Set application name.
|
||||
final TextView labelView = (TextView) mAppHeader.findViewById(R.id.app_detail_title);
|
||||
labelView.setText(appEntry.label);
|
||||
|
||||
// Version number of application
|
||||
final TextView appVersion = (TextView) mAppHeader.findViewById(R.id.app_detail_summary);
|
||||
|
||||
if (!TextUtils.isEmpty(versionName)) {
|
||||
appVersion.setSelected(true);
|
||||
appVersion.setVisibility(View.VISIBLE);
|
||||
appVersion.setText(res.getString(R.string.version_text, String.valueOf(versionName)));
|
||||
} else {
|
||||
appVersion.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Done mutating appheader, rebinds everything and return a new {@link LayoutPreference}.
|
||||
*/
|
||||
public LayoutPreference done(Context context) {
|
||||
final LayoutPreference pref = new LayoutPreference(context, done());
|
||||
public LayoutPreference done(Activity activity, Context uiContext) {
|
||||
final LayoutPreference pref = new LayoutPreference(uiContext, done(activity));
|
||||
// Makes sure it's the first preference onscreen.
|
||||
pref.setOrder(-1000);
|
||||
pref.setKey(PREF_KEY_APP_HEADER);
|
||||
return pref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Done mutating appheader, rebinds everything.
|
||||
*/
|
||||
public View done() {
|
||||
return done(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Done mutating appheader, rebinds everything (optionally skip rebinding buttons).
|
||||
*/
|
||||
public View done(boolean rebindActions) {
|
||||
ImageView iconView = (ImageView) mAppHeader.findViewById(R.id.app_detail_icon);
|
||||
public View done(Activity activity, boolean rebindActions) {
|
||||
styleActionBar(activity);
|
||||
ImageView iconView = mAppHeader.findViewById(R.id.app_detail_icon);
|
||||
if (iconView != null) {
|
||||
iconView.setImageDrawable(mIcon);
|
||||
ImageView badgeView = mAppHeader.findViewById(R.id.app_icon_instant_apps_badge);
|
||||
@@ -239,12 +201,39 @@ public class AppHeaderController {
|
||||
/**
|
||||
* Only binds app header with button actions.
|
||||
*/
|
||||
public void bindAppHeaderButtons() {
|
||||
ImageButton leftButton = (ImageButton) mAppHeader.findViewById(R.id.left_button);
|
||||
ImageButton rightButton = (ImageButton) mAppHeader.findViewById(R.id.right_button);
|
||||
public AppHeaderController bindAppHeaderButtons() {
|
||||
ImageButton leftButton = mAppHeader.findViewById(R.id.left_button);
|
||||
ImageButton rightButton = mAppHeader.findViewById(R.id.right_button);
|
||||
|
||||
bindButton(leftButton, mLeftAction);
|
||||
bindButton(rightButton, mRightAction);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppHeaderController styleActionBar(Activity activity) {
|
||||
if (activity == null) {
|
||||
Log.w(TAG, "No activity, cannot style actionbar.");
|
||||
return this;
|
||||
}
|
||||
final ActionBar actionBar = activity.getActionBar();
|
||||
if (actionBar == null) {
|
||||
Log.w(TAG, "No actionbar, cannot style actionbar.");
|
||||
return this;
|
||||
}
|
||||
final Drawable appHeaderBackground =
|
||||
mAppHeader.findViewById(R.id.app_snippet).getBackground();
|
||||
actionBar.setBackgroundDrawable(appHeaderBackground);
|
||||
actionBar.setElevation(0);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Done mutating appheader, rebinds everything.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
View done(Activity activity) {
|
||||
return done(activity, true /* rebindActions */);
|
||||
}
|
||||
|
||||
private void bindButton(ImageButton button, @ActionType int action) {
|
||||
@@ -328,7 +317,7 @@ public class AppHeaderController {
|
||||
}
|
||||
|
||||
private void setText(@IdRes int id, CharSequence text) {
|
||||
TextView textView = (TextView) mAppHeader.findViewById(id);
|
||||
TextView textView = mAppHeader.findViewById(id);
|
||||
if (textView != null) {
|
||||
textView.setText(text);
|
||||
textView.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE);
|
||||
|
Reference in New Issue
Block a user