Merge "Revert "Use location access for recent location apps."" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb9f578c9b
@@ -22,10 +22,16 @@
|
|||||||
settings:keywords="@string/keywords_location">
|
settings:keywords="@string/keywords_location">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="recent_location_access"
|
android:key="recent_location_requests"
|
||||||
android:title="@string/location_category_recent_location_access"
|
android:title="@string/location_category_recent_location_requests"
|
||||||
settings:controller=
|
settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
|
||||||
"com.android.settings.location.RecentLocationAccessPreferenceController"/>
|
|
||||||
|
<Preference
|
||||||
|
android:key="recent_location_requests_see_all_button"
|
||||||
|
android:title="@string/location_recent_location_requests_see_all"
|
||||||
|
android:icon="@drawable/ic_chevron_right_24dp"
|
||||||
|
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
|
||||||
|
settings:searchable="false"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="location_advanced_settings"
|
android:key="location_advanced_settings"
|
||||||
|
@@ -25,8 +25,14 @@
|
|||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="recent_location_requests"
|
android:key="recent_location_requests"
|
||||||
android:title="@string/location_category_recent_location_requests"
|
android:title="@string/location_category_recent_location_requests"
|
||||||
settings:controller=
|
settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
|
||||||
"com.android.settings.location.RecentLocationAccessPreferenceController"/>
|
|
||||||
|
<Preference
|
||||||
|
android:key="recent_location_requests_see_all_button"
|
||||||
|
android:title="@string/location_recent_location_requests_see_all"
|
||||||
|
android:icon="@drawable/ic_chevron_right_24dp"
|
||||||
|
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
|
||||||
|
settings:searchable="false"/>
|
||||||
|
|
||||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||||
<Preference
|
<Preference
|
||||||
|
@@ -25,8 +25,16 @@
|
|||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="recent_location_requests"
|
android:key="recent_location_requests"
|
||||||
android:title="@string/location_category_recent_location_requests"
|
android:title="@string/location_category_recent_location_requests"
|
||||||
settings:controller=
|
settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
|
||||||
"com.android.settings.location.RecentLocationAccessPreferenceController"/>
|
|
||||||
|
<Preference
|
||||||
|
android:key="recent_location_requests_see_all_button"
|
||||||
|
android:title="@string/location_recent_location_requests_see_all"
|
||||||
|
android:icon="@drawable/ic_chevron_right_24dp"
|
||||||
|
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
|
||||||
|
settings:controller="com.android.settings.core.WorkPreferenceController"
|
||||||
|
settings:forWork="true"
|
||||||
|
settings:searchable="false"/>
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="managed_profile_location_switch"
|
android:key="managed_profile_location_switch"
|
||||||
|
@@ -82,7 +82,7 @@ public class LocationSettings extends DashboardFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
use(AppLocationPermissionPreferenceController.class).init(this);
|
use(AppLocationPermissionPreferenceController.class).init(this);
|
||||||
use(RecentLocationAccessPreferenceController.class).init(this);
|
use(RecentLocationRequestPreferenceController.class).init(this);
|
||||||
use(LocationServicePreferenceController.class).init(this);
|
use(LocationServicePreferenceController.class).init(this);
|
||||||
use(LocationFooterPreferenceController.class).init(this);
|
use(LocationFooterPreferenceController.class).init(this);
|
||||||
use(LocationForWorkPreferenceController.class).init(this);
|
use(LocationForWorkPreferenceController.class).init(this);
|
||||||
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location Setting page for managed profile.
|
* Location Setting page for managed profile.
|
||||||
@@ -53,9 +54,11 @@ public class LocationWorkProfileSettings extends DashboardFragment {
|
|||||||
use(LocationFooterPreferenceController.class).init(this);
|
use(LocationFooterPreferenceController.class).init(this);
|
||||||
use(LocationForWorkPreferenceController.class).init(this);
|
use(LocationForWorkPreferenceController.class).init(this);
|
||||||
|
|
||||||
final RecentLocationAccessPreferenceController controller =
|
final int profileType = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE);
|
||||||
use(RecentLocationAccessPreferenceController.class);
|
final RecentLocationRequestPreferenceController controller = use(
|
||||||
|
RecentLocationRequestPreferenceController.class);
|
||||||
controller.init(this);
|
controller.init(this);
|
||||||
|
controller.setProfileType(profileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -13,141 +13,114 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.location;
|
package com.android.settings.location;
|
||||||
|
|
||||||
import static android.Manifest.permission_group.LOCATION;
|
import static java.util.concurrent.TimeUnit.DAYS;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.UserHandle;
|
import android.icu.text.RelativeDateTimeFormatter;
|
||||||
import android.os.UserManager;
|
import android.provider.DeviceConfig;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.location.RecentLocationAccesses;
|
import com.android.settingslib.location.RecentLocationAccesses;
|
||||||
import com.android.settingslib.widget.AppPreference;
|
import com.android.settingslib.utils.StringUtil;
|
||||||
|
import com.android.settingslib.widget.AppEntitiesHeaderController;
|
||||||
|
import com.android.settingslib.widget.AppEntityInfo;
|
||||||
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
public class RecentLocationAccessPreferenceController extends AbstractPreferenceController
|
||||||
* Preference controller that handles the display of apps that access locations.
|
implements PreferenceControllerMixin {
|
||||||
*/
|
/** Key for the recent location apps dashboard */
|
||||||
public class RecentLocationAccessPreferenceController extends LocationBasePreferenceController {
|
private static final String KEY_APPS_DASHBOARD = "apps_dashboard";
|
||||||
@VisibleForTesting
|
private final RecentLocationAccesses mRecentLocationAccesses;
|
||||||
RecentLocationAccesses mRecentLocationApps;
|
private AppEntitiesHeaderController mController;
|
||||||
private PreferenceCategory mCategoryRecentLocationRequests;
|
private static final int MAXIMUM_APP_COUNT = 3;
|
||||||
private int mType = ProfileSelectFragment.ProfileType.ALL;
|
|
||||||
|
|
||||||
private static class PackageEntryClickedListener implements
|
public RecentLocationAccessPreferenceController(Context context) {
|
||||||
Preference.OnPreferenceClickListener {
|
this(context, new RecentLocationAccesses(context));
|
||||||
private final Context mContext;
|
|
||||||
private final String mPackage;
|
|
||||||
private final UserHandle mUserHandle;
|
|
||||||
|
|
||||||
PackageEntryClickedListener(Context context, String packageName,
|
|
||||||
UserHandle userHandle) {
|
|
||||||
mContext = context;
|
|
||||||
mPackage = packageName;
|
|
||||||
mUserHandle = userHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
|
|
||||||
intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, LOCATION);
|
|
||||||
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackage);
|
|
||||||
intent.putExtra(Intent.EXTRA_USER, mUserHandle);
|
|
||||||
mContext.startActivity(intent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecentLocationAccessPreferenceController(Context context, String key) {
|
|
||||||
this(context, key, new RecentLocationAccesses(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public RecentLocationAccessPreferenceController(Context context, String key,
|
RecentLocationAccessPreferenceController(Context context,
|
||||||
RecentLocationAccesses recentLocationApps) {
|
RecentLocationAccesses recentAccesses) {
|
||||||
super(context, key);
|
super(context);
|
||||||
mRecentLocationApps = recentLocationApps;
|
mRecentLocationAccesses = recentAccesses;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return KEY_APPS_DASHBOARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return Boolean.parseBoolean(
|
||||||
|
DeviceConfig.getProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_PERMISSIONS_HUB_ENABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mCategoryRecentLocationRequests = screen.findPreference(getPreferenceKey());
|
final LayoutPreference preference = screen.findPreference(KEY_APPS_DASHBOARD);
|
||||||
final Context prefContext = mCategoryRecentLocationRequests.getContext();
|
final View view = preference.findViewById(R.id.app_entities_header);
|
||||||
final List<RecentLocationAccesses.Access> recentLocationAccesses = new ArrayList<>();
|
mController = AppEntitiesHeaderController.newInstance(mContext, view)
|
||||||
final UserManager userManager = UserManager.get(mContext);
|
.setHeaderTitleRes(R.string.location_category_recent_location_access)
|
||||||
for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted()) {
|
.setHeaderDetailsRes(R.string.location_recent_location_access_view_details)
|
||||||
if (isRequestMatchesProfileType(userManager, access, mType)) {
|
.setHeaderEmptyRes(R.string.location_no_recent_accesses)
|
||||||
recentLocationAccesses.add(access);
|
.setHeaderDetailsClickListener((View v) -> {
|
||||||
}
|
final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE);
|
||||||
}
|
intent.putExtra(Intent.EXTRA_PERMISSION_NAME,
|
||||||
|
Manifest.permission.ACCESS_FINE_LOCATION);
|
||||||
if (recentLocationAccesses.size() > 0) {
|
intent.putExtra(Intent.EXTRA_DURATION_MILLIS, DAYS.toMillis(1));
|
||||||
// Add preferences to container in original order (already sorted by recency).
|
mContext.startActivity(intent);
|
||||||
for (RecentLocationAccesses.Access access : recentLocationAccesses) {
|
});
|
||||||
mCategoryRecentLocationRequests.addPreference(
|
|
||||||
createAppPreference(prefContext, access, mFragment));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If there's no item to display, add a "No recent apps" item.
|
|
||||||
final Preference banner = new AppPreference(prefContext);
|
|
||||||
banner.setTitle(R.string.location_no_recent_accesses);
|
|
||||||
banner.setSelectable(false);
|
|
||||||
mCategoryRecentLocationRequests.addPreference(banner);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationModeChanged(int mode, boolean restricted) {
|
public void updateState(Preference preference) {
|
||||||
mCategoryRecentLocationRequests.setEnabled(mLocationEnabler.isEnabled(mode));
|
updateRecentApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void updateRecentApps() {
|
||||||
* Initialize {@link ProfileSelectFragment.ProfileType} of the controller
|
final List<RecentLocationAccesses.Access> recentLocationAccesses =
|
||||||
*
|
mRecentLocationAccesses.getAppListSorted();
|
||||||
* @param type {@link ProfileSelectFragment.ProfileType} of the controller.
|
if (recentLocationAccesses.size() > 0) {
|
||||||
*/
|
// Display the top 3 preferences to container in original order.
|
||||||
public void setProfileType(@ProfileSelectFragment.ProfileType int type) {
|
int i = 0;
|
||||||
mType = type;
|
for (; i < Math.min(recentLocationAccesses.size(), MAXIMUM_APP_COUNT); i++) {
|
||||||
}
|
final RecentLocationAccesses.Access access = recentLocationAccesses.get(i);
|
||||||
|
final AppEntityInfo appEntityInfo = new AppEntityInfo.Builder()
|
||||||
/**
|
.setIcon(access.icon)
|
||||||
* Create a {@link AppPreference}
|
.setTitle(access.label)
|
||||||
*/
|
.setSummary(StringUtil.formatRelativeTime(mContext,
|
||||||
public static AppPreference createAppPreference(Context prefContext,
|
System.currentTimeMillis() - access.accessFinishTime, false,
|
||||||
RecentLocationAccesses.Access access, DashboardFragment fragment) {
|
RelativeDateTimeFormatter.Style.SHORT))
|
||||||
final AppPreference pref = new AppPreference(prefContext);
|
.setOnClickListener((v) -> {
|
||||||
pref.setIcon(access.icon);
|
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
|
||||||
pref.setTitle(access.label);
|
intent.putExtra(Intent.EXTRA_PERMISSION_NAME,
|
||||||
pref.setOnPreferenceClickListener(new PackageEntryClickedListener(
|
Manifest.permission.ACCESS_FINE_LOCATION);
|
||||||
fragment.getContext(), access.packageName, access.userHandle));
|
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, access.packageName);
|
||||||
return pref;
|
intent.putExtra(Intent.EXTRA_USER, access.userHandle);
|
||||||
}
|
mContext.startActivity(intent);
|
||||||
|
})
|
||||||
/**
|
.build();
|
||||||
* Return if the {@link RecentLocationAccesses.Access} matches current UI
|
mController.setAppEntity(i, appEntityInfo);
|
||||||
* {@ProfileSelectFragment.ProfileType}
|
}
|
||||||
*/
|
for (; i < MAXIMUM_APP_COUNT; i++) {
|
||||||
public static boolean isRequestMatchesProfileType(UserManager userManager,
|
mController.removeAppEntity(i);
|
||||||
RecentLocationAccesses.Access access, @ProfileSelectFragment.ProfileType int type) {
|
}
|
||||||
|
|
||||||
final boolean isWorkProfile = userManager.isManagedProfile(
|
|
||||||
access.userHandle.getIdentifier());
|
|
||||||
if (isWorkProfile && (type & ProfileSelectFragment.ProfileType.WORK) != 0) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (!isWorkProfile && (type & ProfileSelectFragment.ProfileType.PERSONAL) != 0) {
|
mController.apply();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,17 +24,19 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||||
import com.android.settingslib.location.RecentLocationAccesses;
|
import com.android.settingslib.location.RecentLocationAccesses;
|
||||||
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -53,14 +55,11 @@ import java.util.List;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowDeviceConfig.class})
|
@Config(shadows = {ShadowDeviceConfig.class})
|
||||||
public class RecentLocationAccessPreferenceControllerTest {
|
public class RecentLocationAccessPreferenceControllerTest {
|
||||||
private static final String PREFERENCE_KEY = "test_preference_key";
|
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceCategory mLayoutPreference;
|
private LayoutPreference mLayoutPreference;
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
|
||||||
@Mock
|
|
||||||
private RecentLocationAccesses mRecentLocationApps;
|
private RecentLocationAccesses mRecentLocationApps;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -72,16 +71,15 @@ public class RecentLocationAccessPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mController = spy(
|
mController = spy(
|
||||||
new RecentLocationAccessPreferenceController(mContext, PREFERENCE_KEY,
|
new RecentLocationAccessPreferenceController(mContext, mRecentLocationApps));
|
||||||
mRecentLocationApps));
|
|
||||||
mController.init(mDashboardFragment);
|
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
mAppEntitiesHeaderView = LayoutInflater.from(mContext).inflate(
|
mAppEntitiesHeaderView = LayoutInflater.from(mContext).inflate(
|
||||||
R.layout.app_entities_header, null /* root */);
|
R.layout.app_entities_header, null /* root */);
|
||||||
when(mScreen.findPreference(key)).thenReturn(mLayoutPreference);
|
when(mScreen.findPreference(key)).thenReturn(mLayoutPreference);
|
||||||
when(mLayoutPreference.getKey()).thenReturn(key);
|
when(mLayoutPreference.getKey()).thenReturn(key);
|
||||||
when(mLayoutPreference.getContext()).thenReturn(mContext);
|
when(mLayoutPreference.getContext()).thenReturn(mContext);
|
||||||
when(mDashboardFragment.getContext()).thenReturn(mContext);
|
when(mLayoutPreference.findViewById(R.id.app_entities_header)).thenReturn(
|
||||||
|
mAppEntitiesHeaderView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -90,7 +88,16 @@ public class RecentLocationAccessPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_shouldReturnTrue() {
|
public void isAvailable_permissionHubNotSet_shouldReturnFalse() {
|
||||||
|
// We have not yet set the property to show the Permissions Hub.
|
||||||
|
assertThat(mController.isAvailable()).isEqualTo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_permissionHubEnabled_shouldReturnTrue() {
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isEqualTo(true);
|
assertThat(mController.isAvailable()).isEqualTo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +118,39 @@ public class RecentLocationAccessPreferenceControllerTest {
|
|||||||
assertThat(details.hasOnClickListeners()).isTrue();
|
assertThat(details.hasOnClickListeners()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_whenAppListMoreThanThree_shouldDisplayTopThreeApps() {
|
||||||
|
final List<RecentLocationAccesses.Access> accesses = createMockAccesses(6);
|
||||||
|
doReturn(accesses).when(mRecentLocationApps).getAppListSorted();
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
mController.updateState(mLayoutPreference);
|
||||||
|
|
||||||
|
// The widget can display the top 3 apps from the list when there're more than 3.
|
||||||
|
final View app1View = mAppEntitiesHeaderView.findViewById(R.id.app1_view);
|
||||||
|
final ImageView appIconView1 = app1View.findViewById(R.id.app_icon);
|
||||||
|
final TextView appTitle1 = app1View.findViewById(R.id.app_title);
|
||||||
|
|
||||||
|
assertThat(app1View.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(appIconView1.getDrawable()).isNotNull();
|
||||||
|
assertThat(appTitle1.getText()).isEqualTo("appTitle0");
|
||||||
|
|
||||||
|
final View app2View = mAppEntitiesHeaderView.findViewById(R.id.app2_view);
|
||||||
|
final ImageView appIconView2 = app2View.findViewById(R.id.app_icon);
|
||||||
|
final TextView appTitle2 = app2View.findViewById(R.id.app_title);
|
||||||
|
|
||||||
|
assertThat(app2View.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(appIconView2.getDrawable()).isNotNull();
|
||||||
|
assertThat(appTitle2.getText()).isEqualTo("appTitle1");
|
||||||
|
|
||||||
|
final View app3View = mAppEntitiesHeaderView.findViewById(R.id.app3_view);
|
||||||
|
final ImageView appIconView3 = app3View.findViewById(R.id.app_icon);
|
||||||
|
final TextView appTitle3 = app3View.findViewById(R.id.app_title);
|
||||||
|
|
||||||
|
assertThat(app3View.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(appIconView3.getDrawable()).isNotNull();
|
||||||
|
assertThat(appTitle3.getText()).isEqualTo("appTitle2");
|
||||||
|
}
|
||||||
|
|
||||||
private List<RecentLocationAccesses.Access> createMockAccesses(int count) {
|
private List<RecentLocationAccesses.Access> createMockAccesses(int count) {
|
||||||
final List<RecentLocationAccesses.Access> accesses = new ArrayList<>();
|
final List<RecentLocationAccesses.Access> accesses = new ArrayList<>();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
Reference in New Issue
Block a user