mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
A bunch more refactoring and app menu exiting behaviour changed a bit.
This commit is contained in:
parent
6ceed365bb
commit
e769baeed0
13 changed files with 196 additions and 169 deletions
|
|
@ -14,12 +14,13 @@ class AboutFragment : Fragment() {
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return inflater.inflate(R.layout.fragment_about, container, false)
|
return inflater.inflate(R.layout.fragment_about, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
// Set up about page links
|
||||||
stringUtils.setLink(requireActivity().findViewById(R.id.creditText), getString(R.string.my_website_link))
|
stringUtils.setLink(requireActivity().findViewById(R.id.creditText), getString(R.string.my_website_link))
|
||||||
stringUtils.setLink(requireActivity().findViewById(R.id.codebergLink), getString(R.string.codeberg_link))
|
stringUtils.setLink(requireActivity().findViewById(R.id.codebergLink), getString(R.string.codeberg_link))
|
||||||
stringUtils.setLink(requireActivity().findViewById(R.id.githubLink), getString(R.string.github_link))
|
stringUtils.setLink(requireActivity().findViewById(R.id.githubLink), getString(R.string.github_link))
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ class Animations (context: Context) {
|
||||||
|
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||||
|
|
||||||
|
// fadeViewIn and fadeViewOut are for smaller item transitions, such as the action menu
|
||||||
|
|
||||||
fun fadeViewIn(view: View) {
|
fun fadeViewIn(view: View) {
|
||||||
view.fadeIn()
|
view.fadeIn()
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +24,7 @@ class Animations (context: Context) {
|
||||||
fun fadeViewOut(view: View) {
|
fun fadeViewOut(view: View) {
|
||||||
view.fadeOut()
|
view.fadeOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showHome(homeView: View, appView: View) {
|
fun showHome(homeView: View, appView: View) {
|
||||||
appView.slideOutToBottom()
|
appView.slideOutToBottom()
|
||||||
homeView.fadeIn()
|
homeView.fadeIn()
|
||||||
|
|
@ -35,45 +38,47 @@ class Animations (context: Context) {
|
||||||
fun backgroundIn(activity: Activity) {
|
fun backgroundIn(activity: Activity) {
|
||||||
val originalColor = sharedPreferenceManager.getBgColor()
|
val originalColor = sharedPreferenceManager.getBgColor()
|
||||||
|
|
||||||
val newColor: Int = if (originalColor == Color.parseColor("#00000000")) {
|
// Only animate darkness onto the transparent background
|
||||||
Color.parseColor("#3F000000")
|
if (originalColor == Color.parseColor("#00000000")) {
|
||||||
|
val newColor = Color.parseColor("#3F000000")
|
||||||
|
val colorDrawable = ColorDrawable(originalColor)
|
||||||
|
activity.window.setBackgroundDrawable(colorDrawable)
|
||||||
|
|
||||||
|
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
||||||
|
backgroundColorAnimator.addUpdateListener { animator ->
|
||||||
|
colorDrawable.color = animator.animatedValue as Int
|
||||||
|
}
|
||||||
|
|
||||||
|
val duration = sharedPreferenceManager.getAnimationSpeed()
|
||||||
|
backgroundColorAnimator.duration = duration
|
||||||
|
|
||||||
|
backgroundColorAnimator.start()
|
||||||
} else {
|
} else {
|
||||||
originalColor
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorDrawable = ColorDrawable(originalColor)
|
|
||||||
activity.window.setBackgroundDrawable(colorDrawable)
|
|
||||||
|
|
||||||
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
|
||||||
backgroundColorAnimator.addUpdateListener { animator ->
|
|
||||||
colorDrawable.color = animator.animatedValue as Int
|
|
||||||
}
|
|
||||||
val duration = sharedPreferenceManager.getAnimationSpeed()
|
|
||||||
backgroundColorAnimator.duration = duration
|
|
||||||
|
|
||||||
backgroundColorAnimator.start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun backgroundOut(activity: Activity) {
|
fun backgroundOut(activity: Activity) {
|
||||||
val newColor = sharedPreferenceManager.getBgColor()
|
val newColor = sharedPreferenceManager.getBgColor()
|
||||||
|
|
||||||
val originalColor: Int = if (newColor == Color.parseColor("#00000000")) {
|
// Only animate darkness onto the transparent background
|
||||||
Color.parseColor("#3F000000")
|
if (newColor == Color.parseColor("#00000000")) {
|
||||||
|
val originalColor = Color.parseColor("#3F000000")
|
||||||
|
val colorDrawable = ColorDrawable(originalColor)
|
||||||
|
activity.window.setBackgroundDrawable(colorDrawable)
|
||||||
|
|
||||||
|
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
||||||
|
backgroundColorAnimator.addUpdateListener { animator ->
|
||||||
|
colorDrawable.color = animator.animatedValue as Int
|
||||||
|
}
|
||||||
|
|
||||||
|
val duration = sharedPreferenceManager.getAnimationSpeed()
|
||||||
|
backgroundColorAnimator.duration = duration
|
||||||
|
|
||||||
|
backgroundColorAnimator.start()
|
||||||
} else {
|
} else {
|
||||||
newColor
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorDrawable = ColorDrawable(originalColor)
|
|
||||||
activity.window.setBackgroundDrawable(colorDrawable)
|
|
||||||
|
|
||||||
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
|
||||||
backgroundColorAnimator.addUpdateListener { animator ->
|
|
||||||
colorDrawable.color = animator.animatedValue as Int
|
|
||||||
}
|
|
||||||
val duration = sharedPreferenceManager.getAnimationSpeed()
|
|
||||||
backgroundColorAnimator.duration = duration
|
|
||||||
|
|
||||||
backgroundColorAnimator.start()
|
|
||||||
}
|
}
|
||||||
private fun View.slideInFromBottom() {
|
private fun View.slideInFromBottom() {
|
||||||
if (visibility != View.VISIBLE) {
|
if (visibility != View.VISIBLE) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ class AppActionMenu {
|
||||||
val sharedPreferenceManager = SharedPreferenceManager(activity)
|
val sharedPreferenceManager = SharedPreferenceManager(activity)
|
||||||
|
|
||||||
actionMenu.findViewById<TextView>(R.id.info).setOnClickListener {
|
actionMenu.findViewById<TextView>(R.id.info).setOnClickListener {
|
||||||
|
|
||||||
|
// Launch app info in phone settings
|
||||||
if (mainActivity != null) {
|
if (mainActivity != null) {
|
||||||
launcherApps.startAppDetailsActivity(
|
launcherApps.startAppDetailsActivity(
|
||||||
mainActivity.componentName,
|
mainActivity.componentName,
|
||||||
|
|
@ -75,6 +77,7 @@ class AppActionMenu {
|
||||||
searchView.visibility = View.INVISIBLE
|
searchView.visibility = View.INVISIBLE
|
||||||
editText.requestFocus()
|
editText.requestFocus()
|
||||||
|
|
||||||
|
// Open keyboard
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
val imm =
|
val imm =
|
||||||
|
|
@ -83,6 +86,8 @@ class AppActionMenu {
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
binding.root.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
binding.root.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||||
|
|
||||||
|
// If the keyboard is closed, exit editing mode
|
||||||
if (bottom - top > oldBottom - oldTop) {
|
if (bottom - top > oldBottom - oldTop) {
|
||||||
editLayout.clearFocus()
|
editLayout.clearFocus()
|
||||||
|
|
||||||
|
|
@ -93,6 +98,8 @@ class AppActionMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
editText.setOnEditorActionListener { _, actionId, _ ->
|
editText.setOnEditorActionListener { _, actionId, _ ->
|
||||||
|
|
||||||
|
// Once the new name is confirmed, close the keyboard, save the new app name and update the apps on screen
|
||||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
val imm =
|
val imm =
|
||||||
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
|
@ -113,6 +120,8 @@ class AppActionMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
resetButton.setOnClickListener {
|
resetButton.setOnClickListener {
|
||||||
|
|
||||||
|
// If reset is pressed, close keyboard, remove saved edited name and update the apps on screen
|
||||||
val imm =
|
val imm =
|
||||||
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.hideSoftInputFromWindow(editLayout.windowToken, 0)
|
imm.hideSoftInputFromWindow(editLayout.windowToken, 0)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class AppMenuAdapter(
|
||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<AppMenuAdapter.AppViewHolder>() {
|
RecyclerView.Adapter<AppMenuAdapter.AppViewHolder>() {
|
||||||
|
|
||||||
|
// If the menu is opened to select shortcuts, the below variable is set
|
||||||
var shortcutTextView: TextView? = null
|
var shortcutTextView: TextView? = null
|
||||||
|
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||||
|
|
@ -52,8 +53,7 @@ class AppMenuAdapter(
|
||||||
textView: TextView,
|
textView: TextView,
|
||||||
actionMenuLayout: LinearLayout,
|
actionMenuLayout: LinearLayout,
|
||||||
editView: LinearLayout,
|
editView: LinearLayout,
|
||||||
position: Int,
|
position: Int
|
||||||
shortcutTextView: TextView?
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,6 +71,8 @@ class AppMenuAdapter(
|
||||||
textView.setOnClickListener {
|
textView.setOnClickListener {
|
||||||
val position = bindingAdapterPosition
|
val position = bindingAdapterPosition
|
||||||
val app = apps[position].first
|
val app = apps[position].first
|
||||||
|
|
||||||
|
// If opened to select a shortcut, set the shortcut instead of launching the app
|
||||||
if (shortcutTextView != null) {
|
if (shortcutTextView != null) {
|
||||||
shortcutListener.onShortcut(app, apps[position].second.first, textView, apps[position].second.second, shortcutTextView!!)
|
shortcutListener.onShortcut(app, apps[position].second.first, textView, apps[position].second.second, shortcutTextView!!)
|
||||||
}
|
}
|
||||||
|
|
@ -79,11 +81,17 @@ class AppMenuAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
textView.setOnLongClickListener {
|
textView.setOnLongClickListener {
|
||||||
val position = bindingAdapterPosition
|
val position = bindingAdapterPosition
|
||||||
|
|
||||||
val app = apps[position].first
|
val app = apps[position].first
|
||||||
|
|
||||||
|
// If opened to select a shortcut, set the shortcut instead of opening the action menu
|
||||||
|
if (shortcutTextView != null) {
|
||||||
|
shortcutListener.onShortcut(app, apps[position].second.first, textView, apps[position].second.second, shortcutTextView!!)
|
||||||
|
return@setOnLongClickListener true
|
||||||
|
} else {
|
||||||
|
|
||||||
itemLongClickListener.onItemLongClick(
|
itemLongClickListener.onItemLongClick(
|
||||||
app,
|
app,
|
||||||
apps[position].second.first,
|
apps[position].second.first,
|
||||||
|
|
@ -91,11 +99,10 @@ class AppMenuAdapter(
|
||||||
textView,
|
textView,
|
||||||
actionMenuLayout,
|
actionMenuLayout,
|
||||||
editView,
|
editView,
|
||||||
position,
|
position
|
||||||
shortcutTextView
|
|
||||||
)
|
)
|
||||||
return@setOnLongClickListener true
|
return@setOnLongClickListener true
|
||||||
}
|
}}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +116,7 @@ class AppMenuAdapter(
|
||||||
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
||||||
val app = apps[position]
|
val app = apps[position]
|
||||||
|
|
||||||
|
// Set initial drawables
|
||||||
if (app.second.second != 0) {
|
if (app.second.second != 0) {
|
||||||
holder.textView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_work_app, null),null, ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null),null)
|
holder.textView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_work_app, null),null, ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null),null)
|
||||||
holder.textView.compoundDrawables[0].colorFilter =
|
holder.textView.compoundDrawables[0].colorFilter =
|
||||||
|
|
@ -122,12 +130,15 @@ class AppMenuAdapter(
|
||||||
|
|
||||||
uiUtils.setAppSize(holder.textView, holder.editText)
|
uiUtils.setAppSize(holder.textView, holder.editText)
|
||||||
|
|
||||||
|
// Update the application information (allows updating apps to work)
|
||||||
val appInfo = appUtils.getAppInfo(
|
val appInfo = appUtils.getAppInfo(
|
||||||
app.first.applicationInfo.packageName,
|
app.first.applicationInfo.packageName,
|
||||||
app.second.second
|
app.second.second
|
||||||
)
|
)
|
||||||
|
|
||||||
holder.textView.setTextColor(sharedPreferenceManager.getTextColor())
|
holder.textView.setTextColor(sharedPreferenceManager.getTextColor())
|
||||||
|
|
||||||
|
// Set app name on the menu. If the app has been uninstalled, replace it with "Removing" until the app menu updates.
|
||||||
val appLabel: CharSequence = appInfo?.loadLabel(context.packageManager) ?: "Removing..."
|
val appLabel: CharSequence = appInfo?.loadLabel(context.packageManager) ?: "Removing..."
|
||||||
|
|
||||||
if (appInfo != null) {
|
if (appInfo != null) {
|
||||||
|
|
@ -139,6 +150,7 @@ class AppMenuAdapter(
|
||||||
|
|
||||||
holder.editText.setText(holder.textView.text)
|
holder.editText.setText(holder.textView.text)
|
||||||
|
|
||||||
|
// Remove the uninstall icon for system apps
|
||||||
if (appInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0) {
|
if (appInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0) {
|
||||||
holder.actionMenuLayout.findViewById<TextView>(R.id.uninstall).visibility =
|
holder.actionMenuLayout.findViewById<TextView>(R.id.uninstall).visibility =
|
||||||
View.GONE
|
View.GONE
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@ class AppMenuEdgeFactory(private val activity: Activity) : RecyclerView.EdgeEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class AppMenuEdgeEffect(activity: Activity) : EdgeEffect(activity) {
|
inner class AppMenuEdgeEffect(activity: Activity) : EdgeEffect(activity) {
|
||||||
|
|
||||||
|
//This just speeds up the animation when the scrolling hits the edge so that the app menu can be exited sooner
|
||||||
private val animationSpeedFactor = 0.75f
|
private val animationSpeedFactor = 0.75f
|
||||||
|
|
||||||
override fun onAbsorb(velocity: Int) {
|
override fun onAbsorb(velocity: Int) {
|
||||||
super.onAbsorb((velocity * animationSpeedFactor).toInt())
|
super.onAbsorb((velocity * animationSpeedFactor).toInt())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class AppMenuLinearLayoutManager(private val activity: MainActivity) : LinearLay
|
||||||
val scrollRange = super.scrollVerticallyBy(dy, recycler, state)
|
val scrollRange = super.scrollVerticallyBy(dy, recycler, state)
|
||||||
val overscroll: Int = dy - scrollRange
|
val overscroll: Int = dy - scrollRange
|
||||||
|
|
||||||
if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted && activity.isJobActive) {
|
// If the user scrolls up when already on top, go back to home. Only if the keyboard isn't open, though
|
||||||
|
if (overscroll < 0 && (firstVisibleItemPosition == 0 || firstVisibleItemPosition < 0) && scrollStarted && activity.canExit) {
|
||||||
activity.backToHome()
|
activity.backToHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,19 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA
|
||||||
val allApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
val allApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
||||||
var sortedApps = listOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
var sortedApps = listOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
for (i in launcherApps.profiles.indices) {
|
for (i in launcherApps.profiles.indices) { // Check apps on both, normal and work profiles
|
||||||
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
||||||
if (!sharedPreferenceManager.isAppHidden(
|
if (!sharedPreferenceManager.isAppHidden( // Only include the app if it isn't set as hidden
|
||||||
app.applicationInfo.packageName,
|
app.applicationInfo.packageName,
|
||||||
i
|
i
|
||||||
) && app.applicationInfo.packageName != context.applicationInfo.packageName
|
) && app.applicationInfo.packageName != context.applicationInfo.packageName // Hide the launcher itself
|
||||||
) {
|
) {
|
||||||
allApps.add(Pair(app, Pair(launcherApps.profiles[i], i)))
|
allApps.add(Pair(app, Pair(launcherApps.profiles[i], i)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort apps by name
|
||||||
sortedApps = allApps.sortedBy {
|
sortedApps = allApps.sortedBy {
|
||||||
sharedPreferenceManager.getAppName(
|
sharedPreferenceManager.getAppName(
|
||||||
it.first.applicationInfo.packageName,
|
it.first.applicationInfo.packageName,
|
||||||
|
|
@ -41,8 +42,11 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getHiddenApps(): List<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>> {
|
// Get hidden apps for the hidden apps settings
|
||||||
|
suspend fun getHiddenApps(): List<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>> {
|
||||||
val allApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
val allApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
||||||
|
var sortedApps = listOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
||||||
|
withContext(Dispatchers.Default) {
|
||||||
for (i in launcherApps.profiles.indices) {
|
for (i in launcherApps.profiles.indices) {
|
||||||
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
||||||
if (sharedPreferenceManager.isAppHidden(app.applicationInfo.packageName, i)) {
|
if (sharedPreferenceManager.isAppHidden(app.applicationInfo.packageName, i)) {
|
||||||
|
|
@ -50,13 +54,16 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allApps.sortedBy {
|
|
||||||
|
sortedApps = allApps.sortedBy {
|
||||||
sharedPreferenceManager.getAppName(
|
sharedPreferenceManager.getAppName(
|
||||||
it.first.applicationInfo.packageName,
|
it.first.applicationInfo.packageName,
|
||||||
it.second.second,
|
it.second.second,
|
||||||
context.packageManager.getApplicationLabel(it.first.applicationInfo)
|
context.packageManager.getApplicationLabel(it.first.applicationInfo)
|
||||||
).toString().lowercase()
|
).toString().lowercase()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return sortedApps
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAppInfo(
|
fun getAppInfo(
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class BatteryReceiver(private val activity: MainActivity) : BroadcastReceiver()
|
||||||
val level = it.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
|
val level = it.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
|
||||||
val scale = it.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
|
val scale = it.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
|
||||||
val batteryPct = level * 100 / scale.toFloat()
|
val batteryPct = level * 100 / scale.toFloat()
|
||||||
activity.modifyDate("${batteryPct.toInt()}%", 3)
|
activity.modifyDate("${batteryPct.toInt()}%", 3) // Add battery to the date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ class GestureAppsAdapter(
|
||||||
|
|
||||||
uiUtils.setAppSize(holder.textView)
|
uiUtils.setAppSize(holder.textView)
|
||||||
|
|
||||||
|
// Does not need to be specially updated since it's in a separate activity and thus reloads when opened again
|
||||||
val appInfo = app.first.activityInfo.applicationInfo
|
val appInfo = app.first.activityInfo.applicationInfo
|
||||||
|
|
||||||
holder.textView.text = sharedPreferenceManager.getAppName(
|
holder.textView.text = sharedPreferenceManager.getAppName(
|
||||||
app.first.applicationInfo.packageName,
|
app.first.applicationInfo.packageName,
|
||||||
app.second.second,
|
app.second.second,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class GestureAppsFragment : Fragment(), GestureAppsAdapter.OnItemClickListener {
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return inflater.inflate(R.layout.fragment_gesture_apps, container, false)
|
return inflater.inflate(R.layout.fragment_gesture_apps, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,16 +45,12 @@ class GestureAppsFragment : Fragment(), GestureAppsAdapter.OnItemClickListener {
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
|
|
||||||
withContext(Dispatchers.Default) {
|
adapter = GestureAppsAdapter(
|
||||||
|
requireContext(),
|
||||||
|
appUtils.getInstalledApps().toMutableList(),
|
||||||
|
this@GestureAppsFragment
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
adapter = GestureAppsAdapter(
|
|
||||||
requireContext(),
|
|
||||||
appUtils.getInstalledApps().toMutableList(),
|
|
||||||
this@GestureAppsFragment
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.gestureAppRecycler)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.gestureAppRecycler)
|
||||||
val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity())
|
val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity())
|
||||||
val uiUtils = UIUtils(requireContext())
|
val uiUtils = UIUtils(requireContext())
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
|
|
||||||
|
|
@ -40,10 +42,12 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
appUtils = AppUtils(requireContext(), launcherApps)
|
appUtils = AppUtils(requireContext(), launcherApps)
|
||||||
sharedPreferenceManager = SharedPreferenceManager(requireContext())
|
sharedPreferenceManager = SharedPreferenceManager(requireContext())
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
|
||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.hiddenAppRecycler)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.hiddenAppRecycler)
|
||||||
val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity())
|
val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity())
|
||||||
|
|
||||||
adapter = HiddenAppsAdapter(requireContext(), appUtils.getHiddenApps().toMutableList(), this)
|
adapter = HiddenAppsAdapter(requireContext(), appUtils.getHiddenApps().toMutableList(), this@HiddenAppsFragment)
|
||||||
|
|
||||||
|
|
||||||
recyclerView.edgeEffectFactory = appMenuEdgeFactory
|
recyclerView.edgeEffectFactory = appMenuEdgeFactory
|
||||||
|
|
@ -74,8 +78,9 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
|
lifecycleScope.launch {
|
||||||
filterItems(searchView.text.toString())
|
filterItems(searchView.text.toString())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -87,8 +92,9 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
|
imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun filterItems(query: String?) {
|
private suspend fun filterItems(query: String?) {
|
||||||
|
|
||||||
val cleanQuery = stringUtils.cleanString(query)
|
val cleanQuery = stringUtils.cleanString(query)
|
||||||
val newFilteredApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
val newFilteredApps = mutableListOf<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>()
|
||||||
|
|
@ -128,7 +134,9 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
setTitle("Confirmation")
|
setTitle("Confirmation")
|
||||||
setMessage("Are you sure you want to unhide $appName?")
|
setMessage("Are you sure you want to unhide $appName?")
|
||||||
setPositiveButton("Yes") { _, _ ->
|
setPositiveButton("Yes") { _, _ ->
|
||||||
performConfirmedAction(appInfo, profile)
|
lifecycleScope.launch {
|
||||||
|
performConfirmedAction(appInfo, profile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setNegativeButton("Cancel") { _, _ ->
|
setNegativeButton("Cancel") { _, _ ->
|
||||||
|
|
@ -136,7 +144,7 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||||
}.create().show()
|
}.create().show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun performConfirmedAction(appInfo: LauncherActivityInfo, profile: Int) {
|
private suspend fun performConfirmedAction(appInfo: LauncherActivityInfo, profile: Int) {
|
||||||
sharedPreferenceManager.setAppVisible(appInfo.applicationInfo.packageName, profile)
|
sharedPreferenceManager.setAppVisible(appInfo.applicationInfo.packageName, profile)
|
||||||
adapter?.updateApps(appUtils.getHiddenApps())
|
adapter?.updateApps(appUtils.getHiddenApps())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
private lateinit var preferences: SharedPreferences
|
private lateinit var preferences: SharedPreferences
|
||||||
|
|
||||||
private var isBatteryReceiverRegistered = false
|
private var isBatteryReceiverRegistered = false
|
||||||
var isJobActive = true
|
private var isJobActive = true
|
||||||
|
var canExit = true
|
||||||
|
|
||||||
private val swipeThreshold = 100
|
private val swipeThreshold = 100
|
||||||
private val swipeVelocityThreshold = 100
|
private val swipeVelocityThreshold = 100
|
||||||
|
|
@ -502,8 +503,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
recyclerView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
recyclerView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||||
|
|
||||||
if (bottom - top > oldBottom - oldTop) {
|
if (bottom - top > oldBottom - oldTop) {
|
||||||
|
canExit = true
|
||||||
searchView.clearFocus()
|
searchView.clearFocus()
|
||||||
}
|
}
|
||||||
|
else if (bottom - top < oldBottom - oldTop) {
|
||||||
|
canExit = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchView.addTextChangedListener(object :
|
searchView.addTextChangedListener(object :
|
||||||
|
|
@ -625,7 +630,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
appInfo.applicationInfo.packageName,
|
appInfo.applicationInfo.packageName,
|
||||||
userProfile
|
userProfile
|
||||||
)
|
)
|
||||||
uiUtils.setShortcutDrawables(shortcutView, sharedPreferenceManager.getShortcutAlignment())
|
uiUtils.setDrawables(shortcutView, sharedPreferenceManager.getShortcutAlignment())
|
||||||
backToHome()
|
backToHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,13 +642,8 @@ 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 =
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||||
import android.graphics.BlendMode
|
import android.graphics.BlendMode
|
||||||
import android.graphics.BlendModeColorFilter
|
import android.graphics.BlendModeColorFilter
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
|
@ -15,17 +14,14 @@ import android.view.WindowInsetsController
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextClock
|
import android.widget.TextClock
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.res.ResourcesCompat
|
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
|
||||||
class UIUtils(private val context: Context) {
|
class UIUtils(context: Context) {
|
||||||
|
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||||
|
|
||||||
fun setBackground(window: Window) {
|
fun setBackground(window: Window) {
|
||||||
window.decorView.background = ColorDrawable(Color.parseColor("#00000000"))
|
|
||||||
|
|
||||||
window.decorView.setBackgroundColor(
|
window.decorView.setBackgroundColor(
|
||||||
sharedPreferenceManager.getBgColor()
|
sharedPreferenceManager.getBgColor()
|
||||||
)
|
)
|
||||||
|
|
@ -97,90 +93,63 @@ class UIUtils(private val context: Context) {
|
||||||
fun setShortcutsAlignment(shortcuts: LinearLayout) {
|
fun setShortcutsAlignment(shortcuts: LinearLayout) {
|
||||||
val alignment = sharedPreferenceManager.getShortcutAlignment()
|
val alignment = sharedPreferenceManager.getShortcutAlignment()
|
||||||
shortcuts.children.forEach {
|
shortcuts.children.forEach {
|
||||||
|
|
||||||
if (it is TextView) {
|
if (it is TextView) {
|
||||||
|
setTextGravity(it, alignment)
|
||||||
try {
|
setDrawables(it, alignment)
|
||||||
setShortcutAlignment(it, alignment)
|
|
||||||
setShortcutDrawables(it, alignment)
|
|
||||||
} catch(_: Exception) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setShortcutAlignment(shortcut: TextView, alignment: String?) {
|
|
||||||
when (alignment) {
|
|
||||||
"left" -> {
|
|
||||||
shortcut.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
|
||||||
}
|
|
||||||
|
|
||||||
"center" -> {
|
fun setDrawables(shortcut: TextView, alignment: String?) {
|
||||||
shortcut.gravity = Gravity.CENTER
|
try {
|
||||||
}
|
when (alignment) {
|
||||||
|
"left" -> {
|
||||||
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
"right" -> {
|
"center" -> {
|
||||||
shortcut.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
}
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
}
|
null,
|
||||||
}
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun setShortcutDrawables(shortcut: TextView, alignment: String?) {
|
"right" -> {
|
||||||
when (alignment) {
|
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
"left" -> {
|
null,
|
||||||
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
null,
|
||||||
shortcut.compoundDrawables.filterNotNull().first(), null, null, null
|
shortcut.compoundDrawables.filterNotNull().first(),
|
||||||
)
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (_: Exception) {}
|
||||||
"center" -> {
|
|
||||||
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
|
||||||
shortcut.compoundDrawables.filterNotNull().first(),
|
|
||||||
null,
|
|
||||||
shortcut.compoundDrawables.filterNotNull().first(),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
"right" -> {
|
|
||||||
shortcut.setCompoundDrawablesWithIntrinsicBounds(
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
shortcut.compoundDrawables.filterNotNull().first(),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAppAlignment(
|
fun setAppAlignment(
|
||||||
textView: TextView,
|
textView: TextView,
|
||||||
editText: TextInputEditText? = null,
|
editText: TextView? = null,
|
||||||
regionText: TextView? = null
|
regionText: TextView? = null
|
||||||
) {
|
) {
|
||||||
val alignment = sharedPreferenceManager.getAppAlignment()
|
val alignment = sharedPreferenceManager.getAppAlignment()
|
||||||
setTextGravity(textView, alignment)
|
setTextGravity(textView, alignment)
|
||||||
|
|
||||||
if (regionText != null) {
|
if (regionText != null) {
|
||||||
setTextGravity(textView, alignment)
|
|
||||||
setTextGravity(regionText, alignment)
|
setTextGravity(regionText, alignment)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
when (alignment) {
|
if (editText != null) {
|
||||||
"left" -> {
|
setDrawables(textView, alignment)
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(textView.compoundDrawables.filterNotNull().first(),null, ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null), null)
|
setTextGravity(editText, alignment)
|
||||||
editText?.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
|
||||||
|
|
||||||
}
|
|
||||||
"center" -> {
|
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(textView.compoundDrawables.filterNotNull().first(),null, textView.compoundDrawables.filterNotNull().first(), null)
|
|
||||||
editText?.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
|
||||||
|
|
||||||
}
|
|
||||||
"right" -> {
|
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null),null, textView.compoundDrawables.filterNotNull().first(), null)
|
|
||||||
editText?.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +164,8 @@ class UIUtils(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTextAlignment(view: TextView, alignment: String?) {
|
private fun setTextAlignment(view: TextView, alignment: String?) {
|
||||||
view.textAlignment = when (alignment) {
|
try {
|
||||||
|
view.textAlignment = when (alignment) {
|
||||||
"left" -> View.TEXT_ALIGNMENT_VIEW_START
|
"left" -> View.TEXT_ALIGNMENT_VIEW_START
|
||||||
|
|
||||||
"center" -> View.TEXT_ALIGNMENT_CENTER
|
"center" -> View.TEXT_ALIGNMENT_CENTER
|
||||||
|
|
@ -203,19 +173,22 @@ class UIUtils(private val context: Context) {
|
||||||
"right" -> View.TEXT_ALIGNMENT_VIEW_END
|
"right" -> View.TEXT_ALIGNMENT_VIEW_END
|
||||||
|
|
||||||
else -> View.TEXT_ALIGNMENT_VIEW_START
|
else -> View.TEXT_ALIGNMENT_VIEW_START
|
||||||
}
|
}
|
||||||
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTextGravity(view: TextView, alignment: String?) {
|
private fun setTextGravity(view: TextView, alignment: String?) {
|
||||||
view.gravity = when (alignment) {
|
try {
|
||||||
"left" -> Gravity.CENTER_VERTICAL or Gravity.START
|
view.gravity = when (alignment) {
|
||||||
|
"left" -> Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
|
|
||||||
"center" -> Gravity.CENTER
|
"center" -> Gravity.CENTER
|
||||||
|
|
||||||
"right" -> Gravity.CENTER_VERTICAL or Gravity.END
|
"right" -> Gravity.CENTER_VERTICAL or Gravity.END
|
||||||
|
|
||||||
else -> Gravity.CENTER_VERTICAL or Gravity.START
|
else -> Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
}
|
}
|
||||||
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setClockSize(clock: TextClock) {
|
fun setClockSize(clock: TextClock) {
|
||||||
|
|
@ -227,6 +200,7 @@ class UIUtils(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setShortcutsSize(shortcuts: LinearLayout) {
|
fun setShortcutsSize(shortcuts: LinearLayout) {
|
||||||
|
val alignment = sharedPreferenceManager.getShortcutSize()
|
||||||
|
|
||||||
val viewTreeObserver = shortcuts.viewTreeObserver
|
val viewTreeObserver = shortcuts.viewTreeObserver
|
||||||
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
|
@ -234,30 +208,8 @@ class UIUtils(private val context: Context) {
|
||||||
|
|
||||||
shortcuts.children.forEach {
|
shortcuts.children.forEach {
|
||||||
if (it is TextView) {
|
if (it is TextView) {
|
||||||
|
setShortcutSize(it, alignment)
|
||||||
|
|
||||||
when (sharedPreferenceManager.getShortcutSize()) {
|
|
||||||
"small" -> {
|
|
||||||
it.setPadding(
|
|
||||||
it.paddingLeft,
|
|
||||||
it.height / 4,
|
|
||||||
it.paddingRight,
|
|
||||||
it.height / 4
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
"medium" -> {
|
|
||||||
it.setPadding(
|
|
||||||
it.paddingLeft,
|
|
||||||
(it.height / 4.5).toInt(),
|
|
||||||
it.paddingRight,
|
|
||||||
(it.height / 4.5).toInt()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
"large" -> {
|
|
||||||
it.setPadding(it.paddingLeft, 0, it.paddingRight, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (viewTreeObserver.isAlive) {
|
if (viewTreeObserver.isAlive) {
|
||||||
|
|
@ -271,6 +223,34 @@ class UIUtils(private val context: Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setShortcutSize(shortcut: TextView, alignment: String?) {
|
||||||
|
try {
|
||||||
|
when (alignment) {
|
||||||
|
"small" -> {
|
||||||
|
shortcut.setPadding(
|
||||||
|
shortcut.paddingLeft,
|
||||||
|
shortcut.height / 4,
|
||||||
|
shortcut.paddingRight,
|
||||||
|
shortcut.height / 4
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
"medium" -> {
|
||||||
|
shortcut.setPadding(
|
||||||
|
shortcut.paddingLeft,
|
||||||
|
(shortcut.height / 4.5).toInt(),
|
||||||
|
shortcut.paddingRight,
|
||||||
|
(shortcut.height / 4.5).toInt()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
"large" -> {
|
||||||
|
shortcut.setPadding(shortcut.paddingLeft, 0, shortcut.paddingRight, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(_: Exception) {}
|
||||||
|
}
|
||||||
|
|
||||||
fun setAppSize(
|
fun setAppSize(
|
||||||
textView: TextView,
|
textView: TextView,
|
||||||
editText: TextInputEditText? = null,
|
editText: TextInputEditText? = null,
|
||||||
|
|
@ -291,15 +271,19 @@ class UIUtils(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTextSize(view: TextView, size: String?, s: Float, m: Float, l: Float) {
|
private fun setTextSize(view: TextView, size: String?, s: Float, m: Float, l: Float) {
|
||||||
view.textSize = when (size) {
|
try {
|
||||||
"small" -> s
|
view.textSize = when (size) {
|
||||||
|
"small" -> s
|
||||||
|
|
||||||
"medium" -> m
|
"medium" -> m
|
||||||
|
|
||||||
"large" -> l
|
"large" -> l
|
||||||
|
|
||||||
else -> {0F}
|
else -> {
|
||||||
}
|
0F
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setStatusBar(window: Window) {
|
fun setStatusBar(window: Window) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue