diff --git a/app/build.gradle b/app/build.gradle index 45679c1..c1c6f24 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.well.swipe" minSdkVersion 14 targetSdkVersion 23 - versionCode 7 - versionName "1.0.8" + versionCode 8 + versionName "1.0.9" } buildTypes { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 77313ef..6c7695f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ + - + - + + diff --git a/app/src/main/java/com/well/swipe/BootReceiver.java b/app/src/main/java/com/well/swipe/BootReceiver.java index b9a1339..3132000 100644 --- a/app/src/main/java/com/well/swipe/BootReceiver.java +++ b/app/src/main/java/com/well/swipe/BootReceiver.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.widget.Toast; import com.well.swipe.service.SwipeService; import com.well.swipe.tools.SwipeSetting; @@ -14,8 +15,11 @@ public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { + if (SettingHelper.getInstance(context).getBoolean(SwipeSetting.SWIPE_TOGGLE, true)) { + context.startService(new Intent(context, SwipeService.class)); } } diff --git a/app/src/main/java/com/well/swipe/view/AngleLayout.java b/app/src/main/java/com/well/swipe/view/AngleLayout.java index 4eb99db..cd72084 100644 --- a/app/src/main/java/com/well/swipe/view/AngleLayout.java +++ b/app/src/main/java/com/well/swipe/view/AngleLayout.java @@ -4,6 +4,7 @@ import android.animation.ValueAnimator; import android.content.Context; import android.util.AttributeSet; +import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -23,7 +24,8 @@ * Created by mingwei on 2/26/16. */ public class AngleLayout extends FrameLayout implements AngleView.OnAngleChangeListener, - AngleIndicatorView.OnIndexChangedLitener, AngleView.OnEditModeChangeListener, CornerView.OnCornerClickListener { + AngleIndicatorView.OnIndexChangedLitener, AngleView.OnEditModeChangeListener, CornerView.OnCornerClickListener, + AngleView.OnBindListener { /** * */ @@ -55,6 +57,8 @@ public class AngleLayout extends FrameLayout implements AngleView.OnAngleChangeL private CornerThemeView mCornerTheme; + private LoadingView mLoading; + private float mThemeScale; private int mChildHalfSize; @@ -72,6 +76,8 @@ public class AngleLayout extends FrameLayout implements AngleView.OnAngleChangeL private int mAngleLogoSize; private int mIndicatorSize; + + private int mLoadingSize; /** * 主题的小用像素,然后根据Indocator再做大小变化 */ @@ -217,6 +223,7 @@ public AngleLayout(Context context, AttributeSet attrs, int defStyleAttr) { */ mIndicatorThemeSize = getResources().getDimensionPixelSize(R.dimen.angleindicator_theme_size); mAngleLogoSize = getResources().getDimensionPixelSize(R.dimen.anglelogo_size); + mLoadingSize = getResources().getDimensionPixelSize(R.dimen.loadingview_size); ViewConfiguration mConfig = ViewConfiguration.get(context); mTouchSlop = mConfig.getScaledTouchSlop(); @@ -246,6 +253,9 @@ protected void onFinishInflate() { mCornerTheme = (CornerThemeView) findViewById(R.id.corner_theme); + mLoading = (LoadingView) findViewById(R.id.recent_loading); + mAngleView.setOnBindListener(this); + /** * 拖拽view @@ -288,7 +298,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto mCornerTheme.layout(0, mHeight - mAngleLogoSize, mAngleLogoSize, mHeight); mCornerTheme.setPivotX(0); mCornerTheme.setPivotY(mAngleLogoSize); - //mTestView.layout(0, mHeight - mAngleLogoSize, mAngleLogoSize, mHeight); + mLoading.layout((mAngleSize - mLoadingSize) / 2, mHeight - (mAngleSize + mLoadingSize) / 2, + (mAngleSize + mLoadingSize) / 2, mHeight - (mAngleSize - mLoadingSize) / 2); } else if (mAngleView.isRight()) { mAngleView.layout(mWidth - mAngleSize, mHeight - mAngleSize, mWidth, mHeight); mAngleViewTheme.layout(mWidth - mAngleSize, mHeight - mAngleSize, mWidth, mHeight); @@ -302,7 +313,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto mCornerTheme.layout(mWidth - mAngleLogoSize, mHeight - mAngleLogoSize, mWidth, mHeight); mCornerTheme.setPivotX(mAngleLogoSize); mCornerTheme.setPivotY(mAngleLogoSize); - //mTestView.layout(mWidth - mAngleLogoSize, mHeight - mAngleLogoSize, mWidth, mHeight); + mLoading.layout(mWidth - mAngleSize + (mAngleSize - mLoadingSize) / 2, mHeight - (mAngleSize + mLoadingSize) / 2, + mWidth - mAngleSize + (mAngleSize + mLoadingSize) / 2, mHeight - (mAngleSize - mLoadingSize) / 2); } /** * 根据Indicator来缩放IndicatorTheme保证Theme的质量 @@ -320,7 +332,6 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - //Log.i("Gmw", "AngleLayout_onInterceptTouchEvent"); if (getChildCount() <= 0) { return super.onInterceptTouchEvent(ev); } @@ -354,9 +365,9 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { } } else if (mEditState == STATE_EDIT) { - if ((Math.abs(diffX) > mTouchSlop || Math.abs(diffY) > mTouchSlop) && isAllowAngle) { - return true; - } + //if ((Math.abs(diffX) > mTouchSlop || Math.abs(diffY) > mTouchSlop) && isAllowAngle) { + return true; + //} } break; @@ -822,6 +833,11 @@ public void CornerEvent() { } } + @Override + public void bindComplete() { + mLoading.stop(); + } + /** * 重要方法:反转AngleLayout * 反转之后根据不同情况对子控件做反转 diff --git a/app/src/main/java/com/well/swipe/view/AngleView.java b/app/src/main/java/com/well/swipe/view/AngleView.java index b67b1d2..9ecabf4 100644 --- a/app/src/main/java/com/well/swipe/view/AngleView.java +++ b/app/src/main/java/com/well/swipe/view/AngleView.java @@ -268,6 +268,16 @@ public interface OnEditModeChangeListener { void onCancelDrag(); } + public OnBindListener mOnBindListener; + + interface OnBindListener { + + /** + * 数据绑定完成 + */ + void bindComplete(); + } + /** * 临时坐标信息 @@ -493,6 +503,11 @@ public void putRecentTask(List activityInfoList, } } refresh(); + + /** + * 绑定万Recent之后调用 + */ + mOnBindListener.bindComplete(); } public boolean contains(List activityInfoList, ItemApplication app) { @@ -1283,6 +1298,10 @@ public void setOnAngleLongClickListener(OnEditModeChangeListener listener) { mOnEditModeChangeListener = listener; } + public void setOnBindListener(OnBindListener listener) { + mOnBindListener = listener; + } + /** * 手指按下时的初始角度 */ diff --git a/app/src/main/java/com/well/swipe/view/AngleViewTheme.java b/app/src/main/java/com/well/swipe/view/AngleViewTheme.java index 95b2539..d1b22b7 100644 --- a/app/src/main/java/com/well/swipe/view/AngleViewTheme.java +++ b/app/src/main/java/com/well/swipe/view/AngleViewTheme.java @@ -40,13 +40,13 @@ public AngleViewTheme(Context context, AttributeSet attrs) { public AngleViewTheme(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mInnerSize = getResources().getDimensionPixelSize(R.dimen.angleindicator_size); mDistance = getResources().getDimensionPixelSize(R.dimen.angleview_indicatorview_distance); mColor = getResources().getColor(R.color.angleview_arc_background); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.FILL); + mPaint.setColor(mColor); } @Override @@ -59,15 +59,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - mPaint.setColor(mColor); - if (mPositionState == PositionState.POSITION_STATE_LEFT) { + if (isLeft()) { canvas.drawCircle(0, mHeight, mHeight, mPaint); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); canvas.drawCircle(0, mHeight, mInnerSize + mDistance, mPaint); canvas.drawCircle(0, mHeight, mInnerSize, mPaint); mPaint.setXfermode(null); - } else if (mPositionState == PositionState.POSITION_STATE_RIGHT) { + } else if (isRight()) { canvas.drawCircle(mWidth, mHeight, mHeight, mPaint); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); diff --git a/app/src/main/java/com/well/swipe/view/LoadingView.java b/app/src/main/java/com/well/swipe/view/LoadingView.java new file mode 100644 index 0000000..dee284c --- /dev/null +++ b/app/src/main/java/com/well/swipe/view/LoadingView.java @@ -0,0 +1,146 @@ +package com.well.swipe.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.view.View; + +import com.well.swipe.R; + +/** + * Created by mingwei on 5/31/16. + */ +public class LoadingView extends View { + + private final String TAG = "LoadingView"; + private Paint mTestPaint; + private Paint mOuterPaint; + private RectF mOuterRectF; + private Paint mInnerPaint; + private RectF mInnerRectF; + /** + * mStart 起始值 弧度 mSweep 终点值 弧度 + */ + int mStart = 0; + int mSweep = 90; + + int mWidth, mHeight; + int mArcLenght = 60; + /** + * outer width + */ + int mOuterWidth; + /** + * inner width + */ + int mInnerWidth; + /** + * outer color + */ + int mOuterColor; + /** + * inner color + */ + int mInnerColor; + /** + * inner rotating speed + */ + int mInnerRotatingSpeed = 1; + /** + * Circle degree + */ + int mCircle = 0; + /** + * Circle speed,only mode==circle + */ + int mCircleSpeed = 1; + /** + * custom degree,only mode==custom + */ + int mCustomDegree = 0; + + private boolean isStop; + + public LoadingView(Context context) { + this(context, null); + } + + public LoadingView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initAttr(context, attrs); + + } + + private void setBounds() { + mOuterRectF = new RectF(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() + - getPaddingBottom()); + mInnerRectF = new RectF(mOuterRectF); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + setBounds(); + initPaint(); + } + + private void initPaint() { + mOuterPaint = new Paint(); + mOuterPaint.setAntiAlias(true); + mOuterPaint.setColor(mOuterColor); + mOuterPaint.setStyle(Paint.Style.STROKE); + mOuterPaint.setStrokeWidth(mOuterWidth); + // + mInnerPaint = new Paint(); + mInnerPaint.setAntiAlias(true); + mInnerPaint.setColor(mInnerColor); + mInnerPaint.setStyle(Paint.Style.STROKE); + mInnerPaint.setStrokeWidth(mInnerWidth); + // + mTestPaint = new Paint(); + mTestPaint.setAntiAlias(true); + mTestPaint.setColor(Color.BLACK); + mTestPaint.setStyle(Paint.Style.STROKE); + } + + private void initAttr(Context context, AttributeSet attrs) { + TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Loading); + mOuterWidth = array.getDimensionPixelOffset(R.styleable.Loading_outer_width, 0); + mOuterColor = array.getColor(R.styleable.Loading_outer_color, Color.GRAY); + mInnerWidth = array.getDimensionPixelOffset(R.styleable.Loading_inner_width, R.styleable.Loading_inner_width); + mInnerColor = array.getColor(R.styleable.Loading_inner_color, Color.BLACK); + mInnerRotatingSpeed = array.getInt(R.styleable.Loading_inner_rotating_speed, 1); + array.recycle(); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + // canvas.drawRect(mOuterRectF, mTestPaint); + canvas.drawArc(mOuterRectF, 360, 360, false, mOuterPaint); + canvas.drawArc(mInnerRectF, mStart, mSweep + 2, false, mInnerPaint); + // int d = mRandom.nextInt(8); + mStart += mInnerRotatingSpeed; + if (mStart > 360) { + mStart -= 360; + } + if (!isStop) { + invalidate(); + } + + } + + public void stop() { + isStop = true; + setVisibility(GONE); + } + +} diff --git a/app/src/main/res/drawable/angle_item_bg.xml b/app/src/main/res/drawable/angle_item_bg.xml index 412e00c..472c465 100644 --- a/app/src/main/res/drawable/angle_item_bg.xml +++ b/app/src/main/res/drawable/angle_item_bg.xml @@ -1,6 +1,5 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/angle_layout.xml b/app/src/main/res/layout/angle_layout.xml index a5f1a82..6e6a038 100644 --- a/app/src/main/res/layout/angle_layout.xml +++ b/app/src/main/res/layout/angle_layout.xml @@ -33,4 +33,18 @@ android:id="@+id/corner_view" android:layout_width="@dimen/anglelogo_size" android:layout_height="@dimen/anglelogo_size" /> + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-sw320dp/dimens.xml b/app/src/main/res/values-sw320dp/dimens.xml index 71f2a99..77b4656 100644 --- a/app/src/main/res/values-sw320dp/dimens.xml +++ b/app/src/main/res/values-sw320dp/dimens.xml @@ -5,7 +5,7 @@ 20dp 10dp 330dip - 200dp + 190dp 275dp 144dp 73dp @@ -18,6 +18,7 @@ 200px 90px 186px + 50dp 32dp 62dp diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 1aefb3f..abf5681 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -44,4 +44,13 @@ + + + + + + + + + \ No newline at end of file