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

Commit 794d8008 authored by Michael W's avatar Michael W Committed by Michael Bestas
Browse files

SettingsLib: Add LineageParts settings to tile list

* By adding our own package we can inject settings which also respect
  ordering by priority
* This way we don't have to modify xml files manually when using IA

Change-Id: Iadf05092e8b8512dc07f9fa2305c36fde10084c1
parent b050d8a9
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Coypright (C) 2017 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -93,6 +94,9 @@ public class TileUtils {
    private static final String MANUFACTURER_DEFAULT_CATEGORY =
            "com.android.settings.category.device";

    private static final String LINEAGE_SETTINGS_ACTION =
            "org.lineageos.lineageparts.action.SETTINGS";

    /**
     * The key used to get the category from metadata of activities of action
     * {@link #EXTRA_SETTINGS_ACTION}
@@ -184,6 +188,8 @@ public class TileUtils {

    public static final String SETTING_PKG = "com.android.settings";

    public static final String LINEAGE_SETTING_PKG = "org.lineageos.lineageparts";

    /**
     * Build a list of DashboardCategory. Each category must be defined in manifest.
     * eg: .Settings$DeviceSettings
@@ -226,6 +232,10 @@ public class TileUtils {
                // Only add Settings for this user.
                getTilesForAction(context, user, SETTINGS_ACTION, cache, null, tiles, true,
                        settingPkg);
                if (SETTING_PKG.equals(settingPkg)) {
                    getTilesForAction(context, user, LINEAGE_SETTINGS_ACTION, cache, null, tiles,
                        true, LINEAGE_SETTING_PKG);
                }
                getTilesForAction(context, user, OPERATOR_SETTINGS, cache,
                        OPERATOR_DEFAULT_CATEGORY, tiles, false, true, settingPkg);
                getTilesForAction(context, user, MANUFACTURER_SETTINGS, cache,
@@ -294,8 +304,10 @@ public class TileUtils {
                continue;
            }
            category.title = resolved.activityInfo.loadLabel(pm);
            category.priority = SETTING_PKG.equals(
                    resolved.activityInfo.applicationInfo.packageName) ? resolved.priority : 0;
            String pkgName = resolved.activityInfo.applicationInfo.packageName;
            category.priority = (SETTING_PKG.equals(pkgName) || LINEAGE_SETTING_PKG.equals(pkgName))
                    ? resolved.priority
                    : 0;
            if (DEBUG) Log.d(LOG_TAG, "Adding category " + category.title);
        }