Update the UI and fix #211

This commit is contained in:
Tommaso Berlose 2020-10-14 11:42:03 +02:00
parent c5fefb0e06
commit 878ddcb05e
78 changed files with 145 additions and 8 deletions

View File

@ -11,6 +11,7 @@ import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
@ -21,7 +22,12 @@ import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBin
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel
import kotlinx.android.synthetic.main.activity_choose_application.*
import kotlinx.android.synthetic.main.activity_choose_application.action_back
import kotlinx.android.synthetic.main.activity_choose_application.clear_search
import kotlinx.android.synthetic.main.activity_choose_application.list_view
import kotlinx.android.synthetic.main.activity_choose_application.loader
import kotlinx.android.synthetic.main.activity_choose_application.search
import kotlinx.android.synthetic.main.activity_music_players_filter.*
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
@ -87,6 +93,7 @@ class ChooseApplicationActivity : AppCompatActivity() {
private fun subscribeUi(binding: ActivityChooseApplicationBinding, viewModel: ChooseApplicationViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel.appList.observe(this, Observer {
updateList(list = it)
@ -95,6 +102,7 @@ class ChooseApplicationActivity : AppCompatActivity() {
viewModel.searchInput.observe(this, Observer { search ->
updateList(search = search)
clear_search.isVisible = search.isNotBlank()
})
}
@ -123,6 +131,10 @@ class ChooseApplicationActivity : AppCompatActivity() {
action_back.setOnClickListener {
onBackPressed()
}
clear_search.setOnClickListener {
viewModel.searchInput.value = ""
}
}
private fun saveApp(app: ResolveInfo) {

View File

@ -73,6 +73,7 @@ class CustomDateActivity : AppCompatActivity() {
private fun subscribeUi(binding: ActivityCustomDateBinding, viewModel: CustomDateViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel.dateInput.observe(this, Observer { dateFormat ->
formatJob?.cancel()

View File

@ -29,6 +29,12 @@ import com.tommasoberlose.anotherwidget.helpers.DateHelper
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
import com.tommasoberlose.anotherwidget.ui.viewmodels.CustomFontViewModel
import kotlinx.android.synthetic.main.activity_choose_application.*
import kotlinx.android.synthetic.main.activity_choose_application.action_back
import kotlinx.android.synthetic.main.activity_choose_application.clear_search
import kotlinx.android.synthetic.main.activity_choose_application.list_view
import kotlinx.android.synthetic.main.activity_choose_application.loader
import kotlinx.android.synthetic.main.activity_choose_application.search
import kotlinx.android.synthetic.main.activity_music_players_filter.*
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
import net.idik.lib.slimadapter.diff.DefaultDiffCallback
@ -152,6 +158,7 @@ class CustomFontActivity : AppCompatActivity() {
private fun subscribeUi(binding: ActivityCustomFontBinding, viewModel: CustomFontViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel.fontList.observe(this, Observer {
updateList(list = it)
@ -160,6 +167,7 @@ class CustomFontActivity : AppCompatActivity() {
viewModel.searchInput.observe(this, Observer { search ->
updateList(search = search)
clear_search.isVisible = search.isNotBlank()
})
}
@ -211,6 +219,10 @@ class CustomFontActivity : AppCompatActivity() {
action_back.setOnClickListener {
onBackPressed()
}
clear_search.setOnClickListener {
viewModel.searchInput.value = ""
}
}
private fun saveFont(font: Font, variantPos: Int? = null) {

View File

@ -15,6 +15,7 @@ import android.view.Window
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
@ -35,6 +36,11 @@ import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel
import com.tommasoberlose.anotherwidget.ui.viewmodels.CustomLocationViewModel
import kotlinx.android.synthetic.main.activity_custom_location.*
import kotlinx.android.synthetic.main.activity_custom_location.action_back
import kotlinx.android.synthetic.main.activity_custom_location.clear_search
import kotlinx.android.synthetic.main.activity_custom_location.list_view
import kotlinx.android.synthetic.main.activity_custom_location.loader
import kotlinx.android.synthetic.main.activity_music_players_filter.*
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
import org.greenrobot.eventbus.EventBus
@ -99,6 +105,8 @@ class CustomLocationActivity : AppCompatActivity() {
private fun subscribeUi(binding: ActivityCustomLocationBinding, viewModel: CustomLocationViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel.addresses.observe(this, Observer {
adapter.updateData(listOf("Default") + it)
loader.visibility = View.INVISIBLE
@ -125,6 +133,7 @@ class CustomLocationActivity : AppCompatActivity() {
}
}
clear_search.isVisible = location.isNotBlank()
})
}
@ -162,5 +171,9 @@ class CustomLocationActivity : AppCompatActivity() {
action_back.setOnClickListener {
onBackPressed()
}
clear_search.setOnClickListener {
viewModel.locationInput.value = ""
}
}
}

View File

@ -11,6 +11,7 @@ import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
@ -24,8 +25,7 @@ import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper
import com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel
import com.tommasoberlose.anotherwidget.ui.viewmodels.MusicPlayersFilterViewModel
import kotlinx.android.synthetic.main.activity_choose_application.*
import kotlinx.android.synthetic.main.activity_choose_application.list_view
import kotlinx.android.synthetic.main.activity_music_players_filter.*
import kotlinx.coroutines.*
import net.idik.lib.slimadapter.SlimAdapter
import kotlin.Comparator as Comparator1
@ -81,6 +81,7 @@ class MusicPlayersFilterActivity : AppCompatActivity() {
private fun subscribeUi(binding: ActivityMusicPlayersFilterBinding, viewModel: MusicPlayersFilterViewModel) {
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel.appList.observe(this, Observer {
updateList(list = it)
@ -89,10 +90,12 @@ class MusicPlayersFilterActivity : AppCompatActivity() {
viewModel.searchInput.observe(this, Observer { search ->
updateList(search = search)
clear_search.isVisible = search.isNotBlank()
})
viewModel.musicPlayersFilter.observe(this, {
updateList()
clear_selection.isVisible = Preferences.musicPlayersFilter != ""
})
}
@ -133,6 +136,14 @@ class MusicPlayersFilterActivity : AppCompatActivity() {
action_back.setOnClickListener {
onBackPressed()
}
clear_search.setOnClickListener {
viewModel.searchInput.value = ""
}
clear_selection.setOnClickListener {
Preferences.musicPlayersFilter = ","
}
}
private fun toggleApp(app: ResolveInfo) {

View File

@ -10,6 +10,7 @@ import android.content.IntentFilter
import android.graphics.Canvas
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -280,11 +281,14 @@ class GlanceTabFragment : Fragment() {
R.color.colorPrimaryDark))
}
val topEdge = if ((view.top == 0 && dY < 0) || ((view.top + view.height >= recyclerView.height - 32f.convertDpToPixel(requireContext())) && dY > 0)) 0f else dY
Log.d("ciao", "${view.top} + ${view.height} = ${view.top + view.height} to compare to ${recyclerView.height} - ${32f.convertDpToPixel(requireContext())}")
super.onChildDraw(c,
recyclerView,
viewHolder,
dX,
dY,
topEdge,
actionState,
isCurrentlyActive)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM15.88,8.29L10,14.17l-1.88,-1.88c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41l2.59,2.59c0.39,0.39 1.02,0.39 1.41,0L17.3,9.7c0.39,-0.39 0.39,-1.02 0,-1.41 -0.39,-0.39 -1.03,-0.39 -1.42,0z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,13h12c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6,11c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM4,17h12c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,15c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM7,8c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L8,7c-0.55,0 -1,0.45 -1,1z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5h2L5,3c-1.1,0 -2,0.9 -2,2zM3,13h2v-2L3,11v2zM7,21h2v-2L7,19v2zM3,9h2L5,7L3,7v2zM13,3h-2v2h2L13,3zM19,3v2h2c0,-1.1 -0.9,-2 -2,-2zM5,21v-2L3,19c0,1.1 0.9,2 2,2zM3,17h2v-2L3,15v2zM9,3L7,3v2h2L9,3zM11,21h2v-2h-2v2zM19,13h2v-2h-2v2zM19,21c1.1,0 2,-0.9 2,-2h-2v2zM19,9h2L21,7h-2v2zM19,17h2v-2h-2v2zM15,21h2v-2h-2v2zM15,5h2L17,3h-2v2zM8,17h8c0.55,0 1,-0.45 1,-1L17,8c0,-0.55 -0.45,-1 -1,-1L8,7c-0.55,0 -1,0.45 -1,1v8c0,0.55 0.45,1 1,1zM9,9h6v6L9,15L9,9z"/>
</vector>

View File

@ -90,6 +90,14 @@
android:hint="@string/search"
android:text="@={viewModel.searchInput}"
android:autofillHints="" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_close"
app:tint="@color/colorPrimaryText"
android:layout_gravity="center_vertical|end"
android:id="@+id/clear_search" />
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
<RelativeLayout

View File

@ -79,6 +79,14 @@
android:hint="@string/search"
android:text="@={viewModel.searchInput}"
android:autofillHints="" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_close"
app:tint="@color/colorPrimaryText"
android:layout_gravity="center_vertical|end"
android:id="@+id/clear_search" />
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
<RelativeLayout

View File

@ -78,6 +78,14 @@
android:textDirection="locale"
android:text="@={viewModel.locationInput}"
android:autofillHints="" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_close"
app:tint="@color/colorPrimaryText"
android:layout_gravity="center_vertical|end"
android:id="@+id/clear_search" />
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
<RelativeLayout

View File

@ -45,6 +45,15 @@
android:text="@string/settings_music_players_filter_title"
android:gravity="center"
style="@style/AnotherWidget.Main.Title"/>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_clear_all"
app:tint="@color/colorPrimaryText"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:id="@+id/clear_selection" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
@ -67,8 +76,8 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/colorPrimaryDark"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingStart="16dp"
android:paddingEnd="64dp"
android:inputType="textCapWords"
android:textColor="@color/colorPrimaryText"
android:textColorHint="@color/colorSecondaryText"
@ -79,6 +88,14 @@
android:hint="@string/search"
android:text="@={viewModel.searchInput}"
android:autofillHints="" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_close"
app:tint="@color/colorPrimaryText"
android:layout_gravity="center_vertical|end"
android:id="@+id/clear_search" />
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
<RelativeLayout

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="64dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/selectableItemBackground"
android:focusable="true"
android:clickable="true"
@ -43,4 +43,12 @@
android:id="@+id/checkBox"
android:visibility="gone"
android:layout_gravity="center_vertical" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_check_circle_outline"
android:visibility="gone"
app:tint="@color/colorPrimaryText"
android:id="@+id/selected_icon" />
</LinearLayout>

View File

@ -98,6 +98,9 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingBottom="8dp"
android:id="@+id/providers_list" />
<LinearLayout
android:layout_width="match_parent"

View File

@ -41,7 +41,7 @@
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
android:layout_gravity="center_vertical"
app:cardBackgroundColor="@color/disabledButtonBackground"
app:cardBackgroundColor="@color/badgeBackground"
android:layout_marginTop="4dp"
android:id="@+id/info_container"
app:cardElevation="0dp">

View File

@ -24,4 +24,5 @@
<color name="colorSecondaryText">#99FFFFFF</color>
<!-- <color name="disabledButtonBackground">#131D28</color>-->
<color name="disabledButtonBackground">#33000000</color>
<color name="badgeBackground">#202020</color>
</resources>

View File

@ -33,5 +33,6 @@
<color name="warningColorText">#FB8C00</color>
<color name="disabledButtonBackground">#efefef</color>
<color name="success">#43A047</color>
<color name="badgeBackground">#efefef</color>
</resources>