diff --git a/app/src/main/java/io/timelimit/android/ui/manage/category/apps/AppAdapterHandlers.kt b/app/src/main/java/io/timelimit/android/ui/manage/category/apps/AppAdapterHandlers.kt index 4eaf5b8..df8f8d3 100644 --- a/app/src/main/java/io/timelimit/android/ui/manage/category/apps/AppAdapterHandlers.kt +++ b/app/src/main/java/io/timelimit/android/ui/manage/category/apps/AppAdapterHandlers.kt @@ -1,5 +1,5 @@ /* - * TimeLimit Copyright 2019 - 2020 Jonas Lochmann + * TimeLimit Copyright 2019 - 2021 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 @@ -19,5 +19,6 @@ import io.timelimit.android.ui.manage.category.appsandrules.AppAndRuleItem interface AppAdapterHandlers { fun onAppClicked(app: AppAndRuleItem.AppEntry) + fun onAppLongClicked(app: AppAndRuleItem.AppEntry): Boolean fun onAddAppsClicked() } diff --git a/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/AppAndRuleAdapter.kt b/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/AppAndRuleAdapter.kt index e1f768a..424be00 100644 --- a/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/AppAndRuleAdapter.kt +++ b/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/AppAndRuleAdapter.kt @@ -1,5 +1,5 @@ /* - * TimeLimit Copyright 2019 - 2020 Jonas Lochmann + * TimeLimit Copyright 2019 - 2021 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 @@ -141,6 +141,8 @@ class AppAndRuleAdapter: RecyclerView.Adapter() { binding.handlers = handlers binding.executePendingBindings() + binding.root.setOnLongClickListener { handlers?.onAppLongClicked(item) ?: false } + binding.icon.setImageDrawable( DummyApps.getIcon(item.packageNameWithoutActivityName, context) ?: DefaultAppLogic.with(context) diff --git a/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/CategoryAppsAndRulesFragment.kt b/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/CategoryAppsAndRulesFragment.kt index 8b7005a..1a5490b 100644 --- a/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/CategoryAppsAndRulesFragment.kt +++ b/app/src/main/java/io/timelimit/android/ui/manage/category/appsandrules/CategoryAppsAndRulesFragment.kt @@ -1,5 +1,5 @@ /* - * TimeLimit Copyright 2019 - 2020 Jonas Lochmann + * TimeLimit Copyright 2019 - 2021 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 @@ -41,6 +41,7 @@ import io.timelimit.android.ui.main.getActivityViewModel import io.timelimit.android.ui.manage.category.apps.add.AddCategoryAppsFragment import io.timelimit.android.ui.manage.category.timelimit_rules.edit.EditTimeLimitRuleDialogFragment import io.timelimit.android.ui.manage.category.timelimit_rules.edit.EditTimeLimitRuleDialogFragmentListener +import io.timelimit.android.ui.manage.child.apps.assign.AssignAppCategoryDialogFragment import kotlinx.android.synthetic.main.fragment_category_apps_and_rules.* abstract class CategoryAppsAndRulesFragment: Fragment(), Handlers, EditTimeLimitRuleDialogFragmentListener { @@ -152,6 +153,17 @@ abstract class CategoryAppsAndRulesFragment: Fragment(), Handlers, EditTimeLimit } } + override fun onAppLongClicked(app: AppAndRuleItem.AppEntry): Boolean { + return if (auth.requestAuthenticationOrReturnTrue()) { + AssignAppCategoryDialogFragment.newInstance( + childId = childId, + appPackageName = app.packageName + ).show(parentFragmentManager) + + true + } else false + } + override fun onAddAppsClicked() { if (auth.requestAuthenticationOrReturnTrueAllowChild(childId = childId)) { AddCategoryAppsFragment.newInstance( diff --git a/app/src/main/java/io/timelimit/android/ui/manage/child/apps/assign/AssignAppCategoryDialogFragment.kt b/app/src/main/java/io/timelimit/android/ui/manage/child/apps/assign/AssignAppCategoryDialogFragment.kt index c19526c..fdcfec3 100644 --- a/app/src/main/java/io/timelimit/android/ui/manage/child/apps/assign/AssignAppCategoryDialogFragment.kt +++ b/app/src/main/java/io/timelimit/android/ui/manage/child/apps/assign/AssignAppCategoryDialogFragment.kt @@ -1,5 +1,5 @@ /* - * TimeLimit Copyright 2019 Jonas Lochmann + * TimeLimit Copyright 2019 - 2021 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 @@ -95,12 +95,6 @@ class AssignAppCategoryDialogFragment: BottomSheetDialogFragment() { dismissAllowingStateLoss() } }) - - matchingAppEntries.observe(this, Observer { - if (it.isEmpty()) { - dismissAllowingStateLoss() - } - }) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {