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

Commit 7d0e8b09 authored by d34d's avatar d34d Committed by Steve Kondik
Browse files

Themes: Add previous value and update time to mixnmatch [1/2]

Change-Id: I546f8177cec86005293b8a680766c4b08aace0c1
parent 43f75a8d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -101,9 +101,12 @@ public class ThemeUtils {

    private static final String MEDIA_CONTENT_URI = "content://media/internal/audio/media";

    // Constants for theme change broadcast
    public static final String ACTION_THEME_CHANGED = "org.cyanogenmod.intent.action.THEME_CHANGED";

    public static final String CATEGORY_THEME_COMPONENT_PREFIX = "org.cyanogenmod.intent.category.";
    public static final String EXTRA_COMPONENTS = "components";
    public static final String EXTRA_REQUEST_TYPE = "request_type";
    public static final String EXTRA_UPDATE_TIME = "update_time";

    public static final int SYSTEM_TARGET_API = 0;

+12 −0
Original line number Diff line number Diff line
@@ -283,6 +283,18 @@ public class ThemesContract {
         */
        public static final String COL_VALUE = "value";

        /**
         * The package name that corresponds to where this component was applied from previously
         * <P>Type: String</P>
         */
        public static final String COL_PREV_VALUE = "previous_value";

        /**
         * Time when this entry was last updated
         * <P>Type: INTEGER</P>
         */
        public static final String COL_UPDATE_TIME = "update_time";

        /**
         * Valid keys
         */
+13 −10
Original line number Diff line number Diff line
@@ -368,10 +368,11 @@ public class ThemeService extends IThemeService.Stub {
        }

        if (request == null || request.getNumChangesRequested() == 0) {
            postFinish(true, request);
            postFinish(true, request, 0);
            return;
        }
        mIsThemeApplying = true;
        long updateTime = System.currentTimeMillis();

        incrementProgress(5);

@@ -422,7 +423,7 @@ public class ThemeService extends IThemeService.Stub {
            incrementProgress(progressIncrement);
        }

        updateProvider(request);
        updateProvider(request, updateTime);

        if (shouldUpdateConfiguration(request)) {
            updateConfiguration(request, removePerAppTheme);
@@ -430,7 +431,7 @@ public class ThemeService extends IThemeService.Stub {

        killLaunchers(request);

        postFinish(true, request);
        postFinish(true, request, updateTime);
        mIsThemeApplying = false;
    }

@@ -465,9 +466,9 @@ public class ThemeService extends IThemeService.Stub {
        processInstalledThemes();
    }

    private void updateProvider(ThemeChangeRequest request) {
    private void updateProvider(ThemeChangeRequest request, long updateTime) {
        ContentValues values = new ContentValues();

        values.put(MixnMatchColumns.COL_UPDATE_TIME, updateTime);
        Map<String, String> componentMap = request.getThemeComponentsMap();
        for (String component : componentMap.keySet()) {
            values.put(ThemesContract.MixnMatchColumns.COL_VALUE, componentMap.get(component));
@@ -851,7 +852,7 @@ public class ThemeService extends IThemeService.Stub {
        mClients.finishBroadcast();
    }

    private void postFinish(boolean isSuccess, ThemeChangeRequest request) {
    private void postFinish(boolean isSuccess, ThemeChangeRequest request, long updateTime) {
        synchronized(this) {
            mProgress = 0;
        }
@@ -869,7 +870,7 @@ public class ThemeService extends IThemeService.Stub {

        // if successful, broadcast that the theme changed
        if (isSuccess) {
            broadcastThemeChange(request);
            broadcastThemeChange(request, updateTime);
        }
    }

@@ -886,13 +887,15 @@ public class ThemeService extends IThemeService.Stub {
        mProcessingListeners.finishBroadcast();
    }

    private void broadcastThemeChange(ThemeChangeRequest request) {
    private void broadcastThemeChange(ThemeChangeRequest request, long updateTime) {
        Map<String, String> componentMap = request.getThemeComponentsMap();
        if (componentMap == null || componentMap.size() == 0) return;

        final Intent intent = new Intent(ThemeUtils.ACTION_THEME_CHANGED);
        ArrayList componentsArrayList = new ArrayList(componentMap.keySet());
        intent.putStringArrayListExtra("components", componentsArrayList);
        intent.putStringArrayListExtra(ThemeUtils.EXTRA_COMPONENTS, componentsArrayList);
        intent.putExtra(ThemeUtils.EXTRA_REQUEST_TYPE, request.getReqeustType().ordinal());
        intent.putExtra(ThemeUtils.EXTRA_UPDATE_TIME, updateTime);
        mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
    }

@@ -1112,7 +1115,7 @@ public class ThemeService extends IThemeService.Stub {
                // In case the mixnmatch table has a mods_launcher entry, we'll clear it
                ThemeChangeRequest.Builder builder = new ThemeChangeRequest.Builder();
                builder.setWallpaper("");
                updateProvider(builder.build());
                updateProvider(builder.build(), System.currentTimeMillis());
            } else {
                mWallpaperChangedByUs = false;
            }