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

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

Themes: Allow setting a default theme

This is a forward port from cm-11.0

Change-Id: I045e1e3a0e561331f0964fe33ec25d2d2a82794a
parent 641faf5d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -230,4 +230,7 @@
    <!-- Default for Settings.System.STATUS_BAR_BATTERY_STYLE -->
    <integer name="def_battery_style">0</integer>

    <!-- Default theme -->
    <string name="def_theme_package"></string>
    <string name="def_theme_components"></string>
</resources>
+25 −1
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
@@ -75,7 +78,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
    // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
    // is properly propagated through your change.  Not doing so will result in a loss of user
    // settings.
    private static final int DATABASE_VERSION = 119;
    private static final int DATABASE_VERSION = 120;

    private static final String HEADSET = "_headset";
    private static final String SPEAKER = "_speaker";
@@ -1901,6 +1904,19 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 119;
        }

       if (upgradeVersion == 119) {
            db.beginTransaction();
            SQLiteStatement stmt = null;
            try {
                stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value) VALUES(?,?);");
                loadDefaultThemeSettings(stmt);
                db.setTransactionSuccessful();
            } finally {
                db.endTransaction();
                if (stmt != null) stmt.close();
            }
            upgradeVersion = 120;
        }

        // *** Remember to update DATABASE_VERSION above!

@@ -2521,6 +2537,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
                R.bool.def_haptic_feedback);
    }

    private void loadDefaultThemeSettings(SQLiteStatement stmt) {
        loadStringSetting(stmt, Settings.Secure.DEFAULT_THEME_PACKAGE, R.string.def_theme_package);
        loadStringSetting(stmt, Settings.Secure.DEFAULT_THEME_COMPONENTS,
                R.string.def_theme_components);
    }

    private void loadSecureSettings(SQLiteDatabase db) {
        SQLiteStatement stmt = null;
        try {
@@ -2643,6 +2665,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {

            loadBooleanSetting(stmt, Settings.Secure.STATS_COLLECTION,
                    R.bool.def_cm_stats_collection);

            loadDefaultThemeSettings(stmt);
        } finally {
            if (stmt != null) stmt.close();
        }