Migrate icon shape preference

This commit is contained in:
MM20
2022-01-27 22:22:10 +01:00
parent 1370901f46
commit 75529b8f42
50 changed files with 467 additions and 163 deletions
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#233139</color>
</resources>
@@ -8,7 +8,6 @@ import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
import androidx.preference.Preference
@@ -88,7 +87,6 @@ class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
}
val shapePreference = findPreference<Preference>("icon_shape")!!
shapePreference.summary = getShapeName()
shapePreference.setOnPreferenceClickListener {
val launcherIcon = LauncherIcon(
foreground = requireContext().getDrawable(R.mipmap.ic_launcher_foreground)!!,
@@ -110,23 +108,6 @@ class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT)
val dialog = MaterialDialog(requireContext())
shapes.forEachIndexed { i, shape ->
val view = View.inflate(requireContext(), R.layout.preference_icon_shape_row, null)
view.findViewById<LauncherIconView>(R.id.icon).also { iconView ->
iconView.icon = launcherIcon
iconView.shape = shape.first
}
view.findViewById<TextView>(R.id.label).also { labelView ->
labelView.setText(shape.second)
}
view.layoutParams = layoutParams
iconShapeList.addView(view)
view.setOnClickListener {
LauncherPreferences.instance.iconShape = shape.first
shapePreference.summary = getShapeName()
dialog.dismiss()
}
}
dialog.customView(view = iconShapeList, scrollable = true)
.title(R.string.preference_icon_shape)
@@ -143,19 +124,6 @@ class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
}
}
private fun getShapeName(): String {
return requireContext().getString(when (LauncherIconView.getDefaultShape(requireContext())) {
IconShape.TRIANGLE -> R.string.preference_icon_shape_triangle
IconShape.HEXAGON -> R.string.preference_icon_shape_hexagon
IconShape.ROUNDED_SQUARE -> R.string.preference_icon_shape_rounded_square
IconShape.SQUIRCLE -> R.string.preference_icon_shape_squircle
IconShape.SQUARE -> R.string.preference_icon_shape_square
IconShape.PENTAGON -> R.string.preference_icon_shape_pentagon
IconShape.PLATFORM_DEFAULT -> R.string.preference_icon_shape_platform
else -> R.string.preference_icon_shape_circle
})
}
override fun onResume() {
super.onResume()
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB