Permalink
Browse files

Move Meta Font Type constants to MuzeiContract

Tie Meta Font types to the META_FONT column in MuzeiContract
  • Loading branch information...
1 parent 92108b4 commit 3236c8d20b4e835d922ffb8868b93c5db2595522 @ianhanniballake ianhanniballake committed Dec 17, 2016
@@ -39,8 +39,16 @@
* <p> To create an instance, use the {@link Artwork.Builder} class.
*/
public class Artwork {
- public static final String FONT_TYPE_DEFAULT = "";
- public static final String FONT_TYPE_ELEGANT = "elegant";
+ /**
+ * @deprecated use {@link com.google.android.apps.muzei.api.MuzeiContract.Artwork#META_FONT_TYPE_DEFAULT}
+ */
+ @Deprecated
+ public static final String FONT_TYPE_DEFAULT = MuzeiContract.Artwork.META_FONT_TYPE_DEFAULT;
+ /**
+ * @deprecated use {@link com.google.android.apps.muzei.api.MuzeiContract.Artwork#META_FONT_TYPE_ELEGANT}
+ */
+ @Deprecated
+ public static final String FONT_TYPE_ELEGANT = MuzeiContract.Artwork.META_FONT_TYPE_ELEGANT;
private static final String KEY_COMPONENT_NAME = "componentName";
private static final String KEY_IMAGE_URI = "imageUri";
@@ -355,8 +363,8 @@ public Builder viewIntent(Intent viewIntent) {
/**
* Sets the font type to use to show metadata for the artwork.
*
- * @see #FONT_TYPE_DEFAULT
- * @see #FONT_TYPE_ELEGANT
+ * @see com.google.android.apps.muzei.api.MuzeiContract.Artwork#META_FONT_TYPE_DEFAULT
+ * @see com.google.android.apps.muzei.api.MuzeiContract.Artwork#META_FONT_TYPE_ELEGANT
*/
public Builder metaFont(String metaFont) {
mArtwork.mMetaFont = metaFont;
@@ -105,6 +105,14 @@ private MuzeiContract() {
*/
public static final class Artwork implements BaseColumns {
/**
+ * The default font type for {@link #COLUMN_NAME_META_FONT}
+ */
+ public static final String META_FONT_TYPE_DEFAULT = "";
+ /**
+ * An elegant alternate font type for {@link #COLUMN_NAME_META_FONT}
+ */
+ public static final String META_FONT_TYPE_ELEGANT = "elegant";
+ /**
* Column name for the flattened {@link ComponentName} of the source that is providing
* this wallpaper
* <p>Type: TEXT in the format of {@link ComponentName#flattenToShortString()}
@@ -147,7 +155,7 @@ private MuzeiContract() {
public static final String COLUMN_NAME_VIEW_INTENT = "viewIntent";
/**
* Column name for the font type to use to display artwork meta info.
- * <p>Type: TEXT
+ * <p>Type: TEXT (one of {@link #META_FONT_TYPE_DEFAULT} or {@link #META_FONT_TYPE_ELEGANT})
*/
public static final String COLUMN_NAME_META_FONT = "metaFont";
/**
@@ -145,7 +145,7 @@ public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
Artwork currentArtwork = Artwork.fromCursor(data);
String titleFont = "AlegreyaSans-Black.ttf";
String bylineFont = "AlegreyaSans-Medium.ttf";
- if (Artwork.FONT_TYPE_ELEGANT.equals(currentArtwork.getMetaFont())) {
+ if (MuzeiContract.Artwork.META_FONT_TYPE_ELEGANT.equals(currentArtwork.getMetaFont())) {
titleFont = "Alegreya-BlackItalic.ttf";
bylineFont = "Alegreya-Italic.ttf";
}
@@ -27,6 +27,7 @@
import android.widget.Toast;
import com.google.android.apps.muzei.api.Artwork;
+import com.google.android.apps.muzei.api.MuzeiContract;
import com.google.android.apps.muzei.api.RemoteMuzeiArtSource;
import com.google.android.apps.muzei.api.UserCommand;
@@ -87,7 +88,7 @@ protected void onUpdate(int reason) {
.attribution("wikiart.org")
.viewIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.wikiart.org/en/vincent-van-gogh/the-starry-night-1889")))
- .metaFont(Artwork.FONT_TYPE_ELEGANT)
+ .metaFont(MuzeiContract.Artwork.META_FONT_TYPE_ELEGANT)
.build());
commands.add(new UserCommand(BUILTIN_COMMAND_ID_NEXT_ARTWORK));
// show the latest photo in 15 minutes
@@ -199,7 +200,7 @@ protected void onTryUpdate(int reason) throws RetryException {
Log.d(TAG, "Publishing artwork update: " + artwork);
}
if (artwork != null && jsonObject != null) {
- artwork.setMetaFont(Artwork.FONT_TYPE_ELEGANT);
+ artwork.setMetaFont(MuzeiContract.Artwork.META_FONT_TYPE_ELEGANT);
publishArtwork(artwork);
}
}

0 comments on commit 3236c8d

Please sign in to comment.