Kaynağa Gözat

chore: A remove all button when customizing apps

beautusg 7 yıl önce
ebeveyn
işleme
af7c56cef7

+ 2 - 2
app/src/main/java/com/sduduzog/slimlauncher/data/MainViewModel.kt

@@ -59,8 +59,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
         _baseRepository.update(*args)
     }
 
-    fun remove(app: HomeApp) {
-        _baseRepository.remove(app)
+    fun remove(vararg app: HomeApp) {
+        _baseRepository.remove(*app)
     }
 
     fun remove(note: Note) {

+ 2 - 2
app/src/main/java/com/sduduzog/slimlauncher/data/Repository.kt

@@ -51,8 +51,8 @@ class Repository(application: Application) {
         UpdateTaskAsyncTask(baseDao).execute(*args)
     }
 
-    fun remove(app: HomeApp) {
-        RemoveAppAsyncTask(baseDao).execute(app)
+    fun remove(vararg app: HomeApp) {
+        RemoveAppAsyncTask(baseDao).execute(*app)
     }
 
     fun remove(note: Note) {

+ 5 - 3
app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomiseAppsFragment.kt

@@ -52,11 +52,13 @@ class CustomiseAppsFragment : BaseFragment(), OnShitDoneToAppsListener {
                         customise_apps_fragment_add.visibility = View.GONE
                     }
                 }
-                val count = 7 - apps.size
-                customise_apps_fragment_counter.text = resources.getQuantityString(R.plurals.slots_plurals, count, count)
             } ?: adapter.setItems(listOf())
         })
-
+        customise_apps_fragment_remove_all.setOnClickListener {
+            viewModel.apps.value?.let {
+                viewModel.remove(*it.toTypedArray())
+            }
+        }
         LoadInstalledApps(viewModel).execute(context!!.packageManager)
 
         customise_apps_fragment_list.adapter = adapter

+ 1 - 1
app/src/main/res/layout/add_app_fragment_list_item.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/aa_list_item_app_name"
-    android:layout_width="wrap_content"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:padding="6dp"
     android:textAppearance="@style/TextAppearance.AppCompat"

+ 2 - 1
app/src/main/res/layout/customise_apps_fragment.xml

@@ -51,12 +51,13 @@
         app:layout_constraintStart_toStartOf="parent" />
 
     <TextView
-        android:id="@+id/customise_apps_fragment_counter"
+        android:id="@+id/customise_apps_fragment_remove_all"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginEnd="8dp"
         android:layout_marginRight="8dp"
         android:layout_marginBottom="8dp"
+        android:text="@string/customise_apps_fragment_remove_all"
         android:padding="@dimen/_12sdp"
         android:textSize="@dimen/_16ssp"
         app:layout_constraintBottom_toBottomOf="parent"

+ 1 - 0
app/src/main/res/layout/notes_fragment_list_item.xml

@@ -16,6 +16,7 @@
         android:id="@+id/notes_fragment_list_item_snippet"
         android:layout_width="match_parent"
         android:ellipsize="end"
+        android:layout_marginTop="4dp"
         android:textSize="14sp"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:maxLines="5"

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -64,5 +64,6 @@
     <string name="menu_share">Share</string>
     <string name="menu_delete">Delete</string>
     <string name="notes_fragment_undo">UNDO</string>
+    <string name="customise_apps_fragment_remove_all">Remove all</string>
 
 </resources>