diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGallery.java b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGallery.java new file mode 100644 index 000000000000..ab7326a170e6 --- /dev/null +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGallery.java @@ -0,0 +1,87 @@ + +package org.wordpress.android.util.helpers; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * A model representing a Media Gallery. + * A unique id is not used on the website, but only in this app. + * It is used to uniquely determining the instance of the object, as it is + * passed between post and media gallery editor. + */ +public class MediaGallery implements Serializable { + private static final long serialVersionUID = 2359176987182027508L; + + private long uniqueId; + private boolean isRandom; + private String type; + private int numColumns; + private ArrayList ids; + + public MediaGallery(boolean isRandom, String type, int numColumns, ArrayList ids) { + this.isRandom = isRandom; + this.type = type; + this.numColumns = numColumns; + this.ids = ids; + this.uniqueId = System.currentTimeMillis(); + } + + public MediaGallery() { + isRandom = false; + type = ""; + numColumns = 3; + ids = new ArrayList(); + this.uniqueId = System.currentTimeMillis(); + } + + public boolean isRandom() { + return isRandom; + } + + public void setRandom(boolean isRandom) { + this.isRandom = isRandom; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getNumColumns() { + return numColumns; + } + + public void setNumColumns(int numColumns) { + this.numColumns = numColumns; + } + + public ArrayList getIds() { + return ids; + } + + public String getIdsStr() { + String ids_str = ""; + if (ids.size() > 0) { + for (String id : ids) { + ids_str += id + ","; + } + ids_str = ids_str.substring(0, ids_str.length() - 1); + } + return ids_str; + } + + public void setIds(ArrayList ids) { + this.ids = ids; + } + + /** + * An id to uniquely identify a media gallery object, so that the same object can be edited in the post editor + */ + public long getUniqueId() { + return uniqueId; + } +} diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGalleryImageSpan.java b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGalleryImageSpan.java new file mode 100644 index 000000000000..588b98141c27 --- /dev/null +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/MediaGalleryImageSpan.java @@ -0,0 +1,21 @@ +package org.wordpress.android.util.helpers; + +import android.content.Context; +import android.text.style.ImageSpan; + +public class MediaGalleryImageSpan extends ImageSpan { + private MediaGallery mMediaGallery; + + public MediaGalleryImageSpan(Context context, MediaGallery mediaGallery, int placeHolder) { + super(context, placeHolder); + setMediaGallery(mediaGallery); + } + + public MediaGallery getMediaGallery() { + return mMediaGallery; + } + + public void setMediaGallery(MediaGallery mediaGallery) { + this.mMediaGallery = mediaGallery; + } +} diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/WPUnderlineSpan.java b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/WPUnderlineSpan.java new file mode 100644 index 000000000000..12eadb379253 --- /dev/null +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/WPUnderlineSpan.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2006 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 org.wordpress.android.util.helpers; + +import android.os.Parcel; +import android.text.ParcelableSpan; +import android.text.TextPaint; +import android.text.style.CharacterStyle; +import android.text.style.UpdateAppearance; + +public class WPUnderlineSpan extends CharacterStyle + implements UpdateAppearance, ParcelableSpan { + public WPUnderlineSpan() { + } + + public WPUnderlineSpan(Parcel src) { + } + + public int getSpanTypeId() { + return 6; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + } + + @Override + public void updateDrawState(TextPaint ds) { + ds.setUnderlineText(true); + } +}