mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Refactoring, modified sizing and fixed some memory leaks or whatever
This commit is contained in:
parent
21455d5913
commit
174413982f
4 changed files with 54 additions and 59 deletions
|
|
@ -95,6 +95,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
setMainVariables()
|
||||
|
||||
setPreferences()
|
||||
|
||||
setShortcuts()
|
||||
|
||||
setHomeListeners()
|
||||
|
|
@ -116,7 +117,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupApps()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import android.graphics.BlendMode
|
||||
import android.graphics.BlendModeColorFilter
|
||||
import android.graphics.Color
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -68,14 +69,12 @@ class UIUtils(context: Context) {
|
|||
|
||||
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
searchView.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
println("yoooooooo")
|
||||
val color = sharedPreferenceManager.getTextColor()
|
||||
searchView.setTextColor(color)
|
||||
searchView.setHintTextColor(setAlpha(color, "A9"))
|
||||
searchView.compoundDrawables[0].mutate().colorFilter = BlendModeColorFilter(color, BlendMode.SRC_ATOP)
|
||||
|
||||
if (viewTreeObserver.isAlive) {
|
||||
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,50 +199,57 @@ class UIUtils(context: Context) {
|
|||
}
|
||||
|
||||
fun setShortcutsSize(shortcuts: LinearLayout) {
|
||||
val viewTreeObserver = shortcuts.viewTreeObserver
|
||||
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
|
||||
val size = sharedPreferenceManager.getShortcutSize()
|
||||
val size = sharedPreferenceManager.getShortcutSize()
|
||||
|
||||
shortcuts.children.forEach {
|
||||
if (it is TextView) {
|
||||
setShortcutSize(it, size)
|
||||
|
||||
}
|
||||
}
|
||||
if (viewTreeObserver.isAlive) {
|
||||
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
}
|
||||
shortcuts.children.forEach {
|
||||
if (it is TextView) {
|
||||
setShortcutSize(it, size)
|
||||
}
|
||||
}
|
||||
|
||||
if (viewTreeObserver.isAlive) {
|
||||
viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setShortcutSize(shortcut: TextView, size: String?) {
|
||||
try {
|
||||
val layoutParams = shortcut.layoutParams as LinearLayout.LayoutParams
|
||||
when (size) {
|
||||
"small" -> {
|
||||
layoutParams.weight = 0.08F
|
||||
shortcut.setAutoSizeTextTypeUniformWithConfiguration(
|
||||
18, // Min text size in SP
|
||||
24, // Max text size in SP
|
||||
2, // Step granularity in SP
|
||||
TypedValue.COMPLEX_UNIT_SP // Unit of measurement
|
||||
)
|
||||
}
|
||||
|
||||
"medium" -> {
|
||||
layoutParams.weight = 0.092F
|
||||
shortcut.setAutoSizeTextTypeUniformWithConfiguration(
|
||||
23, // Min text size in SP
|
||||
29, // Max text size in SP
|
||||
2, // Step granularity in SP
|
||||
TypedValue.COMPLEX_UNIT_SP // Unit of measurement
|
||||
)
|
||||
}
|
||||
|
||||
"large" -> {
|
||||
layoutParams.weight = 0.1F
|
||||
shortcut.setAutoSizeTextTypeUniformWithConfiguration(
|
||||
26, // Min text size in SP
|
||||
32, // Max text size in SP
|
||||
2, // Step granularity in SP
|
||||
TypedValue.COMPLEX_UNIT_SP // Unit of measurement
|
||||
)
|
||||
}
|
||||
|
||||
"extra" -> {
|
||||
layoutParams.weight = 0.12F
|
||||
shortcut.setAutoSizeTextTypeUniformWithConfiguration(
|
||||
30, // Min text size in SP
|
||||
36, // Max text size in SP
|
||||
2, // Step granularity in SP
|
||||
TypedValue.COMPLEX_UNIT_SP // Unit of measurement
|
||||
)
|
||||
}
|
||||
}
|
||||
shortcut.layoutParams = layoutParams
|
||||
} catch(_: Exception) {}
|
||||
}
|
||||
|
||||
|
|
@ -253,17 +259,17 @@ class UIUtils(context: Context) {
|
|||
regionText: TextView? = null
|
||||
) {
|
||||
val size = sharedPreferenceManager.getAppSize()
|
||||
setTextSize(textView, size, 24F, 26F, 30F)
|
||||
setTextSize(textView, size, 24F, 27F, 30F)
|
||||
if (editText != null) {
|
||||
setTextSize(editText, size, 24F, 26F, 30F)
|
||||
setTextSize(editText, size, 24F, 27F, 30F)
|
||||
}
|
||||
if (regionText != null) {
|
||||
setTextSize(regionText, size, 14F, 16F, 20F)
|
||||
setTextSize(regionText, size, 14F, 17F, 20F)
|
||||
}
|
||||
}
|
||||
|
||||
fun setSearchSize(searchView: TextInputEditText) {
|
||||
setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 21F, 23F, 27F)
|
||||
setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 21F, 23F, 25F)
|
||||
}
|
||||
|
||||
private fun setTextSize(view: TextView, size: String?, s: Float, m: Float, l: Float) {
|
||||
|
|
|
|||
|
|
@ -131,13 +131,11 @@
|
|||
android:id="@+id/app1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -149,13 +147,11 @@
|
|||
android:id="@+id/app2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -167,13 +163,11 @@
|
|||
android:id="@+id/app3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -185,13 +179,12 @@
|
|||
android:id="@+id/app4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -203,12 +196,11 @@
|
|||
android:id="@+id/app5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -221,12 +213,11 @@
|
|||
android:id="@+id/app6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -239,12 +230,11 @@
|
|||
android:id="@+id/app7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -257,12 +247,11 @@
|
|||
android:id="@+id/app8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
|
|||
|
|
@ -191,15 +191,6 @@
|
|||
app:key="appMenuAlignment"
|
||||
app:title="App Menu Alignment"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:defaultValue="left"
|
||||
app:entries="@array/h_alignment_options"
|
||||
app:entryValues="@array/h_alignment_values"
|
||||
app:key="searchAlignment"
|
||||
app:title="Search Alignment"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -209,6 +200,15 @@
|
|||
app:key="appMenuSize"
|
||||
app:title="App Menu Size"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:defaultValue="left"
|
||||
app:entries="@array/h_alignment_options"
|
||||
app:entryValues="@array/h_alignment_values"
|
||||
app:key="searchAlignment"
|
||||
app:title="Search Alignment"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue