mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Refactoring and modified sizing
This commit is contained in:
parent
90f5fecb8f
commit
21455d5913
7 changed files with 65 additions and 63 deletions
|
|
@ -77,7 +77,6 @@ class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener {
|
|||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
println(searchView.text.toString())
|
||||
lifecycleScope.launch(Dispatchers.IO){
|
||||
val locations = weatherSystem.getSearchedLocations(
|
||||
searchView.text.toString()
|
||||
|
|
|
|||
|
|
@ -224,6 +224,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
}
|
||||
|
||||
private fun toAppMenu() {
|
||||
try {
|
||||
recyclerView.scrollToPosition(0)
|
||||
}
|
||||
catch (_: UninitializedPropertyAccessException) {
|
||||
|
||||
}
|
||||
animations.showApps(binding.homeView, binding.appView)
|
||||
animations.backgroundIn(this@MainActivity)
|
||||
if (sharedPreferenceManager.isAutoKeyboardEnabled()) {
|
||||
|
|
@ -386,14 +392,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
lifecycleScope.launch {
|
||||
refreshAppMenu()
|
||||
|
||||
try {
|
||||
withContext(Dispatchers.Main) {
|
||||
recyclerView.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
catch (_: UninitializedPropertyAccessException) {
|
||||
|
||||
}
|
||||
}}, animSpeed + 50)
|
||||
|
||||
}
|
||||
|
|
@ -482,7 +481,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
recyclerView.layoutManager = appMenuLinearLayoutManager
|
||||
recyclerView.edgeEffectFactory = appMenuEdgeFactory
|
||||
recyclerView.adapter = adapter
|
||||
recyclerView.scrollToPosition(0)
|
||||
|
||||
}
|
||||
|
||||
setupRecyclerListener()
|
||||
|
|
@ -500,7 +499,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
}
|
||||
|
||||
private suspend fun setupSearch() {
|
||||
recyclerView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||
binding.appView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||
|
||||
if (bottom - top > oldBottom - oldTop) {
|
||||
canExit = true
|
||||
|
|
@ -589,13 +588,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|||
super.onStart()
|
||||
// Keyboard is sometimes open when going back to the app, so close it.
|
||||
closeKeyboard()
|
||||
try {
|
||||
recyclerView.scrollToPosition(0)
|
||||
}
|
||||
catch (_: UninitializedPropertyAccessException) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class UIUtils(context: Context) {
|
|||
}
|
||||
|
||||
fun setClockSize(clock: TextClock) {
|
||||
setTextSize(clock, sharedPreferenceManager.getClockSize(), 48F, 58F, 68F)
|
||||
setTextSize(clock, sharedPreferenceManager.getClockSize(), 58F, 68F, 78F)
|
||||
}
|
||||
|
||||
fun setDateSize(dateText: TextClock) {
|
||||
|
|
@ -200,15 +200,15 @@ class UIUtils(context: Context) {
|
|||
}
|
||||
|
||||
fun setShortcutsSize(shortcuts: LinearLayout) {
|
||||
val alignment = sharedPreferenceManager.getShortcutSize()
|
||||
|
||||
val viewTreeObserver = shortcuts.viewTreeObserver
|
||||
val globalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
|
||||
val size = sharedPreferenceManager.getShortcutSize()
|
||||
|
||||
shortcuts.children.forEach {
|
||||
if (it is TextView) {
|
||||
setShortcutSize(it, alignment)
|
||||
setShortcutSize(it, size)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -223,31 +223,27 @@ class UIUtils(context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setShortcutSize(shortcut: TextView, alignment: String?) {
|
||||
private fun setShortcutSize(shortcut: TextView, size: String?) {
|
||||
try {
|
||||
when (alignment) {
|
||||
val layoutParams = shortcut.layoutParams as LinearLayout.LayoutParams
|
||||
when (size) {
|
||||
"small" -> {
|
||||
shortcut.setPadding(
|
||||
shortcut.paddingLeft,
|
||||
shortcut.height / 4,
|
||||
shortcut.paddingRight,
|
||||
shortcut.height / 4
|
||||
)
|
||||
layoutParams.weight = 0.08F
|
||||
}
|
||||
|
||||
"medium" -> {
|
||||
shortcut.setPadding(
|
||||
shortcut.paddingLeft,
|
||||
(shortcut.height / 4.5).toInt(),
|
||||
shortcut.paddingRight,
|
||||
(shortcut.height / 4.5).toInt()
|
||||
)
|
||||
layoutParams.weight = 0.092F
|
||||
}
|
||||
|
||||
"large" -> {
|
||||
shortcut.setPadding(shortcut.paddingLeft, 0, shortcut.paddingRight, 0)
|
||||
layoutParams.weight = 0.1F
|
||||
}
|
||||
|
||||
"extra" -> {
|
||||
layoutParams.weight = 0.12F
|
||||
}
|
||||
}
|
||||
shortcut.layoutParams = layoutParams
|
||||
} catch(_: Exception) {}
|
||||
}
|
||||
|
||||
|
|
@ -257,17 +253,17 @@ class UIUtils(context: Context) {
|
|||
regionText: TextView? = null
|
||||
) {
|
||||
val size = sharedPreferenceManager.getAppSize()
|
||||
setTextSize(textView, size, 24F, 26F, 28F)
|
||||
setTextSize(textView, size, 24F, 26F, 30F)
|
||||
if (editText != null) {
|
||||
setTextSize(editText, size, 24F, 26F, 28F)
|
||||
setTextSize(editText, size, 24F, 26F, 30F)
|
||||
}
|
||||
if (regionText != null) {
|
||||
setTextSize(regionText, size, 14F, 16F, 18F)
|
||||
setTextSize(regionText, size, 14F, 16F, 20F)
|
||||
}
|
||||
}
|
||||
|
||||
fun setSearchSize(searchView: TextInputEditText) {
|
||||
setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 21F, 23F, 25F)
|
||||
setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 21F, 23F, 27F)
|
||||
}
|
||||
|
||||
private fun setTextSize(view: TextView, size: String?, s: Float, m: Float, l: Float) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ class WeatherSystem(private val context: Context) {
|
|||
try {
|
||||
inputStream.bufferedReader().use {
|
||||
val response = it.readText()
|
||||
println("yo")
|
||||
val jsonObject = JSONObject(response)
|
||||
val resultArray = jsonObject.getJSONArray("results")
|
||||
|
||||
|
|
@ -74,8 +73,7 @@ class WeatherSystem(private val context: Context) {
|
|||
))
|
||||
}
|
||||
}
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
}catch (_: Exception){
|
||||
}
|
||||
}
|
||||
return foundLocations
|
||||
|
|
|
|||
|
|
@ -125,18 +125,19 @@
|
|||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.23" />
|
||||
android:layout_weight="0.21" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -148,66 +149,66 @@
|
|||
android:id="@+id/app2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="28sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="28sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeMaxTextSize="32sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="15dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="28sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -220,12 +221,12 @@
|
|||
android:id="@+id/app6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -238,12 +239,12 @@
|
|||
android:id="@+id/app7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
@ -256,12 +257,12 @@
|
|||
android:id="@+id/app8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.09"
|
||||
android:autoSizeMaxTextSize="28sp"
|
||||
android:layout_weight="0.1"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingVertical="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
|
|
|
|||
|
|
@ -78,6 +78,20 @@
|
|||
<item>large</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="shortcut_size_options">
|
||||
<item>Small</item>
|
||||
<item>Medium</item>
|
||||
<item>Large</item>
|
||||
<item>Extra Large</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="shortcut_size_values">
|
||||
<item>small</item>
|
||||
<item>medium</item>
|
||||
<item>large</item>
|
||||
<item>extra</item>
|
||||
</string-array>
|
||||
|
||||
<!--Weather-->
|
||||
<string-array name="temp_units">
|
||||
<item>°C</item>
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:defaultValue="medium"
|
||||
app:entries="@array/size_options"
|
||||
app:entryValues="@array/size_values"
|
||||
app:entries="@array/shortcut_size_options"
|
||||
app:entryValues="@array/shortcut_size_values"
|
||||
app:key="shortcutSize"
|
||||
app:title="Shortcut Size"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue