From b95ff4ec319499236c83b38a8a559d6f02d9b418 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 7 Dec 2016 15:29:43 -0800 Subject: [PATCH] Use a single layout for CreateShortcut activity. The old layout is inherited from LauncherActivity, which uses a inconsistent theme and UI between phone and tablet. It's more consistent to just use a single layout that matches setting theme. Fixes: 32220535 Test: runtest --path packages/apps/Settings/tests/app/src/com/android/settings/CreateShortcutTest.java Change-Id: I769d1404c82c2057bf021e4cf557e7cf397d92a7 --- res/layout/activity_list.xml | 36 +++++++++++++++ res/values/strings.xml | 2 + src/com/android/settings/CreateShortcut.java | 5 +++ .../android/settings/CreateShortcutTest.java | 44 +++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 res/layout/activity_list.xml create mode 100644 tests/app/src/com/android/settings/CreateShortcutTest.java diff --git a/res/layout/activity_list.xml b/res/layout/activity_list.xml new file mode 100644 index 00000000000..ca9e12b7fb3 --- /dev/null +++ b/res/layout/activity_list.xml @@ -0,0 +1,36 @@ + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 75449b20779..4d872b1b278 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -612,6 +612,8 @@ Settings Settings shortcut + + No matching activities found. Airplane mode diff --git a/src/com/android/settings/CreateShortcut.java b/src/com/android/settings/CreateShortcut.java index 73177384325..7cd6748a6d9 100644 --- a/src/com/android/settings/CreateShortcut.java +++ b/src/com/android/settings/CreateShortcut.java @@ -85,6 +85,11 @@ public class CreateShortcut extends LauncherActivity { return false; } + @Override + protected void onSetContentView() { + setContentView(R.layout.activity_list); + } + /** * Perform query on package manager for list items. The default * implementation queries for activities. diff --git a/tests/app/src/com/android/settings/CreateShortcutTest.java b/tests/app/src/com/android/settings/CreateShortcutTest.java new file mode 100644 index 00000000000..9481a64ed04 --- /dev/null +++ b/tests/app/src/com/android/settings/CreateShortcutTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 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; + +import android.app.Instrumentation; +import android.content.Intent; +import android.support.test.InstrumentationRegistry; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist; +import static android.support.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@SmallTest +public class CreateShortcutTest { + + @Test + public void test_layoutDoesNotHaveCancelButton() { + Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + instrumentation.startActivitySync(new Intent(Intent.ACTION_CREATE_SHORTCUT) + .setClassName(instrumentation.getTargetContext(), + CreateShortcut.class.getName())); + onView(withText(R.string.cancel)).check(doesNotExist()); + } +}