diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1e01da --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +/.idea diff --git a/ZJlibrary/.gitignore b/ZJlibrary/.gitignore new file mode 100644 index 0000000..3fe82fd --- /dev/null +++ b/ZJlibrary/.gitignore @@ -0,0 +1,3 @@ +/build +/src/test +/src/androidTest \ No newline at end of file diff --git a/ZJlibrary/build.gradle b/ZJlibrary/build.gradle new file mode 100644 index 0000000..fad0afd --- /dev/null +++ b/ZJlibrary/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.2.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + +} \ No newline at end of file diff --git a/ZJlibrary/consumer-rules.pro b/ZJlibrary/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/ZJlibrary/proguard-rules.pro b/ZJlibrary/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/ZJlibrary/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/ZJlibrary/src/main/AndroidManifest.xml b/ZJlibrary/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1c6224e --- /dev/null +++ b/ZJlibrary/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextView.java b/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextView.java new file mode 100644 index 0000000..575b68a --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextView.java @@ -0,0 +1,34 @@ +package com.zjview.library; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.util.AttributeSet; +import android.view.Gravity; +import android.widget.TextView; + + +@SuppressLint("AppCompatCustomView") +public class ZJCenterTextView extends TextView implements ZJView { + + + private ZJCenterTextViewRenderProxy mSharpViewRenderProxy; + + public ZJCenterTextView(Context context) { + this(context, null); + } + + public ZJCenterTextView(Context context, AttributeSet attrs) { + this(context, attrs, -1); + } + + public ZJCenterTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.mSharpViewRenderProxy = new ZJCenterTextViewRenderProxy(this, context, attrs, defStyleAttr); + setGravity(Gravity.CENTER); + } + + + public ZJCenterTextViewRenderProxy getmSharpViewRenderProxy() { + return mSharpViewRenderProxy; + } +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextViewRenderProxy.java b/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextViewRenderProxy.java new file mode 100644 index 0000000..a44d6ae --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJCenterTextViewRenderProxy.java @@ -0,0 +1,247 @@ +package com.zjview.library; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; + + +public class ZJCenterTextViewRenderProxy { + public static final int TOP_BOTTOM = 0; + public static final int TR_BL = 1; + public static final int RIGHT_LEFT = 2; + public static final int BR_TL = 3; + public static final int BOTTOM_TOP = 4; + public static final int BL_TR = 5; + public static final int LEFT_RIGHT = 6; + public static final int TL_BR = 7; + private View mView; + private int textGravity; + private ZJCenterTextView textView; + + public int getGradientOrientation() { + return gradientOrientation; + } + + public void setGradientOrientation(int gradientOrientation) { + this.gradientOrientation = gradientOrientation; + } + + private int gradientOrientation; + + + public float getRadius() { + return mRadius; + } + + public int getBackgroundColor() { + return mBackgroundColor; + } + + public float getRelativePosition() { + return mRelativePosition; + } + + public float getSharpSize() { + return mSharpSize; + } + + public float getBorder() { + return mBorder; + } + + public int getBorderColor() { + return mBorderColor; + } + + public int[] getBgColors() { + return mBgColors; + } + + public float[] getCornerRadii() { + return mCornerRadii; + } + + public ZJView.ArrowDirection getArrowDirection() { + return mArrowDirection; + } + + private float mRadius; + + private int mBackgroundColor; + + private float mRelativePosition; + + private float mSharpSize; + + private float mBorder; + + private int mBorderColor; + + public void setBgColor(int[] bgColor) { + mBgColors = bgColor; + refreshView(); + } + + private int[] mBgColors; + + public void setCornerRadii(float leftTop, float rightTop, float rightBottom, float leftBottom) { + mCornerRadii[0] = leftTop; + mCornerRadii[1] = leftTop; + mCornerRadii[2] = rightTop; + mCornerRadii[3] = rightTop; + mCornerRadii[4] = rightBottom; + mCornerRadii[5] = rightBottom; + mCornerRadii[6] = leftBottom; + mCornerRadii[7] = leftBottom; + + } + + private float[] mCornerRadii = new float[8]; + + private ZJView.ArrowDirection mArrowDirection = ZJView.ArrowDirection.LEFT; + + public void setBorder(float border) { + mBorder = border; + refreshView(); + } + + public void setBorderColor(int borderColor) { + mBorderColor = borderColor; + refreshView(); + } + + ZJCenterTextViewRenderProxy(View view, Context context, AttributeSet attrs, int defStyleAttr) { + mView = view; + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ZJCenterTextView, defStyleAttr, 0); + mRadius = typedArray.getDimension(R.styleable.ZJCenterTextView_radius, 0); + mCornerRadii[0] = mCornerRadii[1] = typedArray.getDimension(R.styleable.ZJCenterTextView_left_top_radius, 0); + mCornerRadii[2] = mCornerRadii[3] = typedArray.getDimension(R.styleable.ZJCenterTextView_right_top_radius, 0); + mCornerRadii[4] = mCornerRadii[5] = typedArray.getDimension(R.styleable.ZJCenterTextView_right_bottom_radius, 0); + mCornerRadii[6] = mCornerRadii[7] = typedArray.getDimension(R.styleable.ZJCenterTextView_left_bottom_radius, 0); + mBorder = typedArray.getDimension(R.styleable.ZJCenterTextView_border, 0); + mBackgroundColor = typedArray.getColor(R.styleable.ZJCenterTextView_backgroundColor, 0); + mBorderColor = typedArray.getColor(R.styleable.ZJCenterTextView_borderColor, 0); + int direction = typedArray.getInt(R.styleable.ZJCenterTextView_arrowDirection, 3); + mRelativePosition = typedArray.getFraction(R.styleable.ZJCenterTextView_relativePosition, 1, 1, 0.5f); + mSharpSize = typedArray.getDimension(R.styleable.ZJCenterTextView_sharpSize, 0); + textGravity = typedArray.getInt(R.styleable.ZJCenterTextView_android_gravity, Gravity.CENTER); + + gradientOrientation = typedArray.getInt(R.styleable.ZJCenterTextView_gradient_orientation, 6); + switch (direction) { + case 1: + mArrowDirection = ZJView.ArrowDirection.LEFT; + break; + case 2: + mArrowDirection = ZJView.ArrowDirection.TOP; + break; + case 3: + mArrowDirection = ZJView.ArrowDirection.RIGHT; + break; + case 4: + mArrowDirection = ZJView.ArrowDirection.BOTTOM; + break; + } + int start = typedArray.getColor(R.styleable.ZJCenterTextView_startBgColor, -1); + int middle = typedArray.getColor(R.styleable.ZJCenterTextView_middleBgColor, -1); + int end = typedArray.getColor(R.styleable.ZJCenterTextView_endBgColor, -1); + if (start != -1 && end != -1) { + if (middle != -1) { + mBgColors = new int[]{start, middle, end}; + } else { + mBgColors = new int[]{start, end}; + } + } + typedArray.recycle(); + refreshView(); + } + + ZJDrawable mSharpDrawable; + + private void refreshView() { + ZJDrawable bd = new ZJDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null); + mSharpDrawable = bd; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + bd.setColors(mBgColors); + switch (gradientOrientation) { + case TOP_BOTTOM: + bd.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); + break; + case TR_BL: + bd.setOrientation(GradientDrawable.Orientation.TR_BL); + break; + case RIGHT_LEFT: + bd.setOrientation(GradientDrawable.Orientation.RIGHT_LEFT); + break; + case BR_TL: + bd.setOrientation(GradientDrawable.Orientation.BR_TL); + break; + case BOTTOM_TOP: + bd.setOrientation(GradientDrawable.Orientation.BOTTOM_TOP); + break; + case BL_TR: + bd.setOrientation(GradientDrawable.Orientation.BL_TR); + break; + case LEFT_RIGHT: + bd.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); + break; + case TL_BR: + bd.setOrientation(GradientDrawable.Orientation.TL_BR); + break; + } + } else { + bd.setColor(mBgColors[0]); + } + + if (mBgColors != null) { + bd.setColors(mBgColors); + } else { + bd.setBgColor(mBackgroundColor); + } + bd.setSharpSize(mSharpSize); + bd.setArrowDirection(mArrowDirection); + bd.setCornerRadius(mRadius); + bd.setBorder(mBorder); + bd.setBorderColor(mBorderColor); + bd.setRelativePosition(mRelativePosition); + if (mRadius == 0) { + bd.setCornerRadii(mCornerRadii); + } + + mView.setBackground(bd); + textView = (ZJCenterTextView) mView; + textView.setGravity(textGravity); + } + + public void setRadius(float radius) { + mRadius = radius; + refreshView(); + } + + public void setBackgroundColor(int backgroundColor) { + mBackgroundColor = backgroundColor; + mBgColors = null; + refreshView(); + } + + public void setRelativePosition(float relativePosition) { + mRelativePosition = relativePosition; + refreshView(); + } + + public void setSharpSize(float sharpSize) { + mSharpSize = sharpSize; + refreshView(); + } + + public void setArrowDirection(ZJView.ArrowDirection arrowDirection) { + mArrowDirection = arrowDirection; + refreshView(); + } + + +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJDrawable.java b/ZJlibrary/src/main/java/com/zjview/library/ZJDrawable.java new file mode 100644 index 0000000..18cd42f --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJDrawable.java @@ -0,0 +1,158 @@ +package com.zjview.library; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PointF; +import android.graphics.Rect; +import android.graphics.RectF; +import android.graphics.drawable.GradientDrawable; + +import androidx.annotation.ColorInt; + +class ZJDrawable extends GradientDrawable { + + + ZJDrawable(Orientation orientation, @ColorInt int[] colors) { + super(orientation, colors); + init(); + } + + void setBgColor(int bgColor) { + mBgColor = bgColor; + super.setColor(bgColor); + } + + public void setCornerRadius(float cornerRadius) { + mCornerRadius = cornerRadius; + super.setCornerRadius(cornerRadius); + } + + void setArrowDirection(ZJView.ArrowDirection arrowDirection) { + mArrowDirection = arrowDirection; + } + + void setRelativePosition(float relativePosition) { + mRelativePosition = Math.min(Math.max(relativePosition, 0), 1); + } + + void setBorder(float border) { + mBorder = border; + super.setStroke((int) mBorder, mBorderColor); + } + + void setBorderColor(int borderColor) { + mBorderColor = borderColor; + super.setStroke((int) mBorder, mBorderColor); + } + + void setSharpSize(float sharpSize) { + mSharpSize = sharpSize; + } + + private float mSharpSize; + + private int mBgColor; + + private float mCornerRadius; + + private ZJView.ArrowDirection mArrowDirection; + + private float mBorder; + + private int mBorderColor; + + /** + * from 0 to 1 + */ + private float mRelativePosition; + + void setPaint(Paint paint) { + mPaint = paint; + } + + private Paint mPaint; + + private RectF mRect; + + private Path mPath; + + private PointF[] mPointFs; + + ZJDrawable() { + super(); + init(); + } + + private void init() { + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPaint.setAntiAlias(true); + mRect = new RectF(); + mPointFs = new PointF[3]; + mPath = new Path(); + mPointFs[0] = new PointF(); + mPointFs[1] = new PointF(); + mPointFs[2] = new PointF(); + } + + @Override + public void draw(Canvas canvas) { + if (mSharpSize == 0) { + super.draw(canvas); + } else { + Rect bounds = getBounds(); + int left = bounds.left; + int top = bounds.top; + int right = bounds.right; + int bottom = bounds.bottom; + float length; + switch (mArrowDirection) { + case LEFT: + left += mSharpSize; + length = Math.max(mRelativePosition * bounds.height() + bounds.top, mSharpSize + mCornerRadius); + length = Math.min(length, bounds.height() - mSharpSize - mCornerRadius); + mPointFs[0].set(bounds.left, length + bounds.top); + mPointFs[1].set(left, mPointFs[0].y - mSharpSize); + mPointFs[2].set(left, mPointFs[0].y + mSharpSize); + mRect.set(left, top, right, bottom); + break; + case TOP: + top += mSharpSize; + length = Math.max(mRelativePosition * bounds.width() + bounds.top, mSharpSize + mCornerRadius); + length = Math.min(length, bounds.width() - mSharpSize - mCornerRadius); + mPointFs[0].set(bounds.left + length, bounds.top); + mPointFs[1].set(mPointFs[0].x - mSharpSize, top); + mPointFs[2].set(mPointFs[0].x + mSharpSize, top); + mRect.set(left, top, right, bottom); + break; + case RIGHT: + right -= mSharpSize; + length = Math.max(mRelativePosition * bounds.height() + bounds.top, mSharpSize + mCornerRadius); + length = Math.min(length, bounds.height() - mSharpSize - mCornerRadius); + mPointFs[0].set(bounds.right, length + bounds.top); + mPointFs[1].set(right, mPointFs[0].y - mSharpSize); + mPointFs[2].set(right, mPointFs[0].y + mSharpSize); + mRect.set(left, top, right, bottom); + break; + case BOTTOM: + bottom -= mSharpSize; + length = Math.max(mRelativePosition * bounds.width() + bounds.top, mSharpSize + mCornerRadius); + length = Math.min(length, bounds.width() - mSharpSize - mCornerRadius); + mPointFs[0].set(bounds.left + length, bounds.bottom); + mPointFs[1].set(mPointFs[0].x - mSharpSize, bottom); + mPointFs[2].set(mPointFs[0].x + mSharpSize, bottom); + mRect.set(left, top, right, bottom); + break; + } + mPath.reset(); + mPath.addRoundRect(mRect, mCornerRadius, mCornerRadius, Path.Direction.CW); + mPath.moveTo(mPointFs[0].x, mPointFs[0].y); + mPath.lineTo(mPointFs[1].x, mPointFs[1].y); + mPath.lineTo(mPointFs[2].x, mPointFs[2].y); + mPath.lineTo(mPointFs[0].x, mPointFs[0].y); + mPaint.setColor(mBgColor); + canvas.drawPath(mPath, mPaint); + } + } + +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJRelativeLayout.java b/ZJlibrary/src/main/java/com/zjview/library/ZJRelativeLayout.java new file mode 100644 index 0000000..2308721 --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJRelativeLayout.java @@ -0,0 +1,37 @@ +package com.zjview.library; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.util.AttributeSet; +import android.widget.RelativeLayout; + +@SuppressLint("AppCompatCustomView") +public class ZJRelativeLayout extends RelativeLayout implements ZJView { + + + public ZJViewRenderProxy getmSharpViewRenderProxy() { + return mSharpViewRenderProxy; + } + + private ZJViewRenderProxy mSharpViewRenderProxy; + + public ZJRelativeLayout(Context context) { + super(context); + init(context, null, 0); + } + + public ZJRelativeLayout(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs, 0); + } + + public ZJRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context, attrs, defStyleAttr); + } + + private void init(Context context, AttributeSet attrs, int defStyleAttr) { + mSharpViewRenderProxy = new ZJViewRenderProxy(this, context, attrs, defStyleAttr); + } + +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJTextView.java b/ZJlibrary/src/main/java/com/zjview/library/ZJTextView.java new file mode 100644 index 0000000..9a094b6 --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJTextView.java @@ -0,0 +1,32 @@ +package com.zjview.library; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.util.AttributeSet; +import android.widget.TextView; + + +@SuppressLint("AppCompatCustomView") +public class ZJTextView extends TextView implements ZJView { + + + private ZJTextViewRenderProxy mSharpViewRenderProxy; + + public ZJTextView(Context context) { + this(context, null); + } + + public ZJTextView(Context context, AttributeSet attrs) { + this(context, attrs, -1); + } + + public ZJTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.mSharpViewRenderProxy = new ZJTextViewRenderProxy(this, context, attrs, defStyleAttr); + } + + + public ZJTextViewRenderProxy getmSharpViewRenderProxy() { + return mSharpViewRenderProxy; + } +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJTextViewRenderProxy.java b/ZJlibrary/src/main/java/com/zjview/library/ZJTextViewRenderProxy.java new file mode 100644 index 0000000..1a800ad --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJTextViewRenderProxy.java @@ -0,0 +1,248 @@ +package com.zjview.library; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; + + + +public class ZJTextViewRenderProxy { + public static final int TOP_BOTTOM = 0; + public static final int TR_BL = 1; + public static final int RIGHT_LEFT = 2; + public static final int BR_TL = 3; + public static final int BOTTOM_TOP = 4; + public static final int BL_TR = 5; + public static final int LEFT_RIGHT = 6; + public static final int TL_BR = 7; + private View mView; + private int textGravity; + private ZJTextView textView; + + public int getGradientOrientation() { + return gradientOrientation; + } + + public void setGradientOrientation(int gradientOrientation) { + this.gradientOrientation = gradientOrientation; + } + + private int gradientOrientation; + + + public float getRadius() { + return mRadius; + } + + public int getBackgroundColor() { + return mBackgroundColor; + } + + public float getRelativePosition() { + return mRelativePosition; + } + + public float getSharpSize() { + return mSharpSize; + } + + public float getBorder() { + return mBorder; + } + + public int getBorderColor() { + return mBorderColor; + } + + public int[] getBgColors() { + return mBgColors; + } + + public float[] getCornerRadii() { + return mCornerRadii; + } + + public ZJView.ArrowDirection getArrowDirection() { + return mArrowDirection; + } + + private float mRadius; + + private int mBackgroundColor; + + private float mRelativePosition; + + private float mSharpSize; + + private float mBorder; + + private int mBorderColor; + + public void setBgColor(int[] bgColor) { + mBgColors = bgColor; + refreshView(); + } + + private int[] mBgColors; + + public void setCornerRadii(float leftTop, float rightTop, float rightBottom, float leftBottom) { + mCornerRadii[0] = leftTop; + mCornerRadii[1] = leftTop; + mCornerRadii[2] = rightTop; + mCornerRadii[3] = rightTop; + mCornerRadii[4] = rightBottom; + mCornerRadii[5] = rightBottom; + mCornerRadii[6] = leftBottom; + mCornerRadii[7] = leftBottom; + + } + + private float[] mCornerRadii = new float[8]; + + private ZJView.ArrowDirection mArrowDirection = ZJView.ArrowDirection.LEFT; + + public void setBorder(float border) { + mBorder = border; + refreshView(); + } + + public void setBorderColor(int borderColor) { + mBorderColor = borderColor; + refreshView(); + } + + ZJTextViewRenderProxy(View view, Context context, AttributeSet attrs, int defStyleAttr) { + mView = view; + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ZJTextView, defStyleAttr, 0); + mRadius = typedArray.getDimension(R.styleable.ZJTextView_radius, 0); + mCornerRadii[0] = mCornerRadii[1] = typedArray.getDimension(R.styleable.ZJTextView_left_top_radius, 0); + mCornerRadii[2] = mCornerRadii[3] = typedArray.getDimension(R.styleable.ZJTextView_right_top_radius, 0); + mCornerRadii[4] = mCornerRadii[5] = typedArray.getDimension(R.styleable.ZJTextView_right_bottom_radius, 0); + mCornerRadii[6] = mCornerRadii[7] = typedArray.getDimension(R.styleable.ZJTextView_left_bottom_radius, 0); + mBorder = typedArray.getDimension(R.styleable.ZJTextView_border, 0); + mBackgroundColor = typedArray.getColor(R.styleable.ZJTextView_backgroundColor, 0); + mBorderColor = typedArray.getColor(R.styleable.ZJTextView_borderColor, 0); + int direction = typedArray.getInt(R.styleable.ZJTextView_arrowDirection, 3); + mRelativePosition = typedArray.getFraction(R.styleable.ZJTextView_relativePosition, 1, 1, 0.5f); + mSharpSize = typedArray.getDimension(R.styleable.ZJTextView_sharpSize, 0); + textGravity = typedArray.getInt(R.styleable.ZJTextView_android_gravity, Gravity.CENTER); + + gradientOrientation = typedArray.getInt(R.styleable.ZJTextView_gradient_orientation, 6); + switch (direction) { + case 1: + mArrowDirection = ZJView.ArrowDirection.LEFT; + break; + case 2: + mArrowDirection = ZJView.ArrowDirection.TOP; + break; + case 3: + mArrowDirection = ZJView.ArrowDirection.RIGHT; + break; + case 4: + mArrowDirection = ZJView.ArrowDirection.BOTTOM; + break; + } + int start = typedArray.getColor(R.styleable.ZJTextView_startBgColor, -1); + int middle = typedArray.getColor(R.styleable.ZJTextView_middleBgColor, -1); + int end = typedArray.getColor(R.styleable.ZJTextView_endBgColor, -1); + if (start != -1 && end != -1) { + if (middle != -1) { + mBgColors = new int[]{start, middle, end}; + } else { + mBgColors = new int[]{start, end}; + } + } + typedArray.recycle(); + refreshView(); + } + + ZJDrawable mSharpDrawable; + + private void refreshView() { + ZJDrawable bd = new ZJDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null); + mSharpDrawable = bd; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + bd.setColors(mBgColors); + switch (gradientOrientation) { + case TOP_BOTTOM: + bd.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); + break; + case TR_BL: + bd.setOrientation(GradientDrawable.Orientation.TR_BL); + break; + case RIGHT_LEFT: + bd.setOrientation(GradientDrawable.Orientation.RIGHT_LEFT); + break; + case BR_TL: + bd.setOrientation(GradientDrawable.Orientation.BR_TL); + break; + case BOTTOM_TOP: + bd.setOrientation(GradientDrawable.Orientation.BOTTOM_TOP); + break; + case BL_TR: + bd.setOrientation(GradientDrawable.Orientation.BL_TR); + break; + case LEFT_RIGHT: + bd.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); + break; + case TL_BR: + bd.setOrientation(GradientDrawable.Orientation.TL_BR); + break; + } + } else { + bd.setColor(mBgColors[0]); + } + + if (mBgColors != null) { + bd.setColors(mBgColors); + } else { + bd.setBgColor(mBackgroundColor); + } + bd.setSharpSize(mSharpSize); + bd.setArrowDirection(mArrowDirection); + bd.setCornerRadius(mRadius); + bd.setBorder(mBorder); + bd.setBorderColor(mBorderColor); + bd.setRelativePosition(mRelativePosition); + if (mRadius == 0) { + bd.setCornerRadii(mCornerRadii); + } + + mView.setBackground(bd); + textView = (ZJTextView) mView; + textView.setGravity(textGravity); + } + + public void setRadius(float radius) { + mRadius = radius; + refreshView(); + } + + public void setBackgroundColor(int backgroundColor) { + mBackgroundColor = backgroundColor; + mBgColors = null; + refreshView(); + } + + public void setRelativePosition(float relativePosition) { + mRelativePosition = relativePosition; + refreshView(); + } + + public void setSharpSize(float sharpSize) { + mSharpSize = sharpSize; + refreshView(); + } + + public void setArrowDirection(ZJView.ArrowDirection arrowDirection) { + mArrowDirection = arrowDirection; + refreshView(); + } + + +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJView.java b/ZJlibrary/src/main/java/com/zjview/library/ZJView.java new file mode 100644 index 0000000..52a6d7c --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJView.java @@ -0,0 +1,11 @@ +package com.zjview.library; + + + + +public interface ZJView { + + enum ArrowDirection { + LEFT, TOP, RIGHT, BOTTOM + } +} diff --git a/ZJlibrary/src/main/java/com/zjview/library/ZJViewRenderProxy.java b/ZJlibrary/src/main/java/com/zjview/library/ZJViewRenderProxy.java new file mode 100644 index 0000000..68bdd23 --- /dev/null +++ b/ZJlibrary/src/main/java/com/zjview/library/ZJViewRenderProxy.java @@ -0,0 +1,241 @@ +package com.zjview.library; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.util.AttributeSet; +import android.view.View; + + +public class ZJViewRenderProxy { + public static final int TOP_BOTTOM = 0; + public static final int TR_BL = 1; + public static final int RIGHT_LEFT = 2; + public static final int BR_TL = 3; + public static final int BOTTOM_TOP = 4; + public static final int BL_TR = 5; + public static final int LEFT_RIGHT = 6; + public static final int TL_BR = 7; + private View mView; + + public int getGradientOrientation() { + return gradientOrientation; + } + + public void setGradientOrientation(int gradientOrientation) { + this.gradientOrientation = gradientOrientation; + } + + private int gradientOrientation; + + + public float getRadius() { + return mRadius; + } + + public int getBackgroundColor() { + return mBackgroundColor; + } + + public float getRelativePosition() { + return mRelativePosition; + } + + public float getSharpSize() { + return mSharpSize; + } + + public float getBorder() { + return mBorder; + } + + public int getBorderColor() { + return mBorderColor; + } + + public int[] getBgColors() { + return mBgColors; + } + + public float[] getCornerRadii() { + return mCornerRadii; + } + + public ZJView.ArrowDirection getArrowDirection() { + return mArrowDirection; + } + + private float mRadius; + + private int mBackgroundColor; + + private float mRelativePosition; + + private float mSharpSize; + + private float mBorder; + + private int mBorderColor; + + public void setBgColor(int[] bgColor) { + mBgColors = bgColor; + refreshView(); + } + + private int[] mBgColors; + + public void setCornerRadii(float leftTop, float rightTop, float rightBottom, float leftBottom) { + mCornerRadii[0] = leftTop; + mCornerRadii[1] = leftTop; + mCornerRadii[2] = rightTop; + mCornerRadii[3] = rightTop; + mCornerRadii[4] = rightBottom; + mCornerRadii[5] = rightBottom; + mCornerRadii[6] = leftBottom; + mCornerRadii[7] = leftBottom; + + } + + private float[] mCornerRadii = new float[8]; + + private ZJView.ArrowDirection mArrowDirection = ZJView.ArrowDirection.LEFT; + + public void setBorder(float border) { + mBorder = border; + refreshView(); + } + + public void setBorderColor(int borderColor) { + mBorderColor = borderColor; + refreshView(); + } + + ZJViewRenderProxy(View view, Context context, AttributeSet attrs, int defStyleAttr) { + mView = view; + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ZJRelativeLayout, defStyleAttr, 0); + mRadius = typedArray.getDimension(R.styleable.ZJRelativeLayout_radius, 0); + mCornerRadii[0] = mCornerRadii[1] = typedArray.getDimension(R.styleable.ZJRelativeLayout_left_top_radius, 0); + mCornerRadii[2] = mCornerRadii[3] = typedArray.getDimension(R.styleable.ZJRelativeLayout_right_top_radius, 0); + mCornerRadii[4] = mCornerRadii[5] = typedArray.getDimension(R.styleable.ZJRelativeLayout_right_bottom_radius, 0); + mCornerRadii[6] = mCornerRadii[7] = typedArray.getDimension(R.styleable.ZJRelativeLayout_left_bottom_radius, 0); + mBorder = typedArray.getDimension(R.styleable.ZJRelativeLayout_border, 0); + mBackgroundColor = typedArray.getColor(R.styleable.ZJRelativeLayout_backgroundColor, 0); + mBorderColor = typedArray.getColor(R.styleable.ZJRelativeLayout_borderColor, 0); + int direction = typedArray.getInt(R.styleable.ZJRelativeLayout_arrowDirection, 3); + mRelativePosition = typedArray.getFraction(R.styleable.ZJRelativeLayout_relativePosition, 1, 1, 0.5f); + mSharpSize = typedArray.getDimension(R.styleable.ZJRelativeLayout_sharpSize, 0); + + gradientOrientation = typedArray.getInt(R.styleable.ZJRelativeLayout_gradient_orientation, 6); + switch (direction) { + case 1: + mArrowDirection = ZJView.ArrowDirection.LEFT; + break; + case 2: + mArrowDirection = ZJView.ArrowDirection.TOP; + break; + case 3: + mArrowDirection = ZJView.ArrowDirection.RIGHT; + break; + case 4: + mArrowDirection = ZJView.ArrowDirection.BOTTOM; + break; + } + int start = typedArray.getColor(R.styleable.ZJRelativeLayout_startBgColor, -1); + int middle = typedArray.getColor(R.styleable.ZJRelativeLayout_middleBgColor, -1); + int end = typedArray.getColor(R.styleable.ZJRelativeLayout_endBgColor, -1); + if (start != -1 && end != -1) { + if (middle != -1) { + mBgColors = new int[]{start, middle, end}; + } else { + mBgColors = new int[]{start, end}; + } + } + typedArray.recycle(); + refreshView(); + } + + ZJDrawable mSharpDrawable; + + private void refreshView() { + ZJDrawable bd = new ZJDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null); + mSharpDrawable = bd; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + bd.setColors(mBgColors); + switch (gradientOrientation) { + case TOP_BOTTOM: + bd.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); + break; + case TR_BL: + bd.setOrientation(GradientDrawable.Orientation.TR_BL); + break; + case RIGHT_LEFT: + bd.setOrientation(GradientDrawable.Orientation.RIGHT_LEFT); + break; + case BR_TL: + bd.setOrientation(GradientDrawable.Orientation.BR_TL); + break; + case BOTTOM_TOP: + bd.setOrientation(GradientDrawable.Orientation.BOTTOM_TOP); + break; + case BL_TR: + bd.setOrientation(GradientDrawable.Orientation.BL_TR); + break; + case LEFT_RIGHT: + bd.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); + break; + case TL_BR: + bd.setOrientation(GradientDrawable.Orientation.TL_BR); + break; + } + } else { + bd.setColor(mBgColors[0]); + } + + if (mBgColors != null) { + bd.setColors(mBgColors); + } else { + bd.setBgColor(mBackgroundColor); + } + bd.setSharpSize(mSharpSize); + bd.setArrowDirection(mArrowDirection); + bd.setCornerRadius(mRadius); + bd.setBorder(mBorder); + bd.setBorderColor(mBorderColor); + bd.setRelativePosition(mRelativePosition); + if (mRadius == 0) { + bd.setCornerRadii(mCornerRadii); + } + + mView.setBackground(bd); + + } + + public void setRadius(float radius) { + mRadius = radius; + refreshView(); + } + + public void setBackgroundColor(int backgroundColor) { + mBackgroundColor = backgroundColor; + mBgColors = null; + refreshView(); + } + + public void setRelativePosition(float relativePosition) { + mRelativePosition = relativePosition; + refreshView(); + } + + public void setSharpSize(float sharpSize) { + mSharpSize = sharpSize; + refreshView(); + } + + public void setArrowDirection(ZJView.ArrowDirection arrowDirection) { + mArrowDirection = arrowDirection; + refreshView(); + } + +} diff --git a/ZJlibrary/src/main/res/values/attrs.xml b/ZJlibrary/src/main/res/values/attrs.xml new file mode 100644 index 0000000..36f2d95 --- /dev/null +++ b/ZJlibrary/src/main/res/values/attrs.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..3fe82fd --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,3 @@ +/build +/src/test +/src/androidTest \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..e0e652e --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.speechx.textviewdemo3" + minSdkVersion 16 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + + implementation project(":ZJlibrary") + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c68f296 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/zjview/demo/MainActivity.java b/app/src/main/java/com/zjview/demo/MainActivity.java new file mode 100644 index 0000000..2ace3e4 --- /dev/null +++ b/app/src/main/java/com/zjview/demo/MainActivity.java @@ -0,0 +1,14 @@ +package com.zjview.demo; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..7849e4a --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..4faecfa --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #6200EE + #3700B3 + #03DAC5 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..7e3fb60 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ZJViewDemo + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..fac9291 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..461688a --- /dev/null +++ b/build.gradle @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:4.0.2" + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + maven { url "https://jitpack.io" } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c52ac9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a55959a --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu May 13 15:40:23 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..082483b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':ZJlibrary' +include ':app' \ No newline at end of file