Use small icon in location and vpn settings UI
Fixes: 65182905 Test: rerun tests Change-Id: I18aa5c5bb4c8f573872cda3d003506c4dff5177c
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 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.
|
||||
-->
|
||||
|
||||
<!-- text that appears when the recent app list is empty -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="?android:attr/scrollbarSize"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginTop="6dip"
|
||||
android:layout_marginBottom="6dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -25,12 +27,10 @@ import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
public class AccountTypePreference extends Preference implements OnPreferenceClickListener {
|
||||
public class AccountTypePreference extends AppPreference implements OnPreferenceClickListener {
|
||||
/**
|
||||
* Title of the tile that is shown to the user.
|
||||
* @attr ref android.R.styleable#PreferenceHeader_title
|
||||
|
@@ -16,15 +16,14 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* ProviderPreference is used to display an image to the left of a provider name.
|
||||
* The preference ultimately calls AccountManager.addAccount() for the account type.
|
||||
@@ -35,6 +34,7 @@ public class ProviderPreference extends RestrictedPreference {
|
||||
public ProviderPreference(
|
||||
Context context, String accountType, Drawable icon, CharSequence providerName) {
|
||||
super(context);
|
||||
setUseSmallIcon(true);
|
||||
mAccountType = accountType;
|
||||
setIcon(icon);
|
||||
setPersistent(false);
|
||||
|
@@ -43,9 +43,9 @@ import com.android.settings.applications.InstalledAppDetails;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
import com.android.settingslib.location.RecentLocationApps;
|
||||
|
||||
@@ -211,21 +211,19 @@ public class LocationSettings extends LocationSettingsBase
|
||||
|
||||
List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
|
||||
for (final RecentLocationApps.Request request : recentLocationRequests) {
|
||||
RestrictedPreference pref = new RestrictedPreference(getPrefContext());
|
||||
final AppPreference pref = new AppPreference(getPrefContext());
|
||||
pref.setSummary(request.contentDescription);
|
||||
pref.setIcon(request.icon);
|
||||
pref.setTitle(request.label);
|
||||
pref.setOnPreferenceClickListener(
|
||||
new PackageEntryClickedListener(request.packageName, request.userHandle));
|
||||
recentLocationPrefs.add(pref);
|
||||
|
||||
}
|
||||
if (recentLocationRequests.size() > 0) {
|
||||
addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
|
||||
} else {
|
||||
// If there's no item to display, add a "No recent apps" item.
|
||||
Preference banner = new Preference(getPrefContext());
|
||||
banner.setLayoutResource(R.layout.location_list_no_item);
|
||||
Preference banner = new AppPreference(getPrefContext());
|
||||
banner.setTitle(R.string.location_no_recent_apps);
|
||||
banner.setSelectable(false);
|
||||
mCategoryRecentLocationRequests.addPreference(banner);
|
||||
|
@@ -40,6 +40,8 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@@ -268,7 +270,7 @@ class SettingsInjector {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
Drawable appIcon = pm.getDrawable(info.packageName, info.iconId, null);
|
||||
Drawable icon = pm.getUserBadgedIcon(appIcon, info.mUserHandle);
|
||||
Preference pref = new Preference(prefContext);
|
||||
Preference pref = new AppPreference(prefContext);
|
||||
pref.setTitle(info.title);
|
||||
pref.setSummary(null);
|
||||
pref.setIcon(icon);
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.vpn2;
|
||||
|
||||
import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
@@ -23,7 +25,6 @@ import android.view.View;
|
||||
|
||||
import com.android.internal.net.VpnProfile;
|
||||
import com.android.settings.R;
|
||||
import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
|
||||
|
||||
/**
|
||||
* {@link android.support.v7.preference.Preference} tracks the underlying legacy vpn profile and
|
||||
@@ -35,6 +36,7 @@ public class LegacyVpnPreference extends ManageablePreference {
|
||||
LegacyVpnPreference(Context context) {
|
||||
super(context, null /* attrs */);
|
||||
setIcon(R.drawable.ic_vpn_key);
|
||||
setUseSmallIcon(true);
|
||||
}
|
||||
|
||||
public VpnProfile getProfile() {
|
||||
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.accounts;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ProviderPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseSmallIcon() {
|
||||
final ProviderPreference providerPreference = new ProviderPreference(
|
||||
mContext, "account_type", null /* icon */, "provider_name");
|
||||
final boolean useSmallIcon =
|
||||
ReflectionHelpers.getField(providerPreference, "mUseSmallIcon");
|
||||
assertThat(useSmallIcon).isTrue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user