Skip to content

Commit

Permalink
WIP. remove putParcelables
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  • Loading branch information
mahibi committed Jun 29, 2023
1 parent 2cb3dca commit a8543d9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 69 deletions.
46 changes: 4 additions & 42 deletions app/src/main/java/com/nextcloud/talk/contacts/ContactsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -338,46 +338,13 @@ class ContactsActivity :

override fun onNext(roomOverall: RoomOverall) {
val bundle = Bundle()
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, currentUser)
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)

// FIXME once APIv2 or later is used only, the createRoom already returns all the data
ncApi.getRoom(
credentials,
ApiUtils.getUrlForRoom(
apiVersion,
currentUser!!.baseUrl,
roomOverall.ocs!!.data!!.token
)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<RoomOverall> {
override fun onSubscribe(d: Disposable) {
// unused atm
}

override fun onNext(roomOverall: RoomOverall) {
bundle.putParcelable(
BundleKeys.KEY_ACTIVE_CONVERSATION,
Parcels.wrap(roomOverall.ocs!!.data!!)
)

val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(chatIntent)
}

override fun onError(e: Throwable) {
// unused atm
}

override fun onComplete() {
// unused atm
}
})
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(chatIntent)
}

override fun onError(e: Throwable) {
Expand Down Expand Up @@ -818,13 +785,8 @@ class ContactsActivity :

override fun onNext(roomOverall: RoomOverall) {
val bundle = Bundle()
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, currentUser)
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)
bundle.putParcelable(
BundleKeys.KEY_ACTIVE_CONVERSATION,
Parcels.wrap(roomOverall.ocs!!.data!!)
)

val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package com.nextcloud.talk.controllers.bottomsheet
import android.content.Intent
import android.content.res.ColorStateList
import android.os.Bundle
import android.os.Parcelable
import android.text.Editable
import android.text.InputType
import android.text.TextUtils
Expand Down Expand Up @@ -63,7 +62,6 @@ import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import okhttp3.internal.immutableListOf
import org.greenrobot.eventbus.EventBus
import org.parceler.Parcels.unwrap
import javax.inject.Inject

@AutoInjector(NextcloudTalkApplication::class)
Expand Down Expand Up @@ -352,9 +350,6 @@ class EntryMenuController(args: Bundle) :
originalBundle = args
operation = args.getSerializable(BundleKeys.KEY_OPERATION_CODE) as ConversationOperationEnum
roomToken = args.getString(KEY_ROOM_TOKEN, "")
if (args.containsKey(BundleKeys.KEY_SHARE_INTENT)) {
shareIntent = unwrap<Intent>(args.getParcelable<Parcelable>(BundleKeys.KEY_SHARE_INTENT))
}
name = args.getString(BundleKeys.KEY_APP_ITEM_NAME, "")
packageName = args.getString(BundleKeys.KEY_APP_ITEM_PACKAGE_NAME, "")
// callUrl = args.getString(BundleKeys.KEY_CALL_URL, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,6 @@ class OperationsMenuController(args: Bundle) : BaseController(
eventBus.post(ConversationsListFetchDataEvent())
val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken)
// bundle.putString(KEY_CALL_URL, callUrl)
// try {
// bundle.putParcelable(
// KEY_SERVER_CAPABILITIES,
// Parcels.wrap<Capabilities>(currentUser!!.capabilities)
// )
// } catch (e: IOException) {
// Log.e(TAG, "Failed to parse capabilities for guest")
// showResultImage(everythingOK = false, isGuestSupportError = false)
// }
bundle.putSerializable(KEY_OPERATION_CODE, ConversationOperationEnum.OPS_CODE_JOIN_ROOM)
router.pushController(
RouterTransaction.with(EntryMenuController(bundle))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import com.nextcloud.talk.utils.FileUtils
import com.nextcloud.talk.utils.NotificationUtils
import com.nextcloud.talk.utils.RemoteFileUtils
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CALL
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
import com.nextcloud.talk.utils.preferences.AppPreferences
Expand Down Expand Up @@ -244,7 +244,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK

bundle.putString(KEY_ROOM_TOKEN, roomToken)
bundle.putParcelable(KEY_USER_ENTITY, currentUser)
bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id!!)
bundle.putBoolean(KEY_FROM_NOTIFICATION_START_CALL, false)

