Added grant all button on permissions fragment

This commit is contained in:
Sylvain Berfini 2023-10-05 10:09:23 +02:00
parent 7eaa5cfb22
commit 3f24e73978
4 changed files with 48 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.annotation.UiThread
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
@ -54,6 +55,12 @@ class LoginFragment : Fragment() {
R.id.assistant_nav_graph
)
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
goBack()
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -69,6 +76,11 @@ class LoginFragment : Fragment() {
binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
onBackPressedCallback
)
binding.setBackClickListener {
goBack()
}

View file

@ -126,6 +126,18 @@ class PermissionsFragment : Fragment() {
goToLoginFragment()
}
binding.setGrantAllClickListener {
Log.i("$TAG Requesting all permissions")
requestPermissionLauncher.launch(
arrayOf(
Manifest.permission.READ_CONTACTS,
Manifest.permission.POST_NOTIFICATIONS,
Manifest.permission.RECORD_AUDIO,
Manifest.permission.CAMERA
)
)
}
if (ContextCompat.checkSelfPermission(
requireContext(),
Manifest.permission.MANAGE_OWN_CALLS

View file

@ -23,6 +23,9 @@
<variable
name="skipClickListener"
type="View.OnClickListener" />
<variable
name="grantAllClickListener"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.assistant.viewmodel.PermissionsViewModel" />
@ -272,6 +275,26 @@
app:layout_constraintTop_toBottomOf="@id/access_camera_switch"
app:layout_constraintBottom_toBottomOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{grantAllClickListener}"
style="@style/primary_button_label_style"
android:id="@+id/continue_third_party_account_login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="@dimen/screen_bottom_margin"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="@string/assistant_permissions_grant_all_of_them"
app:layout_constraintWidth_max="@dimen/button_max_width"
app:layout_constraintVertical_bias="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/skip"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View file

@ -153,6 +153,7 @@
<string name="assistant_account_login_forbidden_error">Wrong username or password</string>
<string name="assistant_account_login_error">Failed to login: error code is %i</string>
<string name="assistant_permissions_title">Grant permissions</string>
<string name="assistant_permissions_grant_all_of_them">Grant all</string>
<string name="assistant_permissions_subtitle">To be able to work properly, we need you to grand the application the following permissions.\n\nIf you don\'t, some features won\'t be available, but you can grant them later.</string>
<string name="assistant_permissions_read_contacts_title">Read contacts</string>