Merge "Merge "Use support feature provider to provide intro url." into oc-dr1-dev am: bdc0816982" into oc-dr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
afa34b1cc4
@@ -8963,7 +8963,4 @@
|
||||
|
||||
<!-- The divider symbol between different parts of the notification header including spaces. not translatable [CHAR LIMIT=3] -->
|
||||
<string name="notification_header_divider_symbol_with_spaces" translatable="false">" • "</string>
|
||||
|
||||
<!-- url for new device suggestion -->
|
||||
<string name="new_device_suggestion_intro_url" translatable="false"></string>
|
||||
</resources>
|
||||
|
@@ -24,8 +24,8 @@ import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.support.SupportPhone;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -137,6 +137,7 @@ public interface SupportFeatureProvider {
|
||||
|
||||
/**
|
||||
* Checks if support v2 is enabled for this device.
|
||||
*
|
||||
* @return a boolean indicating if support v2 is enabled.
|
||||
*/
|
||||
boolean isSupportV2Enabled();
|
||||
@@ -166,4 +167,9 @@ public interface SupportFeatureProvider {
|
||||
* launches the fragment that displays the system information being sent to support agents.
|
||||
*/
|
||||
void launchSystemInfoFragment(Bundle args, FragmentManager manager);
|
||||
|
||||
/**
|
||||
* Returns a url with information to introduce user to new device.
|
||||
*/
|
||||
String getNewDeviceIntroUrl(Context context);
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.overlay.SupportFeatureProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -107,7 +107,12 @@ public class NewDeviceIntroSuggestionActivity extends Activity {
|
||||
|
||||
@VisibleForTesting
|
||||
static Intent getLaunchIntent(Context context) {
|
||||
final String url = context.getString(R.string.new_device_suggestion_intro_url);
|
||||
final SupportFeatureProvider supportProvider = FeatureFactory.getFactory(context)
|
||||
.getSupportFeatureProvider(context);
|
||||
if (supportProvider == null) {
|
||||
return null;
|
||||
}
|
||||
final String url = supportProvider.getNewDeviceIntroUrl(context);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- url for new device suggestion -->
|
||||
<string name="new_device_suggestion_intro_url" translatable="false">http://www.com.android.settings.test.com</string>
|
||||
</resources>
|
@@ -22,7 +22,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -82,32 +81,27 @@ public class NewDeviceIntroSuggestionActivityTest {
|
||||
|
||||
@Test
|
||||
public void isSuggestionComplete_noUrl_shouldReturnTrue() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.isEqualTo("");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn(null);
|
||||
assertThat(isSuggestionComplete(mContext))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
// Use a non-default resource qualifier to load the test string in
|
||||
// res/values-mcc999/strings.xml.
|
||||
@Config(qualifiers = "mcc999")
|
||||
@Test
|
||||
public void isSuggestionComplete_alreadyLaunchedBefore_shouldReturnTrue() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.startsWith("http");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn("https://com.android.settings");
|
||||
|
||||
getSharedPreferences().edit().putBoolean(PREF_KEY_SUGGGESTION_COMPLETE, true).commit();
|
||||
|
||||
assertThat(isSuggestionComplete(mContext))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
// Use a non-default resource qualifier to load the test string in
|
||||
// res/values-mcc999/strings.xml.
|
||||
@Config(qualifiers = "mcc999")
|
||||
@Test
|
||||
public void isSuggestionComplete_notExpiredAndCanOpenUrlInBrowser_shouldReturnFalse() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.startsWith("http");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn("https://com.android.settings");
|
||||
|
||||
final Intent intent = NewDeviceIntroSuggestionActivity.getLaunchIntent(mContext);
|
||||
mRobolectricPackageManager.addResolveInfoForIntent(intent, new ResolveInfo());
|
||||
|
Reference in New Issue
Block a user