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

Commit 8382fdc7 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Updating logic for setting wallpaper desired size > Only setting...

Merge "Updating logic for setting wallpaper desired size   > Only setting desired size on wallpaper change for pre kitkat   > Removing wallpaper change receiver from manifest   > Removing multi-process wallpaper shared prefs for kitkat+" into ub-launcher3-master
parents bf4c1d40 4b17147c
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -178,13 +178,6 @@
            >
        </service>

        <receiver
            android:name="com.android.launcher3.WallpaperChangedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.WALLPAPER_CHANGED" />
            </intent-filter>
        </receiver>

        <!-- Intent received used to install shortcuts from other applications -->
        <receiver
            android:name="com.android.launcher3.InstallShortcutReceiver"
+3 −26
Original line number Diff line number Diff line
@@ -19,10 +19,7 @@ package com.android.launcher3;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -58,9 +55,6 @@ import java.util.WeakHashMap;
public class WallpaperCropActivity extends BaseActivity implements Handler.Callback {
    private static final String LOGTAG = "Launcher3.CropActivity";

    protected static final String WALLPAPER_WIDTH_KEY = WallpaperUtils.WALLPAPER_WIDTH_KEY;
    protected static final String WALLPAPER_HEIGHT_KEY = WallpaperUtils.WALLPAPER_HEIGHT_KEY;

    /**
     * The maximum bitmap size we allow to be returned through the intent.
     * Intents have a maximum of 1MB in total size. However, the Bitmap seems to
@@ -69,7 +63,6 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
     * array instead of a Bitmap instance to avoid overhead.
     */
    public static final int MAX_BMAP_IN_INTENT = 750000;
    public static final float WALLPAPER_SCREENS_SPAN = WallpaperUtils.WALLPAPER_SCREENS_SPAN;

    private static final int MSG_LOAD_IMAGE = 1;

@@ -302,7 +295,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
        final Point bounds = cropTask.getImageBounds();
        Runnable onEndCrop = new Runnable() {
            public void run() {
                updateWallpaperDimensions(bounds.x, bounds.y);
                WallpaperUtils.saveWallpaperDimensions(bounds.x, bounds.y, WallpaperCropActivity.this);
                if (finishActivityWhenDone) {
                    setResult(Activity.RESULT_OK);
                    finish();
@@ -328,7 +321,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
            public void run() {
                // Passing 0, 0 will cause launcher to revert to using the
                // default wallpaper size
                updateWallpaperDimensions(0, 0);
                WallpaperUtils.saveWallpaperDimensions(0, 0, WallpaperCropActivity.this);
                if (finishActivityWhenDone) {
                    setResult(Activity.RESULT_OK);
                    finish();
@@ -420,7 +413,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb

        Runnable onEndCrop = new Runnable() {
            public void run() {
                updateWallpaperDimensions(outWidth, outHeight);
                WallpaperUtils.saveWallpaperDimensions(outWidth, outHeight, WallpaperCropActivity.this);
                if (finishActivityWhenDone) {
                    setResult(Activity.RESULT_OK);
                    finish();
@@ -435,22 +428,6 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
        cropTask.execute();
    }

    protected void updateWallpaperDimensions(int width, int height) {
        String spKey = LauncherFiles.WALLPAPER_CROP_PREFERENCES_KEY;
        SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
        SharedPreferences.Editor editor = sp.edit();
        if (width != 0 && height != 0) {
            editor.putInt(WALLPAPER_WIDTH_KEY, width);
            editor.putInt(WALLPAPER_HEIGHT_KEY, height);
        } else {
            editor.remove(WALLPAPER_WIDTH_KEY);
            editor.remove(WALLPAPER_HEIGHT_KEY);
        }
        editor.commit();
        WallpaperUtils.suggestWallpaperDimension(getResources(),
                sp, getWindowManager(), WallpaperManager.getInstance(getContext()), true);
    }

    static class LoadRequest {
        BitmapSource src;
        boolean touchEnabled;
+12 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3;

import android.app.SearchManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -37,7 +38,7 @@ public class LauncherAppState {
    private final IconCache mIconCache;
    private final WidgetPreviewLoader mWidgetCache;

    private boolean mWallpaperChangedSinceLastCheck;
    @Thunk boolean mWallpaperChangedSinceLastCheck;

    private static WeakReference<LauncherProvider> sLauncherProvider;
    private static Context sContext;
@@ -100,6 +101,16 @@ public class LauncherAppState {

        sContext.registerReceiver(mModel, filter);
        UserManagerCompat.getInstance(sContext).enableAndResetCache();

        if (!Utilities.ATLEAST_KITKAT) {
            sContext.registerReceiver(new BroadcastReceiver() {

                @Override
                public void onReceive(Context context, Intent intent) {
                    mWallpaperChangedSinceLastCheck = true;
                }
            }, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
        }
    }

    /**
@@ -157,10 +168,6 @@ public class LauncherAppState {
        return mWidgetCache;
    }

    public void onWallpaperChanged() {
        mWallpaperChangedSinceLastCheck = true;
    }

    public boolean hasWallpaperChangedSinceLastCheck() {
        boolean result = mWallpaperChangedSinceLastCheck;
        mWallpaperChangedSinceLastCheck = false;
+0 −29
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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.
 */

package com.android.launcher3;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class WallpaperChangedReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent data) {
        LauncherAppState.setApplicationContext(context.getApplicationContext());
        LauncherAppState appState = LauncherAppState.getInstance();
        appState.onWallpaperChanged();
    }
}
+6 −7
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -1308,12 +1307,12 @@ public class Workspace extends PagedView
    protected void setWallpaperDimension() {
        new AsyncTask<Void, Void, Void>() {
            public Void doInBackground(Void ... args) {
                String spKey = LauncherFiles.WALLPAPER_CROP_PREFERENCES_KEY;
                SharedPreferences sp =
                        mLauncher.getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
                WallpaperUtils.suggestWallpaperDimension(mLauncher.getResources(),
                        sp, mLauncher.getWindowManager(), mWallpaperManager,
                if (Utilities.ATLEAST_KITKAT) {
                    WallpaperUtils.suggestWallpaperDimension(mLauncher);
                } else {
                    WallpaperUtils.suggestWallpaperDimensionPreK(mLauncher,
                            mLauncher.overrideWallpaperDimensions());
                }
                return null;
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
Loading