mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 01:39:22 +02:00
Only remove Apps from categories if the trash icon was tapped
This commit is contained in:
parent
9ea7d55122
commit
45b8d6fcb4
7 changed files with 67 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann
|
||||
* TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,6 +17,7 @@ package io.timelimit.android.ui.manage.category.appsandrules
|
|||
|
||||
interface AppAdapterHandlers {
|
||||
fun onAppClicked(app: AppAndRuleItem.AppEntry)
|
||||
fun onRemoveAppClicked(app: AppAndRuleItem.AppEntry)
|
||||
fun onAppLongClicked(app: AppAndRuleItem.AppEntry): Boolean
|
||||
fun onAddAppsClicked()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* TimeLimit Copyright <C> 2019 - 2023 Jonas Lochmann
|
||||
* TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -142,6 +142,7 @@ class AppAndRuleAdapter: RecyclerView.Adapter<AppAndRuleAdapter.Holder>() {
|
|||
binding.subtitle = item.specifier.copy(deviceId = null).encode()
|
||||
binding.card.setOnClickListener { handlers?.onAppClicked(item) }
|
||||
binding.card.setOnLongClickListener { handlers?.onAppLongClicked(item) ?: false }
|
||||
binding.deleteButton.setOnClickListener { handlers?.onRemoveAppClicked(item) }
|
||||
binding.executePendingBindings()
|
||||
|
||||
binding.icon.setImageDrawable(
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.timelimit.android.ui.manage.category.appsandrules
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import io.timelimit.android.R
|
||||
import io.timelimit.android.extensions.showSafe
|
||||
|
||||
class AppClickedDialogFragment: DialogFragment() {
|
||||
companion object {
|
||||
private const val TAG = "AppClickedDialogFragment"
|
||||
|
||||
fun newInstance() = AppClickedDialogFragment()
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = AlertDialog.Builder(requireContext(), theme)
|
||||
.setMessage(R.string.app_clicked_dialog_message)
|
||||
.setPositiveButton(R.string.generic_ok, null)
|
||||
.create()
|
||||
|
||||
fun show(fragmentManager: FragmentManager) = showSafe(fragmentManager, TAG)
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann
|
||||
* TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -144,6 +144,10 @@ abstract class CategoryAppsAndRulesFragment: Fragment(), Handlers, EditTimeLimit
|
|||
}
|
||||
|
||||
override fun onAppClicked(app: AppAndRuleItem.AppEntry) {
|
||||
AppClickedDialogFragment.newInstance().show(childFragmentManager)
|
||||
}
|
||||
|
||||
override fun onRemoveAppClicked(app: AppAndRuleItem.AppEntry) {
|
||||
if (auth.tryDispatchParentAction(
|
||||
RemoveCategoryAppsAction(
|
||||
categoryId = categoryId,
|
||||
|
@ -164,14 +168,15 @@ abstract class CategoryAppsAndRulesFragment: Fragment(), Handlers, EditTimeLimit
|
|||
}
|
||||
|
||||
override fun onAppLongClicked(app: AppAndRuleItem.AppEntry): Boolean {
|
||||
return if (auth.requestAuthenticationOrReturnTrue()) {
|
||||
if (auth.requestAuthenticationOrReturnTrue()) {
|
||||
AssignAppCategoryDialogFragment.newInstance(
|
||||
childId = childId,
|
||||
appPackageName = app.specifier.encode()
|
||||
).show(parentFragmentManager)
|
||||
}
|
||||
|
||||
true
|
||||
} else false
|
||||
// consume the click in any case
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onAddAppsClicked() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann
|
||||
TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation version 3 of the License.
|
||||
|
@ -82,13 +82,15 @@
|
|||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
android:tint="?colorAccent"
|
||||
android:layout_margin="8dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_delete_black_24dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp" />
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
|
|
@ -1786,4 +1786,8 @@
|
|||
Das wird zu einer Manipulationswarnung führen.
|
||||
</string>
|
||||
<string name="device_owner_transfer_confirm">Berechtigung übertragen</string>
|
||||
|
||||
<string name="app_clicked_dialog_message">Tippen Sie zum Entfernen der App aus der Kategorie auf das Mülleimer-Symbol.
|
||||
Um die Kategorie zu wechseln, müssen Sie lange auf die App tippen.
|
||||
</string>
|
||||
</resources>
|
||||
|
|
|
@ -1838,4 +1838,8 @@
|
|||
This will be interpreted as manipulation.
|
||||
</string>
|
||||
<string name="device_owner_transfer_confirm">Transfer permission</string>
|
||||
|
||||
<string name="app_clicked_dialog_message">Tap the trash icon to remove the App from the category.
|
||||
To move it to another category, hold the App item.
|
||||
</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue