mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Shortcut size customization
This commit is contained in:
parent
c10d6480ea
commit
f5c6fd4ce6
6 changed files with 123 additions and 8 deletions
|
|
@ -46,6 +46,6 @@ dependencies {
|
||||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
|
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
|
||||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
|
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
|
||||||
implementation("com.google.code.gson:gson:2.10")
|
implementation("com.google.code.gson:gson:2.11.0")
|
||||||
implementation("androidx.recyclerview:recyclerview:1.3.2")
|
implementation("androidx.recyclerview:recyclerview:1.3.2")
|
||||||
}
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ import android.view.GestureDetector
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
|
@ -115,7 +116,6 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
backToHome()
|
backToHome()
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
@ -131,6 +131,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
setShortcutSize(binding.homeView)
|
||||||
super.onStart()
|
super.onStart()
|
||||||
startTask()
|
startTask()
|
||||||
|
|
||||||
|
|
@ -144,6 +145,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
open inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
|
open inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||||
|
|
@ -209,8 +211,6 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
setupSearch()
|
setupSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleListItems() {
|
private fun handleListItems() {
|
||||||
|
|
@ -225,7 +225,9 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
if (savedView?.get(1) != "e") {
|
if (savedView?.get(1) != "e") {
|
||||||
selectedSetup(textView, savedView)
|
selectedSetup(textView, savedView)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
|
@ -581,6 +583,48 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
||||||
setLinearAlignment(binding.homeView)
|
setLinearAlignment(binding.homeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setShortcutSize(shortcuts: LinearLayout) {
|
||||||
|
val viewTreeObserver = shortcuts.viewTreeObserver
|
||||||
|
if (viewTreeObserver.isAlive) {
|
||||||
|
viewTreeObserver.addOnGlobalLayoutListener {
|
||||||
|
shortcuts.children.forEach {
|
||||||
|
if (it is TextView) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
0 = small
|
||||||
|
1 = medium
|
||||||
|
2 = large
|
||||||
|
*/
|
||||||
|
when (sharedPreferenceManager.getAppSize(this@MainActivity)) {
|
||||||
|
0 -> {
|
||||||
|
it.setPadding(
|
||||||
|
it.paddingLeft,
|
||||||
|
it.height / 4,
|
||||||
|
it.paddingRight,
|
||||||
|
it.height / 4
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
1 -> {
|
||||||
|
it.setPadding(
|
||||||
|
it.paddingLeft,
|
||||||
|
it.height / 5,
|
||||||
|
it.paddingRight,
|
||||||
|
it.height / 5
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
2 -> {
|
||||||
|
it.setPadding(it.paddingLeft, 0, it.paddingRight, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setLinearAlignment(shortcuts: LinearLayout) {
|
private fun setLinearAlignment(shortcuts: LinearLayout) {
|
||||||
shortcuts.children.forEach {
|
shortcuts.children.forEach {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,17 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.appSize.setSelection(sharedPreferenceManager.getAppSize(this@SettingsActivity))
|
||||||
|
|
||||||
|
binding.appSize.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
|
||||||
|
// Get the selected item
|
||||||
|
sharedPreferenceManager.setAppSize(this@SettingsActivity, position)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,4 +111,17 @@ class SharedPreferenceManager {
|
||||||
val key = "app_menu_alignment"
|
val key = "app_menu_alignment"
|
||||||
return sharedPreferences.getInt(key, 0)
|
return sharedPreferences.getInt(key, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setAppSize(cont: Context, alignment: Int) {
|
||||||
|
val editor = cont.getSharedPreferences("preferences", AppCompatActivity.MODE_PRIVATE).edit()
|
||||||
|
val key = "app_size"
|
||||||
|
editor.putInt(key, alignment)
|
||||||
|
editor.apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAppSize(cont: Context) : Int {
|
||||||
|
val sharedPreferences = cont.getSharedPreferences("preferences", AppCompatActivity.MODE_PRIVATE)
|
||||||
|
val key = "app_size"
|
||||||
|
return sharedPreferences.getInt(key, 2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
android:id="@+id/clock_alignment"
|
android:id="@+id/clock_alignment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:entries="@array/clock_alignment_options"
|
android:entries="@array/h_alignment_options"
|
||||||
android:spinnerMode="dropdown"
|
android:spinnerMode="dropdown"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/clock_alignment_label"
|
app:layout_constraintBottom_toBottomOf="@+id/clock_alignment_label"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
android:id="@+id/home_app_alignment"
|
android:id="@+id/home_app_alignment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:entries="@array/clock_alignment_options"
|
android:entries="@array/h_alignment_options"
|
||||||
android:spinnerMode="dropdown"
|
android:spinnerMode="dropdown"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/home_app_alignment_label"
|
app:layout_constraintBottom_toBottomOf="@+id/home_app_alignment_label"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
android:id="@+id/app_alignment"
|
android:id="@+id/app_alignment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:entries="@array/clock_alignment_options"
|
android:entries="@array/h_alignment_options"
|
||||||
android:spinnerMode="dropdown"
|
android:spinnerMode="dropdown"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/app_alignment_label"
|
app:layout_constraintBottom_toBottomOf="@+id/app_alignment_label"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
@ -130,4 +130,45 @@
|
||||||
android:background="?android:attr/listDivider"
|
android:background="?android:attr/listDivider"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/app_alignment_label" />
|
app:layout_constraintTop_toBottomOf="@+id/app_alignment_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_size_label"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingRight="20dp"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
android:text="App Title Size"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
|
android:textColor="#F3F3F3"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/app_alignment_label"
|
||||||
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/app_size"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:entries="@array/size_options"
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/app_size_label"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/app_size_label"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/app_alignment_label" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider4"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/app_size_label"
|
||||||
|
tools:layout_editor_absoluteX="46dp" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
@ -49,10 +49,15 @@
|
||||||
<string name="search">Search…</string>
|
<string name="search">Search…</string>
|
||||||
<string name="app">App</string>
|
<string name="app">App</string>
|
||||||
<string name="shortcut_default">App</string>
|
<string name="shortcut_default">App</string>
|
||||||
<string-array name="clock_alignment_options">
|
<string-array name="h_alignment_options">
|
||||||
<item>Left</item>
|
<item>Left</item>
|
||||||
<item>Center</item>
|
<item>Center</item>
|
||||||
<item>Right</item>
|
<item>Right</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="size_options">
|
||||||
|
<item>Small</item>
|
||||||
|
<item>Medium</item>
|
||||||
|
<item>Large</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue