add blue and green icons

pull/1138/head
deniscerri 4 months ago
parent 22564a06ee
commit 01e1c2dc29
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -463,6 +463,51 @@
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias
android:name=".BlueIcon"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue"
android:roundIcon="@mipmap/ic_launcher_round_blue"
android:configChanges="locale"
android:launchMode="singleTask"
android:targetActivity=".MainActivity"
android:windowSoftInputMode="adjustPan">
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/txt" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".GreenIcon"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_green"
android:roundIcon="@mipmap/ic_launcher_round_green"
android:configChanges="locale"
android:launchMode="singleTask"
android:targetActivity=".MainActivity"
android:windowSoftInputMode="adjustPan">
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/txt" />
</intent-filter>
</activity-alias>
<activity <activity
android:name=".ui.more.cookies.WebViewActivity" android:name=".ui.more.cookies.WebViewActivity"
android:configChanges="locale" android:configChanges="locale"

@ -1,12 +1,8 @@
package com.deniscerri.ytdl.ui.adapter package com.deniscerri.ytdl.ui.adapter
import android.app.Activity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.deniscerri.ytdl.R
import com.deniscerri.ytdl.databinding.AppIconItemBinding import com.deniscerri.ytdl.databinding.AppIconItemBinding
import com.deniscerri.ytdl.ui.more.settings.SettingHost import com.deniscerri.ytdl.ui.more.settings.SettingHost
import com.deniscerri.ytdl.util.ThemeUtil import com.deniscerri.ytdl.util.ThemeUtil
@ -22,10 +18,10 @@ class IconsSheetAdapter(val host: SettingHost) : RecyclerView.Adapter<IconsSheet
return IconsSheetViewHolder(binding) return IconsSheetViewHolder(binding)
} }
override fun getItemCount() = availableIcons.size override fun getItemCount() = ThemeUtil.availableIcons.size
override fun onBindViewHolder(holder: IconsSheetViewHolder, position: Int) { override fun onBindViewHolder(holder: IconsSheetViewHolder, position: Int) {
val appIcon = availableIcons[position] val appIcon = ThemeUtil.availableIcons[position]
holder.binding.apply { holder.binding.apply {
iconIV.setImageResource(appIcon.iconResource) iconIV.setImageResource(appIcon.iconResource)
iconName.text = root.context.getString(appIcon.nameResource) iconName.text = root.context.getString(appIcon.nameResource)
@ -39,22 +35,4 @@ class IconsSheetAdapter(val host: SettingHost) : RecyclerView.Adapter<IconsSheet
} }
} }
} }
companion object {
sealed class AppIcon(
@StringRes val nameResource: Int,
@DrawableRes val iconResource: Int,
val activityAlias: String
) {
object Default : AppIcon(R.string.auto, R.mipmap.ic_launcher, "default")
object DefaultLight : AppIcon(R.string.light, R.mipmap.ic_launcher_light, "Light")
object DefaultDark : AppIcon(R.string.dark, R.mipmap.ic_launcher_dark, "Dark")
}
val availableIcons = listOf(
AppIcon.Default,
AppIcon.DefaultLight,
AppIcon.DefaultDark,
)
}
} }

@ -209,7 +209,7 @@ object GeneralSettingsModule : SettingModule {
"ytdlnis_icon" -> { "ytdlnis_icon" -> {
pref.apply { pref.apply {
val currentValue = preferences.getString("ytdlnis_icon", "default") val currentValue = preferences.getString("ytdlnis_icon", "default")
IconsSheetAdapter.availableIcons.firstOrNull { it.activityAlias == currentValue }?.let { ThemeUtil.availableIcons.firstOrNull { it.activityAlias == currentValue }?.let {
summary = context.getString(it.nameResource) summary = context.getString(it.nameResource)
} }

@ -9,6 +9,7 @@ import android.os.Bundle
import android.text.Spanned import android.text.Spanned
import android.util.TypedValue import android.util.TypedValue
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.core.text.parseAsHtml import androidx.core.text.parseAsHtml
@ -56,18 +57,23 @@ object ThemeUtil {
} }
sealed class AppIcon( sealed class AppIcon(
@StringRes val nameResource: Int,
@DrawableRes val iconResource: Int, @DrawableRes val iconResource: Int,
val activityAlias: String val activityAlias: String
) { ) {
object Default : AppIcon(R.mipmap.ic_launcher, "Default") object Default : AppIcon(R.string.auto, R.mipmap.ic_launcher, "Default")
object Light : AppIcon(R.mipmap.ic_launcher_light, "LightIcon") object Light : AppIcon(R.string.light, R.mipmap.ic_launcher_light, "LightIcon")
object Dark : AppIcon(R.mipmap.ic_launcher_dark, "DarkIcon") object Dark : AppIcon(R.string.dark, R.mipmap.ic_launcher_dark, "DarkIcon")
object Blue : AppIcon(R.string.blue, R.mipmap.ic_launcher_blue, "BlueIcon")
object Green : AppIcon(R.string.green, R.mipmap.ic_launcher_green, "GreenIcon")
} }
private val availableIcons = listOf( val availableIcons = listOf(
AppIcon.Default, AppIcon.Default,
AppIcon.Light, AppIcon.Light,
AppIcon.Dark AppIcon.Dark,
AppIcon.Blue,
AppIcon.Green,
) )
fun recreateMain() { fun recreateMain() {
@ -125,7 +131,7 @@ object ThemeUtil {
} }
val iconMode = sharedPreferences.getString("ytdlnis_icon", "default")!! val iconMode = sharedPreferences.getString("ytdlnis_icon", "Default")!!
updateAppIcon(activity,theme, iconMode) updateAppIcon(activity,theme, iconMode)
} }
@ -167,27 +173,39 @@ object ThemeUtil {
} }
var iconMode = appIconMode var iconMode = appIconMode
if (appIconMode == "default") { if (appIconMode == "Default") {
iconMode = theme iconMode = theme
} }
when (iconMode) { when (iconMode) {
"Light" -> { "LightIcon" -> {
//set light icon
activity.packageManager.setComponentEnabledSetting( activity.packageManager.setComponentEnabledSetting(
ComponentName(activity.packageName, "com.deniscerri.ytdl.LightIcon"), ComponentName(activity.packageName, "com.deniscerri.ytdl.LightIcon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP PackageManager.DONT_KILL_APP
) )
} }
"Dark" -> { "DarkIcon" -> {
//set dark icon
activity.packageManager.setComponentEnabledSetting( activity.packageManager.setComponentEnabledSetting(
ComponentName(activity.packageName, "com.deniscerri.ytdl.DarkIcon"), ComponentName(activity.packageName, "com.deniscerri.ytdl.DarkIcon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP PackageManager.DONT_KILL_APP
) )
} }
"BlueIcon" -> {
activity.packageManager.setComponentEnabledSetting(
ComponentName(activity.packageName, "com.deniscerri.ytdl.BlueIcon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
}
"GreenIcon" -> {
activity.packageManager.setComponentEnabledSetting(
ComponentName(activity.packageName, "com.deniscerri.ytdl.GreenIcon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
}
// or "System" // or "System"
else -> { else -> {
//set dynamic icon //set dynamic icon

@ -9,7 +9,7 @@
<path <path
android:name="path" android:name="path"
android:pathData="M 73.977 46.512 C 75.734 48.222 76.781 50.662 76.872 53.315 C 76.945 55.412 77 57.629 77 59.482 C 77 61.335 76.945 63.552 76.872 65.649 C 76.718 70.133 73.835 74.006 69.404 74.78 C 65.706 75.426 60.571 76 54 76 C 47.429 76 42.294 75.426 38.596 74.78 C 34.165 74.006 31.282 70.133 31.128 65.649 C 31.055 63.552 31 61.335 31 59.482 C 31 57.629 31.055 55.412 31.128 53.315 C 31.282 48.831 34.165 44.957 38.596 44.183 C 41.576 43.663 45.489 43.189 50.335 43.025 C 51.232 37.348 56.145 33 62.083 33 C 68.658 33 73.977 38.331 73.977 44.895 L 73.977 46.512 Z M 52.345 42.976 C 52.886 42.968 53.438 42.963 54 42.963 L 54.086 42.963 C 53.495 42.964 52.915 42.969 52.347 42.978 C 52.224 43.601 52.16 44.244 52.16 44.902 L 52.16 51.756 L 48.489 51.76 C 46.26 51.763 44.867 54.174 45.98 56.106 L 51.541 65.764 C 52.656 67.699 55.448 67.701 56.565 65.767 L 62.15 56.095 C 63.267 54.161 61.869 51.744 59.636 51.747 L 55.803 51.752 L 55.803 44.902 L 55.803 44.895 L 55.782 44.895 C 55.782 41.413 58.603 38.59 62.083 38.59 C 65.26 38.59 67.888 40.943 68.322 44.003 C 68.695 44.062 69.056 44.122 69.404 44.183 C 70.345 44.347 71.216 44.651 72.006 45.071 L 72.006 44.895 C 72.006 39.412 67.563 34.967 62.083 34.967 C 57.259 34.967 53.239 38.411 52.345 42.976 Z M 66.248 43.705 C 65.731 41.885 64.058 40.557 62.083 40.557 C 60.356 40.557 58.86 41.571 58.166 43.043 C 61.248 43.162 63.941 43.407 66.248 43.705 Z" android:pathData="M 73.977 46.512 C 75.734 48.222 76.781 50.662 76.872 53.315 C 76.945 55.412 77 57.629 77 59.482 C 77 61.335 76.945 63.552 76.872 65.649 C 76.718 70.133 73.835 74.006 69.404 74.78 C 65.706 75.426 60.571 76 54 76 C 47.429 76 42.294 75.426 38.596 74.78 C 34.165 74.006 31.282 70.133 31.128 65.649 C 31.055 63.552 31 61.335 31 59.482 C 31 57.629 31.055 55.412 31.128 53.315 C 31.282 48.831 34.165 44.957 38.596 44.183 C 41.576 43.663 45.489 43.189 50.335 43.025 C 51.232 37.348 56.145 33 62.083 33 C 68.658 33 73.977 38.331 73.977 44.895 L 73.977 46.512 Z M 52.345 42.976 C 52.886 42.968 53.438 42.963 54 42.963 L 54.086 42.963 C 53.495 42.964 52.915 42.969 52.347 42.978 C 52.224 43.601 52.16 44.244 52.16 44.902 L 52.16 51.756 L 48.489 51.76 C 46.26 51.763 44.867 54.174 45.98 56.106 L 51.541 65.764 C 52.656 67.699 55.448 67.701 56.565 65.767 L 62.15 56.095 C 63.267 54.161 61.869 51.744 59.636 51.747 L 55.803 51.752 L 55.803 44.902 L 55.803 44.895 L 55.782 44.895 C 55.782 41.413 58.603 38.59 62.083 38.59 C 65.26 38.59 67.888 40.943 68.322 44.003 C 68.695 44.062 69.056 44.122 69.404 44.183 C 70.345 44.347 71.216 44.651 72.006 45.071 L 72.006 44.895 C 72.006 39.412 67.563 34.967 62.083 34.967 C 57.259 34.967 53.239 38.411 52.345 42.976 Z M 66.248 43.705 C 65.731 41.885 64.058 40.557 62.083 40.557 C 60.356 40.557 58.86 41.571 58.166 43.043 C 61.248 43.162 63.941 43.407 66.248 43.705 Z"
android:fillColor="?android:colorPrimaryDark" android:fillColor="#005EB8"
android:strokeWidth="1" android:strokeWidth="1"
android:fillType="evenOdd"/> android:fillType="evenOdd"/>
</vector> </vector>

@ -0,0 +1,15 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="108dp"
android:gravity="fill_horizontal|fill_vertical"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:name="path"
android:pathData="M 73.977 46.512 C 75.734 48.222 76.781 50.662 76.872 53.315 C 76.945 55.412 77 57.629 77 59.482 C 77 61.335 76.945 63.552 76.872 65.649 C 76.718 70.133 73.835 74.006 69.404 74.78 C 65.706 75.426 60.571 76 54 76 C 47.429 76 42.294 75.426 38.596 74.78 C 34.165 74.006 31.282 70.133 31.128 65.649 C 31.055 63.552 31 61.335 31 59.482 C 31 57.629 31.055 55.412 31.128 53.315 C 31.282 48.831 34.165 44.957 38.596 44.183 C 41.576 43.663 45.489 43.189 50.335 43.025 C 51.232 37.348 56.145 33 62.083 33 C 68.658 33 73.977 38.331 73.977 44.895 L 73.977 46.512 Z M 52.345 42.976 C 52.886 42.968 53.438 42.963 54 42.963 L 54.086 42.963 C 53.495 42.964 52.915 42.969 52.347 42.978 C 52.224 43.601 52.16 44.244 52.16 44.902 L 52.16 51.756 L 48.489 51.76 C 46.26 51.763 44.867 54.174 45.98 56.106 L 51.541 65.764 C 52.656 67.699 55.448 67.701 56.565 65.767 L 62.15 56.095 C 63.267 54.161 61.869 51.744 59.636 51.747 L 55.803 51.752 L 55.803 44.902 L 55.803 44.895 L 55.782 44.895 C 55.782 41.413 58.603 38.59 62.083 38.59 C 65.26 38.59 67.888 40.943 68.322 44.003 C 68.695 44.062 69.056 44.122 69.404 44.183 C 70.345 44.347 71.216 44.651 72.006 45.071 L 72.006 44.895 C 72.006 39.412 67.563 34.967 62.083 34.967 C 57.259 34.967 53.239 38.411 52.345 42.976 Z M 66.248 43.705 C 65.731 41.885 64.058 40.557 62.083 40.557 C 60.356 40.557 58.86 41.571 58.166 43.043 C 61.248 43.162 63.941 43.407 66.248 43.705 Z"
android:fillColor="#43bf24"
android:strokeWidth="1"
android:fillType="evenOdd"/>
</vector>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_green"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_green"/>
</adaptive-icon>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_green"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_green"/>
</adaptive-icon>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/> <background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_themed"/> <foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_themed"/> <monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon> </adaptive-icon>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_dark"/> <background android:drawable="@drawable/ic_launcher_background_dark"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_themed"/> <foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_themed"/> <monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon> </adaptive-icon>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_light"/> <background android:drawable="@drawable/ic_launcher_background_light"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_themed"/> <foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_themed"/> <monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon> </adaptive-icon>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background_dark"/> <background android:drawable="@drawable/ic_launcher_background_dark"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_themed"/> <foreground android:drawable="@drawable/ic_launcher_foreground_blue"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground_themed"/> <monochrome android:drawable="@drawable/ic_launcher_foreground_blue"/>
</adaptive-icon> </adaptive-icon>
Loading…
Cancel
Save