diff options
author | Fyodor Kupolov <fkupolov@google.com> | 2015-05-08 15:54:38 -0700 |
---|---|---|
committer | Fyodor Kupolov <fkupolov@google.com> | 2015-05-19 16:44:13 -0700 |
commit | a7a7bfe59fc03ffb00d2f2f0fe0fb011834bf22e (patch) | |
tree | cae4668709ce4e55061c13671213499854ecd748 /src/com/android/settings/location | |
parent | c80084e55afeaeebfb0546c0112fb2e666e35700 (diff) | |
download | packages_apps_Settings-a7a7bfe59fc03ffb00d2f2f0fe0fb011834bf22e.zip packages_apps_Settings-a7a7bfe59fc03ffb00d2f2f0fe0fb011834bf22e.tar.gz packages_apps_Settings-a7a7bfe59fc03ffb00d2f2f0fe0fb011834bf22e.tar.bz2 |
Use DimmableIconPreference for Add user action
Moved DimmableIconPreference from location to the root package since it is
now used in several places.
Add user action now uses DimmableIconPreference. Added a new summary string,
which is displayed when no more users can be added.
Bug: 20892920
Change-Id: I00b00f80ba8933a00a2de85777b9f7e55d03c31b
Diffstat (limited to 'src/com/android/settings/location')
3 files changed, 4 insertions, 83 deletions
diff --git a/src/com/android/settings/location/DimmableIconPreference.java b/src/com/android/settings/location/DimmableIconPreference.java deleted file mode 100644 index f785992..0000000 --- a/src/com/android/settings/location/DimmableIconPreference.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2014 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.location; - -import android.annotation.Nullable; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.preference.Preference; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.view.View; -import android.widget.TextView; - -/** - * A preference item that can dim the icon when it's disabled, either directly or because its parent - * is disabled. - */ -public class DimmableIconPreference extends Preference { - private static final int ICON_ALPHA_ENABLED = 255; - private static final int ICON_ALPHA_DISABLED = 102; - - private final CharSequence mContentDescription; - - public DimmableIconPreference(Context context, AttributeSet attrs, int defStyle, - @Nullable CharSequence contentDescription) { - super(context, attrs, defStyle); - mContentDescription = contentDescription; - } - - public DimmableIconPreference(Context context, AttributeSet attrs, - @Nullable CharSequence contentDescription) { - super(context, attrs); - mContentDescription = contentDescription; - } - - public DimmableIconPreference(Context context, @Nullable CharSequence contentDescription) { - super(context); - mContentDescription = contentDescription; - } - - private void dimIcon(boolean dimmed) { - Drawable icon = getIcon(); - if (icon != null) { - icon.mutate().setAlpha(dimmed ? ICON_ALPHA_DISABLED : ICON_ALPHA_ENABLED); - setIcon(icon); - } - } - - @Override - public void onParentChanged(Preference parent, boolean disableChild) { - dimIcon(disableChild); - super.onParentChanged(parent, disableChild); - } - - @Override - public void setEnabled(boolean enabled) { - dimIcon(!enabled); - super.setEnabled(enabled); - } - - @Override - protected void onBindView(View view) { - super.onBindView(view); - if (!TextUtils.isEmpty(mContentDescription)) { - final TextView titleView = (TextView) view.findViewById(android.R.id.title); - titleView.setContentDescription(mContentDescription); - } - } -} diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java index d7b62e7..66bdda5 100644 --- a/src/com/android/settings/location/RecentLocationApps.java +++ b/src/com/android/settings/location/RecentLocationApps.java @@ -31,6 +31,8 @@ import android.os.UserHandle; import android.os.UserManager; import android.preference.Preference; import android.util.Log; + +import com.android.settings.DimmableIconPreference; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.applications.InstalledAppDetails; diff --git a/src/com/android/settings/location/SettingsInjector.java b/src/com/android/settings/location/SettingsInjector.java index ef6117b..283430e 100644 --- a/src/com/android/settings/location/SettingsInjector.java +++ b/src/com/android/settings/location/SettingsInjector.java @@ -39,6 +39,8 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Xml; +import com.android.settings.DimmableIconPreference; + import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; |