mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added missing plain/text sharing feature + proper sliding pane layout sizes in landscape
This commit is contained in:
parent
7f10548ecb
commit
e62b1b4999
15 changed files with 50 additions and 22 deletions
|
|
@ -71,6 +71,7 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/*" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="audio/*" />
|
||||
<data android:mimeType="video/*" />
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
|||
private const val NATIVE_ADDRESS_BOOK_FRIEND_LIST = "Native address-book"
|
||||
const val LINPHONE_ADDRESS_BOOK_FRIEND_LIST = "Linphone address-book"
|
||||
|
||||
private const val MAX_INTERVAL_TO_REFRESH = 60000L
|
||||
private const val MAX_INTERVAL_TO_REFRESH = 60000L // 1 minute
|
||||
}
|
||||
|
||||
@MainThread
|
||||
|
|
|
|||
|
|
@ -371,20 +371,28 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private fun handleSendIntent(intent: Intent, multiple: Boolean) {
|
||||
val parcelablesUri = arrayListOf<Uri>()
|
||||
if (multiple) {
|
||||
val parcelables = intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)
|
||||
for (parcelable in parcelables.orEmpty()) {
|
||||
val uri = parcelable as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra list")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
|
||||
if (intent.type == "text/plain") {
|
||||
intent.getStringExtra(Intent.EXTRA_TEXT)?.let { extraText ->
|
||||
sharedViewModel.textToShareFromIntent.value = extraText
|
||||
}
|
||||
} else {
|
||||
val uri = intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra")
|
||||
parcelablesUri.add(uri)
|
||||
if (multiple) {
|
||||
val parcelables =
|
||||
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)
|
||||
for (parcelable in parcelables.orEmpty()) {
|
||||
val uri = parcelable as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra list")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val uri = intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri
|
||||
if (uri != null) {
|
||||
Log.i("$TAG Found URI [$uri] in parcelable extra")
|
||||
parcelablesUri.add(uri)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,10 +430,15 @@ class MainActivity : AppCompatActivity() {
|
|||
Log.i("$TAG Found file to share [$path] in intent")
|
||||
if (path != null) list.add(path)
|
||||
}
|
||||
|
||||
if (list.isNotEmpty()) {
|
||||
sharedViewModel.filesToShareFromIntent.value = list
|
||||
} else {
|
||||
Log.w("$TAG Failed to find at least one file to share!")
|
||||
if (sharedViewModel.textToShareFromIntent.value.orEmpty().isNotEmpty()) {
|
||||
Log.i("$TAG Found plain text to share")
|
||||
} else {
|
||||
Log.w("$TAG Failed to find at least one file or text to share!")
|
||||
}
|
||||
}
|
||||
|
||||
findNavController().setGraph(navGraph, intent.extras)
|
||||
|
|
|
|||
|
|
@ -400,6 +400,15 @@ class ConversationFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.textToShareFromIntent.observe(viewLifecycleOwner) { text ->
|
||||
if (text.isNotEmpty()) {
|
||||
Log.i("$TAG Found text to share from intent")
|
||||
sendMessageViewModel.textToSend.value = text
|
||||
|
||||
sharedViewModel.textToShareFromIntent.value = ""
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.filesToShareFromIntent.observe(viewLifecycleOwner) { files ->
|
||||
if (files.isNotEmpty()) {
|
||||
Log.i("$TAG Found [${files.size}] files to share from intent")
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
/* Conversation related */
|
||||
|
||||
val textToShareFromIntent = MutableLiveData<String>()
|
||||
|
||||
val filesToShareFromIntent = MutableLiveData<ArrayList<String>>()
|
||||
|
||||
var displayedChatRoom: ChatRoom? = null // Prevents the need to go look for the chat room
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/sliding_pane_left_fragment_width"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="sliding_pane_left_fragment_width">450dp</dimen>
|
||||
|
||||
<dimen name="call_main_actions_menu_height">110dp</dimen>
|
||||
<dimen name="call_extra_actions_menu_height">125dp</dimen>
|
||||
<dimen name="call_all_actions_menu_height">235dp</dimen> <!-- sum of above two -->
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<dimen name="screen_bottom_margin">32dp</dimen>
|
||||
|
||||
<dimen name="landscape_nav_bar_width">75dp</dimen>
|
||||
<dimen name="sliding_pane_left_fragment_width">350dp</dimen>
|
||||
<dimen name="sliding_pane_right_fragment_width">300dp</dimen>
|
||||
|
||||
<dimen name="small_icon_size">14dp</dimen>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue