true
if the {@link Crouton} is being displayed, else
+ * false
.
+ */
+ boolean isShowing() {
+ return (null != activity) && (null != croutonView) && (null != croutonView.getParent());
+ }
+
+ /**
+ * Removes the activity reference this {@link Crouton} is holding
+ */
+ void detachActivity() {
+ activity = null;
+ }
+
+ /**
+ * Removes the viewGroup reference this {@link Crouton} is holding
+ */
+ void detachViewGroup() {
+ viewGroup = null;
+ }
+
+ /**
+ * Removes the lifecycleCallback reference this {@link Crouton} is holding
+ */
+ void detachLifecycleCallback() {
+ lifecycleCallback = null;
+ }
+
+ /**
+ * @return the lifecycleCallback
+ */
+ LifecycleCallback getLifecycleCallback() {
+ return lifecycleCallback;
+ }
+
+ /**
+ * @return the style
+ */
+ Style getStyle() {
+ return style;
+ }
+
+ /**
+ * @return the activity
+ */
+ Activity getActivity() {
+ return activity;
+ }
+
+ /**
+ * @return the viewGroup
+ */
+ ViewGroup getViewGroup() {
+ return viewGroup;
+ }
+
+ /**
+ * @return the text
+ */
+ CharSequence getText() {
+ return text;
+ }
+
+ /**
+ * @return the view
+ */
+ View getView() {
+ // return the custom view if one exists
+ if (null != this.customView) {
+ return this.customView;
+ }
+
+ // if already setup return the view
+ if (null == this.croutonView) {
+ initializeCroutonView();
+ }
+
+ return croutonView;
+ }
+
+ private void initializeCroutonView() {
+ Resources resources = this.activity.getResources();
+
+ this.croutonView = initializeCroutonViewGroup(resources);
+
+ // create content view
+ RelativeLayout contentView = initializeContentView(resources);
+ this.croutonView.addView(contentView);
+ }
+
+ private FrameLayout initializeCroutonViewGroup(Resources resources) {
+ FrameLayout croutonView = new FrameLayout(this.activity);
+
+ if(null != onClickListener)
+ croutonView.setOnClickListener(onClickListener);
+
+ final int height;
+ if (this.style.heightDimensionResId > 0) {
+ height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
+ } else {
+ height = this.style.heightInPixels;
+ }
+
+ final int width;
+ if (this.style.widthDimensionResId > 0) {
+ width = resources.getDimensionPixelSize(this.style.widthDimensionResId);
+ } else {
+ width = this.style.widthInPixels;
+ }
+
+ croutonView.setLayoutParams(
+ new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
+
+ // set background
+ if (this.style.backgroundColorValue != -1) {
+ croutonView.setBackgroundColor(this.style.backgroundColorValue);
+ } else {
+ croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
+ }
+
+ // set the background drawable if set. This will override the background
+ // color.
+ if (this.style.backgroundDrawableResourceId != 0) {
+ Bitmap background = BitmapFactory.decodeResource(resources, this.style.backgroundDrawableResourceId);
+ BitmapDrawable drawable = new BitmapDrawable(resources, background);
+ if (this.style.isTileEnabled) {
+ drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ }
+ croutonView.setBackgroundDrawable(drawable);
+ }
+ return croutonView;
+ }
+
+ private RelativeLayout initializeContentView(final Resources resources) {
+ RelativeLayout contentView = new RelativeLayout(this.activity);
+ contentView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT));
+
+ // set padding
+ int padding = this.style.paddingInPixels;
+
+ // if a padding dimension has been set, this will overwrite any padding
+ // in pixels
+ if (this.style.paddingDimensionResId > 0) {
+ padding = resources.getDimensionPixelSize(this.style.paddingDimensionResId);
+ }
+ contentView.setPadding(padding, padding, padding, padding);
+
+ // only setup image if one is requested
+ ImageView image = null;
+ if ((null != this.style.imageDrawable) || (0 != this.style.imageResId)) {
+ image = initializeImageView();
+ contentView.addView(image, image.getLayoutParams());
+ }
+
+ TextView text = initializeTextView(resources);
+
+ RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ if (null != image) {
+ textParams.addRule(RelativeLayout.RIGHT_OF, image.getId());
+ }
+ contentView.addView(text, textParams);
+ return contentView;
+ }
+
+ private TextView initializeTextView(final Resources resources) {
+ TextView text = new TextView(this.activity);
+ text.setId(TEXT_ID);
+ text.setText(this.text);
+ text.setTypeface(Typeface.DEFAULT_BOLD);
+ text.setGravity(this.style.gravity);
+
+ // set the text color if set
+ if (this.style.textColorResourceId != 0) {
+ text.setTextColor(resources.getColor(this.style.textColorResourceId));
+ }
+
+ // Set the text size. If the user has set a text size and text
+ // appearance, the text size in the text appearance
+ // will override this.
+ if (this.style.textSize != 0) {
+ text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize);
+ }
+
+ // Setup the shadow if requested
+ if (this.style.textShadowColorResId != 0) {
+ initializeTextViewShadow(resources, text);
+ }
+
+ // Set the text appearance
+ if (this.style.textAppearanceResId != 0) {
+ text.setTextAppearance(this.activity, this.style.textAppearanceResId);
+ }
+ return text;
+ }
+
+ private void initializeTextViewShadow(final Resources resources, final TextView text) {
+ int textShadowColor = resources.getColor(this.style.textShadowColorResId);
+ float textShadowRadius = this.style.textShadowRadius;
+ float textShadowDx = this.style.textShadowDx;
+ float textShadowDy = this.style.textShadowDy;
+ text.setShadowLayer(textShadowRadius, textShadowDx, textShadowDy, textShadowColor);
+ }
+
+ private ImageView initializeImageView() {
+ ImageView image;
+ image = new ImageView(this.activity);
+ image.setId(IMAGE_ID);
+ image.setAdjustViewBounds(true);
+ image.setScaleType(this.style.imageScaleType);
+
+ // set the image drawable if not null
+ if (null != this.style.imageDrawable) {
+ image.setImageDrawable(this.style.imageDrawable);
+ }
+
+ // set the image resource if not 0. This will overwrite the drawable
+ // if both are set
+ if (this.style.imageResId != 0) {
+ image.setImageResource(this.style.imageResId);
+ }
+
+ RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ imageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+ imageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
+
+ image.setLayoutParams(imageParams);
+
+ return image;
+ }
+
+ @Override
+ public String toString() {
+ return "Crouton{" +
+ "text=" + text +
+ ", style=" + style +
+ ", customView=" + customView +
+ ", activity=" + activity +
+ ", viewGroup=" + viewGroup +
+ ", croutonView=" + croutonView +
+ ", inAnimation=" + inAnimation +
+ ", outAnimation=" + outAnimation +
+ ", lifecycleCallback=" + lifecycleCallback +
+ '}';
+ }
+}
diff --git a/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
new file mode 100644
index 00000000..b1109c86
--- /dev/null
+++ b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2012 - 2013 Benjamin Weiss
+ * Copyright 2012 Neofonie Mobile GmbH
+ *
+ * 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 de.keyboardsurfer.android.widget.crouton;
+
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
+
+/**
+ * Builds the default animations for showing and hiding a {@link Crouton}.
+ */
+final class DefaultAnimationsBuilder {
+ private static Animation slideInDownAnimation, slideOutUpAnimation;
+
+ protected static final class SlideInDownAnimationParameters {
+ private SlideInDownAnimationParameters() {
+ /* no-op */
+ }
+
+ public static final float FROM_X_DELTA = 0;
+ public static final float TO_X_DELTA = 0;
+ public static final float FROM_Y_DELTA = -50;
+ public static final float TO_Y_DELTA = 0;
+
+ public static final long DURATION = 400;
+ }
+
+ protected static final class SlideOutUpAnimationParameters {
+ private SlideOutUpAnimationParameters() {
+ /* no-op */
+ }
+
+ public static final float FROM_X_DELTA = 0;
+ public static final float TO_X_DELTA = 0;
+ public static final float FROM_Y_DELTA = 0;
+ public static final float TO_Y_DELTA = -50;
+
+ public static final long DURATION = 400;
+ }
+
+ private DefaultAnimationsBuilder() {
+ /* no-op */
+ }
+
+ /**
+ * @return The default Animation for a showing {@link Crouton}.
+ */
+ public static Animation buildDefaultSlideInDownAnimation() {
+ if (null == slideInDownAnimation) {
+ slideInDownAnimation = new TranslateAnimation(SlideInDownAnimationParameters.FROM_X_DELTA,
+ SlideInDownAnimationParameters.TO_X_DELTA,
+ SlideInDownAnimationParameters.FROM_Y_DELTA, SlideInDownAnimationParameters.TO_Y_DELTA);
+ slideInDownAnimation.setDuration(SlideInDownAnimationParameters.DURATION);
+ }
+
+ return slideInDownAnimation;
+ }
+
+ /**
+ * @return The default Animation for a hiding {@link Crouton}.
+ */
+ public static Animation buildDefaultSlideOutUpAnimation() {
+ if (null == slideOutUpAnimation) {
+ slideOutUpAnimation = new TranslateAnimation(SlideOutUpAnimationParameters.FROM_X_DELTA,
+ SlideOutUpAnimationParameters.TO_X_DELTA,
+ SlideOutUpAnimationParameters.FROM_Y_DELTA, SlideOutUpAnimationParameters.TO_Y_DELTA);
+ slideOutUpAnimation.setDuration(SlideOutUpAnimationParameters.DURATION);
+ }
+ return slideOutUpAnimation;
+ }
+}
diff --git a/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java
new file mode 100644
index 00000000..a2ade574
--- /dev/null
+++ b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2012 - 2013 Benjamin Weiss
+ * Copyright 2012 Neofonie Mobile GmbH
+ *
+ * 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 de.keyboardsurfer.android.widget.crouton;
+
+public interface LifecycleCallback {
+ public void onDisplayed();
+ public void onRemoved();
+ //public void onCeasarDressing();
+}
diff --git a/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Manager.java b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Manager.java
new file mode 100644
index 00000000..0d462941
--- /dev/null
+++ b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Manager.java
@@ -0,0 +1,403 @@
+/*
+ * Copyright 2012 - 2013 Benjamin Weiss
+ * Copyright 2012 Neofonie Mobile GmbH
+ *
+ * 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 de.keyboardsurfer.android.widget.crouton;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v4.view.accessibility.AccessibilityEventCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+import android.widget.FrameLayout;
+import java.util.Iterator;
+import java.util.Queue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+
+/**
+ * Manages the lifecycle of {@link Crouton}s.
+ */
+final class Manager extends Handler {
+ private static final class Messages {
+ private Messages() { /* no-op */
+ }
+
+ public static final int DISPLAY_CROUTON = 0xc2007;
+ public static final int ADD_CROUTON_TO_VIEW = 0xc20074dd;
+ public static final int REMOVE_CROUTON = 0xc2007de1;
+ }
+
+ private static Manager INSTANCE;
+
+ private Queue+ * For backwards compatibility, we're constructing an event from scratch + * using the appropriate event type. If your application only targets SDK + * 16+, you can just call View.announceForAccessibility(CharSequence). + *
+ * + * note: AccessibilityManager is only available from API lvl 4. + * + * Adapted from https://http://eyes-free.googlecode.com/files/accessibility_codelab_demos_v2_src.zip + * via https://github.com/coreform/android-formidable-validation + * + * @param context + * Used to get {@link AccessibilityManager} + * @param text + * The text to announce. + */ + public static void announceForAccessibilityCompat(Context context, CharSequence text) { + if (Build.VERSION.SDK_INT >= 4) { + AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService( + Context.ACCESSIBILITY_SERVICE); + if (!accessibilityManager.isEnabled()) { + return; + } + + // Prior to SDK 16, announcements could only be made through FOCUSED + // events. Jelly Bean (SDK 16) added support for speaking text verbatim + // using the ANNOUNCEMENT event type. + final int eventType; + if (Build.VERSION.SDK_INT < 16) { + eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED; + } else { + eventType = AccessibilityEventCompat.TYPE_ANNOUNCEMENT; + } + + // Construct an accessibility event with the minimum recommended + // attributes. An event without a class name or package may be dropped. + final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); + event.getText().add(text); + event.setClassName(Manager.class.getName()); + event.setPackageName(context.getPackageName()); + + // Sends the event directly through the accessibility manager. If your + // application only targets SDK 14+, you should just call + // getParent().requestSendAccessibilityEvent(this, event); + accessibilityManager.sendAccessibilityEvent(event); + } + } +} diff --git a/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Style.java b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Style.java new file mode 100644 index 00000000..28f2adaa --- /dev/null +++ b/external/Crouton/library/src/de/keyboardsurfer/android/widget/crouton/Style.java @@ -0,0 +1,539 @@ +/* + * Copyright 2012 - 2013 Benjamin Weiss + * Copyright 2012 Neofonie Mobile GmbH + * + * 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 de.keyboardsurfer.android.widget.crouton; + +import android.graphics.drawable.Drawable; +import android.view.Gravity; +import android.view.ViewGroup.LayoutParams; +import android.widget.ImageView; + + +/** + * The style for a {@link Crouton}. + */ + +public class Style { + + /** + * Display a {@link Crouton} for an infinite amount of time or + * until {@link de.keyboardsurfer.android.widget.crouton.Crouton#cancel()} has been called. + */ + public static final int DURATION_INFINITE = -1; + + /** + * Default style for alerting the user. + */ + public static final Style ALERT; + /** + * Default style for confirming an action. + */ + public static final Style CONFIRM; + /** + * Default style for general information. + */ + public static final Style INFO; + + public static final int holoRedLight = 0xffff4444; + public static final int holoGreenLight = 0xff99cc00; + public static final int holoBlueLight = 0xff33b5e5; + + static { + ALERT = new Builder().setDuration(5000).setBackgroundColorValue(holoRedLight).setHeight(LayoutParams.WRAP_CONTENT) + .build(); + CONFIRM = new Builder().setDuration(3000).setBackgroundColorValue(holoGreenLight).setHeight( + LayoutParams.WRAP_CONTENT).build(); + INFO = new Builder().setDuration(3000).setBackgroundColorValue(holoBlueLight).setHeight(LayoutParams.WRAP_CONTENT) + .build(); + } + + /** + * The durationInMilliseconds the {@link Crouton} will be displayed in + * milliseconds. + */ + final int durationInMilliseconds; + + /** + * The resource id of the backgroundResourceId. + * + * 0 for no backgroundResourceId. + */ + final int backgroundColorResourceId; + + /** + * The resource id of the backgroundDrawableResourceId. + * + * 0 for no backgroundDrawableResourceId. + */ + final int backgroundDrawableResourceId; + + /** + * The backgroundColorResourceValue's e.g. 0xffff4444; + * + * -1 for no value. + */ + final int backgroundColorValue; + + /** + * Whether we should isTileEnabled the backgroundResourceId or not. + */ + final boolean isTileEnabled; + + /** + * The text colorResourceId's resource id. + * + * 0 sets the text colorResourceId to the system theme default. + */ + final int textColorResourceId; + + /** + * The height of the {@link Crouton} in pixels. + */ + final int heightInPixels; + + /** + * Resource ID for the height of the {@link Crouton}. + */ + final int heightDimensionResId; + + /** + * The width of the {@link Crouton} in pixels. + */ + final int widthInPixels; + + /** + * Resource ID for the width of the {@link Crouton}. + */ + final int widthDimensionResId; + + /** + * The text's gravity as provided by {@link Gravity}. + */ + final int gravity; + + /** + * An additional image to display in the {@link Crouton}. + */ + final Drawable imageDrawable; + + /** + * An additional image to display in the {@link Crouton}. + */ + final int imageResId; + + /** + * The {@link ImageView.ScaleType} for the image to display in the + * {@link Crouton}. + */ + final ImageView.ScaleType imageScaleType; + + /** + * The text size in sp + * + * 0 sets the text size to the system theme default + */ + final int textSize; + + /** + * The text shadow color's resource id + */ + final int textShadowColorResId; + + /** + * The text shadow radius + */ + final float textShadowRadius; + + /** + * The text shadow vertical offset + */ + final float textShadowDy; + + /** + * The text shadow horizontal offset + */ + final float textShadowDx; + + /** + * The text appearance resource id for the text. + */ + final int textAppearanceResId; + + /** + * The resource id for the in animation + */ + final int inAnimationResId; + + /** + * The resource id for the out animation + */ + final int outAnimationResId; + + /** + * The padding for the crouton view content in pixels + */ + final int paddingInPixels; + + /** + * The resource id for the padding for the view content + */ + final int paddingDimensionResId; + + private Style(final Builder builder) { + this.durationInMilliseconds = builder.durationInMilliseconds; + this.backgroundColorResourceId = builder.backgroundColorResourceId; + this.backgroundDrawableResourceId = builder.backgroundDrawableResourceId; + this.isTileEnabled = builder.isTileEnabled; + this.textColorResourceId = builder.textColorResourceId; + this.heightInPixels = builder.heightInPixels; + this.heightDimensionResId = builder.heightDimensionResId; + this.widthInPixels = builder.widthInPixels; + this.widthDimensionResId = builder.widthDimensionResId; + this.gravity = builder.gravity; + this.imageDrawable = builder.imageDrawable; + this.textSize = builder.textSize; + this.textShadowColorResId = builder.textShadowColorResId; + this.textShadowRadius = builder.textShadowRadius; + this.textShadowDx = builder.textShadowDx; + this.textShadowDy = builder.textShadowDy; + this.textAppearanceResId = builder.textAppearanceResId; + this.inAnimationResId = builder.inAnimationResId; + this.outAnimationResId = builder.outAnimationResId; + this.imageResId = builder.imageResId; + this.imageScaleType = builder.imageScaleType; + this.paddingInPixels = builder.paddingInPixels; + this.paddingDimensionResId = builder.paddingDimensionResId; + this.backgroundColorValue = builder.backgroundColorValue; + } + + /** + * Builder for the {@link Style} object. + */ + public static class Builder { + private int durationInMilliseconds; + private int backgroundColorValue; + private int backgroundColorResourceId; + private int backgroundDrawableResourceId; + private boolean isTileEnabled; + private int textColorResourceId; + private int heightInPixels; + private int heightDimensionResId; + private int widthInPixels; + private int widthDimensionResId; + private int gravity; + private Drawable imageDrawable; + private int textSize; + private int textShadowColorResId; + private float textShadowRadius; + private float textShadowDx; + private float textShadowDy; + private int textAppearanceResId; + private int inAnimationResId; + private int outAnimationResId; + private int imageResId; + private ImageView.ScaleType imageScaleType; + private int paddingInPixels; + private int paddingDimensionResId; + + public Builder() { + durationInMilliseconds = 3000; + paddingInPixels = 10; + backgroundColorResourceId = android.R.color.holo_blue_light; + backgroundDrawableResourceId = 0; + backgroundColorValue = -1; + isTileEnabled = false; + textColorResourceId = android.R.color.white; + heightInPixels = LayoutParams.WRAP_CONTENT; + widthInPixels = LayoutParams.MATCH_PARENT; + gravity = Gravity.CENTER; + imageDrawable = null; + inAnimationResId = 0; + outAnimationResId = 0; + imageResId = 0; + imageScaleType = ImageView.ScaleType.FIT_XY; + } + + /** + * Set the durationInMilliseconds option of the {@link Crouton}. + * + * @param duration + * The durationInMilliseconds the crouton will be displayed + * {@link Crouton} in milliseconds. + * @return the {@link Builder}. + */ + public Builder setDuration(int duration) { + this.durationInMilliseconds = duration; + + return this; + } + + /** + * Set the backgroundColorResourceId option of the {@link Crouton}. + * + * @param backgroundColorResourceId + * The backgroundColorResourceId's resource id. + * @return the {@link Builder}. + */ + public Builder setBackgroundColor(int backgroundColorResourceId) { + this.backgroundColorResourceId = backgroundColorResourceId; + + return this; + } + + /** + * Set the backgroundColorResourceValue option of the {@link Crouton}. + * + * @param backgroundColorValue + * The backgroundColorResourceValue's e.g. 0xffff4444; + * @return the {@link Builder}. + */ + public Builder setBackgroundColorValue(int backgroundColorValue) { + this.backgroundColorValue = backgroundColorValue; + return this; + } + + /** + * Set the backgroundDrawableResourceId option for the {@link Crouton}. + * + * @param backgroundDrawableResourceId + * Resource ID of a backgroundDrawableResourceId image drawable. + * @return the {@link Builder}. + */ + public Builder setBackgroundDrawable(int backgroundDrawableResourceId) { + this.backgroundDrawableResourceId = backgroundDrawableResourceId; + + return this; + } + + /** + * Set the heightInPixels option for the {@link Crouton}. + * + * @param height + * The height of the {@link Crouton} in pixel. Can also be + * {@link LayoutParams#MATCH_PARENT} or + * {@link LayoutParams#WRAP_CONTENT}. + * @return the {@link Builder}. + */ + public Builder setHeight(int height) { + this.heightInPixels = height; + + return this; + } + + /** + * Set the resource id for the height option for the {@link Crouton}. + * + * @param heightDimensionResId + * Resource ID of a dimension for the height of the {@link Crouton}. + * @return the {@link Builder}. + */ + public Builder setHeightDimensionResId(int heightDimensionResId) { + this.heightDimensionResId = heightDimensionResId; + + return this; + } + + /** + * Set the widthInPixels option for the {@link Crouton}. + * + * @param width + * The width of the {@link Crouton} in pixel. Can also be + * {@link LayoutParams#MATCH_PARENT} or + * {@link LayoutParams#WRAP_CONTENT}. + * @return the {@link Builder}. + */ + public Builder setWidth(int width) { + this.widthInPixels = width; + + return this; + } + + /** + * Set the resource id for the width option for the {@link Crouton}. + * + * @param widthDimensionResId + * Resource ID of a dimension for the width of the {@link Crouton}. + * @return the {@link Builder}. + */ + public Builder setWidthDimensionResId(int widthDimensionResId) { + this.widthDimensionResId = widthDimensionResId; + + return this; + } + + /** + * Set the isTileEnabled option for the {@link Crouton}. + * + * @param isTileEnabled + *true
if you want the backgroundResourceId to be
+ * tiled, else false
.
+ * @return the {@link Builder}.
+ */
+ public Builder setTileEnabled(boolean isTileEnabled) {
+ this.isTileEnabled = isTileEnabled;
+
+ return this;
+ }
+
+ /**
+ * Set the textColorResourceId option for the {@link Crouton}.
+ *
+ * @param textColor
+ * The resource id of the text colorResourceId.
+ * @return the {@link Builder}.
+ */
+ public Builder setTextColor(int textColor) {
+ this.textColorResourceId = textColor;
+
+ return this;
+ }
+
+ /**
+ * Set the gravity option for the {@link Crouton}.
+ *
+ * @param gravity
+ * The text's gravity as provided by {@link Gravity}.
+ * @return the {@link Builder}.
+ */
+ public Builder setGravity(int gravity) {
+ this.gravity = gravity;
+
+ return this;
+ }
+
+ /**
+ * Set the image option for the {@link Crouton}.
+ *
+ * @param imageDrawable
+ * An additional image to display in the {@link Crouton}.
+ * @return the {@link Builder}.
+ */
+ public Builder setImageDrawable(Drawable imageDrawable) {
+ this.imageDrawable = imageDrawable;
+
+ return this;
+ }
+
+ /**
+ * Set the image resource option for the {@link Crouton}.
+ *
+ * @param imageResId
+ * An additional image to display in the {@link Crouton}.
+ * @return the {@link Builder}.
+ */
+ public Builder setImageResource(int imageResId) {
+ this.imageResId = imageResId;
+
+ return this;
+ }
+
+ /**
+ * The text size in sp
+ */
+ public Builder setTextSize(int textSize) {
+ this.textSize = textSize;
+ return this;
+ }
+
+ /**
+ * The text shadow color's resource id
+ */
+ public Builder setTextShadowColor(int textShadowColorResId) {
+ this.textShadowColorResId = textShadowColorResId;
+ return this;
+ }
+
+ /**
+ * The text shadow radius
+ */
+ public Builder setTextShadowRadius(float textShadowRadius) {
+ this.textShadowRadius = textShadowRadius;
+ return this;
+ }
+
+ /**
+ * The text shadow horizontal offset
+ */
+ public Builder setTextShadowDx(float textShadowDx) {
+ this.textShadowDx = textShadowDx;
+ return this;
+ }
+
+ /**
+ * The text shadow vertical offset
+ */
+ public Builder setTextShadowDy(float textShadowDy) {
+ this.textShadowDy = textShadowDy;
+ return this;
+ }
+
+ /**
+ * The text appearance resource id for the text.
+ */
+ public Builder setTextAppearance(int textAppearanceResId) {
+ this.textAppearanceResId = textAppearanceResId;
+ return this;
+ }
+
+ /**
+ * The resource id for the in animation
+ */
+ public Builder setInAnimation(int inAnimationResId) {
+ this.inAnimationResId = inAnimationResId;
+ return this;
+ }
+
+ /**
+ * The resource id for the out animation
+ */
+ public Builder setOutAnimation(int outAnimationResId) {
+ this.outAnimationResId = outAnimationResId;
+ return this;
+ }
+
+ /**
+ * The {@link android.widget.ImageView.ScaleType} for the image
+ */
+ public Builder setImageScaleType(ImageView.ScaleType imageScaleType) {
+ this.imageScaleType = imageScaleType;
+ return this;
+ }
+
+ /**
+ * The padding for the crouton view's content in pixels
+ */
+ public Builder setPaddingInPixels(int padding) {
+ this.paddingInPixels = padding;
+ return this;
+ }
+
+ /**
+ * The resource id for the padding for the crouton view's content
+ */
+ public Builder setPaddingDimensionResId(int paddingResId) {
+ this.paddingDimensionResId = paddingResId;
+ return this;
+ }
+
+ /**
+ * @return a configured {@link Style} object.
+ */
+ public Style build() {
+ return new Style(this);
+ }
+ }
+}
diff --git a/external/Crouton/pom.xml b/external/Crouton/pom.xml
new file mode 100644
index 00000000..a56203e5
--- /dev/null
+++ b/external/Crouton/pom.xml
@@ -0,0 +1,102 @@
+
+
+
+
+