mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Moved quit button to drawer menu, only visible if keep service alive setting is enabled
This commit is contained in:
parent
899a3ea374
commit
d0ded694f8
5 changed files with 50 additions and 44 deletions
|
|
@ -36,6 +36,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Account
|
||||
import org.linphone.core.tools.Log
|
||||
|
|
@ -94,6 +95,18 @@ class DrawerMenuFragment : GenericMainFragment() {
|
|||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setQuitClickedListener {
|
||||
coreContext.stopKeepAliveService()
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i("$TAG Stopping Core Context")
|
||||
coreContext.quitSafely()
|
||||
}
|
||||
|
||||
Log.i("$TAG Quitting app")
|
||||
requireActivity().finishAndRemoveTask()
|
||||
}
|
||||
|
||||
viewModel.startAssistantEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
startActivity(Intent(requireActivity(), AssistantActivity::class.java))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import android.view.ViewGroup
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.HelpFragmentBinding
|
||||
|
|
@ -74,18 +73,6 @@ class HelpFragment : GenericMainFragment() {
|
|||
findNavController().navigate(action)
|
||||
}
|
||||
|
||||
binding.setQuitClickListener {
|
||||
coreContext.stopKeepAliveService()
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i("$TAG Stopping Core Context")
|
||||
coreContext.quitSafely()
|
||||
}
|
||||
|
||||
Log.i("$TAG Quitting app")
|
||||
requireActivity().finishAndRemoveTask()
|
||||
}
|
||||
|
||||
binding.setPrivacyPolicyClickListener {
|
||||
val url = getString(R.string.website_privacy_policy_url)
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class DrawerMenuViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
val shortcuts = MutableLiveData<ArrayList<ShortcutModel>>()
|
||||
|
||||
val hideQuitButton = MutableLiveData<Boolean>()
|
||||
|
||||
val startAssistantEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -124,6 +126,7 @@ class DrawerMenuViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
hideRecordings.postValue(corePreferences.disableCallRecordings)
|
||||
hideSettings.postValue(corePreferences.hideSettings)
|
||||
hideQuitButton.postValue(!corePreferences.keepServiceAlive)
|
||||
|
||||
computeAccountsList()
|
||||
computeShortcuts()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
<variable
|
||||
name="helpClickedListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="quitClickedListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.viewmodel.DrawerMenuViewModel" />
|
||||
|
|
@ -206,6 +209,37 @@
|
|||
app:drawableTint="?attr/color_main2_500"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/separator_2" />
|
||||
|
||||
<View
|
||||
android:id="@+id/separator_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?attr/color_main2_200"
|
||||
android:visibility="@{viewModel.hideQuitButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/quit" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{quitClickedListener}"
|
||||
style="@style/header_style"
|
||||
android:id="@+id/quit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/help_quit_title"
|
||||
android:visibility="@{viewModel.hideQuitButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:drawableStart="@drawable/power"
|
||||
android:drawablePadding="8dp"
|
||||
app:drawableTint="?attr/color_main2_500"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@
|
|||
<variable
|
||||
name="debugClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="quitClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.help.viewmodel.HelpViewModel" />
|
||||
|
|
@ -309,34 +306,6 @@
|
|||
app:layout_constraintStart_toEndOf="@id/debug_icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{quitClickListener}"
|
||||
android:id="@+id/quit_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:src="@drawable/power"
|
||||
android:contentDescription="@null"
|
||||
app:tint="?attr/color_main1_500"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/quit_title"
|
||||
app:layout_constraintTop_toTopOf="@id/quit_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/quit_title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
android:onClick="@{quitClickListener}"
|
||||
android:id="@+id/quit_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/help_quit_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/debug_icon"
|
||||
app:layout_constraintStart_toEndOf="@id/quit_icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue