Added missing layouts for tablets + added video preview on dialer for tablets + don't ask telephony permission on tablets and use login with username/password as default

This commit is contained in:
Sylvain Berfini 2020-04-24 16:04:43 +02:00
parent 667b17a8c7
commit e53db5491a
9 changed files with 705 additions and 6 deletions

View file

@ -49,11 +49,13 @@ abstract class AbstractPhoneFragment : Fragment() {
}
protected fun checkPermission() {
if (!PermissionHelper.get().hasReadPhoneState()) {
Log.i("[Assistant] Asking for READ_PHONE_STATE permission")
requestPermissions(arrayOf(Manifest.permission.READ_PHONE_STATE), 0)
} else {
updateFromDeviceInfo()
if (!resources.getBoolean(R.bool.isTablet)) {
if (!PermissionHelper.get().hasReadPhoneState()) {
Log.i("[Assistant] Asking for READ_PHONE_STATE permission")
requestPermissions(arrayOf(Manifest.permission.READ_PHONE_STATE), 0)
} else {
updateFromDeviceInfo()
}
}
}

View file

@ -59,6 +59,10 @@ class AccountLoginFragment : AbstractPhoneFragment() {
viewModel = ViewModelProvider(this, AccountLoginViewModelFactory(sharedViewModel.getAccountCreator())).get(AccountLoginViewModel::class.java)
binding.viewModel = viewModel
if (resources.getBoolean(R.bool.isTablet)) {
viewModel.loginWithUsernamePassword.value = true
}
binding.setInfoClickListener {
showPhoneNumberInfoDialog()
}

View file

@ -27,6 +27,8 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.activities.main.dialer.viewmodels.DialerViewModel
import org.linphone.activities.main.viewmodels.SharedMainViewModel
import org.linphone.core.tools.Log
@ -94,4 +96,13 @@ class DialerFragment : Fragment() {
Log.i("[Dialer] Pending call transfer mode = ${sharedViewModel.pendingCallTransfer}")
viewModel.transferVisibility.value = sharedViewModel.pendingCallTransfer
}
override fun onResume() {
super.onResume()
if (resources.getBoolean(R.bool.isTablet)) {
coreContext.core.nativePreviewWindowId = binding.videoPreviewWindow
}
viewModel.updateShowVideoPreview()
}
}

View file

@ -33,6 +33,8 @@ class DialerViewModel : ViewModel() {
val transferVisibility = MutableLiveData<Boolean>()
val showPreview = MutableLiveData<Boolean>()
val onKeyClick: NumpadDigitListener = object : NumpadDigitListener {
override fun handleClick(key: Char) {
enteredUri.value += key.toString()
@ -79,6 +81,12 @@ class DialerViewModel : ViewModel() {
super.onCleared()
}
fun updateShowVideoPreview() {
val videoPreview = corePreferences.videoPreview
showPreview.value = videoPreview
coreContext.core.enableVideoPreview(videoPreview)
}
fun eraseLastChar() {
enteredUri.value = enteredUri.value?.dropLast(1)
}
@ -108,6 +116,10 @@ class DialerViewModel : ViewModel() {
}
}
fun switchCamera() {
coreContext.switchCamera()
}
private fun setLastOutgoingCallAddress() {
val callLog = coreContext.core.lastOutgoingCallLog
if (callLog != null) {

View file

@ -79,7 +79,6 @@ class CorePreferences constructor(private val context: Context) {
/* Video */
// TODO: use it to show video preview on dialer for tablets
var videoPreview: Boolean
get() = config.getBool("app", "video_preview", false)
set(value) = config.setBool("app", "video_preview", value)

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable
name="createAccountClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="accountLoginClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="genericAccountLoginClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="remoteProvisioningClickListener"
type="android.view.View.OnClickListener"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/top_bar_fragment"
android:name="org.linphone.activities.assistant.fragments.TopBarFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
tools:layout="@layout/assistant_top_bar_fragment" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/top_bar_fragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/standard_text_font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/assistant_welcome_title"
android:paddingTop="10dp"
android:textAllCaps="true" />
<TextView
style="@style/standard_small_text_font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="top"
android:paddingTop="10dp"
android:text="@string/assistant_welcome_desc" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2">
<TextView
android:id="@+id/account_creation"
android:onClick="@{createAccountClickListener}"
style="@style/button_font"
android:gravity="center"
android:padding="10dp"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_gravity="fill"
android:layout_columnWeight="1"
android:layout_height="wrap_content"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
android:text="@string/assistant_create_account" />
<TextView
android:id="@+id/account_connection"
android:onClick="@{accountLoginClickListener}"
style="@style/button_font"
android:gravity="center"
android:padding="10dp"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_gravity="fill"
android:layout_columnWeight="1"
android:layout_height="wrap_content"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
android:text="@string/assistant_login_linphone" />
<TextView
android:id="@+id/generic_connection"
android:onClick="@{genericAccountLoginClickListener}"
style="@style/button_font"
android:gravity="center"
android:padding="10dp"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_gravity="fill"
android:layout_columnWeight="1"
android:layout_height="wrap_content"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
android:text="@string/assistant_login_generic" />
<TextView
android:id="@+id/remote_configuration"
android:onClick="@{remoteProvisioningClickListener}"
style="@style/button_font"
android:gravity="center"
android:padding="10dp"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_gravity="fill"
android:layout_columnWeight="1"
android:layout_height="wrap_content"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
android:text="@string/assistant_remote_provisioning" />
</GridLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</layout>

View file

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<import type="android.view.View"/>
<variable
name="eraseClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="eraseLongClickListener"
type="android.view.View.OnLongClickListener"/>
<variable
name="newContactClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="startCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="addCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="transferCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="viewModel"
type="org.linphone.activities.main.dialer.viewmodels.DialerViewModel"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_color">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
tools:layout="@layout/tabs_fragment" />
<ImageView
android:visibility="@{viewModel.showPreview ? View.GONE : View.VISIBLE}"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tabs_fragment"
android:layout_toLeftOf="@id/ui_layout"
android:padding="30dp"
android:contentDescription="@null"
android:src="@drawable/dialer_background" />
<TextureView
android:id="@+id/video_preview_window"
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"/>
<ImageView
android:onClick="@{() -> viewModel.switchCamera()}"
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_switch_camera"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="20dp"
android:src="@drawable/switch_camera" />
<RelativeLayout
android:id="@+id/ui_layout"
android:layout_width="300dp"
android:layout_height="460dp"
android:layout_marginRight="50dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:background="?attr/backgroundColor">
<RelativeLayout
android:id="@+id/address_bar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:background="?attr/lightToolbarBackgroundColor">
<ImageView
android:id="@+id/erase"
android:onClick="@{eraseClickListener}"
android:onLongClick="@{eraseLongClickListener}"
android:contentDescription="@string/content_description_dialer_erase"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusableInTouchMode="true"
android:src="@drawable/backspace" />
<EditText
android:text="@={viewModel.enteredUri}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/erase"
android:background="@color/transparent_color"
android:backgroundTint="@color/transparent_color"
android:ellipsize="start"
android:hint="@string/dialer_address_bar_hint"
android:inputType="textEmailAddress"
android:paddingLeft="20dp"
android:paddingRight="5dp"
android:textColorHint="@color/light_grey_color" />
</RelativeLayout>
<LinearLayout
android:id="@+id/controls"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:onClick="@{newContactClickListener}"
android:enabled="@{viewModel.enteredUri.length() > 0}"
android:contentDescription="@string/content_description_add_contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="?attr/button_background_drawable"
android:padding="15dp"
android:src="@drawable/contact_add" />
<ImageView
android:onClick="@{startCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall ? View.GONE : View.VISIBLE}"
android:contentDescription="@string/content_description_start_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_audio_start" />
<ImageView
android:onClick="@{addCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall &amp;&amp; !viewModel.transferVisibility ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_add_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_add" />
<ImageView
android:onClick="@{transferCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall &amp;&amp; viewModel.transferVisibility ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_transfer_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_transfer" />
</LinearLayout>
<include
layout="@layout/numpad"
android:layout_above="@id/controls"
android:layout_below="@id/address_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:keyListener="@{viewModel.onKeyClick}" />
</RelativeLayout>
</RelativeLayout>
</layout>

View file

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<import type="android.view.View"/>
<variable
name="eraseClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="eraseLongClickListener"
type="android.view.View.OnLongClickListener"/>
<variable
name="newContactClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="startCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="addCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="transferCallClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="viewModel"
type="org.linphone.activities.main.dialer.viewmodels.DialerViewModel"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_color">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/tabs_fragment"
android:name="org.linphone.activities.main.fragments.TabsFragment"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
tools:layout="@layout/tabs_fragment" />
<ImageView
android:visibility="@{viewModel.showPreview ? View.GONE : View.VISIBLE}"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_above="@id/ui_layout"
android:padding="30dp"
android:layout_centerHorizontal="true"
android:contentDescription="@null"
android:src="@drawable/dialer_background" />
<TextureView
android:id="@+id/video_preview_window"
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"/>
<ImageView
android:onClick="@{() -> viewModel.switchCamera()}"
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_switch_camera"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="20dp"
android:src="@drawable/switch_camera" />
<RelativeLayout
android:id="@+id/ui_layout"
android:layout_width="300dp"
android:layout_height="460dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:layout_above="@id/tabs_fragment"
android:background="?attr/backgroundColor">
<RelativeLayout
android:id="@+id/address_bar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:background="?attr/lightToolbarBackgroundColor">
<ImageView
android:id="@+id/erase"
android:onClick="@{eraseClickListener}"
android:onLongClick="@{eraseLongClickListener}"
android:contentDescription="@string/content_description_dialer_erase"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusableInTouchMode="true"
android:src="@drawable/backspace" />
<EditText
android:text="@={viewModel.enteredUri}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/erase"
android:background="@color/transparent_color"
android:backgroundTint="@color/transparent_color"
android:ellipsize="start"
android:hint="@string/dialer_address_bar_hint"
android:inputType="textEmailAddress"
android:paddingLeft="20dp"
android:paddingRight="5dp"
android:textColorHint="@color/light_grey_color" />
</RelativeLayout>
<LinearLayout
android:id="@+id/controls"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:onClick="@{newContactClickListener}"
android:enabled="@{viewModel.enteredUri.length() > 0}"
android:contentDescription="@string/content_description_add_contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="?attr/button_background_drawable"
android:padding="15dp"
android:src="@drawable/contact_add" />
<ImageView
android:onClick="@{startCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall ? View.GONE : View.VISIBLE}"
android:contentDescription="@string/content_description_start_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_audio_start" />
<ImageView
android:onClick="@{addCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall &amp;&amp; !viewModel.transferVisibility ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_add_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_add" />
<ImageView
android:onClick="@{transferCallClickListener}"
android:visibility="@{viewModel.atLeastOneCall &amp;&amp; viewModel.transferVisibility ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_transfer_call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/call"
android:padding="12dp"
android:src="@drawable/call_transfer" />
</LinearLayout>
<include
layout="@layout/numpad"
android:layout_above="@id/controls"
android:layout_below="@id/address_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:keyListener="@{viewModel.onKeyClick}" />
</RelativeLayout>
</RelativeLayout>
</layout>

View file

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View"/>
<variable
name="backClickListener"
type="android.view.View.OnClickListener"/>
<variable
name="viewModel"
type="org.linphone.activities.main.settings.viewmodels.SettingsViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:background="?attr/lightToolbarBackgroundColor"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:onClick="@{backClickListener}"
android:contentDescription="@string/content_description_go_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="?attr/button_background_drawable"
android:padding="18dp"
android:src="@drawable/back" />
<TextView
style="@style/accent_colored_title_font"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end"
android:padding="15dp"
android:text="@string/settings"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:visibility="invisible" />
</LinearLayout>
<ScrollView
android:layout_below="@id/top_bar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:orientation="vertical">
<TextView
style="@style/settings_category_font"
android:text="@string/settings_accounts_title"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
linphone:entries="@{viewModel.accounts}"
linphone:layout="@{@layout/settings_account_cell}"/>
<TextView
style="@style/settings_category_font"
android:text="@string/settings_list_title"
android:paddingTop="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.tunnelSettingsListener}"
android:visibility="@{viewModel.tunnelAvailable ? View.VISIBLE : View.GONE}"
linphone:title="@{@string/settings_tunnel_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.audioSettingsListener}"
linphone:title="@{@string/settings_audio_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.videoSettingsListener}"
linphone:title="@{@string/settings_video_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.callSettingsListener}"
linphone:title="@{@string/settings_call_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.chatSettingsListener}"
linphone:title="@{@string/settings_chat_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.networkSettingsListener}"
linphone:title="@{@string/settings_network_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.contactsSettingsListener}"
linphone:title="@{@string/settings_contacts_title}" />
<include
layout="@layout/settings_widget_basic"
linphone:listener="@{viewModel.advancedSettingsListener}"
linphone:title="@{@string/settings_advanced_title}" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dividerColor" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
linphone:defaultNavHost="false"
linphone:navGraph="@navigation/settings_nav_graph"/>
</RelativeLayout>
</LinearLayout>
</layout>