Merge "Add setting suggestion for style" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1d1f1b321e
@@ -31,6 +31,7 @@ import com.android.settings.notification.ZenOnboardingActivity;
|
||||
import com.android.settings.notification.ZenSuggestionActivity;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.ScreenLockSuggestionActivity;
|
||||
import com.android.settings.wallpaper.StyleSuggestionActivity;
|
||||
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
|
||||
import com.android.settings.wifi.calling.WifiCallingSuggestionActivity;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -62,6 +63,8 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
final String className = component.getClassName();
|
||||
if (className.equals(WallpaperSuggestionActivity.class.getName())) {
|
||||
return WallpaperSuggestionActivity.isSuggestionComplete(context);
|
||||
} else if (className.equals(StyleSuggestionActivity.class.getName())) {
|
||||
return StyleSuggestionActivity.isSuggestionComplete(context);
|
||||
} else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
|
||||
return FingerprintSuggestionActivity.isSuggestionComplete(context);
|
||||
} else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
public class StyleSuggestionActivity extends StyleSuggestionActivityBase {
|
||||
|
||||
@VisibleForTesting
|
||||
public static boolean isSuggestionComplete(Context context) {
|
||||
if (!isWallpaperServiceEnabled(context)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String currentTheme = Settings.Secure.getStringForUser(context.getContentResolver(),
|
||||
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, context.getUserId());
|
||||
if (TextUtils.isEmpty(currentTheme)) {
|
||||
// Empty value means the user has not visited the styles tab yet
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.wallpaper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.display.WallpaperPreferenceController;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
public abstract class StyleSuggestionActivityBase extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final PackageManager pm = getPackageManager();
|
||||
final Intent intent = new Intent()
|
||||
.setComponent(new WallpaperPreferenceController(this, "dummy key")
|
||||
.getComponentName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
|
||||
// passing the necessary extra to next page
|
||||
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
|
||||
|
||||
addExtras(intent);
|
||||
|
||||
if (pm.resolveActivity(intent, 0) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
startFallbackSuggestion();
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any extras to the intent before launching the wallpaper activity
|
||||
* @param intent
|
||||
*/
|
||||
protected void addExtras(Intent intent) { }
|
||||
|
||||
@VisibleForTesting
|
||||
void startFallbackSuggestion() {
|
||||
// fall back to default wallpaper picker
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(WallpaperTypeSettings.class.getName())
|
||||
.setTitleRes(R.string.wallpaper_suggestion_title)
|
||||
.setSourceMetricsCategory(SettingsEnums.DASHBOARD_SUMMARY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
|
||||
.launch();
|
||||
}
|
||||
|
||||
protected static boolean isWallpaperServiceEnabled(Context context) {
|
||||
return context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_enableWallpaperService);
|
||||
}
|
||||
}
|
@@ -16,63 +16,31 @@
|
||||
|
||||
package com.android.settings.wallpaper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.WallpaperManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.display.WallpaperPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class WallpaperSuggestionActivity extends Activity implements Indexable {
|
||||
public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase implements Indexable {
|
||||
|
||||
private static final String WALLPAPER_FLAVOR_EXTRA = "com.android.launcher3.WALLPAPER_FLAVOR";
|
||||
private static final String WALLPAPER_FOCUS = "focus_wallpaper";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final PackageManager pm = getPackageManager();
|
||||
final Intent intent = new Intent()
|
||||
.setComponent(new WallpaperPreferenceController(this, "dummy key")
|
||||
.getComponentName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
|
||||
// passing the necessary extra to next page
|
||||
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
|
||||
|
||||
if (pm.resolveActivity(intent, 0) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
startFallbackSuggestion();
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void startFallbackSuggestion() {
|
||||
// fall back to default wallpaper picker
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(WallpaperTypeSettings.class.getName())
|
||||
.setTitleRes(R.string.wallpaper_suggestion_title)
|
||||
.setSourceMetricsCategory(SettingsEnums.DASHBOARD_SUMMARY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
|
||||
.launch();
|
||||
protected void addExtras(Intent intent) {
|
||||
intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -85,11 +53,6 @@ public class WallpaperSuggestionActivity extends Activity implements Indexable {
|
||||
return manager.getWallpaperId(WallpaperManager.FLAG_SYSTEM) > 0;
|
||||
}
|
||||
|
||||
private static boolean isWallpaperServiceEnabled(Context context) {
|
||||
return context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_enableWallpaperService);
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";
|
||||
|
Reference in New Issue
Block a user