mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Fixed multiple context menus appearing + customizable app menu spacing + renaming view is unscrollable
This commit is contained in:
parent
e453742ce8
commit
5a3012f0f1
10 changed files with 91 additions and 13 deletions
|
|
@ -108,6 +108,7 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
|
|||
}
|
||||
|
||||
private fun renameApp(textView: TextView, editLayout: LinearLayout, actionMenu: View, appActivity: LauncherActivityInfo?, appInfo: ApplicationInfo, userHandle: UserHandle, workProfile: Int) {
|
||||
activity.disableAppMenuScroll()
|
||||
textView.visibility = View.INVISIBLE
|
||||
animations.fadeViewIn(editLayout)
|
||||
animations.fadeViewOut(actionMenu)
|
||||
|
|
@ -134,8 +135,9 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
|
|||
editLayout.clearFocus()
|
||||
|
||||
animations.fadeViewOut(editLayout)
|
||||
textView.visibility = View.VISIBLE
|
||||
animations.fadeViewIn(textView)
|
||||
searchView.visibility = View.VISIBLE
|
||||
activity.enableAppMenuScroll()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +156,7 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
|
|||
activity.lifecycleScope.launch {
|
||||
activity.applySearch()
|
||||
}
|
||||
|
||||
activity.enableAppMenuScroll()
|
||||
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@ class AppMenuAdapter(
|
|||
val editText: TextInputEditText = editView.findViewById(R.id.appNameEdit)
|
||||
|
||||
init {
|
||||
actionMenuLayout.visibility = View.INVISIBLE
|
||||
editView.visibility = View.INVISIBLE
|
||||
|
||||
textView.setOnClickListener {
|
||||
val position = bindingAdapterPosition
|
||||
val app = apps[position].first
|
||||
|
|
@ -119,6 +116,8 @@ class AppMenuAdapter(
|
|||
}
|
||||
|
||||
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
||||
holder.actionMenuLayout.visibility = View.INVISIBLE
|
||||
holder.editView.visibility = View.INVISIBLE
|
||||
val app = apps[position]
|
||||
|
||||
// Set initial drawables
|
||||
|
|
@ -166,6 +165,8 @@ class AppMenuAdapter(
|
|||
}
|
||||
else {holder.textView.text = appLabel}
|
||||
|
||||
uiUtils.setAppSpacing(holder.textView)
|
||||
|
||||
holder.textView.visibility = View.VISIBLE
|
||||
|
||||
if (appInfo != null) {
|
||||
|
|
|
|||
|
|
@ -660,6 +660,16 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
}
|
||||
}
|
||||
|
||||
fun disableAppMenuScroll() {
|
||||
appMenuLinearLayoutManager.setScrollEnabled(false)
|
||||
recyclerView.layoutManager = appMenuLinearLayoutManager
|
||||
}
|
||||
|
||||
fun enableAppMenuScroll() {
|
||||
appMenuLinearLayoutManager.setScrollEnabled(true)
|
||||
recyclerView.layoutManager = appMenuLinearLayoutManager
|
||||
}
|
||||
|
||||
// On home key or swipe, return to home screen
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
|
|
|
|||
|
|
@ -164,6 +164,10 @@ class SharedPreferenceManager (private val context: Context) {
|
|||
return preferences.getString("searchSize", "medium")
|
||||
}
|
||||
|
||||
fun getAppSpacing(): Int? {
|
||||
return preferences.getString("appSpacing", "20")?.toInt()
|
||||
}
|
||||
|
||||
fun isAutoKeyboardEnabled(): Boolean {
|
||||
return preferences.getBoolean("autoKeyboard", false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class Animations (context: Context) {
|
|||
.setDuration(duration/2)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
visibility = View.GONE
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,16 @@ class AppMenuLinearLayoutManager(private val activity: MainActivity) : LinearLay
|
|||
|
||||
private var firstVisibleItemPosition = 0
|
||||
private var scrollStarted = false
|
||||
private var isScrollEnabled: Boolean = true
|
||||
|
||||
fun setScrollEnabled(enabled: Boolean) {
|
||||
isScrollEnabled = enabled
|
||||
}
|
||||
|
||||
override fun canScrollVertically(): Boolean {
|
||||
// Control vertical scrolling based on the flag
|
||||
return isScrollEnabled && super.canScrollVertically()
|
||||
}
|
||||
|
||||
fun setScrollInfo() {
|
||||
firstVisibleItemPosition = findFirstCompletelyVisibleItemPosition()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import androidx.core.view.children
|
|||
import com.google.android.material.textfield.TextInputEditText
|
||||
import eu.ottop.yamlauncher.settings.SharedPreferenceManager
|
||||
|
||||
class UIUtils(context: Context) {
|
||||
class UIUtils(private val context: Context) {
|
||||
|
||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||
|
||||
|
|
@ -335,4 +335,17 @@ class UIUtils(context: Context) {
|
|||
|
||||
shortcut.layoutParams = layoutParams
|
||||
}
|
||||
|
||||
fun setAppSpacing(app: TextView) {
|
||||
val spacing = sharedPreferenceManager.getAppSpacing()
|
||||
if (spacing != null) {
|
||||
val spacingPx = dpToPx(spacing)
|
||||
app.setPadding(app.paddingLeft, spacingPx, app.paddingRight, spacingPx)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dpToPx(dp: Int): Int {
|
||||
val density = context.resources.displayMetrics.density
|
||||
return (dp * density).toInt()
|
||||
}
|
||||
}
|
||||
|
|
@ -10,24 +10,28 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/renameView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingVertical="10dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="5dp"
|
||||
android:visibility="invisible">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/appNameEdit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:clickable="true"
|
||||
android:elegantTextHeight="false"
|
||||
android:gravity="center_vertical"
|
||||
android:imeOptions="actionDone"
|
||||
android:includeFontPadding="true"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
@ -52,9 +56,10 @@
|
|||
android:id="@+id/appName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="start"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="20dp"
|
||||
|
|
@ -69,6 +74,7 @@
|
|||
android:id="@+id/actionMenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:visibility="invisible">
|
||||
|
||||
|
|
@ -79,6 +85,7 @@
|
|||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:foreground="@drawable/app_action_foreground"
|
||||
android:paddingVertical="3dp"
|
||||
android:text="@string/info"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
@ -92,6 +99,7 @@
|
|||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:foreground="@drawable/app_action_foreground"
|
||||
android:paddingVertical="3dp"
|
||||
android:text="@string/uninstall"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
@ -105,6 +113,7 @@
|
|||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:foreground="@drawable/app_action_foreground"
|
||||
android:paddingVertical="3dp"
|
||||
android:text="@string/rename"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
@ -118,6 +127,7 @@
|
|||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:foreground="@drawable/app_action_foreground"
|
||||
android:paddingVertical="3dp"
|
||||
android:text="@string/hide"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
@ -131,6 +141,7 @@
|
|||
android:layout_weight="1"
|
||||
android:background="#A7000000"
|
||||
android:foreground="@drawable/app_action_foreground"
|
||||
android:paddingVertical="3dp"
|
||||
android:text="@string/close"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
|
|
|
|||
|
|
@ -123,6 +123,24 @@
|
|||
<item>0.21</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="app_spacing_options">
|
||||
<item>Tiny</item>
|
||||
<item>Small</item>
|
||||
<item>Medium</item>
|
||||
<item>Large</item>
|
||||
<item>Extra Large</item>
|
||||
<item>Huge</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="app_spacing_values">
|
||||
<item>0</item>
|
||||
<item>15</item>
|
||||
<item>20</item>
|
||||
<item>25</item>
|
||||
<item>30</item>
|
||||
<item>35</item>
|
||||
</string-array>
|
||||
|
||||
<!--Weather-->
|
||||
<string-array name="temp_units">
|
||||
<item>°C</item>
|
||||
|
|
|
|||
|
|
@ -241,6 +241,15 @@
|
|||
app:key="searchSize"
|
||||
app:title="Search Size"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:defaultValue="20"
|
||||
app:entries="@array/app_spacing_options"
|
||||
app:entryValues="@array/app_spacing_values"
|
||||
app:key="appSpacing"
|
||||
app:title="App Spacing"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue