mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Added options to toggle clock, date and search on or off
This commit is contained in:
parent
54200a0181
commit
a08bc25f6e
5 changed files with 91 additions and 2 deletions
|
|
@ -289,6 +289,10 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
uiUtils.setMenuItemColors(searchView)
|
uiUtils.setMenuItemColors(searchView)
|
||||||
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
||||||
|
|
||||||
|
uiUtils.setClockVisibility(clock)
|
||||||
|
uiUtils.setDateVisibility(dateText)
|
||||||
|
uiUtils.setSearchVisibility(searchView, binding.searchReplacement)
|
||||||
|
|
||||||
uiUtils.setClockAlignment(clock, dateText)
|
uiUtils.setClockAlignment(clock, dateText)
|
||||||
uiUtils.setSearchAlignment(searchView)
|
uiUtils.setSearchAlignment(searchView)
|
||||||
|
|
||||||
|
|
@ -387,6 +391,18 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"clockEnabled" -> {
|
||||||
|
uiUtils.setClockVisibility(clock)
|
||||||
|
}
|
||||||
|
|
||||||
|
"dateEnabled" -> {
|
||||||
|
uiUtils.setDateVisibility(dateText)
|
||||||
|
}
|
||||||
|
|
||||||
|
"searchEnabled" -> {
|
||||||
|
uiUtils.setSearchVisibility(searchView, binding.searchReplacement)
|
||||||
|
}
|
||||||
|
|
||||||
"clockAlignment" -> {
|
"clockAlignment" -> {
|
||||||
uiUtils.setClockAlignment(clock, dateText)
|
uiUtils.setClockAlignment(clock, dateText)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,10 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Home Screen
|
// Home Screen
|
||||||
|
fun isClockEnabled(): Boolean {
|
||||||
|
return preferences.getBoolean("clockEnabled", true)
|
||||||
|
}
|
||||||
|
|
||||||
fun getClockAlignment(): String? {
|
fun getClockAlignment(): String? {
|
||||||
return preferences.getString("clockAlignment", "left")
|
return preferences.getString("clockAlignment", "left")
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +60,10 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
return preferences.getString("clockSize","medium")
|
return preferences.getString("clockSize","medium")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isDateEnabled(): Boolean {
|
||||||
|
return preferences.getBoolean("dateEnabled", true)
|
||||||
|
}
|
||||||
|
|
||||||
fun getDateSize(): String? {
|
fun getDateSize(): String? {
|
||||||
return preferences.getString("dateSize", "medium")
|
return preferences.getString("dateSize", "medium")
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +164,10 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
return preferences.getString("appMenuSize", "medium")
|
return preferences.getString("appMenuSize", "medium")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isSearchEnabled(): Boolean {
|
||||||
|
return preferences.getBoolean("searchEnabled", true)
|
||||||
|
}
|
||||||
|
|
||||||
fun getSearchAlignment(): String? {
|
fun getSearchAlignment(): String? {
|
||||||
return preferences.getString("searchAlignment", "left")
|
return preferences.getString("searchAlignment", "left")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import android.util.TypedValue
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
|
|
@ -94,6 +95,39 @@ class UIUtils(private val context: Context) {
|
||||||
return Color.argb(newAlpha, r, g, b)
|
return Color.argb(newAlpha, r, g, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visibility
|
||||||
|
fun setClockVisibility(clock: TextClock) {
|
||||||
|
val layoutParams = clock.layoutParams
|
||||||
|
|
||||||
|
if (sharedPreferenceManager.isClockEnabled()) {
|
||||||
|
layoutParams.height = WRAP_CONTENT
|
||||||
|
} else {
|
||||||
|
layoutParams.height = 1
|
||||||
|
}
|
||||||
|
clock.layoutParams = layoutParams
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDateVisibility(dateText: TextClock) {
|
||||||
|
dateText.visibility = when (sharedPreferenceManager.isDateEnabled()) {
|
||||||
|
true -> {
|
||||||
|
View.VISIBLE
|
||||||
|
}
|
||||||
|
false -> {
|
||||||
|
View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setSearchVisibility(searchView: TextInputEditText, replacementView: View) {
|
||||||
|
if (sharedPreferenceManager.isSearchEnabled()) {
|
||||||
|
searchView.visibility = View.VISIBLE
|
||||||
|
replacementView.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
searchView.visibility = View.GONE
|
||||||
|
replacementView.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Alignment
|
// Alignment
|
||||||
fun setClockAlignment(clock: TextClock, dateText: TextClock) {
|
fun setClockAlignment(clock: TextClock, dateText: TextClock) {
|
||||||
val alignment = sharedPreferenceManager.getClockAlignment()
|
val alignment = sharedPreferenceManager.getClockAlignment()
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,13 @@
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textSize="25sp" />
|
android:textSize="25sp" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:id="@+id/searchReplacement"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="0.1"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
@ -116,6 +123,7 @@
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textColor="#F3F3F3"
|
android:textColor="#F3F3F3"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/textClock"
|
app:layout_constraintEnd_toEndOf="@+id/textClock"
|
||||||
app:layout_constraintStart_toStartOf="@+id/textClock"
|
app:layout_constraintStart_toStartOf="@+id/textClock"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textClock" />
|
app:layout_constraintTop_toBottomOf="@+id/textClock" />
|
||||||
|
|
@ -380,8 +388,7 @@
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="0.3"
|
android:layout_weight="0.3" />
|
||||||
android:visibility="visible" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:allowDividerAbove="false"
|
app:allowDividerAbove="false"
|
||||||
app:title="Home Screen">
|
app:title="Home Screen">
|
||||||
|
<SwitchPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="Enable Clock"
|
||||||
|
app:key="clockEnabled" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:defaultValue="left"
|
app:defaultValue="left"
|
||||||
app:entries="@array/h_alignment_options"
|
app:entries="@array/h_alignment_options"
|
||||||
|
|
@ -69,6 +75,12 @@
|
||||||
app:key="clockSize"
|
app:key="clockSize"
|
||||||
app:title="Clock Size"
|
app:title="Clock Size"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="Enable Date"
|
||||||
|
app:key="dateEnabled" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -119,6 +131,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="Battery Indicator"
|
android:title="Battery Indicator"
|
||||||
|
app:dependency="dateEnabled"
|
||||||
app:key="batteryEnabled" />
|
app:key="batteryEnabled" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
@ -131,6 +144,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="Weather"
|
android:title="Weather"
|
||||||
|
app:dependency="dateEnabled"
|
||||||
app:key="weatherEnabled" />
|
app:key="weatherEnabled" />
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
@ -223,6 +237,12 @@
|
||||||
app:key="appMenuSize"
|
app:key="appMenuSize"
|
||||||
app:title="App Menu Size"
|
app:title="App Menu Size"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="Enable Search"
|
||||||
|
app:key="searchEnabled" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
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