Loading app/build.gradle +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,8 +3,8 @@ apply plugin: 'io.fabric' // Manifest version information! // Manifest version information! def versionMajor = 1 def versionMajor = 1 def versionMinor = 0 def versionMinor = 1 def versionPatch = 2 def versionPatch = 0 android { android { compileSdkVersion rootProject.ext.compileSdkVersion compileSdkVersion rootProject.ext.compileSdkVersion Loading app/src/main/AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ android:name=".features.launcher.LauncherActivity" android:name=".features.launcher.LauncherActivity" android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true" android:launchMode="singleTask" android:launchMode="singleTask" android:resumeWhilePausing="true" android:screenOrientation="nosensor" android:screenOrientation="nosensor" android:stateNotNeeded="true" android:stateNotNeeded="true" android:theme="@style/HomeScreenTheme" android:theme="@style/HomeScreenTheme" Loading app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -19,8 +19,6 @@ public class BlissLauncher extends Application { private static WidgetHost sAppWidgetHost; private static WidgetHost sAppWidgetHost; private static AppWidgetManager sAppWidgetManager; private static AppWidgetManager sAppWidgetManager; private static int sLongPressTimeout = 300; private static final String TAG = "BlissLauncher"; private static final String TAG = "BlissLauncher"; @Override @Override Loading Loading @@ -92,6 +90,6 @@ public class BlissLauncher extends Application { } } public static long getLongPressTimeout() { public static long getLongPressTimeout() { return sLongPressTimeout; return 500; } } } } app/src/main/java/foundation/e/blisslauncher/core/customviews/AppWidgetResizeFrame.java +3 −98 Original line number Original line Diff line number Diff line Loading @@ -5,11 +5,9 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.support.annotation.NonNull; import android.support.annotation.NonNull; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ImageView; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; public class AppWidgetResizeFrame extends FrameLayout { public class AppWidgetResizeFrame extends FrameLayout { Loading Loading @@ -58,6 +56,8 @@ public class AppWidgetResizeFrame extends FrameLayout { private Context mContext; private Context mContext; private static final String TAG = "AppWidgetResizeFrame"; public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { super(context); super(context); Loading @@ -72,101 +72,6 @@ public class AppWidgetResizeFrame extends FrameLayout { setBackgroundResource(R.drawable.widget_resize_frame); setBackgroundResource(R.drawable.widget_resize_frame); setPadding(0, 0, 0, 0); setPadding(0, 0, 0, 0); //setLayoutParams(mRoundedWidgetView.getLayoutParams()); LayoutParams lp; mTopHandle = new ImageView(context); mTopHandle.setImageResource(R.drawable.widget_resize_handle_top); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP); addView(mTopHandle, lp); mBottomHandle = new ImageView(context); mBottomHandle.setImageResource(R.drawable.widget_resize_handle_bottom); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); addView(mBottomHandle, lp); Rect p = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); mWidgetPaddingTop = p.top; mWidgetPaddingBottom = p.bottom; if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) { mTopHandle.setVisibility(GONE); mBottomHandle.setVisibility(GONE); } final float density = context.getResources().getDisplayMetrics().density; mBackgroundPadding = (int) Math.ceil(density * BACKGROUND_PADDING); mTouchTargetWidth = 2 * mBackgroundPadding; } public boolean beginResizeIfPointInRegion(int x, int y) { boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0; boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0; mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) && verticalActive; mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment) && verticalActive; boolean anyBordersActive = mTopBorderActive || mBottomBorderActive; mBaselineWidth = getMeasuredWidth(); mBaselineHeight = getMeasuredHeight(); mBaselineX = getLeft(); mBaselineY = getTop(); if (anyBordersActive) { mTopHandle.setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA); mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA); } return anyBordersActive; } /** * Here we bound the deltas such that the frame cannot be stretched beyond the extents * of the CellLayout, and such that the frame's borders can't cross. */ public void updateDeltas(int deltaX, int deltaY) { if (mTopBorderActive) { mDeltaY = Math.max(-mBaselineY, deltaY); mDeltaY = Math.min(mBaselineHeight - 2 * mTouchTargetWidth, mDeltaY); } else if (mBottomBorderActive) { mDeltaY = Math.min(BlissLauncher.getApplication( mContext).getDeviceProfile().availableHeightPx - (mBaselineY + mBaselineHeight), deltaY); mDeltaY = Math.max(-mBaselineHeight + 2 * mTouchTargetWidth, mDeltaY); } } public void visualizeResizeForDelta(int deltaX, int deltaY) { visualizeResizeForDelta(deltaX, deltaY, false); } /** * Based on the deltas, we resize the frame, and, if needed, we resize the widget. */ private void visualizeResizeForDelta(int deltaX, int deltaY, boolean onDismiss) { updateDeltas(deltaX, deltaY); /* DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); if (mTopBorderActive) { lp.y = mBaselineY + mDeltaY; lp.height = mBaselineHeight - mDeltaY; } else if (mBottomBorderActive) { lp.height = mBaselineHeight + mDeltaY; } resizeWidgetIfNeeded(onDismiss);*/ requestLayout(); } /** * This is the final step of the resize. Here we save the new widget size and position * to LauncherModel and animate the resize frame. */ public void commitResize() { //resizeWidgetIfNeeded(true); requestLayout(); } } } } app/src/main/java/foundation/e/blisslauncher/core/customviews/RoundedWidgetView.java +73 −1 Original line number Original line Diff line number Diff line Loading @@ -4,8 +4,14 @@ import android.appwidget.AppWidgetHostView; import android.content.Context; import android.content.Context; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.graphics.Rect; import android.support.annotation.Nullable; import android.util.Log; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; Loading @@ -15,10 +21,18 @@ public class RoundedWidgetView extends AppWidgetHostView { private final Path stencilPath = new Path(); private final Path stencilPath = new Path(); private float cornerRadius; private float cornerRadius; private CheckLongPressHelper mLongPressHelper; private CheckLongPressHelper mLongPressHelper; private Context mContext; private static final String TAG = "RoundedWidgetView"; private static final String TAG = "RoundedWidgetView"; private ImageView resizeBorder; private OnTouchListener _onTouchListener; private OnLongClickListener _longClick; private long _down; private boolean mChildrenFocused; public RoundedWidgetView(Context context) { public RoundedWidgetView(Context context) { super(context); super(context); this.mContext = context; this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); mLongPressHelper = new CheckLongPressHelper(this); mLongPressHelper = new CheckLongPressHelper(this); } } Loading @@ -44,6 +58,11 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { Log.d(TAG, "onInterceptTouchEvent() called with: ev = [" + ev.getAction() + "]"); if (ev.getAction() == MotionEvent.ACTION_DOWN) { mLongPressHelper.cancelLongPress(); } // Consume any touch events for ourselves after longpress is triggered // Consume any touch events for ourselves after longpress is triggered if (mLongPressHelper.hasPerformedLongPress()) { if (mLongPressHelper.hasPerformedLongPress()) { Loading @@ -60,6 +79,9 @@ public class RoundedWidgetView extends AppWidgetHostView { } } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP: mLongPressHelper.cancelLongPress(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); mLongPressHelper.cancelLongPress(); break; break; Loading @@ -67,6 +89,7 @@ public class RoundedWidgetView extends AppWidgetHostView { // Otherwise continue letting touch events fall through to children // Otherwise continue letting touch events fall through to children return false; return false; } } @Override @Override Loading @@ -78,6 +101,55 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public int getDescendantFocusability() { public int getDescendantFocusability() { return ViewGroup.FOCUS_BLOCK_DESCENDANTS; return mChildrenFocused ? ViewGroup.FOCUS_BEFORE_DESCENDANTS : ViewGroup.FOCUS_BLOCK_DESCENDANTS; } @Override protected void onFocusChanged(boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) { if (gainFocus) { mChildrenFocused = false; dispatchChildFocus(false); } super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); } @Override public void requestChildFocus(View child, View focused) { super.requestChildFocus(child, focused); dispatchChildFocus(mChildrenFocused && focused != null); if (focused != null) { focused.setFocusableInTouchMode(false); } } @Override public boolean dispatchUnhandledMove(View focused, int direction) { return mChildrenFocused; } private void dispatchChildFocus(boolean childIsFocused) { // The host view's background changes when selected, to indicate the focus is inside. setSelected(childIsFocused); } public void addBorder() { if (resizeBorder != null) { removeBorder(); } resizeBorder = new ImageView(mContext); resizeBorder.setImageResource(R.drawable.widget_resize_frame); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); resizeBorder.setLayoutParams(layoutParams); addView(resizeBorder); } public void removeBorder() { if (resizeBorder != null) { removeView(resizeBorder); resizeBorder = null; } } } } } Loading
app/build.gradle +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,8 +3,8 @@ apply plugin: 'io.fabric' // Manifest version information! // Manifest version information! def versionMajor = 1 def versionMajor = 1 def versionMinor = 0 def versionMinor = 1 def versionPatch = 2 def versionPatch = 0 android { android { compileSdkVersion rootProject.ext.compileSdkVersion compileSdkVersion rootProject.ext.compileSdkVersion Loading
app/src/main/AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ android:name=".features.launcher.LauncherActivity" android:name=".features.launcher.LauncherActivity" android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true" android:launchMode="singleTask" android:launchMode="singleTask" android:resumeWhilePausing="true" android:screenOrientation="nosensor" android:screenOrientation="nosensor" android:stateNotNeeded="true" android:stateNotNeeded="true" android:theme="@style/HomeScreenTheme" android:theme="@style/HomeScreenTheme" Loading
app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -19,8 +19,6 @@ public class BlissLauncher extends Application { private static WidgetHost sAppWidgetHost; private static WidgetHost sAppWidgetHost; private static AppWidgetManager sAppWidgetManager; private static AppWidgetManager sAppWidgetManager; private static int sLongPressTimeout = 300; private static final String TAG = "BlissLauncher"; private static final String TAG = "BlissLauncher"; @Override @Override Loading Loading @@ -92,6 +90,6 @@ public class BlissLauncher extends Application { } } public static long getLongPressTimeout() { public static long getLongPressTimeout() { return sLongPressTimeout; return 500; } } } }
app/src/main/java/foundation/e/blisslauncher/core/customviews/AppWidgetResizeFrame.java +3 −98 Original line number Original line Diff line number Diff line Loading @@ -5,11 +5,9 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.support.annotation.NonNull; import android.support.annotation.NonNull; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ImageView; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; public class AppWidgetResizeFrame extends FrameLayout { public class AppWidgetResizeFrame extends FrameLayout { Loading Loading @@ -58,6 +56,8 @@ public class AppWidgetResizeFrame extends FrameLayout { private Context mContext; private Context mContext; private static final String TAG = "AppWidgetResizeFrame"; public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { super(context); super(context); Loading @@ -72,101 +72,6 @@ public class AppWidgetResizeFrame extends FrameLayout { setBackgroundResource(R.drawable.widget_resize_frame); setBackgroundResource(R.drawable.widget_resize_frame); setPadding(0, 0, 0, 0); setPadding(0, 0, 0, 0); //setLayoutParams(mRoundedWidgetView.getLayoutParams()); LayoutParams lp; mTopHandle = new ImageView(context); mTopHandle.setImageResource(R.drawable.widget_resize_handle_top); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP); addView(mTopHandle, lp); mBottomHandle = new ImageView(context); mBottomHandle.setImageResource(R.drawable.widget_resize_handle_bottom); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); addView(mBottomHandle, lp); Rect p = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); mWidgetPaddingTop = p.top; mWidgetPaddingBottom = p.bottom; if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) { mTopHandle.setVisibility(GONE); mBottomHandle.setVisibility(GONE); } final float density = context.getResources().getDisplayMetrics().density; mBackgroundPadding = (int) Math.ceil(density * BACKGROUND_PADDING); mTouchTargetWidth = 2 * mBackgroundPadding; } public boolean beginResizeIfPointInRegion(int x, int y) { boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0; boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0; mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) && verticalActive; mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment) && verticalActive; boolean anyBordersActive = mTopBorderActive || mBottomBorderActive; mBaselineWidth = getMeasuredWidth(); mBaselineHeight = getMeasuredHeight(); mBaselineX = getLeft(); mBaselineY = getTop(); if (anyBordersActive) { mTopHandle.setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA); mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA); } return anyBordersActive; } /** * Here we bound the deltas such that the frame cannot be stretched beyond the extents * of the CellLayout, and such that the frame's borders can't cross. */ public void updateDeltas(int deltaX, int deltaY) { if (mTopBorderActive) { mDeltaY = Math.max(-mBaselineY, deltaY); mDeltaY = Math.min(mBaselineHeight - 2 * mTouchTargetWidth, mDeltaY); } else if (mBottomBorderActive) { mDeltaY = Math.min(BlissLauncher.getApplication( mContext).getDeviceProfile().availableHeightPx - (mBaselineY + mBaselineHeight), deltaY); mDeltaY = Math.max(-mBaselineHeight + 2 * mTouchTargetWidth, mDeltaY); } } public void visualizeResizeForDelta(int deltaX, int deltaY) { visualizeResizeForDelta(deltaX, deltaY, false); } /** * Based on the deltas, we resize the frame, and, if needed, we resize the widget. */ private void visualizeResizeForDelta(int deltaX, int deltaY, boolean onDismiss) { updateDeltas(deltaX, deltaY); /* DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); if (mTopBorderActive) { lp.y = mBaselineY + mDeltaY; lp.height = mBaselineHeight - mDeltaY; } else if (mBottomBorderActive) { lp.height = mBaselineHeight + mDeltaY; } resizeWidgetIfNeeded(onDismiss);*/ requestLayout(); } /** * This is the final step of the resize. Here we save the new widget size and position * to LauncherModel and animate the resize frame. */ public void commitResize() { //resizeWidgetIfNeeded(true); requestLayout(); } } } }
app/src/main/java/foundation/e/blisslauncher/core/customviews/RoundedWidgetView.java +73 −1 Original line number Original line Diff line number Diff line Loading @@ -4,8 +4,14 @@ import android.appwidget.AppWidgetHostView; import android.content.Context; import android.content.Context; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.graphics.Rect; import android.support.annotation.Nullable; import android.util.Log; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; Loading @@ -15,10 +21,18 @@ public class RoundedWidgetView extends AppWidgetHostView { private final Path stencilPath = new Path(); private final Path stencilPath = new Path(); private float cornerRadius; private float cornerRadius; private CheckLongPressHelper mLongPressHelper; private CheckLongPressHelper mLongPressHelper; private Context mContext; private static final String TAG = "RoundedWidgetView"; private static final String TAG = "RoundedWidgetView"; private ImageView resizeBorder; private OnTouchListener _onTouchListener; private OnLongClickListener _longClick; private long _down; private boolean mChildrenFocused; public RoundedWidgetView(Context context) { public RoundedWidgetView(Context context) { super(context); super(context); this.mContext = context; this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); mLongPressHelper = new CheckLongPressHelper(this); mLongPressHelper = new CheckLongPressHelper(this); } } Loading @@ -44,6 +58,11 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { Log.d(TAG, "onInterceptTouchEvent() called with: ev = [" + ev.getAction() + "]"); if (ev.getAction() == MotionEvent.ACTION_DOWN) { mLongPressHelper.cancelLongPress(); } // Consume any touch events for ourselves after longpress is triggered // Consume any touch events for ourselves after longpress is triggered if (mLongPressHelper.hasPerformedLongPress()) { if (mLongPressHelper.hasPerformedLongPress()) { Loading @@ -60,6 +79,9 @@ public class RoundedWidgetView extends AppWidgetHostView { } } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP: mLongPressHelper.cancelLongPress(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); mLongPressHelper.cancelLongPress(); break; break; Loading @@ -67,6 +89,7 @@ public class RoundedWidgetView extends AppWidgetHostView { // Otherwise continue letting touch events fall through to children // Otherwise continue letting touch events fall through to children return false; return false; } } @Override @Override Loading @@ -78,6 +101,55 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public int getDescendantFocusability() { public int getDescendantFocusability() { return ViewGroup.FOCUS_BLOCK_DESCENDANTS; return mChildrenFocused ? ViewGroup.FOCUS_BEFORE_DESCENDANTS : ViewGroup.FOCUS_BLOCK_DESCENDANTS; } @Override protected void onFocusChanged(boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) { if (gainFocus) { mChildrenFocused = false; dispatchChildFocus(false); } super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); } @Override public void requestChildFocus(View child, View focused) { super.requestChildFocus(child, focused); dispatchChildFocus(mChildrenFocused && focused != null); if (focused != null) { focused.setFocusableInTouchMode(false); } } @Override public boolean dispatchUnhandledMove(View focused, int direction) { return mChildrenFocused; } private void dispatchChildFocus(boolean childIsFocused) { // The host view's background changes when selected, to indicate the focus is inside. setSelected(childIsFocused); } public void addBorder() { if (resizeBorder != null) { removeBorder(); } resizeBorder = new ImageView(mContext); resizeBorder.setImageResource(R.drawable.widget_resize_frame); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); resizeBorder.setLayoutParams(layoutParams); addView(resizeBorder); } public void removeBorder() { if (resizeBorder != null) { removeView(resizeBorder); resizeBorder = null; } } } } }