mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 17:59:51 +02:00
Remove the allowed contacts from the overview
This commit is contained in:
parent
363212f86d
commit
f72e1f0d9f
6 changed files with 11 additions and 136 deletions
|
@ -26,7 +26,7 @@ import io.timelimit.android.R
|
||||||
import io.timelimit.android.livedata.liveDataFromValue
|
import io.timelimit.android.livedata.liveDataFromValue
|
||||||
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
||||||
import io.timelimit.android.ui.main.AuthenticationFab
|
import io.timelimit.android.ui.main.AuthenticationFab
|
||||||
import kotlinx.android.synthetic.main.fragment_main.*
|
import kotlinx.android.synthetic.main.single_fragment_wrapper.*
|
||||||
|
|
||||||
abstract class SingleFragmentWrapper: Fragment() {
|
abstract class SingleFragmentWrapper: Fragment() {
|
||||||
val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
||||||
|
|
|
@ -18,13 +18,8 @@ package io.timelimit.android.ui.overview.main
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentTransaction
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.navigation.NavController
|
|
||||||
import androidx.navigation.Navigation
|
|
||||||
import io.timelimit.android.BuildConfig
|
|
||||||
import io.timelimit.android.R
|
import io.timelimit.android.R
|
||||||
import io.timelimit.android.async.Threads
|
import io.timelimit.android.async.Threads
|
||||||
import io.timelimit.android.coroutines.executeAndWait
|
import io.timelimit.android.coroutines.executeAndWait
|
||||||
|
@ -37,24 +32,20 @@ import io.timelimit.android.livedata.switchMap
|
||||||
import io.timelimit.android.livedata.waitForNullableValue
|
import io.timelimit.android.livedata.waitForNullableValue
|
||||||
import io.timelimit.android.logic.AppLogic
|
import io.timelimit.android.logic.AppLogic
|
||||||
import io.timelimit.android.logic.DefaultAppLogic
|
import io.timelimit.android.logic.DefaultAppLogic
|
||||||
import io.timelimit.android.ui.contacts.ContactsFragment
|
import io.timelimit.android.ui.fragment.SingleFragmentWrapper
|
||||||
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
|
||||||
import io.timelimit.android.ui.main.AuthenticationFab
|
|
||||||
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
||||||
import io.timelimit.android.ui.manage.device.add.AddDeviceFragment
|
import io.timelimit.android.ui.manage.device.add.AddDeviceFragment
|
||||||
import io.timelimit.android.ui.obsolete.ObsoleteDialogFragment
|
import io.timelimit.android.ui.obsolete.ObsoleteDialogFragment
|
||||||
import io.timelimit.android.ui.overview.about.AboutFragment
|
|
||||||
import io.timelimit.android.ui.overview.about.AboutFragmentParentHandlers
|
import io.timelimit.android.ui.overview.about.AboutFragmentParentHandlers
|
||||||
import io.timelimit.android.ui.overview.overview.OverviewFragment
|
import io.timelimit.android.ui.overview.overview.OverviewFragment
|
||||||
import io.timelimit.android.ui.overview.overview.OverviewFragmentParentHandlers
|
import io.timelimit.android.ui.overview.overview.OverviewFragmentParentHandlers
|
||||||
import io.timelimit.android.ui.overview.uninstall.UninstallFragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_main.*
|
|
||||||
|
|
||||||
class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentParentHandlers, FragmentWithCustomTitle {
|
class MainFragment : SingleFragmentWrapper(), OverviewFragmentParentHandlers, AboutFragmentParentHandlers, FragmentWithCustomTitle {
|
||||||
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
||||||
private lateinit var navigation: NavController
|
|
||||||
private val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
|
||||||
private var didRedirectToUserScreen = false
|
private var didRedirectToUserScreen = false
|
||||||
|
override val showAuthButton: Boolean = true
|
||||||
|
|
||||||
|
override fun createChildFragment(): Fragment = OverviewFragment()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -62,25 +53,9 @@ class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentPa
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
navigation = Navigation.findNavController(container!!)
|
|
||||||
|
|
||||||
return inflater.inflate(R.layout.fragment_main, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
AuthenticationFab.manageAuthenticationFab(
|
|
||||||
fab = fab,
|
|
||||||
fragment = this,
|
|
||||||
shouldHighlight = activity.getActivityViewModel().shouldHighlightAuthenticationButton,
|
|
||||||
authenticatedUser = activity.getActivityViewModel().authenticatedUser,
|
|
||||||
doesSupportAuth = liveDataFromValue(true)
|
|
||||||
)
|
|
||||||
|
|
||||||
fab.setOnClickListener { activity.showAuthenticationScreen() }
|
|
||||||
|
|
||||||
logic.isInitialized.switchMap { isInitialized ->
|
logic.isInitialized.switchMap { isInitialized ->
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
logic.database.config().getOwnDeviceId().map { it == null }
|
logic.database.config().getOwnDeviceId().map { it == null }
|
||||||
|
@ -114,13 +89,13 @@ class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentPa
|
||||||
val user = logic.deviceUserEntry.waitForNullableValue()
|
val user = logic.deviceUserEntry.waitForNullableValue()
|
||||||
|
|
||||||
if (user?.type == UserType.Child) {
|
if (user?.type == UserType.Child) {
|
||||||
if (isAdded && parentFragmentManager.isStateSaved == false) {
|
if (isAdded && !parentFragmentManager.isStateSaved) {
|
||||||
openManageChildScreen(user.id, fromRedirect = true)
|
openManageChildScreen(user.id, fromRedirect = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (isAdded && parentFragmentManager.isStateSaved == false) {
|
if (isAdded && !parentFragmentManager.isStateSaved) {
|
||||||
ObsoleteDialogFragment.show(getActivity()!!, false)
|
ObsoleteDialogFragment.show(getActivity()!!, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,34 +103,10 @@ class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentPa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
bottom_navigation_view.setOnNavigationItemReselectedListener { /* ignore */ }
|
|
||||||
bottom_navigation_view.setOnNavigationItemSelectedListener { menuItem ->
|
|
||||||
if (childFragmentManager.isStateSaved) {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
childFragmentManager.beginTransaction()
|
|
||||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
|
||||||
.replace(R.id.container, when (menuItem.itemId) {
|
|
||||||
R.id.main_tab_overview -> OverviewFragment()
|
|
||||||
R.id.main_tab_contacts -> ContactsFragment()
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
})
|
|
||||||
.commit()
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (childFragmentManager.findFragmentById(R.id.container) == null) {
|
|
||||||
childFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.container, OverviewFragment())
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openAddDeviceScreen() {
|
override fun openAddDeviceScreen() {
|
||||||
AddDeviceFragment().show(fragmentManager!!)
|
AddDeviceFragment().show(parentFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openAddUserScreen() {
|
override fun openAddUserScreen() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import io.timelimit.android.livedata.liveDataFromValue
|
||||||
import io.timelimit.android.logic.DefaultAppLogic
|
import io.timelimit.android.logic.DefaultAppLogic
|
||||||
import io.timelimit.android.ui.backdoor.BackdoorDialogFragment
|
import io.timelimit.android.ui.backdoor.BackdoorDialogFragment
|
||||||
import io.timelimit.android.ui.main.*
|
import io.timelimit.android.ui.main.*
|
||||||
import kotlinx.android.synthetic.main.fragment_main.*
|
import kotlinx.android.synthetic.main.single_fragment_wrapper.*
|
||||||
|
|
||||||
class UninstallFragment : Fragment(), FragmentWithCustomTitle {
|
class UninstallFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.view.ViewGroup
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import io.timelimit.android.R
|
import io.timelimit.android.R
|
||||||
import io.timelimit.android.ui.overview.about.AboutFragment
|
import io.timelimit.android.ui.overview.about.AboutFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_main.*
|
import kotlinx.android.synthetic.main.parent_mode_fragment.*
|
||||||
|
|
||||||
class ParentModeFragment : Fragment() {
|
class ParentModeFragment : Fragment() {
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<!--
|
|
||||||
TimeLimit Copyright <C> 2019 - 2020 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/>.
|
|
||||||
-->
|
|
||||||
<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="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
tools:context="io.timelimit.android.ui.overview.main.MainFragment">
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="0dp">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/fab"
|
|
||||||
app:fabSize="normal"
|
|
||||||
android:src="@drawable/ic_lock_open_white_24dp"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:layout_gravity="end|bottom"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
|
||||||
android:id="@+id/bottom_navigation_view"
|
|
||||||
app:menu="@menu/fragment_main_bottom"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
TimeLimit Copyright <C> 2019 - 2020 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/>.
|
|
||||||
-->
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item
|
|
||||||
android:icon="@drawable/ic_account_circle_black_24dp"
|
|
||||||
android:title="@string/main_tab_overview"
|
|
||||||
android:id="@+id/main_tab_overview" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:icon="@drawable/ic_phone_black_24dp"
|
|
||||||
android:title="@string/contacts_title"
|
|
||||||
android:id="@+id/main_tab_contacts" />
|
|
||||||
</menu>
|
|
Loading…
Add table
Add a link
Reference in a new issue