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

Commit 64903f53 authored by Yash Garg's avatar Yash Garg 💬 Committed by Mohammed Althaf T
Browse files

feat: force alias selected apps through array

parent 3ad1120f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7,4 +7,9 @@
        <item>com.android.stk</item>
        <item>foundation.e.blissweather</item>
    </array>

    <!-- Key | Value string array to force alias -->
    <string-array name="aliased_apps">
        <item>com.generalmagic.magicearth</item> <item>@string/maps</item>
    </string-array>
</resources>
+2 −1
Original line number Diff line number Diff line
@@ -3,4 +3,5 @@
    <string name="edit">Edit</string>
    <string name="search">Search</string>
    <string name="suggestions">SUGGESTIONS</string>
    <string name="maps">Maps</string>
</resources>
+1 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="derived_app_name" translatable="false">BlissLauncher</string>
    <string name="launcher_activity_logic_class" translatable="false">foundation.e.bliss.LauncherActivityCachingLogic</string>

    <string-array name="filtered_components">
        <item>@string/quickstep_component</item>
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright © MURENA SAS 2023.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 */
package foundation.e.bliss

import android.content.Context
import android.content.pm.LauncherActivityInfo
import androidx.annotation.Keep
import com.android.launcher3.R
import com.android.launcher3.icons.LauncherActivityCachingLogic as BaseLogic
import foundation.e.bliss.utils.resourcesToMap

@Keep
@Suppress("Unused")
class LauncherActivityCachingLogic(context: Context) : BaseLogic() {
    private val aliasedApps by lazy {
        val list = context.resources.getStringArray(R.array.aliased_apps).toList()
        resourcesToMap(list)
    }

    override fun getLabel(info: LauncherActivityInfo): CharSequence {
        val customLabel = aliasedApps[info.componentName.packageName]
        return if (!customLabel.isNullOrEmpty()) {
            customLabel
        } else super.getLabel(info)
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package foundation.e.bliss.utils
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import kotlin.Exception

fun Context.toggleKeyboard(view: View, hasFocus: Boolean) {
    val inputMethodManager = getSystemService(InputMethodManager::class.java)
@@ -29,3 +30,17 @@ fun Context.toggleKeyboard(view: View, hasFocus: Boolean) {
        inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
    }
}

fun <T> resourcesToMap(array: List<T>): Map<T, T> {
    val map = mutableMapOf<T, T>()

    if (array.size.mod(2) == 0) {
        for (i in array.indices step 2) {
            map[array[i]] = array[i + 1]
        }
    } else {
        throw Exception("Failed to parse array resource")
    }

    return map
}