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

Commit eb615a5e authored by Abhishek Aggarwal's avatar Abhishek Aggarwal Committed by Mohammed Althaf T
Browse files

feat(widget): Use launcher to handle activity result also remove internal api usage

parent 67424760
Loading
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.Intent
import android.content.res.Configuration
import android.graphics.Rect
import android.os.Bundle
import android.os.ServiceManager
import android.os.UserHandle
import android.util.AttributeSet
import android.view.LayoutInflater
@@ -41,7 +40,6 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.Toast
import com.android.internal.appwidget.IAppWidgetService
import com.android.launcher3.InvariantDeviceProfile
import com.android.launcher3.Launcher
import com.android.launcher3.LauncherPrefs
@@ -406,20 +404,11 @@ class WidgetContainer(context: Context, attrs: AttributeSet?) : FrameLayout(cont

        private fun sendIntent(widgetId: Int) {
            val bundle = Bundle().apply { putInt(EXTRA_APPWIDGET_ID, widgetId) }
            // Access internal AppWidgetService through Stub
            val intentSender =
                IAppWidgetService.Stub.asInterface(
                        ServiceManager.getService(Context.APPWIDGET_SERVICE)
                    )
                    .createAppWidgetConfigIntentSender(context.opPackageName, widgetId, 0)

            startIntentSenderForResult(
                intentSender,
                REQUEST_CONFIGURE_APPWIDGET,
                null,
                0,
                0,
            mWidgetHost.startAppWidgetConfigureActivityForResult(
                launcher,
                widgetId,
                0,
                REQUEST_CONFIGURE_APPWIDGET,
                bundle
            )
        }
+9 −0
Original line number Diff line number Diff line
@@ -103,6 +103,8 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.ItemInfoMatcher.forFolderMatch;
import static com.android.launcher3.util.SettingsCache.TOUCHPAD_NATURAL_SCROLLING;

import static foundation.e.bliss.widgets.BlissAppWidgetHost.REQUEST_CONFIGURE_APPWIDGET;

import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -303,6 +305,7 @@ import foundation.e.bliss.blur.BlurWallpaperProvider;
import foundation.e.bliss.multimode.MultiModeController;
import foundation.e.bliss.utils.Logger;
import foundation.e.bliss.widgets.RoundedWidgetView;
import foundation.e.bliss.widgets.WidgetContainer;
import foundation.e.bliss.widgets.WidgetsDbHelper;
import foundation.e.lib.telemetry.Telemetry;
import timber.log.Timber;
@@ -1076,6 +1079,12 @@ public class Launcher extends StatefulActivity<LauncherState>
    public void onActivityResult(
            final int requestCode, final int resultCode, final Intent data) {
        mPendingActivityRequestCode = -1;
        if (requestCode == REQUEST_CONFIGURE_APPWIDGET) {
            WidgetContainer.WidgetFragment widgetFragment = (WidgetContainer.WidgetFragment) getFragmentManager().findFragmentByTag("qsb_view");
            widgetFragment.onActivityResult(requestCode, resultCode, data);
            mPendingActivityRequestCode = -1;
            return;
        }
        handleActivityResult(requestCode, resultCode, data);
    }

+1 −1
Original line number Diff line number Diff line
@@ -1047,7 +1047,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
                    this::getEmptySpaceHeight,
                    /* iconClickListener= */ !isEditMode ? WidgetsFullSheet.this :
                    v -> WidgetFragment.onWidgetClick(context, v, close -> {
                        closeAllOpenViews(Launcher.getLauncher(context));
                        handleClose(false);
                        return null;
                    }),
                    /* iconLongClickListener= */ !isEditMode ? WidgetsFullSheet.this : null,