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