fix shareTo feature

it was broken since ConversationsList was migrated to Activity

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-05-01 17:40:27 +02:00
parent fe86e57f82
commit 6c2c15cd89
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
4 changed files with 84 additions and 70 deletions

View file

@ -54,8 +54,8 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
@ -71,7 +71,8 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
@ -89,7 +90,7 @@
<permission
android:name="${applicationId}.${broadcastPermission}"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.${broadcastPermission}"/>
<uses-permission android:name="${applicationId}.${broadcastPermission}" />
<application
android:name=".application.NextcloudTalkApplication"
@ -99,9 +100,9 @@
android:label="@string/nc_app_name"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppTheme.Launcher"
android:requestLegacyExternalStorage="true"
tools:ignore="UnusedAttribute"
tools:replace="label, icon, theme, name, allowBackup">
@ -118,21 +119,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.com.nextcloud.talk2.chat" />
<data android:scheme="content" />
<data android:scheme="file" />
@ -141,41 +131,38 @@
<activity
android:name=".activities.CallActivity"
android:theme="@style/AppTheme.CallLauncher"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:launchMode="singleTask"
android:taskAffinity=".call"
android:excludeFromRecents="true"
android:showOnLockScreen="true"/>
android:launchMode="singleTask"
android:showOnLockScreen="true"
android:supportsPictureInPicture="true"
android:taskAffinity=".call"
android:theme="@style/AppTheme.CallLauncher" />
<activity
android:name=".activities.CallNotificationActivity"
android:theme="@style/AppTheme.CallLauncher"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:launchMode="singleTask"
android:taskAffinity=".call"
android:excludeFromRecents="true"
android:showOnLockScreen="true" />
android:launchMode="singleTask"
android:showOnLockScreen="true"
android:supportsPictureInPicture="true"
android:taskAffinity=".call"
android:theme="@style/AppTheme.CallLauncher" />
<activity
android:name=".activities.FullScreenImageActivity"
android:theme="@style/FullScreenImageTheme"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenImageTheme"></activity>
<activity
android:name=".activities.FullScreenMediaActivity"
android:theme="@style/FullScreenMediaTheme"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenMediaTheme"></activity>
<activity
android:name=".activities.FullScreenTextViewerActivity"
android:theme="@style/FullScreenTextTheme"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenTextTheme"></activity>
<activity
android:name=".activities.TakePhotoActivity"
@ -224,16 +211,31 @@
<activity
android:name=".chat.ChatActivity"
android:theme="@style/AppTheme"
android:launchMode="singleInstance"
android:noHistory="true"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".conversationlist.ConversationsListActivity"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme"
android:exported="true">
<receiver android:name=".receivers.PackageReplacedReceiver"
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<receiver
android:name=".receivers.PackageReplacedReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
@ -260,7 +262,8 @@
android:resource="@xml/contacts" />
</service>
<service android:name=".utils.AuthenticatorService"
<service
android:name=".utils.AuthenticatorService"
android:exported="false">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />

View file

@ -110,7 +110,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
override fun onSuccess(users: List<User>) {
if (users.isNotEmpty()) {
runOnUiThread {
setDefaultRootController()
openConversationList()
}
} else {
runOnUiThread {
@ -166,33 +166,13 @@ class MainActivity : BaseActivity(), ActionBarProvider {
super.onStop()
}
private fun setDefaultRootController() {
private fun openConversationList() {
val intent = Intent(this, ConversationsListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.putExtras(Bundle())
startActivity(intent)
}
fun resetConversationsList() {
userManager.users.subscribe(object : SingleObserver<List<User>> {
override fun onSubscribe(d: Disposable) {
// unused atm
}
override fun onSuccess(users: List<User>) {
if (users.isNotEmpty()) {
runOnUiThread {
setDefaultRootController()
}
}
}
override fun onError(e: Throwable) {
Log.e(TAG, "Error loading existing users", e)
}
})
}
fun addAccount() {
router!!.pushController(
RouterTransaction.with(ServerSelectionController())
@ -348,7 +328,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
if (!router!!.hasRootController()) {
setDefaultRootController()
openConversationList()
}
val callNotificationIntent = Intent(this, CallNotificationActivity::class.java)
intent.extras?.let { callNotificationIntent.putExtras(it) }

View file

@ -374,10 +374,10 @@ class ConversationsListActivity :
if (showShareToScreen) {
hideSearchBar()
actionBar?.setTitle(R.string.send_to_three_dots)
supportActionBar?.setTitle(R.string.send_to_three_dots)
} else if (forwardMessage) {
hideSearchBar()
actionBar?.setTitle(R.string.nc_forward_to_three_dots)
supportActionBar?.setTitle(R.string.nc_forward_to_three_dots)
} else {
searchItem!!.isVisible = conversationItems.size > 0
if (adapter!!.hasFilter()) {
@ -1010,8 +1010,7 @@ class ConversationsListActivity :
)
}
} else {
// TODO
// requestStoragePermission(this@ConversationsListController)
UploadAndShareFilesWorker.requestStoragePermission(this)
}
}

View file

@ -27,6 +27,7 @@ import android.annotation.SuppressLint
import android.app.Dialog
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -34,7 +35,6 @@ import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.LinearLayoutManager
import autodagger.AutoInjector
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.activities.MainActivity
import com.nextcloud.talk.adapters.items.AdvancedUserItem
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
@ -46,6 +46,8 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
import io.reactivex.SingleObserver
import io.reactivex.disposables.Disposable
import java.net.CookieManager
import javax.inject.Inject
@ -160,7 +162,37 @@ class ChooseAccountShareToDialogFragment : DialogFragment() {
val user = userItems[position].user
if (userManager!!.setUserAsActive(user).blockingGet()) {
cookieManager!!.cookieStore.removeAll()
activity?.runOnUiThread { (activity as MainActivity?)!!.resetConversationsList() }
// activity?.runOnUiThread { (activity as MainActivity?)!!.resetConversationsList() }
userManager!!.users.subscribe(object : SingleObserver<List<User>> {
override fun onSubscribe(d: Disposable) {
// unused atm
}
override fun onSuccess(users: List<User>) {
if (users.isNotEmpty()) {
// runOnUiThread {
// setDefaultRootController()
// }
// val intent = Intent(activity, ConversationsListActivity::class.java)
//
// // val intent = Intent(context, ConversationsListActivity::class.java)
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// activity?.intent?.extras?.let { intent.putExtras(it) }
// startActivity(intent)
// startActivity(activity?.intent)
activity?.recreate()
}
}
override fun onError(e: Throwable) {
Log.e(TAG, "Error loading existing users", e)
}
})
dismiss()
}
}