mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +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) {
|
private fun renameApp(textView: TextView, editLayout: LinearLayout, actionMenu: View, appActivity: LauncherActivityInfo?, appInfo: ApplicationInfo, userHandle: UserHandle, workProfile: Int) {
|
||||||
|
activity.disableAppMenuScroll()
|
||||||
textView.visibility = View.INVISIBLE
|
textView.visibility = View.INVISIBLE
|
||||||
animations.fadeViewIn(editLayout)
|
animations.fadeViewIn(editLayout)
|
||||||
animations.fadeViewOut(actionMenu)
|
animations.fadeViewOut(actionMenu)
|
||||||
|
|
@ -134,8 +135,9 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
|
||||||
editLayout.clearFocus()
|
editLayout.clearFocus()
|
||||||
|
|
||||||
animations.fadeViewOut(editLayout)
|
animations.fadeViewOut(editLayout)
|
||||||
textView.visibility = View.VISIBLE
|
animations.fadeViewIn(textView)
|
||||||
searchView.visibility = View.VISIBLE
|
searchView.visibility = View.VISIBLE
|
||||||
|
activity.enableAppMenuScroll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +156,7 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
|
||||||
activity.lifecycleScope.launch {
|
activity.lifecycleScope.launch {
|
||||||
activity.applySearch()
|
activity.applySearch()
|
||||||
}
|
}
|
||||||
|
activity.enableAppMenuScroll()
|
||||||
|
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,6 @@ class AppMenuAdapter(
|
||||||
val editText: TextInputEditText = editView.findViewById(R.id.appNameEdit)
|
val editText: TextInputEditText = editView.findViewById(R.id.appNameEdit)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
actionMenuLayout.visibility = View.INVISIBLE
|
|
||||||
editView.visibility = View.INVISIBLE
|
|
||||||
|
|
||||||
textView.setOnClickListener {
|
textView.setOnClickListener {
|
||||||
val position = bindingAdapterPosition
|
val position = bindingAdapterPosition
|
||||||
val app = apps[position].first
|
val app = apps[position].first
|
||||||
|
|
@ -119,6 +116,8 @@ class AppMenuAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
||||||
|
holder.actionMenuLayout.visibility = View.INVISIBLE
|
||||||
|
holder.editView.visibility = View.INVISIBLE
|
||||||
val app = apps[position]
|
val app = apps[position]
|
||||||
|
|
||||||
// Set initial drawables
|
// Set initial drawables
|
||||||
|
|
@ -166,6 +165,8 @@ class AppMenuAdapter(
|
||||||
}
|
}
|
||||||
else {holder.textView.text = appLabel}
|
else {holder.textView.text = appLabel}
|
||||||
|
|
||||||
|
uiUtils.setAppSpacing(holder.textView)
|
||||||
|
|
||||||
holder.textView.visibility = View.VISIBLE
|
holder.textView.visibility = View.VISIBLE
|
||||||
|
|
||||||
if (appInfo != null) {
|
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
|
// On home key or swipe, return to home screen
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,10 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
return preferences.getString("searchSize", "medium")
|
return preferences.getString("searchSize", "medium")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getAppSpacing(): Int? {
|
||||||
|
return preferences.getString("appSpacing", "20")?.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
fun isAutoKeyboardEnabled(): Boolean {
|
fun isAutoKeyboardEnabled(): Boolean {
|
||||||
return preferences.getBoolean("autoKeyboard", false)
|
return preferences.getBoolean("autoKeyboard", false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class Animations (context: Context) {
|
||||||
.setDuration(duration/2)
|
.setDuration(duration/2)
|
||||||
.setListener(object : AnimatorListenerAdapter() {
|
.setListener(object : AnimatorListenerAdapter() {
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
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 firstVisibleItemPosition = 0
|
||||||
private var scrollStarted = false
|
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() {
|
fun setScrollInfo() {
|
||||||
firstVisibleItemPosition = findFirstCompletelyVisibleItemPosition()
|
firstVisibleItemPosition = findFirstCompletelyVisibleItemPosition()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import androidx.core.view.children
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import eu.ottop.yamlauncher.settings.SharedPreferenceManager
|
import eu.ottop.yamlauncher.settings.SharedPreferenceManager
|
||||||
|
|
||||||
class UIUtils(context: Context) {
|
class UIUtils(private val context: Context) {
|
||||||
|
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||||
|
|
||||||
|
|
@ -335,4 +335,17 @@ class UIUtils(context: Context) {
|
||||||
|
|
||||||
shortcut.layoutParams = layoutParams
|
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
|
<LinearLayout
|
||||||
android:id="@+id/renameView"
|
android:id="@+id/renameView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:paddingVertical="10dp"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingVertical="5dp"
|
||||||
android:visibility="invisible">
|
android:visibility="invisible">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/appNameEdit"
|
android:id="@+id/appNameEdit"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:elegantTextHeight="false"
|
android:elegantTextHeight="false"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:includeFontPadding="true"
|
android:includeFontPadding="true"
|
||||||
android:paddingLeft="20dp"
|
android:paddingLeft="20dp"
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="0dp"
|
||||||
android:paddingRight="20dp"
|
android:paddingRight="20dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="0dp"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
@ -52,9 +56,10 @@
|
||||||
android:id="@+id/appName"
|
android:id="@+id/appName"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:drawablePadding="3dp"
|
android:drawablePadding="3dp"
|
||||||
android:gravity="start"
|
android:gravity="start|center_vertical"
|
||||||
android:paddingLeft="20dp"
|
android:paddingLeft="20dp"
|
||||||
android:paddingTop="20dp"
|
android:paddingTop="20dp"
|
||||||
android:paddingRight="20dp"
|
android:paddingRight="20dp"
|
||||||
|
|
@ -69,6 +74,7 @@
|
||||||
android:id="@+id/actionMenu"
|
android:id="@+id/actionMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:visibility="invisible">
|
android:visibility="invisible">
|
||||||
|
|
||||||
|
|
@ -79,6 +85,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:foreground="@drawable/app_action_foreground"
|
android:foreground="@drawable/app_action_foreground"
|
||||||
|
android:paddingVertical="3dp"
|
||||||
android:text="@string/info"
|
android:text="@string/info"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
@ -92,6 +99,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:foreground="@drawable/app_action_foreground"
|
android:foreground="@drawable/app_action_foreground"
|
||||||
|
android:paddingVertical="3dp"
|
||||||
android:text="@string/uninstall"
|
android:text="@string/uninstall"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
@ -105,6 +113,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:foreground="@drawable/app_action_foreground"
|
android:foreground="@drawable/app_action_foreground"
|
||||||
|
android:paddingVertical="3dp"
|
||||||
android:text="@string/rename"
|
android:text="@string/rename"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
@ -118,6 +127,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:foreground="@drawable/app_action_foreground"
|
android:foreground="@drawable/app_action_foreground"
|
||||||
|
android:paddingVertical="3dp"
|
||||||
android:text="@string/hide"
|
android:text="@string/hide"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
@ -131,6 +141,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#A7000000"
|
android:background="#A7000000"
|
||||||
android:foreground="@drawable/app_action_foreground"
|
android:foreground="@drawable/app_action_foreground"
|
||||||
|
android:paddingVertical="3dp"
|
||||||
android:text="@string/close"
|
android:text="@string/close"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,24 @@
|
||||||
<item>0.21</item>
|
<item>0.21</item>
|
||||||
</string-array>
|
</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-->
|
<!--Weather-->
|
||||||
<string-array name="temp_units">
|
<string-array name="temp_units">
|
||||||
<item>°C</item>
|
<item>°C</item>
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,15 @@
|
||||||
app:key="searchSize"
|
app:key="searchSize"
|
||||||
app:title="Search Size"
|
app:title="Search Size"
|
||||||
app:useSimpleSummaryProvider="true" />
|
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
|
<SwitchPreference
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue