Snap for 6492189 from 6c214b14d7 to mainline-release
Change-Id: Iea47525e3b11e62727d6f9d521768380f660665c
This commit is contained in:
@@ -14,119 +14,132 @@
|
||||
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:paddingTop="6dp"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:orientation="vertical"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@*android:dimen/status_bar_icon_size"
|
||||
android:paddingBottom="6dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:contentDescription="@null"
|
||||
android:adjustViewBounds="true"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pkgname"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:marqueeRepeatLimit = "marquee_forever"
|
||||
android:scrollHorizontally = "true"
|
||||
android:textStyle="bold"
|
||||
android:textAlignment="viewStart" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/alerted_icon"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:paddingTop="1dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
android:src="@drawable/ic_notifications_alert"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_badge"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:paddingTop="1dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@*android:string/notification_work_profile_content_description"
|
||||
android:layout_toStartOf="@id/timestamp"
|
||||
/>
|
||||
|
||||
<DateTimeView
|
||||
android:id="@+id/timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_alignBottom="@android:id/widget_frame"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignTop="@android:id/widget_frame"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
||||
android:textAlignment="viewEnd"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="6dp"
|
||||
android:minHeight="48dp"
|
||||
android:orientation="vertical"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
android:minHeight="@*android:dimen/status_bar_icon_size"
|
||||
android:paddingBottom="6dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:contentDescription="@null"
|
||||
android:adjustViewBounds="true"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pkgname"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:marqueeRepeatLimit = "marquee_forever"
|
||||
android:scrollHorizontally = "true"
|
||||
android:textStyle="bold"
|
||||
android:textAlignment="viewStart" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/alerted_icon"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:paddingTop="1dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
android:src="@drawable/ic_notifications_alert"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_badge"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:paddingTop="1dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@*android:string/notification_work_profile_content_description"
|
||||
android:layout_toStartOf="@id/timestamp"
|
||||
/>
|
||||
|
||||
<DateTimeView
|
||||
android:id="@+id/timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_alignBottom="@android:id/widget_frame"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignTop="@android:id/widget_frame"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
||||
android:textAlignment="viewEnd"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginTop="17dp"
|
||||
android:background="@color/material_grey_300" />
|
||||
</LinearLayout>
|
||||
@@ -42,6 +42,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
@@ -1101,4 +1102,13 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
context.getString(R.string.config_settingsintelligence_package_name));
|
||||
return isSettingsIntelligence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the night mode is enabled.
|
||||
*/
|
||||
public static boolean isNightMode(Context context) {
|
||||
final int currentNightMode =
|
||||
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,15 +126,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
getPrefContext());
|
||||
setPreferenceScreen(preferenceScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
|
||||
removeDialog(DialogEnums.EDIT_SHORTCUT);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
};
|
||||
|
||||
final List<String> shortcutFeatureKeys = new ArrayList<>();
|
||||
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
|
||||
@@ -146,6 +137,15 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
updateShortcutPreference();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
|
||||
removeDialog(DialogEnums.EDIT_SHORTCUT);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
};
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,14 +197,7 @@ public class AccountTypePreferenceLoader {
|
||||
ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
|
||||
ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
|
||||
try {
|
||||
if (resolvedActivityInfo.exported) {
|
||||
if (resolvedActivityInfo.permission == null) {
|
||||
return true; // exported activity without permission.
|
||||
} else if (pm.checkPermission(resolvedActivityInfo.permission,
|
||||
authDesc.packageName) == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Allows to launch only authenticator owned activities.
|
||||
ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
|
||||
return resolvedAppInfo.uid == authenticatorAppInf.uid;
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class NightDisplayAutoModePreferenceController extends BasePreferenceCont
|
||||
if (String.valueOf(ColorDisplayManager.AUTO_MODE_TWILIGHT).equals(newValue)
|
||||
&& !mLocationManager.isLocationEnabled()) {
|
||||
TwilightLocationDialog.show(mContext);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return mColorDisplayManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.android.settings.display.TwilightLocationDialog;
|
||||
*/
|
||||
public class DarkModeScheduleSelectorController extends BasePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
private static final String TAG = DarkModeScheduleSelectorController.class.getSimpleName();
|
||||
|
||||
private final UiModeManager mUiModeManager;
|
||||
private PowerManager mPowerManager;
|
||||
private DropDownPreference mPreference;
|
||||
@@ -51,6 +51,7 @@ public class DarkModeScheduleSelectorController extends BasePreferenceController
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,8 +59,7 @@ public class DarkModeScheduleSelectorController extends BasePreferenceController
|
||||
return BasePreferenceController.AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void updateState(Preference preference) {
|
||||
private void init() {
|
||||
final boolean batterySaver = mPowerManager.isPowerSaveMode();
|
||||
mPreference.setEnabled(!batterySaver);
|
||||
mCurrentMode = getCurrentMode();
|
||||
@@ -87,25 +87,25 @@ public class DarkModeScheduleSelectorController extends BasePreferenceController
|
||||
if (newMode == mCurrentMode) {
|
||||
return false;
|
||||
}
|
||||
if (newMode == mPreference.findIndexOfValue(
|
||||
mCurrentMode = newMode;
|
||||
if (mCurrentMode == mPreference.findIndexOfValue(
|
||||
mContext.getString(R.string.dark_ui_auto_mode_never))) {
|
||||
boolean active = (mContext.getResources().getConfiguration().uiMode
|
||||
& Configuration.UI_MODE_NIGHT_YES) != 0;
|
||||
int mode = active ? UiModeManager.MODE_NIGHT_YES
|
||||
: UiModeManager.MODE_NIGHT_NO;
|
||||
mUiModeManager.setNightMode(mode);
|
||||
} else if (newMode == mPreference.findIndexOfValue(
|
||||
} else if (mCurrentMode == mPreference.findIndexOfValue(
|
||||
mContext.getString(R.string.dark_ui_auto_mode_auto))) {
|
||||
if (!mLocationManager.isLocationEnabled()) {
|
||||
TwilightLocationDialog.show(mContext);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
|
||||
} else if (newMode == mPreference.findIndexOfValue(
|
||||
} else if (mCurrentMode == mPreference.findIndexOfValue(
|
||||
mContext.getString(R.string.dark_ui_auto_mode_custom))) {
|
||||
mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
|
||||
}
|
||||
mCurrentMode = newMode;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +105,6 @@ public class BluetoothDevicesSlice implements CustomSliceable {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Reload theme for switching dark mode on/off
|
||||
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.app.PendingIntent;
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
@@ -107,7 +106,7 @@ public class DarkThemeSlice implements CustomSliceable {
|
||||
final IconCompat icon =
|
||||
IconCompat.createWithResource(mContext, R.drawable.dark_theme);
|
||||
|
||||
final boolean isChecked = isDarkThemeMode(mContext);
|
||||
final boolean isChecked = Utils.isNightMode(mContext);
|
||||
if (sPreChecked != isChecked) {
|
||||
// Dark(Night) mode changed and reset the sSliceClicked.
|
||||
resetValue(isChecked, false);
|
||||
@@ -157,7 +156,7 @@ public class DarkThemeSlice implements CustomSliceable {
|
||||
@VisibleForTesting
|
||||
boolean isAvailable(Context context) {
|
||||
// check if dark theme mode is enabled or if dark theme scheduling is on.
|
||||
if (isDarkThemeMode(context) || isNightModeScheduled()) {
|
||||
if (Utils.isNightMode(context) || isNightModeScheduled()) {
|
||||
return false;
|
||||
}
|
||||
// checking the current battery level
|
||||
@@ -167,13 +166,6 @@ public class DarkThemeSlice implements CustomSliceable {
|
||||
return level <= BATTERY_LEVEL_THRESHOLD;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static boolean isDarkThemeMode(Context context) {
|
||||
final int currentNightMode =
|
||||
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
private void resetValue(boolean preChecked, boolean clicked) {
|
||||
sPreChecked = preChecked;
|
||||
sSliceClicked = clicked;
|
||||
|
||||
@@ -75,8 +75,6 @@ public class MediaOutputGroupSlice implements CustomSliceable {
|
||||
|
||||
@Override
|
||||
public Slice getSlice() {
|
||||
// Reload theme for switching dark mode on/off
|
||||
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED);
|
||||
// Add "Group" row
|
||||
|
||||
@@ -81,9 +81,6 @@ public class MediaOutputSlice implements CustomSliceable {
|
||||
|
||||
@Override
|
||||
public Slice getSlice() {
|
||||
// Reload theme for switching dark mode on/off
|
||||
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED);
|
||||
if (!isVisible()) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
||||
private String mClickedPrefKey;
|
||||
|
||||
private ActiveSubsciptionsListener mActiveSubsciptionsListener;
|
||||
private boolean mActiveSubsciptionsListenerStarting;
|
||||
private boolean mDropFirstSubscriptionChangeNotify;
|
||||
private int mActiveSubsciptionsListenerCount;
|
||||
|
||||
public MobileNetworkSettings() {
|
||||
@@ -207,20 +207,20 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mActiveSubsciptionsListener == null) {
|
||||
mActiveSubsciptionsListenerStarting = true;
|
||||
mActiveSubsciptionsListener = new ActiveSubsciptionsListener(
|
||||
getContext().getMainLooper(), getContext(), mSubId) {
|
||||
public void onChanged() {
|
||||
onSubscriptionDetailChanged();
|
||||
}
|
||||
};
|
||||
mActiveSubsciptionsListenerStarting = false;
|
||||
mDropFirstSubscriptionChangeNotify = true;
|
||||
}
|
||||
mActiveSubsciptionsListener.start();
|
||||
}
|
||||
|
||||
private void onSubscriptionDetailChanged() {
|
||||
if (mActiveSubsciptionsListenerStarting) {
|
||||
if (mDropFirstSubscriptionChangeNotify) {
|
||||
mDropFirstSubscriptionChangeNotify = false;
|
||||
Log.d(LOG_TAG, "Callback during onResume()");
|
||||
return;
|
||||
}
|
||||
@@ -235,6 +235,14 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mActiveSubsciptionsListener != null) {
|
||||
mActiveSubsciptionsListener.stop();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void onRestoreInstance(Bundle icicle) {
|
||||
if (icicle != null) {
|
||||
|
||||
@@ -266,9 +266,6 @@ public class NotificationHistoryActivity extends Activity {
|
||||
mSnoozedRv.setLayoutManager(lm);
|
||||
mSnoozedRv.setAdapter(
|
||||
new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
|
||||
mSnoozedRv.getContext(), lm.getOrientation());
|
||||
mSnoozedRv.addItemDecoration(dividerItemDecoration);
|
||||
mSnoozedRv.setNestedScrollingEnabled(false);
|
||||
|
||||
if (snoozed == null || snoozed.length == 0) {
|
||||
@@ -284,9 +281,6 @@ public class NotificationHistoryActivity extends Activity {
|
||||
mDismissedRv.setLayoutManager(dismissLm);
|
||||
mDismissedRv.setAdapter(
|
||||
new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
|
||||
DividerItemDecoration dismissDivider = new DividerItemDecoration(
|
||||
mDismissedRv.getContext(), dismissLm.getOrientation());
|
||||
mDismissedRv.addItemDecoration(dismissDivider);
|
||||
mDismissedRv.setNestedScrollingEnabled(false);
|
||||
|
||||
if (dismissed == null || dismissed.length == 0) {
|
||||
|
||||
@@ -94,6 +94,7 @@ public class NotificationSbnAdapter extends
|
||||
holder.setTitle(getTitleString(sbn.getNotification()));
|
||||
holder.setSummary(getTextString(mContext, sbn.getNotification()));
|
||||
holder.setPostedTime(sbn.getPostTime());
|
||||
holder.setDividerVisible(position < (mValues.size() -1));
|
||||
int userId = normalizeUserId(sbn);
|
||||
if (!mUserBadgeCache.containsKey(userId)) {
|
||||
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
|
||||
|
||||
@@ -45,6 +45,7 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView mTitle;
|
||||
private final TextView mSummary;
|
||||
private final ImageView mProfileBadge;
|
||||
private final View mDivider;
|
||||
|
||||
NotificationSbnViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -54,6 +55,7 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
mTitle = itemView.findViewById(R.id.title);
|
||||
mSummary = itemView.findViewById(R.id.text);
|
||||
mProfileBadge = itemView.findViewById(R.id.profile_badge);
|
||||
mDivider = itemView.findViewById(R.id.divider);
|
||||
}
|
||||
|
||||
void setSummary(CharSequence summary) {
|
||||
@@ -85,6 +87,10 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
mProfileBadge.setVisibility(badge != null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
void setDividerVisible(boolean visible) {
|
||||
mDivider.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
void addOnClick(String pkg, int userId, PendingIntent pi) {
|
||||
Intent appIntent = itemView.getContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(pkg);
|
||||
|
||||
@@ -66,6 +66,7 @@ public class SettingsPanelActivity extends FragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getApplicationContext().getTheme().rebase();
|
||||
createOrUpdatePanel(true /* shouldForceCreation */);
|
||||
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||
}
|
||||
|
||||
@@ -215,7 +215,6 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
|
||||
|
||||
private void updateDisplay() {
|
||||
if (isLockToAppEnabled(getActivity())) {
|
||||
mFooterPreference.setVisible(false);
|
||||
mUseScreenLock.setVisible(true);
|
||||
mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
@@ -226,7 +225,6 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
|
||||
mUseScreenLock.setChecked(isScreenLockUsed());
|
||||
mUseScreenLock.setTitle(getCurrentSecurityTitle());
|
||||
} else {
|
||||
mFooterPreference.setVisible(true);
|
||||
mFooterPreference.setSummary(getAppPinningContent());
|
||||
mUseScreenLock.setVisible(false);
|
||||
}
|
||||
|
||||
@@ -140,8 +140,11 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
@VisibleForTesting
|
||||
Map<Uri, SliceData> mSliceWeakDataCache;
|
||||
|
||||
@VisibleForTesting
|
||||
final Map<Uri, SliceBackgroundWorker> mPinnedWorkers = new ArrayMap<>();
|
||||
|
||||
private boolean mNightMode;
|
||||
|
||||
public SettingsSliceProvider() {
|
||||
super(READ_SEARCH_INDEXABLES);
|
||||
}
|
||||
@@ -150,6 +153,8 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
public boolean onCreateSliceProvider() {
|
||||
mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext());
|
||||
mSliceWeakDataCache = new WeakHashMap<>();
|
||||
mNightMode = Utils.isNightMode(getContext());
|
||||
getContext().setTheme(R.style.Theme_SettingsBase);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,6 +206,13 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean nightMode = Utils.isNightMode(getContext());
|
||||
if (mNightMode != nightMode) {
|
||||
Log.d(TAG, "Night mode changed, reload theme");
|
||||
mNightMode = nightMode;
|
||||
getContext().getTheme().rebase();
|
||||
}
|
||||
|
||||
// Before adding a slice to {@link CustomSliceManager}, please get approval
|
||||
// from the Settings team.
|
||||
if (CustomSliceRegistry.isValidUri(sliceUri)) {
|
||||
|
||||
@@ -73,8 +73,6 @@ public class SliceBuilderUtils {
|
||||
* {@param sliceData} is an inline controller.
|
||||
*/
|
||||
public static Slice buildSlice(Context context, SliceData sliceData) {
|
||||
// Reload theme for switching dark mode on/off
|
||||
context.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
Log.d(TAG, "Creating slice for: " + sliceData.getPreferenceController());
|
||||
final BasePreferenceController controller = getPreferenceController(context, sliceData);
|
||||
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
||||
|
||||
@@ -86,9 +86,6 @@ public class WifiSlice implements CustomSliceable {
|
||||
|
||||
@Override
|
||||
public Slice getSlice() {
|
||||
// Reload theme for switching dark mode on/off
|
||||
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
|
||||
final boolean isWifiEnabled = isWifiEnabled();
|
||||
ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* accessPoint */);
|
||||
if (!isWifiEnabled) {
|
||||
|
||||
@@ -20,6 +20,8 @@ package com.android.settings.slices;
|
||||
import static android.content.ContentResolver.SCHEME_CONTENT;
|
||||
import static android.content.pm.PackageManager.PERMISSION_DENIED;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.content.res.Configuration.UI_MODE_NIGHT_NO;
|
||||
import static android.content.res.Configuration.UI_MODE_NIGHT_YES;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -39,6 +41,7 @@ import android.app.slice.SliceManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.net.Uri;
|
||||
import android.os.StrictMode;
|
||||
import android.provider.Settings;
|
||||
@@ -96,7 +99,8 @@ import java.util.Set;
|
||||
@Config(shadows = {ShadowUserManager.class, ShadowUtils.class,
|
||||
SlicesDatabaseAccessorTest.ShadowApplicationPackageManager.class,
|
||||
ShadowBluetoothAdapter.class, ShadowLockPatternUtils.class,
|
||||
SettingsSliceProviderTest.ShadowWifiScanWorker.class})
|
||||
SettingsSliceProviderTest.ShadowWifiScanWorker.class,
|
||||
SettingsSliceProviderTest.ShadowTheme.class})
|
||||
public class SettingsSliceProviderTest {
|
||||
|
||||
private static final String KEY = "KEY";
|
||||
@@ -162,6 +166,7 @@ public class SettingsSliceProviderTest {
|
||||
@After
|
||||
public void cleanUp() {
|
||||
ShadowThreadUtils.reset();
|
||||
ShadowTheme.reset();
|
||||
DatabaseTestUtils.clearDb(mContext);
|
||||
}
|
||||
|
||||
@@ -263,6 +268,28 @@ public class SettingsSliceProviderTest {
|
||||
assertThat(slice).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindSlice_nightModeChanged_shouldReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
|
||||
|
||||
final SliceData data = getDummyData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
assertThat(ShadowTheme.isThemeRebased()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindSlice_nightModeNotChanged_shouldNotReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
|
||||
SliceData data = getDummyData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
assertThat(ShadowTheme.isThemeRebased()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDescendantUris_fullActionUri_returnsSelf() {
|
||||
final Collection<Uri> descendants = mProvider.onGetSliceDescendants(ACTION_SLICE_URI);
|
||||
@@ -722,4 +749,23 @@ public class SettingsSliceProviderTest {
|
||||
return sSetThreadPolicyCount != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Implements(Theme.class)
|
||||
public static class ShadowTheme {
|
||||
private static boolean sThemeRebased;
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sThemeRebased = false;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void rebase() {
|
||||
sThemeRebased = true;
|
||||
}
|
||||
|
||||
static boolean isThemeRebased() {
|
||||
return sThemeRebased;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,16 +137,19 @@ public class SliceTester {
|
||||
*/
|
||||
public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
|
||||
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
||||
|
||||
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||
final int color = colorItem.getInt();
|
||||
assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
|
||||
|
||||
final SliceAction primaryAction = metadata.getPrimaryAction();
|
||||
|
||||
final IconCompat expectedIcon = IconCompat.createWithResource(context,
|
||||
sliceData.getIconResource());
|
||||
assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
|
||||
final IconCompat icon = primaryAction.getIcon();
|
||||
if (icon == null) {
|
||||
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||
final int color = colorItem.getInt();
|
||||
assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
|
||||
|
||||
} else {
|
||||
final IconCompat expectedIcon = IconCompat.createWithResource(context,
|
||||
sliceData.getIconResource());
|
||||
assertThat(expectedIcon.toString()).isEqualTo(icon.toString());
|
||||
}
|
||||
|
||||
final long sliceTTL = metadata.getExpiry();
|
||||
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
|
||||
|
||||
Reference in New Issue
Block a user