intent.putExtras(bundle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.DialogPollMainBinding
import com.nextcloud.talk.polls.viewmodels.PollMainViewModel
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import javax.inject.Inject

@AutoInjector(NextcloudTalkApplication::class)
Expand All @@ -48,16 +49,22 @@ class PollMainDialogFragment : DialogFragment() {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils

var currentUserProvider: CurrentUserProviderNew? = null
@Inject set

private lateinit var binding: DialogPollMainBinding
private lateinit var viewModel: PollMainViewModel

lateinit var user: User

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)

viewModel = ViewModelProvider(this, viewModelFactory)[PollMainViewModel::class.java]

val user: User = arguments?.getParcelable(KEY_USER_ENTITY)!!
user = currentUserProvider?.currentUser?.blockingGet()!!

val roomToken = arguments?.getString(KEY_ROOM_TOKEN)!!
val isOwnerOrModerator = arguments?.getBoolean(KEY_OWNER_OR_MODERATOR)!!
val pollId = arguments?.getString(KEY_POLL_ID)!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
lateinit var currentUser: User
private var systemNotificationId: Int? = null
private var link: String? = null
var roomToken: String? = null
var conversationOfShareTarget: User? = null

init {
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
Expand All @@ -68,9 +66,6 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
systemNotificationId = intent!!.getIntExtra(KEY_SYSTEM_NOTIFICATION_ID, 0)
link = intent.getStringExtra(BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL)

roomToken = intent.getStringExtra(BundleKeys.KEY_ROOM_TOKEN)
conversationOfShareTarget = intent.getParcelableExtra<User>(BundleKeys.KEY_USER_ENTITY)

val id = intent.getLongExtra(KEY_INTERNAL_USER_ID, userManager.currentUser.blockingGet().id!!)
currentUser = userManager.getUserWithId(id).blockingGet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private void setupListeners(User user) {
dismiss();

if (status != null) {
SetStatusDialogFragment setStatusDialog = SetStatusDialogFragment.newInstance(user, status);
SetStatusDialogFragment setStatusDialog = SetStatusDialogFragment.newInstance(status);
setStatusDialog.show(getActivity().getSupportFragmentManager(), "fragment_set_status");
} else {
Log.w(TAG, "status was null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import com.nextcloud.talk.models.json.status.predefined.PredefinedStatusOverall
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import com.vanniktech.emoji.EmojiPopup
import com.vanniktech.emoji.installDisableKeyboardInput
import com.vanniktech.emoji.installForceSingleEmoji
Expand Down Expand Up @@ -113,6 +114,9 @@ class SetStatusDialogFragment :
@Inject
lateinit var viewThemeUtils: ViewThemeUtils

var currentUserProvider: CurrentUserProviderNew? = null
@Inject set

lateinit var credentials: String

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -121,7 +125,7 @@ class SetStatusDialogFragment :
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)

arguments?.let {
currentUser = it.getParcelable(ARG_CURRENT_USER_PARAM)
currentUser = currentUserProvider?.currentUser?.blockingGet()
currentStatus = it.getParcelable(ARG_CURRENT_STATUS_PARAM)

credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token)
Expand Down Expand Up @@ -559,9 +563,8 @@ class SetStatusDialogFragment :
private val TAG = SetStatusDialogFragment::class.simpleName

@JvmStatic
fun newInstance(user: User, status: Status): SetStatusDialogFragment {
fun newInstance(status: Status): SetStatusDialogFragment {
val args = Bundle()
args.putParcelable(ARG_CURRENT_USER_PARAM, user)
args.putParcelable(ARG_CURRENT_STATUS_PARAM, status)

val dialogFragment = SetStatusDialogFragment()
Expand Down

0 comments on commit a8543d9

Please sign in to comment.