From 015a50bef99a23a8c795486b99021a5784d65d64 Mon Sep 17 00:00:00 2001 From: Doris Ling Date: Wed, 15 Feb 2017 15:42:30 -0800 Subject: [PATCH] Modify text in Apps & notifications settings. - in Settings->Apps & notifications->Apps->[select app], update the header summary to installation status, and move the version text to the bottom of the page. - updatd preference title from Apps to App info - update preference title from Notifications to App notifications Bug: 34977561 Test: make RunSettingsRoboTests Change-Id: I97e9b81c739fb99eaca2cf45fb11f208ad6cd9ca --- res/values/strings.xml | 6 +- res/xml/installed_app_details_ia.xml | 5 ++ .../applications/InstalledAppDetails.java | 14 ++++- .../applications/InstalledAppDetailsTest.java | 63 +++++++++++++++++++ .../search/DatabaseIndexingManagerTest.java | 10 +-- 5 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 852e81d94f1..1ad398dc776 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3322,7 +3322,7 @@ Manage and remove installed apps - Apps + App info Manage apps, set up quick launch shortcuts @@ -3473,6 +3473,8 @@ Disabled Not installed for this user + + Installed No apps. @@ -6289,7 +6291,7 @@ Profile notifications - Notifications + App notifications Importance diff --git a/res/xml/installed_app_details_ia.xml b/res/xml/installed_app_details_ia.xml index e72384a0bf1..38ce41a004f 100644 --- a/res/xml/installed_app_details_ia.xml +++ b/res/xml/installed_app_details_ia.xml @@ -58,4 +58,9 @@ android:enabled="false" android:selectable="true"/> + + \ No newline at end of file diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 873c5fd1230..5b962441aff 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -151,6 +151,7 @@ public class InstalledAppDetails extends AppInfoBase private static final String KEY_LAUNCH = "preferred_settings"; private static final String KEY_BATTERY = "battery"; private static final String KEY_MEMORY = "memory"; + private static final String KEY_VERSION = "app_version"; private static final String NOTIFICATION_TUNER_SETTING = "show_importance_slider"; @@ -171,6 +172,7 @@ public class InstalledAppDetails extends AppInfoBase private Preference mLaunchPreference; private Preference mDataPreference; private Preference mMemoryPreference; + private Preference mVersionPreference; private boolean mDisableAfterUninstall; @@ -416,6 +418,7 @@ public class InstalledAppDetails extends AppInfoBase mBatteryPreference.setOnPreferenceClickListener(this); mMemoryPreference = findPreference(KEY_MEMORY); mMemoryPreference.setOnPreferenceClickListener(this); + mVersionPreference = findPreference(KEY_VERSION); mLaunchPreference = findPreference(KEY_LAUNCH); if (mAppEntry != null && mAppEntry.info != null) { @@ -559,14 +562,23 @@ public class InstalledAppDetails extends AppInfoBase .newAppHeaderController(this, appSnippet) .setLabel(mAppEntry) .setIcon(mAppEntry) - .setSummary(pkgInfo) + .setSummary(getString(getInstallationStatus(mAppEntry.info))) .done(false /* rebindActions */); + mVersionPreference.setSummary(getString(R.string.version_text, pkgInfo.versionName)); } else { setupAppSnippet(appSnippet, mAppEntry.label, mAppEntry.icon, pkgInfo != null ? pkgInfo.versionName : null); } } + @VisibleForTesting + int getInstallationStatus(ApplicationInfo info) { + if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) { + return R.string.not_installed; + } + return info.enabled ? R.string.installed : R.string.disabled; + } + private boolean signaturesMatch(String pkg1, String pkg2) { if (pkg1 != null && pkg2 != null) { try { diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java new file mode 100644 index 00000000000..dc370791c55 --- /dev/null +++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java @@ -0,0 +1,63 @@ +/* + * 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.applications; + +import android.content.pm.ApplicationInfo; + +import com.android.settings.R; +import com.android.settings.SettingsRobolectricTestRunner; +import com.android.settings.TestConfig; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.annotation.Config; + +import static com.google.common.truth.Truth.assertThat; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public final class InstalledAppDetailsTest { + + @Test + public void getInstallationStatus_notInstalled_shouldReturnUninstalled() { + final InstalledAppDetails mAppDetail = new InstalledAppDetails(); + + assertThat(mAppDetail.getInstallationStatus(new ApplicationInfo())) + .isEqualTo(R.string.not_installed); + } + + @Test + public void getInstallationStatus_enabled_shouldReturnInstalled() { + final InstalledAppDetails mAppDetail = new InstalledAppDetails(); + final ApplicationInfo info = new ApplicationInfo(); + info.flags = ApplicationInfo.FLAG_INSTALLED; + info.enabled = true; + + assertThat(mAppDetail.getInstallationStatus(info)).isEqualTo(R.string.installed); + } + + @Test + public void getInstallationStatus_disabled_shouldReturnDisabled() { + final InstalledAppDetails mAppDetail = new InstalledAppDetails(); + final ApplicationInfo info = new ApplicationInfo(); + info.flags = ApplicationInfo.FLAG_INSTALLED; + info.enabled = false; + + assertThat(mAppDetail.getInstallationStatus(info)).isEqualTo(R.string.disabled); + } + +} diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java index 2e13393748d..7f1e9408418 100644 --- a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java +++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java @@ -241,9 +241,9 @@ public class DatabaseIndexingManagerTest { // Data Rank assertThat(cursor.getInt(1)).isEqualTo(rank); // Data Title - assertThat(cursor.getString(2)).isEqualTo("Apps"); + assertThat(cursor.getString(2)).isEqualTo("App info"); // Normalized Title - assertThat(cursor.getString(3)).isEqualTo("apps"); + assertThat(cursor.getString(3)).isEqualTo("app info"); // Summary On assertThat(cursor.getString(4)).isEqualTo("Manage apps, set up quick launch shortcuts"); // Summary On Normalized @@ -257,7 +257,7 @@ public class DatabaseIndexingManagerTest { // Keywords assertThat(cursor.getString(9)).isEmpty(); // Screen Title - assertThat(cursor.getString(10)).isEqualTo("Apps"); + assertThat(cursor.getString(10)).isEqualTo("App info"); // Class Name assertThat(cursor.getString(11)).isEqualTo(className); // Icon @@ -395,7 +395,7 @@ public class DatabaseIndexingManagerTest { // Keywords assertThat(cursor.getString(9)).isEmpty(); // Screen Title - assertThat(cursor.getString(10)).isEqualTo("Apps"); + assertThat(cursor.getString(10)).isEqualTo("App info"); // Class Name assertThat(cursor.getString(11)).isEqualTo(className); // Icon @@ -450,7 +450,7 @@ public class DatabaseIndexingManagerTest { // Keywords assertThat(cursor.getString(9)).isEmpty(); // Screen Title - assertThat(cursor.getString(10)).isEqualTo("Apps"); + assertThat(cursor.getString(10)).isEqualTo("App info"); // Class Name assertThat(cursor.getString(11)).isEqualTo(className); // Icon