Skip to content

Commit

Permalink
Fix: Add key event handling and click listeners for feature phones
Browse files Browse the repository at this point in the history
Enhanced HomeFragment with key event handling for menu button press
and added click listeners for certain views to improve user interaction.
  • Loading branch information
HeCodes2Much committed Apr 28, 2024
1 parent 7a8aea8 commit 97818e5
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.os.Vibrator
import android.text.format.DateFormat
import android.util.Log
import android.view.Gravity
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
Expand Down Expand Up @@ -173,6 +174,16 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
binding.setDefaultLauncher.setTextColor(fontColor)
binding.homeScreenPager.setTextColor(fontColor)
}

binding.mainLayout.setOnKeyListener { _, keyCode, _ ->
if (keyCode == KeyEvent.KEYCODE_MENU) {
// Handle menu button press
// Open the desired fragment here
showAppList(AppDrawerFlag.LaunchApp, includeHiddenApps = false)
return@setOnKeyListener true
}
return@setOnKeyListener false
}
}

override fun onResume() {
Expand Down Expand Up @@ -614,7 +625,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
} else {
sendToSettingFragment()
}

}
}

Expand Down Expand Up @@ -790,6 +800,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
id = i
text = prefs.getHomeAppModel(i).appLabel
setOnTouchListener(getHomeAppsGestureListener(context, this))
setOnClickListener(this@HomeFragment)
if (!prefs.extendHomeAppsArea) {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
Expand All @@ -816,6 +827,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
id = i
text = formatMillisToHMS(getUsageStats(context, prefs.getHomeAppModel(i).appPackage))
setOnTouchListener(getHomeAppsGestureListener(context, this))
setOnClickListener(this@HomeFragment)
if (!prefs.extendHomeAppsArea) {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
Expand Down Expand Up @@ -885,6 +897,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
id = i
text = prefs.getHomeAppModel(i).appLabel
setOnTouchListener(getHomeAppsGestureListener(context, this))
setOnClickListener(this@HomeFragment)
if (!prefs.extendHomeAppsArea) {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
Expand Down

0 comments on commit 97818e5

Please sign in to comment.