Merge "Add support for custom action button for url" into ub-launcher3-edmonton
diff --git a/src/com/android/wallpaper/model/CurrentWallpaperInfoV16.java b/src/com/android/wallpaper/model/CurrentWallpaperInfoV16.java
index c682b9f..41a7459 100755
--- a/src/com/android/wallpaper/model/CurrentWallpaperInfoV16.java
+++ b/src/com/android/wallpaper/model/CurrentWallpaperInfoV16.java
@@ -18,6 +18,8 @@
import android.app.Activity;
import android.content.Context;
import android.os.Parcel;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.StringRes;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.CurrentWallpaperAssetV16;
@@ -50,11 +52,19 @@
private List<String> mAttributions;
private Asset mAsset;
private String mActionUrl;
+ @StringRes
+ private int mActionLabelRes;
+ @DrawableRes
+ private int mActionIconRes;
private String mCollectionId;
- public CurrentWallpaperInfoV16(List<String> attributions, String actionUrl, String collectionId) {
+ public CurrentWallpaperInfoV16(List<String> attributions, String actionUrl,
+ @StringRes int actionLabelRes, @DrawableRes int actionIconRes,
+ String collectionId) {
mAttributions = attributions;
mActionUrl = actionUrl;
+ mActionLabelRes = actionLabelRes;
+ mActionIconRes = actionIconRes;
mCollectionId = collectionId;
}
@@ -63,6 +73,8 @@
in.readStringList(mAttributions);
mActionUrl = in.readString();
mCollectionId = in.readString();
+ mActionLabelRes = in.readInt();
+ mActionIconRes = in.readInt();
}
@Override
@@ -95,6 +107,16 @@
}
@Override
+ public int getActionIconRes() {
+ return mActionIconRes != 0 ? mActionIconRes : WallpaperInfo.getDefaultActionIcon();
+ }
+
+ @Override
+ public int getActionLabelRes() {
+ return mActionLabelRes != 0 ? mActionLabelRes : WallpaperInfo.getDefaultActionLabel();
+ }
+
+ @Override
public String getCollectionId(Context unused) {
return mCollectionId;
}
@@ -104,6 +126,8 @@
parcel.writeStringList(mAttributions);
parcel.writeString(mActionUrl);
parcel.writeString(mCollectionId);
+ parcel.writeInt(mActionLabelRes);
+ parcel.writeInt(mActionIconRes);
}
@Override
diff --git a/src/com/android/wallpaper/model/CurrentWallpaperInfoVN.java b/src/com/android/wallpaper/model/CurrentWallpaperInfoVN.java
index e502acf..87ea124 100755
--- a/src/com/android/wallpaper/model/CurrentWallpaperInfoVN.java
+++ b/src/com/android/wallpaper/model/CurrentWallpaperInfoVN.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.StringRes;
import android.util.Log;
import com.android.wallpaper.asset.Asset;
@@ -56,6 +58,10 @@
private List<String> mAttributions;
private Asset mAsset;
private String mActionUrl;
+ @StringRes
+ private int mActionLabelRes;
+ @DrawableRes
+ private int mActionIconRes;
private String mCollectionId;
@WallpaperLocation
private int mWallpaperManagerFlag;
@@ -66,11 +72,15 @@
* @param wallpaperManagerFlag Either SYSTEM or LOCK--the source of image data which this object
* represents.
*/
- public CurrentWallpaperInfoVN(List<String> attributions, String actionUrl, String collectionId,
+ public CurrentWallpaperInfoVN(List<String> attributions, String actionUrl,
+ @StringRes int actionLabelRes, @DrawableRes int actionIconRes,
+ String collectionId,
@WallpaperLocation int wallpaperManagerFlag) {
mAttributions = attributions;
mWallpaperManagerFlag = wallpaperManagerFlag;
mActionUrl = actionUrl;
+ mActionLabelRes = actionLabelRes;
+ mActionIconRes = actionIconRes;
mCollectionId = collectionId;
}
@@ -81,6 +91,8 @@
mWallpaperManagerFlag = in.readInt();
mActionUrl = in.readString();
mCollectionId = in.readString();
+ mActionLabelRes = in.readInt();
+ mActionIconRes = in.readInt();
}
@Override
@@ -111,6 +123,16 @@
return mCollectionId;
}
+ @Override
+ public int getActionIconRes() {
+ return mActionIconRes != 0 ? mActionIconRes : WallpaperInfo.getDefaultActionIcon();
+ }
+
+ @Override
+ public int getActionLabelRes() {
+ return mActionLabelRes != 0 ? mActionLabelRes : WallpaperInfo.getDefaultActionLabel();
+ }
+
/**
* Constructs and returns an Asset instance representing the currently-set wallpaper asset.
*/
@@ -155,6 +177,8 @@
parcel.writeInt(mWallpaperManagerFlag);
parcel.writeString(mActionUrl);
parcel.writeString(mCollectionId);
+ parcel.writeInt(mActionLabelRes);
+ parcel.writeInt(mActionIconRes);
}
@Override
diff --git a/src/com/android/wallpaper/model/WallpaperInfo.java b/src/com/android/wallpaper/model/WallpaperInfo.java
index e9fe86c..01ff774 100755
--- a/src/com/android/wallpaper/model/WallpaperInfo.java
+++ b/src/com/android/wallpaper/model/WallpaperInfo.java
@@ -19,8 +19,11 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
+import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
+import android.support.annotation.StringRes;
+import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import java.util.List;
@@ -30,6 +33,16 @@
*/
public abstract class WallpaperInfo implements Parcelable {
+ @DrawableRes
+ public static int getDefaultActionIcon() {
+ return R.drawable.ic_explore_24px;
+ }
+
+ @StringRes
+ public static int getDefaultActionLabel() {
+ return R.string.explore;
+ }
+
public static final int BACKUP_NOT_ALLOWED = 0;
public static final int BACKUP_ALLOWED = 1;
@@ -63,6 +76,24 @@
}
/**
+ * Returns the icon to use to represent the action link corresponding to
+ * {@link #getActionUrl(Context)}
+ */
+ @DrawableRes
+ public int getActionIconRes() {
+ return getDefaultActionIcon();
+ }
+
+ /**
+ * Returns the label to use for the action link corresponding to
+ * {@link #getActionUrl(Context)}
+ */
+ @StringRes
+ public int getActionLabelRes() {
+ return getDefaultActionLabel();
+ }
+
+ /**
* @param context
* @return An overlay icon to be used instead of a thumbnail, if appropriate, or null if not
* applicable.
diff --git a/src/com/android/wallpaper/model/WallpaperMetadata.java b/src/com/android/wallpaper/model/WallpaperMetadata.java
index c89b7f2..289275a 100755
--- a/src/com/android/wallpaper/model/WallpaperMetadata.java
+++ b/src/com/android/wallpaper/model/WallpaperMetadata.java
@@ -16,6 +16,8 @@
package com.android.wallpaper.model;
import android.app.WallpaperInfo;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.StringRes;
import java.util.List;
@@ -28,11 +30,17 @@
private final String mActionUrl;
private final String mCollectionId;
private final android.app.WallpaperInfo mWallpaperComponent;
+ @StringRes private final int mActionLabelRes;
+ @DrawableRes private final int mActionIconRes;
- public WallpaperMetadata(List<String> attributions, String actionUrl, String collectionId,
+ public WallpaperMetadata(List<String> attributions, String actionUrl,
+ @StringRes int actionLabelRes,
+ @DrawableRes int actionIconRes, String collectionId,
android.app.WallpaperInfo wallpaperComponent) {
mAttributions = attributions;
mActionUrl = actionUrl;
+ mActionLabelRes = actionLabelRes;
+ mActionIconRes = actionIconRes;
mCollectionId = collectionId;
mWallpaperComponent = wallpaperComponent;
}
@@ -52,6 +60,22 @@
}
/**
+ * Returns the wallpaper's action label.
+ */
+ @StringRes
+ public int getActionLabelRes() {
+ return mActionLabelRes;
+ }
+
+ /**
+ * Returns the wallpaper's action icon.
+ */
+ @DrawableRes
+ public int getActionIconRes() {
+ return mActionIconRes;
+ }
+
+ /**
* Returns the wallpaper's collection ID or null if there is none.
*/
public String getCollectionId() {
diff --git a/src/com/android/wallpaper/module/DefaultCurrentWallpaperInfoFactory.java b/src/com/android/wallpaper/module/DefaultCurrentWallpaperInfoFactory.java
index a76fbbf..165db39 100755
--- a/src/com/android/wallpaper/module/DefaultCurrentWallpaperInfoFactory.java
+++ b/src/com/android/wallpaper/module/DefaultCurrentWallpaperInfoFactory.java
@@ -82,12 +82,16 @@
homeWallpaper = new CurrentWallpaperInfoVN(
homeWallpaperMetadata.getAttributions(),
homeWallpaperMetadata.getActionUrl(),
+ homeWallpaperMetadata.getActionLabelRes(),
+ homeWallpaperMetadata.getActionIconRes(),
homeWallpaperMetadata.getCollectionId(),
WallpaperManagerCompat.FLAG_SYSTEM);
} else {
homeWallpaper = new CurrentWallpaperInfoV16(
homeWallpaperMetadata.getAttributions(),
homeWallpaperMetadata.getActionUrl(),
+ homeWallpaperMetadata.getActionLabelRes(),
+ homeWallpaperMetadata.getActionIconRes(),
homeWallpaperMetadata.getCollectionId());
}
} else { // Live wallpaper
@@ -100,6 +104,8 @@
lockWallpaper = new CurrentWallpaperInfoVN(
lockWallpaperMetadata.getAttributions(),
lockWallpaperMetadata.getActionUrl(),
+ lockWallpaperMetadata.getActionLabelRes(),
+ lockWallpaperMetadata.getActionIconRes(),
lockWallpaperMetadata.getCollectionId(),
WallpaperManagerCompat.FLAG_LOCK);
}
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
index 4df0e71..5d371a3 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
@@ -337,15 +337,18 @@
@Override
public boolean setWallpaperInRotation(Bitmap wallpaperBitmap, List<String> attributions,
+ int actionLabelRes, int actionIconRes,
String actionUrl, String collectionId) {
@RotatingWallpaperComponent int rotatingWallpaperComponent = mRotatingWallpaperComponentChecker
.getCurrentRotatingWallpaperComponent(mAppContext);
switch (rotatingWallpaperComponent) {
case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC:
- return setWallpaperInRotationStatic(wallpaperBitmap, attributions, actionUrl, collectionId);
+ return setWallpaperInRotationStatic(wallpaperBitmap, attributions, actionUrl,
+ actionLabelRes, actionIconRes, collectionId);
case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE:
- return setWallpaperInRotationLive(wallpaperBitmap, attributions, actionUrl, collectionId);
+ return setWallpaperInRotationLive(wallpaperBitmap, attributions, actionUrl,
+ actionLabelRes, actionIconRes, collectionId);
default:
Log.e(TAG, "Unknown rotating wallpaper component: " + rotatingWallpaperComponent);
return false;
@@ -371,11 +374,12 @@
@Override
public boolean finalizeWallpaperForNextRotation(List<String> attributions, String actionUrl,
+ int actionLabelRes, int actionIconRes,
String collectionId, int wallpaperId) {
- @RotatingWallpaperComponent int rotatingWallpaperComponent = mRotatingWallpaperComponentChecker
- .getNextRotatingWallpaperComponent(mAppContext);
- return finalizeWallpaperForRotatingComponent(attributions, actionUrl, collectionId,
- wallpaperId, rotatingWallpaperComponent);
+ @RotatingWallpaperComponent int rotatingWallpaperComponent =
+ mRotatingWallpaperComponentChecker.getNextRotatingWallpaperComponent(mAppContext);
+ return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
+ actionIconRes, collectionId, wallpaperId, rotatingWallpaperComponent);
}
/**
@@ -383,15 +387,17 @@
* current "daily wallpaper".
*/
private boolean setWallpaperInRotationStatic(Bitmap wallpaperBitmap, List<String> attributions,
- String actionUrl, String collectionId) {
+ String actionUrl, int actionLabelRes,
+ int actionIconRes, String collectionId) {
final int wallpaperId = setWallpaperBitmapInRotationStatic(wallpaperBitmap);
if (wallpaperId == 0) {
return false;
}
- return finalizeWallpaperForRotatingComponent(attributions, actionUrl, collectionId,
- wallpaperId, RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC);
+ return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
+ actionIconRes, collectionId, wallpaperId,
+ RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC);
}
/**
@@ -402,8 +408,12 @@
* @return Whether the operation was successful.
*/
private boolean finalizeWallpaperForRotatingComponent(List<String> attributions,
- String actionUrl, String collectionId, int wallpaperId,
- @RotatingWallpaperComponent int rotatingWallpaperComponent) {
+ String actionUrl,
+ int actionLabelRes,
+ int actionIconRes,
+ String collectionId,
+ int wallpaperId,
+ @RotatingWallpaperComponent int rotatingWallpaperComponent) {
mWallpaperPreferences.clearHomeWallpaperMetadata();
boolean isLockWallpaperSet = isSeparateLockScreenWallpaperSet();
@@ -481,6 +491,8 @@
mWallpaperPreferences.setHomeWallpaperAttributions(attributions);
mWallpaperPreferences.setHomeWallpaperActionUrl(actionUrl);
+ mWallpaperPreferences.setHomeWallpaperActionLabelRes(actionLabelRes);
+ mWallpaperPreferences.setHomeWallpaperActionIconRes(actionIconRes);
// Only set base image URL for static Backdrop images, not for rotation.
mWallpaperPreferences.setHomeWallpaperBaseImageUrl(null);
mWallpaperPreferences.setHomeWallpaperCollectionId(collectionId);
@@ -492,6 +504,8 @@
&& !isLockWallpaperSet) {
mWallpaperPreferences.setLockWallpaperAttributions(attributions);
mWallpaperPreferences.setLockWallpaperActionUrl(actionUrl);
+ mWallpaperPreferences.setLockWallpaperActionLabelRes(actionLabelRes);
+ mWallpaperPreferences.setLockWallpaperActionIconRes(actionIconRes);
mWallpaperPreferences.setLockWallpaperCollectionId(collectionId);
}
@@ -503,15 +517,18 @@
* current "daily wallpaper".
*/
private boolean setWallpaperInRotationLive(Bitmap wallpaperBitmap, List<String> attributions,
- String actionUrl, String collectionId) {
+ String actionUrl, int actionLabelRes,
+ int actionIconRes, String collectionId) {
synchronized (RotatingWallpaperLockProvider.getInstance()) {
if (!setWallpaperBitmapInRotationLive(wallpaperBitmap, false /* isPreview */)) {
return false;
}
- return finalizeWallpaperForRotatingComponent(attributions, actionUrl, collectionId,
- 0 /* wallpaperId */, RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE);
+ return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
+ actionIconRes, collectionId,
+ 0 /* wallpaperId */,
+ RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE);
}
}
@@ -907,6 +924,10 @@
mWallpaperPreferences.getHomeWallpaperAttributions());
mWallpaperPreferences.setLockWallpaperActionUrl(
mWallpaperPreferences.getHomeWallpaperActionUrl());
+ mWallpaperPreferences.setLockWallpaperActionLabelRes(
+ mWallpaperPreferences.getHomeWallpaperActionLabelRes());
+ mWallpaperPreferences.setLockWallpaperActionIconRes(
+ mWallpaperPreferences.getHomeWallpaperActionIconRes());
mWallpaperPreferences.setLockWallpaperCollectionId(
mWallpaperPreferences.getHomeWallpaperCollectionId());
@@ -976,18 +997,26 @@
mWallpaperPreferences.setHomeWallpaperHashCode(bitmapHash);
- mWallpaperPreferences.setHomeWallpaperAttributions(mWallpaper.getAttributions(mAppContext));
+ mWallpaperPreferences.setHomeWallpaperAttributions(
+ mWallpaper.getAttributions(mAppContext));
mWallpaperPreferences.setHomeWallpaperBaseImageUrl(mWallpaper.getBaseImageUrl());
mWallpaperPreferences.setHomeWallpaperActionUrl(mWallpaper.getActionUrl(mAppContext));
- mWallpaperPreferences.setHomeWallpaperCollectionId(mWallpaper.getCollectionId(mAppContext));
+ mWallpaperPreferences.setHomeWallpaperActionLabelRes(mWallpaper.getActionLabelRes());
+ mWallpaperPreferences.setHomeWallpaperActionIconRes(mWallpaper.getActionIconRes());
+ mWallpaperPreferences.setHomeWallpaperCollectionId(
+ mWallpaper.getCollectionId(mAppContext));
mWallpaperPreferences.setHomeWallpaperRemoteId(mWallpaper.getWallpaperId());
}
private void setImageWallpaperLockMetadata(int lockWallpaperId) {
mWallpaperPreferences.setLockWallpaperId(lockWallpaperId);
- mWallpaperPreferences.setLockWallpaperAttributions(mWallpaper.getAttributions(mAppContext));
+ mWallpaperPreferences.setLockWallpaperAttributions(
+ mWallpaper.getAttributions(mAppContext));
mWallpaperPreferences.setLockWallpaperActionUrl(mWallpaper.getActionUrl(mAppContext));
- mWallpaperPreferences.setLockWallpaperCollectionId(mWallpaper.getCollectionId(mAppContext));
+ mWallpaperPreferences.setHomeWallpaperActionLabelRes(mWallpaper.getActionLabelRes());
+ mWallpaperPreferences.setHomeWallpaperActionIconRes(mWallpaper.getActionIconRes());
+ mWallpaperPreferences.setLockWallpaperCollectionId(
+ mWallpaper.getCollectionId(mAppContext));
// Save the lock wallpaper image's hash code as well for the sake of backup & restore because
// WallpaperManager-generated IDs are specific to a physical device and cannot be used to
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java b/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
index 2754f38..0b2c976 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
@@ -40,12 +40,15 @@
private static final String TAG = "DefaultWPPreferences";
private SharedPreferences mSharedPrefs;
+ private Context mContext;
+
// Keep a strong reference to this OnSharedPreferenceChangeListener to prevent the listener from
// being garbage collected because SharedPreferences only holds a weak reference.
private OnSharedPreferenceChangeListener mSharedPrefsChangedListener;
public DefaultWallpaperPreferences(Context context) {
mSharedPrefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
+ mContext = context.getApplicationContext();
// Register a prefs changed listener so that all prefs changes trigger a backup event.
final BackupManager backupManager = new BackupManager(context);
@@ -58,6 +61,20 @@
mSharedPrefs.registerOnSharedPreferenceChangeListener(mSharedPrefsChangedListener);
}
+ private int getResIdPersistedByName(String key, String type) {
+ String resName = mSharedPrefs.getString(key, null);
+ if (resName == null) {
+ return 0;
+ }
+ return mContext.getResources().getIdentifier(resName, type,
+ mContext.getPackageName());
+ }
+
+ private void persistResIdByName(String key, int resId) {
+ String resName = mContext.getResources().getResourceName(resId);
+ mSharedPrefs.edit().putString(key, resName).apply();
+ }
+
@Override
public int getWallpaperPresentationMode() {
@PresentationMode
@@ -110,6 +127,30 @@
}
@Override
+ public int getHomeWallpaperActionLabelRes() {
+ // We need to store and read the resource names as their ids could change from build to
+ // build and we might end up reading the wrong id
+ return getResIdPersistedByName(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_LABEL_RES,
+ "string");
+ }
+
+ @Override
+ public void setHomeWallpaperActionLabelRes(int resId) {
+ persistResIdByName(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_LABEL_RES, resId);
+ }
+
+ @Override
+ public int getHomeWallpaperActionIconRes() {
+ return getResIdPersistedByName(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_ICON_RES,
+ "drawable");
+ }
+
+ @Override
+ public void setHomeWallpaperActionIconRes(int resId) {
+ persistResIdByName(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_ICON_RES, resId);
+ }
+
+ @Override
public String getHomeWallpaperBaseImageUrl() {
return mSharedPrefs.getString(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_BASE_IMAGE_URL, null);
}
@@ -150,6 +191,8 @@
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ATTRIB_2)
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ATTRIB_3)
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_URL)
+ .remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_LABEL_RES)
+ .remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_ACTION_ICON_RES)
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_BASE_IMAGE_URL)
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_HASH_CODE)
.remove(WallpaperPreferenceKeys.KEY_HOME_WALLPAPER_MANAGER_ID)
@@ -229,6 +272,30 @@
}
@Override
+ public int getLockWallpaperActionLabelRes() {
+ // We need to store and read the resource names as their ids could change from build to
+ // build and we might end up reading the wrong id
+ return getResIdPersistedByName(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_ACTION_LABEL_RES,
+ "string");
+ }
+
+ @Override
+ public void setLockWallpaperActionLabelRes(int resId) {
+ persistResIdByName(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_ACTION_LABEL_RES, resId);
+ }
+
+ @Override
+ public int getLockWallpaperActionIconRes() {
+ return getResIdPersistedByName(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_ACTION_ICON_RES,
+ "drawable");
+ }
+
+ @Override
+ public void setLockWallpaperActionIconRes(int resId) {
+ persistResIdByName(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_ACTION_ICON_RES, resId);
+ }
+
+ @Override
@Nullable
public String getLockWallpaperCollectionId() {
return mSharedPrefs.getString(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_COLLECTION_ID, null);
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperRefresher.java b/src/com/android/wallpaper/module/DefaultWallpaperRefresher.java
index 1858dff..b5dc7bf 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperRefresher.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperRefresher.java
@@ -113,6 +113,8 @@
wallpaperMetadatas.add(new WallpaperMetadata(
mWallpaperPreferences.getHomeWallpaperAttributions(),
mWallpaperPreferences.getHomeWallpaperActionUrl(),
+ mWallpaperPreferences.getHomeWallpaperActionLabelRes(),
+ mWallpaperPreferences.getHomeWallpaperActionIconRes(),
mWallpaperPreferences.getHomeWallpaperCollectionId(),
mWallpaperManager.getWallpaperInfo()));
return wallpaperMetadatas;
@@ -126,12 +128,16 @@
wallpaperMetadatas.add(new WallpaperMetadata(
mWallpaperPreferences.getHomeWallpaperAttributions(),
mWallpaperPreferences.getHomeWallpaperActionUrl(),
+ mWallpaperPreferences.getHomeWallpaperActionLabelRes(),
+ mWallpaperPreferences.getHomeWallpaperActionIconRes(),
mWallpaperPreferences.getHomeWallpaperCollectionId(),
mWallpaperManager.getWallpaperInfo()));
wallpaperMetadatas.add(new WallpaperMetadata(
mWallpaperPreferences.getLockWallpaperAttributions(),
mWallpaperPreferences.getLockWallpaperActionUrl(),
+ mWallpaperPreferences.getLockWallpaperActionLabelRes(),
+ mWallpaperPreferences.getLockWallpaperActionIconRes(),
mWallpaperPreferences.getLockWallpaperCollectionId(),
null /* wallpaperComponent */));
diff --git a/src/com/android/wallpaper/module/WallpaperPersister.java b/src/com/android/wallpaper/module/WallpaperPersister.java
index 1191242..bb59cb1 100755
--- a/src/com/android/wallpaper/module/WallpaperPersister.java
+++ b/src/com/android/wallpaper/module/WallpaperPersister.java
@@ -82,6 +82,7 @@
* @return Whether the set wallpaper operation was successful.
*/
boolean setWallpaperInRotation(Bitmap wallpaperBitmap, List<String> attributions,
+ int actionLabelRes, int actionIconRes,
String actionUrl, String collectionId);
/**
@@ -107,6 +108,7 @@
* @return Whether the operation succeeded.
*/
boolean finalizeWallpaperForNextRotation(List<String> attributions, String actionUrl,
+ int actionLabelRes, int actionIconRes,
String collectionId, int wallpaperId);
/**
diff --git a/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java b/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
index 1e255b9..9f7acbf 100755
--- a/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
+++ b/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
@@ -25,6 +25,8 @@
public static final String KEY_HOME_WALLPAPER_ATTRIB_2 = "home_wallpaper_attribution_line_2";
public static final String KEY_HOME_WALLPAPER_ATTRIB_3 = "home_wallpaper_attribution_line_3";
public static final String KEY_HOME_WALLPAPER_ACTION_URL = "home_wallpaper_action_url";
+ public static final String KEY_HOME_WALLPAPER_ACTION_LABEL_RES = "home_wallpaper_action_label";
+ public static final String KEY_HOME_WALLPAPER_ACTION_ICON_RES = "home_wallpaper_action_icon";
public static final String KEY_HOME_WALLPAPER_COLLECTION_ID = "home_wallpaper_collection_id";
public static final String KEY_HOME_WALLPAPER_BASE_IMAGE_URL = "home_wallpaper_base_image_url";
public static final String KEY_HOME_WALLPAPER_HASH_CODE = "home_wallpaper_hash_code";
@@ -36,6 +38,8 @@
public static final String KEY_LOCK_WALLPAPER_ATTRIB_2 = "lock_wallpaper_attribution_line_2";
public static final String KEY_LOCK_WALLPAPER_ATTRIB_3 = "lock_wallpaper_attribution_line_3";
public static final String KEY_LOCK_WALLPAPER_ACTION_URL = "lock_wallpaper_action_url";
+ public static final String KEY_LOCK_WALLPAPER_ACTION_LABEL_RES = "lock_wallpaper_action_label";
+ public static final String KEY_LOCK_WALLPAPER_ACTION_ICON_RES = "lock_wallpaper_action_icon";
public static final String KEY_LOCK_WALLPAPER_HASH_CODE = "lock_wallpaper_hash_code";
public static final String KEY_LOCK_WALLPAPER_COLLECTION_ID = "lock_wallpaper_collection_id";
public static final String KEY_LOCK_WALLPAPER_MANAGER_ID = "lock_wallpaper_id";
diff --git a/src/com/android/wallpaper/module/WallpaperPreferences.java b/src/com/android/wallpaper/module/WallpaperPreferences.java
index 3b77760..2427f23 100755
--- a/src/com/android/wallpaper/module/WallpaperPreferences.java
+++ b/src/com/android/wallpaper/module/WallpaperPreferences.java
@@ -67,6 +67,26 @@
void setHomeWallpaperActionUrl(String actionUrl);
/**
+ * Returns the resource id for the home wallpaper's action label.
+ */
+ int getHomeWallpaperActionLabelRes();
+
+ /**
+ * Sets the resource id for the home wallpaper's action label.
+ */
+ void setHomeWallpaperActionLabelRes(int resId);
+
+ /**
+ * Returns the resource id for the home wallpaper's action icon.
+ */
+ int getHomeWallpaperActionIconRes();
+
+ /**
+ * Sets the resource id for the home wallpaper's action icon.
+ */
+ void setHomeWallpaperActionIconRes(int resId);
+
+ /**
* Returns the home wallpaper's base image URL or if there is none.
*/
String getHomeWallpaperBaseImageUrl();
@@ -146,6 +166,26 @@
void setLockWallpaperActionUrl(String actionUrl);
/**
+ * Returns the resource id for the lock wallpaper's action label.
+ */
+ int getLockWallpaperActionLabelRes();
+
+ /**
+ * Sets the resource id for the lock wallpaper's action label.
+ */
+ void setLockWallpaperActionLabelRes(int resId);
+
+ /**
+ * Returns the resource id for the lock wallpaper's action icon.
+ */
+ int getLockWallpaperActionIconRes();
+
+ /**
+ * Sets the resource id for the lock wallpaper's action icon.
+ */
+ void setLockWallpaperActionIconRes(int resId);
+
+ /**
* Returns the lock wallpaper's collection ID or null if there is none.
*/
String getLockWallpaperCollectionId();
diff --git a/src/com/android/wallpaper/picker/CategoryPickerFragment.java b/src/com/android/wallpaper/picker/CategoryPickerFragment.java
index 259bd71..6b9adee 100755
--- a/src/com/android/wallpaper/picker/CategoryPickerFragment.java
+++ b/src/com/android/wallpaper/picker/CategoryPickerFragment.java
@@ -30,6 +30,7 @@
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
+import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup;
@@ -554,14 +555,28 @@
if (showSkipWallpaperButton) {
exploreButton = mWallpaperExploreButtonNoText;
+ mWallpaperExploreButtonNoText.setImageDrawable(getContext().getDrawable(
+ mWallpaperInfo.getActionIconRes()));
+ mWallpaperExploreButtonNoText.setContentDescription(
+ getString(mWallpaperInfo.getActionLabelRes()));
mWallpaperExploreButtonNoText.setColorFilter(
- getResources().getColor(R.color.currently_set_explore_button_color), Mode.SRC_IN);
+ getResources().getColor(R.color.currently_set_explore_button_color),
+ Mode.SRC_IN);
mWallpaperExploreButton.setVisibility(View.GONE);
} else {
exploreButton = mWallpaperExploreButton;
+
+ Drawable drawable = getContext().getDrawable(
+ mWallpaperInfo.getActionIconRes()).getConstantState()
+ .newDrawable().mutate();
+ // Color the "compass" icon with the accent color.
+ drawable.setColorFilter(
+ getResources().getColor(R.color.accent_color), Mode.SRC_IN);
+ ButtonDrawableSetterCompat.setDrawableToButtonStart(
+ mWallpaperExploreButton, drawable);
+ mWallpaperExploreButton.setText(mWallpaperInfo.getActionLabelRes());
mWallpaperExploreButtonNoText.setVisibility(View.GONE);
}
-
exploreButton.setVisibility(View.VISIBLE);
exploreButton.setOnClickListener((View view) -> {
eventLogger.logExploreClicked(mWallpaperInfo.getCollectionId(appContext));
@@ -709,6 +724,10 @@
}
exploreButton.setVisibility(View.VISIBLE);
+ exploreButton.setImageDrawable(getContext().getDrawable(
+ homeWallpaper.getActionIconRes()));
+ exploreButton.setContentDescription(getString(homeWallpaper
+ .getActionLabelRes()));
exploreButton.setColorFilter(
getResources().getColor(R.color.currently_set_explore_button_color), Mode.SRC_IN);
exploreButton.setOnClickListener(new OnClickListener() {
@@ -795,10 +814,15 @@
if (exploreIntent == null || getActivity() == null) {
return;
}
-
+ exploreButton.setImageDrawable(getContext().getDrawable(
+ lockWallpaper.getActionIconRes()));
+ exploreButton.setContentDescription(getString(
+ lockWallpaper.getActionLabelRes()));
exploreButton.setVisibility(View.VISIBLE);
exploreButton.setColorFilter(
- getResources().getColor(R.color.currently_set_explore_button_color), Mode.SRC_IN);
+ getResources().getColor(
+ R.color.currently_set_explore_button_color),
+ Mode.SRC_IN);
exploreButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/com/android/wallpaper/picker/PreviewFragment.java b/src/com/android/wallpaper/picker/PreviewFragment.java
index 8240a46..dfbd7cb 100755
--- a/src/com/android/wallpaper/picker/PreviewFragment.java
+++ b/src/com/android/wallpaper/picker/PreviewFragment.java
@@ -593,16 +593,19 @@
if (mExploreIntent != null) {
if (Flags.skipDailyWallpaperButtonEnabled) {
Drawable exploreButtonDrawable = context.getDrawable(
- R.drawable.ic_explore_24px);
+ mWallpaper.getActionIconRes());
// This Drawable's state is shared across the app, so make a copy of it before applying a
// color tint as not to affect other clients elsewhere in the app.
- exploreButtonDrawable = exploreButtonDrawable.getConstantState().newDrawable().mutate();
+ exploreButtonDrawable = exploreButtonDrawable.getConstantState()
+ .newDrawable().mutate();
// Color the "compass" icon with the accent color.
exploreButtonDrawable.setColorFilter(
getResources().getColor(R.color.accent_color), Mode.SRC_IN);
ButtonDrawableSetterCompat.setDrawableToButtonStart(
mAttributionExploreButton, exploreButtonDrawable);
+ mAttributionExploreButton.setText(context.getString(
+ mWallpaper.getActionLabelRes()));
}
mAttributionExploreSection.setVisibility(View.VISIBLE);
diff --git a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
index 782180f..e0b2dec 100755
--- a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
+++ b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
@@ -471,19 +471,6 @@
private void setUpBottomSheet() {
mBottomSheet.setVisibility(View.VISIBLE);
- // Add "compass" icon to the Explore button
- Drawable exploreButtonDrawable = getResources().getDrawable(
- R.drawable.ic_explore_18px);
-
- // This Drawable's state is shared across the app, so make a copy of it before applying a
- // color tint as not to affect other clients elsewhere in the app.
- exploreButtonDrawable = exploreButtonDrawable.getConstantState().newDrawable().mutate();
- // Color the "compass" icon with the accent color.
- exploreButtonDrawable.setColorFilter(
- getResources().getColor(R.color.accent_color), Mode.SRC_IN);
- ButtonDrawableSetterCompat.setDrawableToButtonStart(
- mCurrentWallpaperExploreButton, exploreButtonDrawable);
-
if (Flags.skipDailyWallpaperButtonEnabled) {
// Add "next" icon to the Next Wallpaper button
Drawable nextWallpaperButtonDrawable = getResources().getDrawable(
@@ -592,11 +579,29 @@
ExploreIntentChecker intentChecker = injector.getExploreIntentChecker(appContext);
intentChecker.fetchValidActionViewIntent(exploreUri, (@Nullable Intent exploreIntent) -> {
if (exploreIntent != null && !isDestroyed()) {
+ // Set the icon for the button
+ Drawable exploreButtonDrawable = getResources().getDrawable(
+ homeWallpaper.getActionIconRes());
+
+ // This Drawable's state is shared across the app, so make a copy of it
+ // before applying a color tint as not to affect other clients elsewhere
+ // in the app.
+ exploreButtonDrawable = exploreButtonDrawable.getConstantState()
+ .newDrawable().mutate();
+ // Color the "compass" icon with the accent color.
+ exploreButtonDrawable.setColorFilter(
+ getResources().getColor(R.color.accent_color), Mode.SRC_IN);
+
+ ButtonDrawableSetterCompat.setDrawableToButtonStart(
+ mCurrentWallpaperExploreButton, exploreButtonDrawable);
+ mCurrentWallpaperExploreButton.setText(getString(
+ homeWallpaper.getActionLabelRes()));
mCurrentWallpaperExploreButton.setVisibility(View.VISIBLE);
mCurrentWallpaperExploreButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- mUserEventLogger.logExploreClicked(homeWallpaper.getCollectionId(appContext));
+ mUserEventLogger.logExploreClicked(
+ homeWallpaper.getCollectionId(appContext));
startActivity(exploreIntent);
}
});