mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Fixed bugs with shortcut selection:
- Incorrect drawable alignment - Action menu working in shortcut selection view
This commit is contained in:
parent
ba90132ce2
commit
3b3f9d716a
4 changed files with 85 additions and 60 deletions
|
|
@ -22,14 +22,14 @@ class Animations (context: Context) {
|
||||||
fun fadeViewOut(view: View, duration: Long = 100) {
|
fun fadeViewOut(view: View, duration: Long = 100) {
|
||||||
view.fadeOut(duration)
|
view.fadeOut(duration)
|
||||||
}
|
}
|
||||||
fun showHome(binding: ActivityMainBinding) {
|
fun showHome(homeView: View, appView: View) {
|
||||||
binding.appView.slideOutToBottom()
|
appView.slideOutToBottom()
|
||||||
binding.homeView.fadeIn()
|
homeView.fadeIn()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showApps(binding: ActivityMainBinding) {
|
fun showApps(homeView: View, appView: View) {
|
||||||
binding.appView.slideInFromBottom()
|
appView.slideInFromBottom()
|
||||||
binding.homeView.fadeOut()
|
homeView.fadeOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun backgroundIn(activity: Activity, duration: Long = 100) {
|
fun backgroundIn(activity: Activity, duration: Long = 100) {
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ class AppMenuAdapter(
|
||||||
textView: TextView,
|
textView: TextView,
|
||||||
actionMenuLayout: LinearLayout,
|
actionMenuLayout: LinearLayout,
|
||||||
editView: LinearLayout,
|
editView: LinearLayout,
|
||||||
position: Int
|
position: Int,
|
||||||
|
shortcutTextView: TextView?
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +79,7 @@ class AppMenuAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortcutTextView == null) {
|
|
||||||
textView.setOnLongClickListener {
|
textView.setOnLongClickListener {
|
||||||
val position = bindingAdapterPosition
|
val position = bindingAdapterPosition
|
||||||
|
|
||||||
|
|
@ -90,13 +91,12 @@ class AppMenuAdapter(
|
||||||
textView,
|
textView,
|
||||||
actionMenuLayout,
|
actionMenuLayout,
|
||||||
editView,
|
editView,
|
||||||
position
|
position,
|
||||||
|
shortcutTextView
|
||||||
)
|
)
|
||||||
return@setOnLongClickListener true
|
return@setOnLongClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
uiUtils.setClockSize(clock)
|
uiUtils.setClockSize(clock)
|
||||||
uiUtils.setDateSize(dateText)
|
uiUtils.setDateSize(dateText)
|
||||||
uiUtils.setShortcutSize(binding.homeView)
|
uiUtils.setShortcutsSize(binding.homeView)
|
||||||
uiUtils.setSearchSize(searchView)
|
uiUtils.setSearchSize(searchView)
|
||||||
|
|
||||||
uiUtils.setStatusBar(window)
|
uiUtils.setStatusBar(window)
|
||||||
|
|
@ -188,7 +188,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
setShortcutSetup(textView, savedView)
|
setShortcutSetup(textView, savedView)
|
||||||
}
|
}
|
||||||
|
|
||||||
uiUtils.setShortcutAlignment(binding.homeView)
|
uiUtils.setShortcutsAlignment(binding.homeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -223,7 +223,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toAppMenu() {
|
private fun toAppMenu() {
|
||||||
animations.showApps(binding)
|
animations.showApps(binding.homeView, binding.appView)
|
||||||
animations.backgroundIn(this@MainActivity)
|
animations.backgroundIn(this@MainActivity)
|
||||||
if (sharedPreferenceManager.isAutoKeyboardEnabled()) {
|
if (sharedPreferenceManager.isAutoKeyboardEnabled()) {
|
||||||
val imm =
|
val imm =
|
||||||
|
|
@ -309,7 +309,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
|
|
||||||
"shortcutAlignment" -> {
|
"shortcutAlignment" -> {
|
||||||
uiUtils.setShortcutAlignment(binding.homeView)
|
uiUtils.setShortcutsAlignment(binding.homeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
"searchAlignment" -> {
|
"searchAlignment" -> {
|
||||||
|
|
@ -325,7 +325,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
|
|
||||||
"shortcutSize" -> {
|
"shortcutSize" -> {
|
||||||
uiUtils.setShortcutSize(binding.homeView)
|
uiUtils.setShortcutsSize(binding.homeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
"searchSize" -> {
|
"searchSize" -> {
|
||||||
|
|
@ -368,7 +368,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
fun backToHome() {
|
fun backToHome() {
|
||||||
closeKeyboard()
|
closeKeyboard()
|
||||||
animations.showHome(binding)
|
animations.showHome(binding.homeView, binding.appView)
|
||||||
animations.backgroundOut(this@MainActivity)
|
animations.backgroundOut(this@MainActivity)
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
|
|
@ -623,6 +623,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
appInfo.applicationInfo.packageName,
|
appInfo.applicationInfo.packageName,
|
||||||
userProfile
|
userProfile
|
||||||
)
|
)
|
||||||
|
uiUtils.setShortcutDrawables(shortcutView, sharedPreferenceManager.getShortcutAlignment())
|
||||||
backToHome()
|
backToHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -634,8 +635,13 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
textView: TextView,
|
textView: TextView,
|
||||||
actionMenuLayout: LinearLayout,
|
actionMenuLayout: LinearLayout,
|
||||||
editView: LinearLayout,
|
editView: LinearLayout,
|
||||||
position: Int
|
position: Int,
|
||||||
|
shortcutTextView: TextView?
|
||||||
) {
|
) {
|
||||||
|
if (shortcutTextView != null) {
|
||||||
|
onShortcut(appInfo, userHandle, textView, userProfile, shortcutTextView)
|
||||||
|
return
|
||||||
|
}
|
||||||
textView.visibility = View.INVISIBLE
|
textView.visibility = View.INVISIBLE
|
||||||
animations.fadeViewIn(actionMenuLayout)
|
animations.fadeViewIn(actionMenuLayout)
|
||||||
val mainActivity =
|
val mainActivity =
|
||||||
|
|
|
||||||
|
|
@ -94,41 +94,60 @@ class UIUtils(private val context: Context) {
|
||||||
setTextAlignment(dateText, alignment)
|
setTextAlignment(dateText, alignment)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setShortcutAlignment(shortcuts: LinearLayout) {
|
fun setShortcutsAlignment(shortcuts: LinearLayout) {
|
||||||
|
val alignment = sharedPreferenceManager.getShortcutAlignment()
|
||||||
shortcuts.children.forEach {
|
shortcuts.children.forEach {
|
||||||
|
|
||||||
if (it is TextView) {
|
if (it is TextView) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
when (sharedPreferenceManager.getShortcutAlignment()) {
|
setShortcutAlignment(it, alignment)
|
||||||
|
setShortcutDrawables(it, alignment)
|
||||||
|
} catch(_: Exception) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setShortcutAlignment(shortcut: TextView, alignment: String?) {
|
||||||
|
when (alignment) {
|
||||||
"left" -> {
|
"left" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(
|
shortcut.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
it.compoundDrawables.filterNotNull().first(), null, null, null
|
|
||||||
)
|
|
||||||
it.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"center" -> {
|
"center" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(
|
shortcut.gravity = Gravity.CENTER
|
||||||
it.compoundDrawables.filterNotNull().first(),
|
|
||||||
null,
|
|
||||||
it.compoundDrawables.filterNotNull().first(),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
it.gravity = Gravity.CENTER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"right" -> {
|
"right" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(
|
shortcut.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setShortcutDrawables(shortcut: TextView, alignment: String?) {
|
||||||
|
when (alignment) {
|
||||||
|
"left" -> {
|
||||||
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
shortcut.compoundDrawables.filterNotNull().first(), null, null, null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
"center" -> {
|
||||||
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
null,
|
null,
|
||||||
null,
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
it.compoundDrawables.filterNotNull().first(),
|
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
it.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch(_: Exception) {}
|
"right" -> {
|
||||||
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +226,7 @@ class UIUtils(private val context: Context) {
|
||||||
setTextSize(dateText, sharedPreferenceManager.getDateSize(), 17F, 20F, 23F)
|
setTextSize(dateText, sharedPreferenceManager.getDateSize(), 17F, 20F, 23F)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setShortcutSize(shortcuts: LinearLayout) {
|
fun setShortcutsSize(shortcuts: LinearLayout) {
|
||||||
|
|
||||||
val viewTreeObserver = shortcuts.viewTreeObserver
|
val viewTreeObserver = shortcuts.viewTreeObserver
|
||||||
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue