Add wallpaper suggestion if one isn't set.

Change-Id: I81380323f0d4f5af842a81028a763219958833bc
This commit is contained in:
Jason Monk
2016-01-26 17:43:57 -05:00
parent 4a60c8876e
commit b9e5d238b6
5 changed files with 47 additions and 2 deletions

View File

@@ -830,6 +830,20 @@
android:resource="@string/zen_mode_automation_suggestion_title" /> android:resource="@string/zen_mode_automation_suggestion_title" />
</activity> </activity>
<activity android:name="Settings$WallpaperSuggestionActivity"
android:label="@string/wallpaper_settings_title"
android:exported="true"
android:taskAffinity="">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.SETTINGS_ONLY" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.WallpaperTypeSettings" />
<meta-data android:name="com.android.settings.title"
android:resource="@string/wallpaper_suggestion_title" />
</activity>
<activity android:name="Settings$ZenModeScheduleRuleSettingsActivity" <activity android:name="Settings$ZenModeScheduleRuleSettingsActivity"
android:exported="true" android:exported="true"
android:taskAffinity=""> android:taskAffinity="">

View File

@@ -2064,6 +2064,8 @@
<string name="screen_timeout_summary">After <xliff:g id="timeout_description">%1$s</xliff:g> of inactivity</string> <string name="screen_timeout_summary">After <xliff:g id="timeout_description">%1$s</xliff:g> of inactivity</string>
<!-- Wallpaper settings title [CHAR LIMIT=30] --> <!-- Wallpaper settings title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_title">Wallpaper</string> <string name="wallpaper_settings_title">Wallpaper</string>
<!-- Wallpaper suggestion title [CHAR LIMIT=30] -->
<string name="wallpaper_suggestion_title">Set up wallpaper</string>
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] --> <!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string> <string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
<!-- Display settings screen, trigger for screen saver options --> <!-- Display settings screen, trigger for screen saver options -->

View File

@@ -125,6 +125,8 @@ public class Settings extends SettingsActivity {
public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ } public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageDefaultAppsActivity extends SettingsActivity { /* empty */ } public static class ManageDefaultAppsActivity extends SettingsActivity { /* empty */ }
public static class WallpaperSuggestionActivity extends SettingsActivity { /* empty */ }
// Categories. // Categories.
public static class WirelessSettings extends SettingsActivity { /* empty */ } public static class WirelessSettings extends SettingsActivity { /* empty */ }
public static class DeviceSettings extends SettingsActivity { /* empty */ } public static class DeviceSettings extends SettingsActivity { /* empty */ }

View File

@@ -314,6 +314,7 @@ public class SettingsActivity extends SettingsDrawerActivity
DrawOverlayDetails.class.getName(), DrawOverlayDetails.class.getName(),
WriteSettingsDetails.class.getName(), WriteSettingsDetails.class.getName(),
ManageDefaultApps.class.getName(), ManageDefaultApps.class.getName(),
WallpaperTypeSettings.class.getName(),
}; };

View File

@@ -15,8 +15,16 @@
package com.android.settings.dashboard; package com.android.settings.dashboard;
import android.app.AutomaticZenRule; import android.app.AutomaticZenRule;
import android.app.IWallpaperManager;
import android.app.IWallpaperManager.Stub;
import android.app.IWallpaperManagerCallback;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import com.android.settings.Settings.WallpaperSuggestionActivity;
import com.android.settings.Settings.ZenModeAutomationSuggestionActivity; import com.android.settings.Settings.ZenModeAutomationSuggestionActivity;
import com.android.settingslib.drawer.Tile; import com.android.settingslib.drawer.Tile;
@@ -34,9 +42,11 @@ public class SuggestionsChecks {
} }
public boolean isSuggestionComplete(Tile suggestion) { public boolean isSuggestionComplete(Tile suggestion) {
if (suggestion.intent.getComponent().getClassName().equals( String className = suggestion.intent.getComponent().getClassName();
ZenModeAutomationSuggestionActivity.class.getName())) { if (className.equals(ZenModeAutomationSuggestionActivity.class.getName())) {
return hasEnabledZenAutoRules(); return hasEnabledZenAutoRules();
} else if (className.equals(WallpaperSuggestionActivity.class.getName())) {
return hasWallpaperSet();
} }
return false; return false;
} }
@@ -52,4 +62,20 @@ public class SuggestionsChecks {
return false; return false;
} }
private boolean hasWallpaperSet() {
IBinder b = ServiceManager.getService(Context.WALLPAPER_SERVICE);
IWallpaperManager service = Stub.asInterface(b);
try {
return service.getWallpaper(mCallback, new Bundle()) != null;
} catch (RemoteException e) {
}
return false;
}
private final IWallpaperManagerCallback mCallback = new IWallpaperManagerCallback.Stub() {
@Override
public void onWallpaperChanged() throws RemoteException {
// Don't care.
}
};
} }