Loading app/build.gradle +2 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,7 @@ dependencies { apiNougatImplementation 'org.cyanogenmod:platform.sdk:6.0' apiNougatImplementation 'org.cyanogenmod:platform.sdk:6.0' apiOreoImplementation files('libs/lineage-sdk.jar') apiOreoImplementation files('libs/lineage-sdk.jar') debugImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.8' debugImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' debugImplementation 'com.google.firebase:firebase-core:16.0.6' debugImplementation 'com.google.firebase:firebase-core:16.0.6' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' Loading Loading @@ -122,3 +122,4 @@ dependencies { } } apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.getkeepsafe.dexcount' app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +8 −2 Original line number Original line Diff line number Diff line Loading @@ -20,8 +20,10 @@ public class BlissLauncher extends Application { private AppProvider mAppProvider; private AppProvider mAppProvider; private WidgetHost sAppWidgetHost; private static WidgetHost sAppWidgetHost; private AppWidgetManager sAppWidgetManager; private static AppWidgetManager sAppWidgetManager; private static int sLongPressTimeout = 300; private static final String TAG = "BlissLauncher"; private static final String TAG = "BlissLauncher"; Loading Loading @@ -105,4 +107,8 @@ public class BlissLauncher extends Application { sAppWidgetHost.stopListening(); sAppWidgetHost.stopListening(); sAppWidgetHost = null; sAppWidgetHost = null; } } public static long getLongPressTimeout() { return sLongPressTimeout; } } } app/src/main/java/foundation/e/blisslauncher/core/customviews/AppWidgetResizeFrame.java 0 → 100644 +172 −0 Original line number Original line Diff line number Diff line package foundation.e.blisslauncher.core.customviews; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.graphics.Rect; import android.support.annotation.NonNull; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; public class AppWidgetResizeFrame extends FrameLayout { private RoundedWidgetView mRoundedWidgetView; private ImageView mTopHandle; private ImageView mBottomHandle; private boolean mTopBorderActive; private boolean mBottomBorderActive; private int mWidgetPaddingTop; private int mWidgetPaddingBottom; private int mBaselineWidth; private int mBaselineHeight; private int mBaselineX; private int mBaselineY; private int mResizeMode; private int mRunningHInc; private int mRunningVInc; private int mMinHeight; private int mDeltaX; private int mDeltaY; private int mDeltaXAddOn; private int mDeltaYAddOn; private int mBackgroundPadding; private int mTouchTargetWidth; private int mTopTouchRegionAdjustment = 0; private int mBottomTouchRegionAdjustment = 0; int[] mDirectionVector = new int[2]; int[] mLastDirectionVector = new int[2]; final int SNAP_DURATION = 150; final int BACKGROUND_PADDING = 24; final float DIMMED_HANDLE_ALPHA = 0f; final float RESIZE_THRESHOLD = 0.66f; private static Rect mTmpRect = new Rect(); public static final int TOP = 1; public static final int BOTTOM = 3; private Context mContext; public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { super(context); mRoundedWidgetView = widgetView; mContext = context; final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, info.provider, null); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested mMinHeight = info.minHeight + padding.top + padding.bottom; setBackgroundResource(R.drawable.widget_resize_frame); setPadding(0, 0, 0, 0); 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 +37 −8 Original line number Original line Diff line number Diff line Loading @@ -5,19 +5,22 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.ViewGroup; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; public class RoundedWidgetView extends AppWidgetHostView { public class RoundedWidgetView extends AppWidgetHostView { private final Path stencilPath = new Path(); private final Path stencilPath = new Path(); private float cornerRadius = 0; private float cornerRadius; private CheckLongPressHelper mLongPressHelper; private static final String TAG = "RoundedWidgetView"; private static final String TAG = "RoundedWidgetView"; public RoundedWidgetView(Context context) { public RoundedWidgetView(Context context) { super(context); super(context); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); mLongPressHelper = new CheckLongPressHelper(this); } } @Override @Override Loading @@ -41,14 +44,40 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { /*getParent().requestDisallowInterceptTouchEvent(true); int action = ev.getAction(); // Consume any touch events for ourselves after longpress is triggered switch (action) { if (mLongPressHelper.hasPerformedLongPress()) { mLongPressHelper.cancelLongPress(); return true; } // Watch for longpress events at this level to make sure // users can always pick up this widget switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: { mLongPressHelper.postCheckForLongPress(); break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP: getParent().requestDisallowInterceptTouchEvent(false); case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); break; break; }*/ } return super.onInterceptTouchEvent(ev); // Otherwise continue letting touch events fall through to children return false; } @Override public void cancelLongPress() { super.cancelLongPress(); mLongPressHelper.cancelLongPress(); } @Override public int getDescendantFocusability() { return ViewGroup.FOCUS_BLOCK_DESCENDANTS; } } } } app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +14 −24 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,7 @@ import foundation.e.blisslauncher.features.weather.WeatherSourceListenerService; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; import foundation.e.blisslauncher.features.weather.WeatherUtils; import foundation.e.blisslauncher.features.weather.WeatherUtils; import foundation.e.blisslauncher.features.widgets.WidgetManager; import foundation.e.blisslauncher.features.widgets.WidgetManager; import foundation.e.blisslauncher.features.widgets.WidgetViewBuilder; import foundation.e.blisslauncher.features.widgets.WidgetsActivity; import foundation.e.blisslauncher.features.widgets.WidgetsActivity; import io.reactivex.Observable; import io.reactivex.Observable; import io.reactivex.ObservableSource; import io.reactivex.ObservableSource; Loading Loading @@ -397,9 +398,6 @@ public class LauncherActivity extends AppCompatActivity implements RoundedWidgetView widgetView = widgetManager.dequeAddWidgetView(); RoundedWidgetView widgetView = widgetManager.dequeAddWidgetView(); while (widgetView != null) { while (widgetView != null) { int appWidgetId = widgetView.getAppWidgetId(); AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); widgetView.post(() -> updateWidgetOption(appWidgetId, info)); addWidgetToContainer(widgetContainer, widgetView); addWidgetToContainer(widgetContainer, widgetView); widgetView = widgetManager.dequeAddWidgetView(); widgetView = widgetManager.dequeAddWidgetView(); } } Loading @@ -407,14 +405,15 @@ public class LauncherActivity extends AppCompatActivity implements private void addWidgetToContainer(LinearLayout widgetHolderLinearLayout, private void addWidgetToContainer(LinearLayout widgetHolderLinearLayout, RoundedWidgetView widgetView) { RoundedWidgetView widgetView) { View view = WidgetViewBuilder.create(this, widgetView); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams.WRAP_CONTENT); int margin = getResources().getDimensionPixelSize(R.dimen.widget_margin); int margin = getResources().getDimensionPixelSize(R.dimen.widget_margin); layoutParams.setMargins(0, margin, 0, margin); layoutParams.setMargins(0, margin, 0, margin); widgetView.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams); widgetView.setPadding(0, 0, 0, 0); view.setPadding(0, 0, 0, 0); widgetHolderLinearLayout.addView(widgetView); widgetHolderLinearLayout.addView(view); } } @Override @Override Loading Loading @@ -1026,8 +1025,12 @@ public class LauncherActivity extends AppCompatActivity implements mIndicator.animate().alpha(0).setDuration(100).withEndAction( mIndicator.animate().alpha(0).setDuration(100).withEndAction( () -> mIndicator.setVisibility(GONE)); () -> mIndicator.setVisibility(GONE)); refreshSuggestedApps(forceRefreshSuggestedApps); refreshSuggestedApps(forceRefreshSuggestedApps); if (Preferences.weatherRefreshIntervalInMs(LauncherActivity.this) == 0) { Intent intent = new Intent(LauncherActivity.this, WeatherUpdateService.class); intent.setAction(WeatherUpdateService.ACTION_FORCE_UPDATE); startService(intent); } } else { } else { if (mIndicator.getAlpha() != 1.0f) { if (mIndicator.getAlpha() != 1.0f) { mIndicator.setVisibility(View.VISIBLE); mIndicator.setVisibility(View.VISIBLE); Loading Loading @@ -1321,12 +1324,12 @@ public class LauncherActivity extends AppCompatActivity implements Preferences.setEnableLocation(this); Preferences.setEnableLocation(this); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } } } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } // [[END]] // [[END]] Loading @@ -1339,24 +1342,11 @@ public class LauncherActivity extends AppCompatActivity implements getApplicationContext(), id, getApplicationContext(), id, appWidgetInfo); appWidgetInfo); hostView.setAppWidget(id, appWidgetInfo); hostView.setAppWidget(id, appWidgetInfo); hostView.post(() -> updateWidgetOption(id, appWidgetInfo)); addWidgetToContainer(widgetContainer, hostView); addWidgetToContainer(widgetContainer, hostView); } } } } } } private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { Bundle newOps = new Bundle(); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetHeight()); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); } @Override @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { @NonNull int[] grantResults) { Loading @@ -1371,7 +1361,7 @@ public class LauncherActivity extends AppCompatActivity implements Preferences.setEnableLocation(this); Preferences.setEnableLocation(this); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } } } } Loading Loading @@ -1421,7 +1411,7 @@ public class LauncherActivity extends AppCompatActivity implements Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show(); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } else { } else { super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); Loading Loading
app/build.gradle +2 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,7 @@ dependencies { apiNougatImplementation 'org.cyanogenmod:platform.sdk:6.0' apiNougatImplementation 'org.cyanogenmod:platform.sdk:6.0' apiOreoImplementation files('libs/lineage-sdk.jar') apiOreoImplementation files('libs/lineage-sdk.jar') debugImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.8' debugImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' debugImplementation 'com.google.firebase:firebase-core:16.0.6' debugImplementation 'com.google.firebase:firebase-core:16.0.6' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' Loading Loading @@ -122,3 +122,4 @@ dependencies { } } apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.getkeepsafe.dexcount'
app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +8 −2 Original line number Original line Diff line number Diff line Loading @@ -20,8 +20,10 @@ public class BlissLauncher extends Application { private AppProvider mAppProvider; private AppProvider mAppProvider; private WidgetHost sAppWidgetHost; private static WidgetHost sAppWidgetHost; private AppWidgetManager sAppWidgetManager; private static AppWidgetManager sAppWidgetManager; private static int sLongPressTimeout = 300; private static final String TAG = "BlissLauncher"; private static final String TAG = "BlissLauncher"; Loading Loading @@ -105,4 +107,8 @@ public class BlissLauncher extends Application { sAppWidgetHost.stopListening(); sAppWidgetHost.stopListening(); sAppWidgetHost = null; sAppWidgetHost = null; } } public static long getLongPressTimeout() { return sLongPressTimeout; } } }
app/src/main/java/foundation/e/blisslauncher/core/customviews/AppWidgetResizeFrame.java 0 → 100644 +172 −0 Original line number Original line Diff line number Diff line package foundation.e.blisslauncher.core.customviews; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.graphics.Rect; import android.support.annotation.NonNull; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.R; public class AppWidgetResizeFrame extends FrameLayout { private RoundedWidgetView mRoundedWidgetView; private ImageView mTopHandle; private ImageView mBottomHandle; private boolean mTopBorderActive; private boolean mBottomBorderActive; private int mWidgetPaddingTop; private int mWidgetPaddingBottom; private int mBaselineWidth; private int mBaselineHeight; private int mBaselineX; private int mBaselineY; private int mResizeMode; private int mRunningHInc; private int mRunningVInc; private int mMinHeight; private int mDeltaX; private int mDeltaY; private int mDeltaXAddOn; private int mDeltaYAddOn; private int mBackgroundPadding; private int mTouchTargetWidth; private int mTopTouchRegionAdjustment = 0; private int mBottomTouchRegionAdjustment = 0; int[] mDirectionVector = new int[2]; int[] mLastDirectionVector = new int[2]; final int SNAP_DURATION = 150; final int BACKGROUND_PADDING = 24; final float DIMMED_HANDLE_ALPHA = 0f; final float RESIZE_THRESHOLD = 0.66f; private static Rect mTmpRect = new Rect(); public static final int TOP = 1; public static final int BOTTOM = 3; private Context mContext; public AppWidgetResizeFrame(@NonNull Context context, RoundedWidgetView widgetView) { super(context); mRoundedWidgetView = widgetView; mContext = context; final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, info.provider, null); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested mMinHeight = info.minHeight + padding.top + padding.bottom; setBackgroundResource(R.drawable.widget_resize_frame); setPadding(0, 0, 0, 0); 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 +37 −8 Original line number Original line Diff line number Diff line Loading @@ -5,19 +5,22 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.ViewGroup; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.features.widgets.CheckLongPressHelper; public class RoundedWidgetView extends AppWidgetHostView { public class RoundedWidgetView extends AppWidgetHostView { private final Path stencilPath = new Path(); private final Path stencilPath = new Path(); private float cornerRadius = 0; private float cornerRadius; private CheckLongPressHelper mLongPressHelper; private static final String TAG = "RoundedWidgetView"; private static final String TAG = "RoundedWidgetView"; public RoundedWidgetView(Context context) { public RoundedWidgetView(Context context) { super(context); super(context); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); this.cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.corner_radius); mLongPressHelper = new CheckLongPressHelper(this); } } @Override @Override Loading @@ -41,14 +44,40 @@ public class RoundedWidgetView extends AppWidgetHostView { @Override @Override public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { /*getParent().requestDisallowInterceptTouchEvent(true); int action = ev.getAction(); // Consume any touch events for ourselves after longpress is triggered switch (action) { if (mLongPressHelper.hasPerformedLongPress()) { mLongPressHelper.cancelLongPress(); return true; } // Watch for longpress events at this level to make sure // users can always pick up this widget switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: { mLongPressHelper.postCheckForLongPress(); break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP: getParent().requestDisallowInterceptTouchEvent(false); case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); break; break; }*/ } return super.onInterceptTouchEvent(ev); // Otherwise continue letting touch events fall through to children return false; } @Override public void cancelLongPress() { super.cancelLongPress(); mLongPressHelper.cancelLongPress(); } @Override public int getDescendantFocusability() { return ViewGroup.FOCUS_BLOCK_DESCENDANTS; } } } }
app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +14 −24 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,7 @@ import foundation.e.blisslauncher.features.weather.WeatherSourceListenerService; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; import foundation.e.blisslauncher.features.weather.WeatherUtils; import foundation.e.blisslauncher.features.weather.WeatherUtils; import foundation.e.blisslauncher.features.widgets.WidgetManager; import foundation.e.blisslauncher.features.widgets.WidgetManager; import foundation.e.blisslauncher.features.widgets.WidgetViewBuilder; import foundation.e.blisslauncher.features.widgets.WidgetsActivity; import foundation.e.blisslauncher.features.widgets.WidgetsActivity; import io.reactivex.Observable; import io.reactivex.Observable; import io.reactivex.ObservableSource; import io.reactivex.ObservableSource; Loading Loading @@ -397,9 +398,6 @@ public class LauncherActivity extends AppCompatActivity implements RoundedWidgetView widgetView = widgetManager.dequeAddWidgetView(); RoundedWidgetView widgetView = widgetManager.dequeAddWidgetView(); while (widgetView != null) { while (widgetView != null) { int appWidgetId = widgetView.getAppWidgetId(); AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); widgetView.post(() -> updateWidgetOption(appWidgetId, info)); addWidgetToContainer(widgetContainer, widgetView); addWidgetToContainer(widgetContainer, widgetView); widgetView = widgetManager.dequeAddWidgetView(); widgetView = widgetManager.dequeAddWidgetView(); } } Loading @@ -407,14 +405,15 @@ public class LauncherActivity extends AppCompatActivity implements private void addWidgetToContainer(LinearLayout widgetHolderLinearLayout, private void addWidgetToContainer(LinearLayout widgetHolderLinearLayout, RoundedWidgetView widgetView) { RoundedWidgetView widgetView) { View view = WidgetViewBuilder.create(this, widgetView); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams.WRAP_CONTENT); int margin = getResources().getDimensionPixelSize(R.dimen.widget_margin); int margin = getResources().getDimensionPixelSize(R.dimen.widget_margin); layoutParams.setMargins(0, margin, 0, margin); layoutParams.setMargins(0, margin, 0, margin); widgetView.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams); widgetView.setPadding(0, 0, 0, 0); view.setPadding(0, 0, 0, 0); widgetHolderLinearLayout.addView(widgetView); widgetHolderLinearLayout.addView(view); } } @Override @Override Loading Loading @@ -1026,8 +1025,12 @@ public class LauncherActivity extends AppCompatActivity implements mIndicator.animate().alpha(0).setDuration(100).withEndAction( mIndicator.animate().alpha(0).setDuration(100).withEndAction( () -> mIndicator.setVisibility(GONE)); () -> mIndicator.setVisibility(GONE)); refreshSuggestedApps(forceRefreshSuggestedApps); refreshSuggestedApps(forceRefreshSuggestedApps); if (Preferences.weatherRefreshIntervalInMs(LauncherActivity.this) == 0) { Intent intent = new Intent(LauncherActivity.this, WeatherUpdateService.class); intent.setAction(WeatherUpdateService.ACTION_FORCE_UPDATE); startService(intent); } } else { } else { if (mIndicator.getAlpha() != 1.0f) { if (mIndicator.getAlpha() != 1.0f) { mIndicator.setVisibility(View.VISIBLE); mIndicator.setVisibility(View.VISIBLE); Loading Loading @@ -1321,12 +1324,12 @@ public class LauncherActivity extends AppCompatActivity implements Preferences.setEnableLocation(this); Preferences.setEnableLocation(this); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } } } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } // [[END]] // [[END]] Loading @@ -1339,24 +1342,11 @@ public class LauncherActivity extends AppCompatActivity implements getApplicationContext(), id, getApplicationContext(), id, appWidgetInfo); appWidgetInfo); hostView.setAppWidget(id, appWidgetInfo); hostView.setAppWidget(id, appWidgetInfo); hostView.post(() -> updateWidgetOption(id, appWidgetInfo)); addWidgetToContainer(widgetContainer, hostView); addWidgetToContainer(widgetContainer, hostView); } } } } } } private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { Bundle newOps = new Bundle(); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetHeight()); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); } @Override @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { @NonNull int[] grantResults) { Loading @@ -1371,7 +1361,7 @@ public class LauncherActivity extends AppCompatActivity implements Preferences.setEnableLocation(this); Preferences.setEnableLocation(this); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } } } } Loading Loading @@ -1421,7 +1411,7 @@ public class LauncherActivity extends AppCompatActivity implements Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show(); } else { } else { startService(new Intent(this, WeatherUpdateService.class) startService(new Intent(this, WeatherUpdateService.class) .putExtra(WeatherUpdateService.ACTION_FORCE_UPDATE, true)); .setAction(WeatherUpdateService.ACTION_FORCE_UPDATE)); } } } else { } else { super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); Loading