Feature: Added the ability for home app to be at bottom.
This commit is contained in:
@@ -10,12 +10,12 @@ import javax.inject.Inject
|
||||
|
||||
class BottomDialogHelper @Inject constructor() {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun setupDialogStyle(dialog: Dialog?) {
|
||||
|
||||
val window = dialog?.window
|
||||
if (window != null) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
@Suppress("DEPRECATION")
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||
window.statusBarColor = Color.TRANSPARENT
|
||||
}
|
||||
|
||||
@@ -175,6 +175,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getInt(Constants.WIDGET_BATTERY, 2)
|
||||
set(value) = prefs.edit().putInt(Constants.WIDGET_BATTERY, value).apply()
|
||||
|
||||
var homeAlignmentBottom: Boolean
|
||||
get() = prefs.getBoolean(Constants.HOME_ALLIGNMENT_BOTTOM, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.HOME_ALLIGNMENT_BOTTOM, value).apply()
|
||||
|
||||
var settingsLock: Boolean
|
||||
get() = prefs.getBoolean(Constants.TOGGLE_SETTING_LOCK, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.TOGGLE_SETTING_LOCK, value).apply()
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.os.BatteryManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@@ -188,8 +189,26 @@ class HomeFragment : Fragment(),
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
|
||||
// Set the bottom margin instead of top
|
||||
layoutParams.topMargin = marginInPixels.toInt()
|
||||
// Determine the gravity and margin based on the alignment preference
|
||||
val gravity = if (preferenceHelper.homeAlignmentBottom)
|
||||
Gravity.BOTTOM
|
||||
else
|
||||
Gravity.TOP
|
||||
|
||||
// Apply the margin and gravity
|
||||
val parentLayout = binding.appListTouchArea
|
||||
val params = parentLayout.layoutParams.apply {
|
||||
height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
parentLayout.layoutParams = params
|
||||
parentLayout.gravity = gravity
|
||||
|
||||
// Set the appropriate margin based on the alignment
|
||||
if (preferenceHelper.homeAlignmentBottom)
|
||||
layoutParams.bottomMargin = marginInPixels.toInt()
|
||||
else
|
||||
layoutParams.topMargin = marginInPixels.toInt()
|
||||
|
||||
|
||||
// Set gravity to align RecyclerView to the bottom
|
||||
layoutParams.gravity = when (preferenceHelper.homeAppAlignment) {
|
||||
@@ -231,6 +250,9 @@ class HomeFragment : Fragment(),
|
||||
clock.setOnClickListener { context.launchClock() }
|
||||
date.setOnClickListener { context.launchCalendar() }
|
||||
battery.setOnClickListener { context.openBatteryManager() }
|
||||
|
||||
touchArea.setBackgroundColor(Color.parseColor("#00FFFF"))
|
||||
appListTouchArea.setBackgroundColor(Color.parseColor("#FF00FF"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.github.droidworksstudio.launcher.ui.home
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
@@ -27,6 +28,7 @@ class HomeViewHolder @Inject constructor(
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
fun bind(appInfo: AppInfo) {
|
||||
binding.apply {
|
||||
itemView.setBackgroundColor(Color.parseColor("#0000FF"))
|
||||
// Get the current LayoutParams of appHiddenName
|
||||
val layoutAppNameParams = appHomeName.layoutParams as LinearLayoutCompat.LayoutParams
|
||||
|
||||
|
||||
@@ -363,6 +363,12 @@ class SettingsFeaturesFragment : Fragment(),
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
|
||||
homeAlignmentBottomSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setHomeAlignmentBottom(isChecked)
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
|
||||
disableAnimationsSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setDisableAnimations(isChecked)
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
|
||||
@@ -63,6 +63,7 @@ object Constants {
|
||||
const val AUTOMATIC_OPEN_APP = "AUTOMATIC_OPEN_APP"
|
||||
const val SEARCH_FROM_START = "SEARCH_FROM_START"
|
||||
const val FILTER_STRENGTH = "FILTER_STRENGTH"
|
||||
const val HOME_ALLIGNMENT_BOTTOM = "HOME_ALLIGNMENT_BOTTOM"
|
||||
const val TOGGLE_SETTING_LOCK = "TOGGLE_SETTING_LOCK"
|
||||
const val DISABLE_ANIMATIONS = "DISABLE_ANIMATIONS"
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val dailyWordTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val autoOpenAppsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val searchFromStartLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val homeAlignmentBottomLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoKeyboardLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val lockSettingsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val disableAnimationsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
@@ -269,6 +270,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
autoOpenAppsLiveData.postValue((preferenceHelper.automaticOpenApp))
|
||||
}
|
||||
|
||||
fun setHomeAlignmentBottom(homeAlignmentBottom: Boolean) {
|
||||
preferenceHelper.homeAlignmentBottom = homeAlignmentBottom
|
||||
homeAlignmentBottomLiveData.postValue((preferenceHelper.homeAlignmentBottom))
|
||||
}
|
||||
|
||||
fun setSearchFromStart(searchFromStart: Boolean) {
|
||||
preferenceHelper.searchFromStart = searchFromStart
|
||||
searchFromStartLiveData.postValue((preferenceHelper.searchFromStart))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<com.github.droidworksstudio.launcher.view.GestureNestedScrollView
|
||||
android:id="@+id/nestScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="48dp"
|
||||
@@ -34,7 +34,6 @@
|
||||
android:id="@+id/mainView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginVertical="32dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -105,7 +104,8 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/appListAdapter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
@@ -153,6 +153,37 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/homeAlignmentBottom_text"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_home_alignment_bottom"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/homeAlignmentBottom_switchCompat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.8"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
<string name="settings_display_app_icons">Show App Icons</string>
|
||||
<string name="settings_display_automatic_keyboard">Auto Show Keyboard</string>
|
||||
<string name="settings_display_auto_open_apps">Auto Open Last App</string>
|
||||
<string name="settings_home_alignment_bottom">Home Alignment Bottom</string>
|
||||
<string name="settings_search_from_start">Search From Start</string>
|
||||
<string name="settings_display_lock_settings">Lock Settings</string>
|
||||
<string name="settings_display_disable_animations">Disable Animations</string>
|
||||
|
||||
Reference in New Issue
Block a user