mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 09:49:25 +02:00
Add option to change parent timezone
This commit is contained in:
parent
ef744008b5
commit
1bc3f60e82
8 changed files with 143 additions and 65 deletions
|
@ -38,10 +38,9 @@ import io.timelimit.android.ui.main.getActivityViewModel
|
||||||
import io.timelimit.android.ui.manage.child.ManageChildFragmentArgs
|
import io.timelimit.android.ui.manage.child.ManageChildFragmentArgs
|
||||||
import io.timelimit.android.ui.manage.child.advanced.managedisabletimelimits.ManageDisableTimelimitsViewHelper
|
import io.timelimit.android.ui.manage.child.advanced.managedisabletimelimits.ManageDisableTimelimitsViewHelper
|
||||||
import io.timelimit.android.ui.manage.child.advanced.password.ManageChildPassword
|
import io.timelimit.android.ui.manage.child.advanced.password.ManageChildPassword
|
||||||
import io.timelimit.android.ui.manage.child.advanced.timezone.SetChildTimezoneDialogFragment
|
import io.timelimit.android.ui.manage.child.advanced.timezone.UserTimezoneView
|
||||||
import io.timelimit.android.ui.manage.child.primarydevice.PrimaryDeviceView
|
import io.timelimit.android.ui.manage.child.primarydevice.PrimaryDeviceView
|
||||||
import io.timelimit.android.ui.payment.RequiresPurchaseDialogFragment
|
import io.timelimit.android.ui.payment.RequiresPurchaseDialogFragment
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class ManageChildAdvancedFragment : Fragment() {
|
class ManageChildAdvancedFragment : Fragment() {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -142,20 +141,14 @@ class ManageChildAdvancedFragment : Fragment() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
run {
|
UserTimezoneView.bind(
|
||||||
// timezone
|
userEntry = childEntry,
|
||||||
childEntry.observe(this, Observer {
|
view = binding.userTimezone,
|
||||||
binding.timezone = TimeZone.getTimeZone(it?.timeZone ?: "").displayName
|
fragmentManager = fragmentManager!!,
|
||||||
})
|
lifecycleOwner = this,
|
||||||
|
userId = params.childId,
|
||||||
binding.changeTimezoneButton.setOnClickListener {
|
auth = auth
|
||||||
if (auth.requestAuthenticationOrReturnTrue()) {
|
)
|
||||||
SetChildTimezoneDialogFragment.newInstance(
|
|
||||||
childId = params.childId
|
|
||||||
).show(fragmentManager!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.renameChildButton.setOnClickListener {
|
binding.renameChildButton.setOnClickListener {
|
||||||
if (auth.requestAuthenticationOrReturnTrue()) {
|
if (auth.requestAuthenticationOrReturnTrue()) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* TimeLimit Copyright <C> 2019 Jonas Lochmann
|
* TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,20 +39,20 @@ import io.timelimit.android.ui.main.ActivityViewModel
|
||||||
import io.timelimit.android.ui.main.getActivityViewModel
|
import io.timelimit.android.ui.main.getActivityViewModel
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SetChildTimezoneDialogFragment : DialogFragment() {
|
class SetUserTimezoneDialogFragment : DialogFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val EXTRA_CHILD_ID = "childId"
|
private const val EXTRA_USER_ID = "userId"
|
||||||
private const val DIALOG_TAG = "SetChildTimezoneDialogFragment"
|
private const val DIALOG_TAG = "SetUserTimezoneDialogFragment"
|
||||||
|
|
||||||
fun newInstance(childId: String) = SetChildTimezoneDialogFragment().apply {
|
fun newInstance(userId: String) = SetUserTimezoneDialogFragment().apply {
|
||||||
arguments = Bundle().apply {
|
arguments = Bundle().apply {
|
||||||
putString(EXTRA_CHILD_ID, childId)
|
putString(EXTRA_USER_ID, userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val childId: String by lazy {
|
val userId: String by lazy {
|
||||||
arguments!!.getString(EXTRA_CHILD_ID)!!
|
arguments!!.getString(EXTRA_USER_ID)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
val auth: ActivityViewModel by lazy {
|
val auth: ActivityViewModel by lazy {
|
||||||
|
@ -81,7 +81,7 @@ class SetChildTimezoneDialogFragment : DialogFragment() {
|
||||||
override fun onTimezoneClicked(timeZone: TimeZone) {
|
override fun onTimezoneClicked(timeZone: TimeZone) {
|
||||||
auth.tryDispatchParentAction(
|
auth.tryDispatchParentAction(
|
||||||
SetUserTimezoneAction(
|
SetUserTimezoneAction(
|
||||||
userId = childId,
|
userId = userId,
|
||||||
timezone = timeZone.id
|
timezone = timeZone.id
|
||||||
)
|
)
|
||||||
)
|
)
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
package io.timelimit.android.ui.manage.child.advanced.timezone
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import io.timelimit.android.data.model.User
|
||||||
|
import io.timelimit.android.databinding.UserTimezoneViewBinding
|
||||||
|
import io.timelimit.android.ui.main.ActivityViewModel
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object UserTimezoneView {
|
||||||
|
fun bind(
|
||||||
|
userEntry: LiveData<User?>,
|
||||||
|
view: UserTimezoneViewBinding,
|
||||||
|
fragmentManager: FragmentManager,
|
||||||
|
lifecycleOwner: LifecycleOwner,
|
||||||
|
auth: ActivityViewModel,
|
||||||
|
userId: String
|
||||||
|
) {
|
||||||
|
userEntry.observe(lifecycleOwner, Observer {
|
||||||
|
view.timezone = TimeZone.getTimeZone(it?.timeZone ?: "").displayName
|
||||||
|
})
|
||||||
|
|
||||||
|
view.changeTimezoneButton.setOnClickListener {
|
||||||
|
if (auth.requestAuthenticationOrReturnTrue()) {
|
||||||
|
SetUserTimezoneDialogFragment.newInstance(
|
||||||
|
userId = userId
|
||||||
|
).show(fragmentManager)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* TimeLimit Copyright <C> 2019 Jonas Lochmann
|
* TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,6 +36,7 @@ import io.timelimit.android.logic.DefaultAppLogic
|
||||||
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 io.timelimit.android.ui.main.FragmentWithCustomTitle
|
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
||||||
|
import io.timelimit.android.ui.manage.child.advanced.timezone.UserTimezoneView
|
||||||
import io.timelimit.android.ui.manage.parent.delete.DeleteParentView
|
import io.timelimit.android.ui.manage.parent.delete.DeleteParentView
|
||||||
|
|
||||||
class ManageParentFragment : Fragment(), FragmentWithCustomTitle {
|
class ManageParentFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
|
@ -105,6 +106,15 @@ class ManageParentFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
userEntry = parentUser
|
userEntry = parentUser
|
||||||
)
|
)
|
||||||
|
|
||||||
|
UserTimezoneView.bind(
|
||||||
|
view = binding.timezone,
|
||||||
|
userId = params.parentId,
|
||||||
|
lifecycleOwner = this,
|
||||||
|
fragmentManager = fragmentManager!!,
|
||||||
|
auth = activity.getActivityViewModel(),
|
||||||
|
userEntry = parentUser
|
||||||
|
)
|
||||||
|
|
||||||
binding.handlers = object: ManageParentFragmentHandlers {
|
binding.handlers = object: ManageParentFragmentHandlers {
|
||||||
override fun onChangePasswordClicked() {
|
override fun onChangePasswordClicked() {
|
||||||
navigation.safeNavigate(
|
navigation.safeNavigate(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!--
|
<!--
|
||||||
TimeLimit Copyright <C> 2019 Jonas Lochmann
|
TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation version 3 of the License.
|
the Free Software Foundation version 3 of the License.
|
||||||
|
@ -18,10 +18,6 @@
|
||||||
tools:context="io.timelimit.android.ui.manage.child.advanced.ManageChildAdvancedFragment">
|
tools:context="io.timelimit.android.ui.manage.child.advanced.ManageChildAdvancedFragment">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
<variable
|
|
||||||
name="timezone"
|
|
||||||
type="String" />
|
|
||||||
|
|
||||||
<import type="io.timelimit.android.BuildConfig" />
|
<import type="io.timelimit.android.BuildConfig" />
|
||||||
<import type="android.view.View" />
|
<import type="android.view.View" />
|
||||||
</data>
|
</data>
|
||||||
|
@ -94,38 +90,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<include android:id="@+id/user_timezone"
|
||||||
app:cardUseCompatPadding="true"
|
layout="@layout/user_timezone_view" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@string/manage_child_timezone_title"
|
|
||||||
android:textAppearance="?android:textAppearanceLarge"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:textAppearance="?android:textAppearanceMedium"
|
|
||||||
tools:text="GMT"
|
|
||||||
android:text="@{timezone}"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/change_timezone_button"
|
|
||||||
android:text="@string/manage_child_timezone_change_button"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
<include android:id="@+id/password"
|
<include android:id="@+id/password"
|
||||||
layout="@layout/manage_child_password" />
|
layout="@layout/manage_child_password" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!--
|
<!--
|
||||||
TimeLimit Copyright <C> 2019 Jonas Lochmann
|
TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation version 3 of the License.
|
the Free Software Foundation version 3 of the License.
|
||||||
|
@ -157,6 +157,9 @@
|
||||||
<include android:id="@+id/manage_notifications"
|
<include android:id="@+id/manage_notifications"
|
||||||
layout="@layout/manage_parent_notifications" />
|
layout="@layout/manage_parent_notifications" />
|
||||||
|
|
||||||
|
<include android:id="@+id/timezone"
|
||||||
|
layout="@layout/user_timezone_view" />
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
app:cardUseCompatPadding="true"
|
app:cardUseCompatPadding="true"
|
||||||
android:onClick="@{() -> handlers.onManageBlockedTimesClicked()}"
|
android:onClick="@{() -> handlers.onManageBlockedTimesClicked()}"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
-->
|
-->
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="io.timelimit.android.ui.manage.child.advanced.timezone.SetChildTimezoneDialogFragment">
|
tools:context="io.timelimit.android.ui.manage.child.advanced.timezone.SetUserTimezoneDialogFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
58
app/src/main/res/layout/user_timezone_view.xml
Normal file
58
app/src/main/res/layout/user_timezone_view.xml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?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/>.
|
||||||
|
-->
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="timezone"
|
||||||
|
type="String" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
app:cardUseCompatPadding="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/manage_child_timezone_title"
|
||||||
|
android:textAppearance="?android:textAppearanceLarge"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
|
tools:text="GMT"
|
||||||
|
android:text="@{timezone}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/change_timezone_button"
|
||||||
|
android:text="@string/manage_child_timezone_change_button"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</layout>
|
Loading…
Add table
Add a link
Reference in a new issue