Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a88ca44 authored by Amit Kumar's avatar Amit Kumar
Browse files

Fix a shortcut bug and refactor source code

parent 5b27c797
Loading
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -3,15 +3,14 @@ package org.indin.blisslaunchero.core.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
import org.indin.blisslaunchero.BlissLauncher;
import org.indin.blisslaunchero.features.launcher.AppProvider;
import org.indin.blisslaunchero.core.events.AppAddEvent;
import org.indin.blisslaunchero.core.events.AppChangeEvent;
import org.indin.blisslaunchero.core.events.AppRemoveEvent;
import org.indin.blisslaunchero.core.utils.UserHandle;
import org.indin.blisslaunchero.features.launcher.AppProvider;

public class PackageAddedRemovedHandler extends BroadcastReceiver {

@@ -19,13 +18,8 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {

    public static void handleEvent(Context ctx, String action, String packageName, UserHandle user,
            boolean replacing) {
        Log.d(TAG, "handleEvent() called with: ctx = [" + ctx + "], action = [" + action
                + "], packageName = [" + packageName + "], user = [" + user + "], replacing = ["
                + replacing + "]");
        // Insert into history new packages (not updated ones)
        if ("android.intent.action.PACKAGE_ADDED".equals(action) && !replacing) {
            Log.i(TAG, "handleEvent: added " + packageName);

            Intent launchIntent = ctx.getPackageManager().getLaunchIntentForPackage(packageName);
            if (launchIntent == null) {//for some plugin app
                return;
@@ -39,7 +33,6 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
        }

        if ("android.intent.action.PACKAGE_CHANGED".equalsIgnoreCase(action)) {
            Log.i(TAG, "handleEvent: changed " + packageName);
            Intent launchIntent = ctx.getPackageManager().getLaunchIntentForPackage(packageName);
            if (launchIntent != null) {
                BlissLauncher.getApplication(ctx).getIconsHandler().resetIconDrawableForPackage(
@@ -54,7 +47,6 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {

        }
        if ("android.intent.action.PACKAGE_REMOVED".equals(action) && !replacing) {
            Log.i(TAG, "handleEvent: removed " + packageName);
            AppRemoveEvent appRemoveEvent = new AppRemoveEvent();
            appRemoveEvent.packageName = packageName;
            EventBus.getDefault().post(appRemoveEvent);
@@ -70,8 +62,6 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
    @Override
    public void onReceive(Context ctx, Intent intent) {
        String packageName = intent.getData().getSchemeSpecificPart();

        Log.d(TAG, "onReceive() called with: ctx = [" + ctx + "], intent = [" + intent + "]");
        if (packageName.equalsIgnoreCase(ctx.getPackageName())) {
            return;
        }
+1 −1
Original line number Diff line number Diff line
package org.indin.blisslaunchero.features.launcher;
package org.indin.blisslaunchero.core.customviews;

import org.indin.blisslaunchero.BlissLauncher;
import org.indin.blisslaunchero.core.DeviceProfile;
+4 −4
Original line number Diff line number Diff line
package org.indin.blisslaunchero.features.launcher;

import org.indin.blisslaunchero.BlissLauncher;
import org.indin.blisslaunchero.core.DeviceProfile;
package org.indin.blisslaunchero.core.customviews;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import org.indin.blisslaunchero.BlissLauncher;
import org.indin.blisslaunchero.core.DeviceProfile;

public class PageIndicatorLinearLayout extends LinearLayout {
    private Context mContext;

+0 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package org.indin.blisslaunchero.core.utils;

import android.app.usage.UsageStats;
import android.util.Log;

import java.util.ArrayList;
import java.util.Arrays;
@@ -54,12 +53,10 @@ public class ListUtil {

        Set<String> packages = new HashSet<>();
        for (UsageStats usageStats : first) {
            Log.i("Package from first", usageStats.getPackageName());
            packages.add(usageStats.getPackageName());
        }

        for (UsageStats usageStats : second) {
            Log.i("Package from second", usageStats.getPackageName());
            packages.remove(usageStats.getPackageName());
        }

+0 −108
Original line number Diff line number Diff line
package org.indin.blisslaunchero.features.launcher;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class CustomScrollVIew extends NestedScrollView {

    private static final String TAG = "CustomScrollVIew";

    private View nestedScrollTarget;
    private boolean nestedScrollTargetIsBeingDragged = false;
    private boolean nestedScrollTargetWasUnableToScroll = false;
    private boolean skipsTouchInterception = false;

    public CustomScrollVIew(Context context) {
        super(context);
    }

    public CustomScrollVIew(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomScrollVIew(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.d(TAG, "dispatchTouchEvent() called with: ev = [" + ev + "]");
        boolean tempSkipsInterception = nestedScrollTarget != null;
        if(tempSkipsInterception){
            skipsTouchInterception = true;
        }

        boolean handled = super.dispatchTouchEvent(ev);
        if(tempSkipsInterception){
            skipsTouchInterception = false;

            if(!handled || nestedScrollTargetWasUnableToScroll){
                handled = super.dispatchTouchEvent(ev);
            }
        }
        return handled;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.d(TAG, "onInterceptTouchEvent() called with: ev = [" + ev + "]");
        return !skipsTouchInterception && super.onInterceptTouchEvent(ev);
    }

    @Override
    public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed,
            int dyUnconsumed) {
        Log.d(TAG, "onNestedScroll() called with: target = [" + target + "], dxConsumed = ["
                + dxConsumed + "], dyConsumed = [" + dyConsumed + "], dxUnconsumed = ["
                + dxUnconsumed + "], dyUnconsumed = [" + dyUnconsumed + "]");
        if (target == nestedScrollTarget && !nestedScrollTargetIsBeingDragged) {
            if (dyConsumed != 0) {
                // The descendent was actually scrolled, so we won't bother it any longer.
                // It will receive all future events until it finished scrolling.
                nestedScrollTargetIsBeingDragged = true;
                nestedScrollTargetWasUnableToScroll = false;
            }
            else if (dyUnconsumed != 0) {
                // The descendent tried scrolling in response to touch movements but was not able to do so.
                // We remember that in order to allow RecyclerView to take over scrolling.
                nestedScrollTargetWasUnableToScroll = true;
                target.getParent().requestDisallowInterceptTouchEvent(false);
            }
        }
    }

    @Override
    public void onNestedScrollAccepted(@NonNull View child, @NonNull View target, int axes) {
        Log.d(TAG,
                "onNestedScrollAccepted() called with: child = [" + child + "], target = [" + target
                        + "], axes = [" + axes + "]");
        if((axes & View.SCROLL_AXIS_VERTICAL) != 0){
            nestedScrollTarget = target;
            nestedScrollTargetIsBeingDragged = false;
            nestedScrollTargetWasUnableToScroll = false;
        }

        super.onNestedScrollAccepted(child, target, axes);
    }

    @Override
    public boolean onStartNestedScroll(@NonNull View child, @NonNull View target, int axes,
            int type) {
        Log.d(TAG, "onStartNestedScroll() called with: child = [" + child + "], target = [" + target
                + "], axes = [" + axes + "], type = [" + type + "]");
        return (axes & View.SCROLL_AXIS_VERTICAL) != 0;
    }

    @Override
    public void onStopNestedScroll(View target) {
        Log.d(TAG, "onStopNestedScroll() called with: target = [" + target + "]");
        nestedScrollTarget = null;
        nestedScrollTargetIsBeingDragged = false;
        nestedScrollTargetWasUnableToScroll = false;
    }
}
Loading