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

Commit c7a6c297 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

migrate custom widgets in comply with plugin framework

Bug: 139888225
Change-Id: I8a3d0fe2689ad5ba24b19309728bbad0b6287f71
parent 19b15701
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -152,21 +152,6 @@
        <attr name="canThumbDetach" format="boolean" />
    </declare-styleable>

    <declare-styleable name="CustomAppWidgetProviderInfo">
        <attr name="providerId" format="integer" />

        <attr name="android:label" />
        <attr name="android:initialLayout" />
        <attr name="android:icon" />
        <attr name="android:previewImage" />
        <attr name="android:resizeMode" />

        <attr name="numRows" />
        <attr name="numColumns" />
        <attr name="numMinRows" format="integer" />
        <attr name="numMinColumns" format="integer" />
    </declare-styleable>

    <declare-styleable name="PreviewFragment">
        <attr name="android:name" />
        <attr name="android:id" />

res/xml/custom_widgets.xml

deleted100644 → 0
+0 −31
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<widgets>
    <!-- Sample widget definition
        <widget
            android:label="My custom widget"
            android:initialLayout="@layout/sample_widget_layout"
            android:icon="@drawable/ic_launcher_home"
            android:resizeMode="horizontal|vertical"
            launcher:numRows="2"
            launcher:numColumns="3"
            launcher:numMinRows="1"
            launcher:numMinColumns="2"
            launcher:providerId="1" />
    -->
</widgets>
 No newline at end of file
+4 −5
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ import com.android.launcher3.widget.WidgetAddFlowHandler;
import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetListRowEntry;
import com.android.launcher3.widget.WidgetsFullSheet;
import com.android.launcher3.widget.custom.CustomWidgetParser;
import com.android.launcher3.widget.custom.CustomWidgetManager;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -1657,10 +1657,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        } else {
            // In this case, we either need to start an activity to get permission to bind
            // the widget, or we need to start an activity to configure the widget, or both.
            if (FeatureFlags.ENABLE_CUSTOM_WIDGETS &&
                    info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET) {
                appWidgetId = CustomWidgetParser.getWidgetIdForCustomProvider(
                        this, info.componentName);
            if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET) {
                appWidgetId = CustomWidgetManager.INSTANCE.get(this).getWidgetIdForCustomProvider(
                        info.componentName);
            } else {
                appWidgetId = getAppWidgetHost().allocateAppWidgetId();
            }
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SecureSettingsObserver;
import com.android.launcher3.widget.custom.CustomWidgetManager;

public class LauncherAppState {

@@ -148,6 +149,8 @@ public class LauncherAppState {
    LauncherModel setLauncher(Launcher launcher) {
        getLocalProvider(mContext).setLauncherProviderChangeListener(launcher);
        mModel.initialize(launcher);
        CustomWidgetManager.INSTANCE.get(launcher)
                .setWidgetRefreshCallback(mModel::refreshAndBindWidgetsAndShortcuts);
        return mModel;
    }

+2 −4
Original line number Diff line number Diff line
@@ -27,12 +27,12 @@ import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.widget.Toast;

import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.widget.DeferredAppWidgetHostView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.custom.CustomWidgetManager;

import java.util.ArrayList;

@@ -180,10 +180,8 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
            LauncherAppWidgetProviderInfo appWidget) {
        if (appWidget.isCustomWidget()) {
            LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
            LayoutInflater inflater = (LayoutInflater)
                    context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            inflater.inflate(appWidget.initialLayout, lahv);
            lahv.setAppWidget(0, appWidget);
            CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
            return lahv;
        } else if ((mFlags & FLAG_LISTENING) == 0) {
            DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
Loading