mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 14:40:22 +00:00
Remove ParcelableGroupId.
This commit is contained in:
committed by
Jeffrey Starke
parent
d49ef1dd7d
commit
146a5f5701
@@ -27,7 +27,6 @@ import org.thoughtcrime.securesms.avatar.text.TextAvatarCreationFragment
|
||||
import org.thoughtcrime.securesms.avatar.vector.VectorAvatarCreationFragment
|
||||
import org.thoughtcrime.securesms.components.ButtonStripItemView
|
||||
import org.thoughtcrime.securesms.components.recyclerview.GridDividerDecoration
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.mediasend.AvatarSelectionActivity
|
||||
import org.thoughtcrime.securesms.mediasend.Media
|
||||
import org.thoughtcrime.securesms.mediasend.camerax.CameraXUtil
|
||||
@@ -57,9 +56,8 @@ class AvatarPickerFragment : Fragment(R.layout.avatar_picker_fragment) {
|
||||
|
||||
private fun createFactory(): AvatarPickerViewModel.Factory {
|
||||
val args = AvatarPickerFragmentArgs.fromBundle(requireArguments())
|
||||
val groupId = ParcelableGroupId.get(args.groupId)
|
||||
|
||||
return AvatarPickerViewModel.Factory(AvatarPickerRepository(requireContext()), groupId, args.isNewGroup, args.groupAvatarMedia)
|
||||
return AvatarPickerViewModel.Factory(AvatarPickerRepository(requireContext()), args.groupId, args.isNewGroup, args.groupAvatarMedia)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.StringRes
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.signal.donations.InAppPaymentType
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListId
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.profiles.manage.UsernameEditMode
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
|
||||
@@ -46,7 +46,7 @@ sealed interface AppSettingsRoute : Parcelable {
|
||||
data class Privacy(@StringRes val titleId: Int) : StoriesRoute
|
||||
data object MyStory : StoriesRoute
|
||||
data class PrivateStory(val distributionListId: DistributionListId) : StoriesRoute
|
||||
data class GroupStory(val groupId: ParcelableGroupId) : StoriesRoute
|
||||
data class GroupStory(val groupId: GroupId) : StoriesRoute
|
||||
data object OnlyShareWith : StoriesRoute
|
||||
data object AllExcept : StoriesRoute
|
||||
data object SignalConnections : StoriesRoute
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.google.android.material.transition.platform.MaterialContainerTransfor
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsActivity
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.DynamicConversationSettingsTheme
|
||||
@@ -67,7 +66,7 @@ open class ConversationSettingsActivity : DSLSettingsActivity(), ConversationSet
|
||||
|
||||
@JvmStatic
|
||||
fun forGroup(context: Context, groupId: GroupId): Intent {
|
||||
val startBundle = ConversationSettingsFragmentArgs.Builder(null, ParcelableGroupId.from(groupId), null)
|
||||
val startBundle = ConversationSettingsFragmentArgs.Builder(null, groupId, null)
|
||||
.build()
|
||||
.toBundle()
|
||||
|
||||
@@ -88,7 +87,7 @@ open class ConversationSettingsActivity : DSLSettingsActivity(), ConversationSet
|
||||
@JvmStatic
|
||||
fun forCall(context: Context, callPeer: Recipient, callMessageIds: LongArray): Intent {
|
||||
val startBundleBuilder = if (callPeer.isGroup) {
|
||||
ConversationSettingsFragmentArgs.Builder(null, ParcelableGroupId.from(callPeer.requireGroupId()), callMessageIds)
|
||||
ConversationSettingsFragmentArgs.Builder(null, callPeer.requireGroupId(), callMessageIds)
|
||||
} else {
|
||||
ConversationSettingsFragmentArgs.Builder(callPeer.id, null, callMessageIds)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ import org.thoughtcrime.securesms.components.settings.conversation.preferences.U
|
||||
import org.thoughtcrime.securesms.contacts.ContactSelectionDisplayMode
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupErrors
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupLimitDialog
|
||||
import org.thoughtcrime.securesms.groups.ui.LeaveGroupDialog
|
||||
@@ -136,11 +136,11 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
|
||||
private val viewModel by viewModels<ConversationSettingsViewModel>(
|
||||
factoryProducer = {
|
||||
val groupId = args.groupId as? ParcelableGroupId
|
||||
val groupId = args.groupId as? GroupId
|
||||
|
||||
ConversationSettingsViewModel.Factory(
|
||||
recipientId = args.recipientId,
|
||||
groupId = ParcelableGroupId.get(groupId),
|
||||
groupId = groupId,
|
||||
callMessageIds = args.callMessageIds ?: longArrayOf(),
|
||||
repository = ConversationSettingsRepository(requireContext()),
|
||||
messageRequestRepository = MessageRequestRepository(requireContext())
|
||||
@@ -210,9 +210,9 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == R.id.action_edit) {
|
||||
val args = ConversationSettingsFragmentArgs.fromBundle(requireArguments())
|
||||
val groupId = args.groupId as ParcelableGroupId
|
||||
val groupId = args.groupId as GroupId
|
||||
|
||||
startActivity(CreateProfileActivity.getIntentForGroupProfile(requireActivity(), requireNotNull(ParcelableGroupId.get(groupId))))
|
||||
startActivity(CreateProfileActivity.getIntentForGroupProfile(requireActivity(), requireNotNull(groupId)))
|
||||
true
|
||||
} else {
|
||||
super.onOptionsItemSelected(item)
|
||||
@@ -820,7 +820,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
icon = DSLSettingsIcon.from(R.drawable.ic_lock_24),
|
||||
isEnabled = !state.isDeprecatedOrUnregistered,
|
||||
onClick = {
|
||||
val action = ConversationSettingsFragmentDirections.actionConversationSettingsFragmentToPermissionsSettingsFragment(ParcelableGroupId.from(groupState.groupId))
|
||||
val action = ConversationSettingsFragmentDirections.actionConversationSettingsFragmentToPermissionsSettingsFragment(groupState.groupId)
|
||||
navController.safeNavigate(action)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.components.settings.DSLConfiguration
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsFragment
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsText
|
||||
import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupErrors
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
|
||||
@@ -23,7 +23,7 @@ class PermissionsSettingsFragment : DSLSettingsFragment(
|
||||
private val viewModel: PermissionsSettingsViewModel by viewModels(
|
||||
factoryProducer = {
|
||||
val args = PermissionsSettingsFragmentArgs.fromBundle(requireArguments())
|
||||
val groupId = requireNotNull(ParcelableGroupId.get(args.groupId as ParcelableGroupId))
|
||||
val groupId = requireNotNull(args.groupId as GroupId)
|
||||
val repository = PermissionsSettingsRepository(requireContext())
|
||||
|
||||
PermissionsSettingsViewModel.Factory(groupId, repository)
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId;
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupMemberListView;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil;
|
||||
@@ -46,7 +45,7 @@ public final class ShowAdminsBottomSheetDialog extends BottomSheetDialogFragment
|
||||
ShowAdminsBottomSheetDialog fragment = new ShowAdminsBottomSheetDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(KEY_GROUP_ID, ParcelableGroupId.from(groupId));
|
||||
args.putParcelable(KEY_GROUP_ID, groupId);
|
||||
fragment.setArguments(args);
|
||||
|
||||
fragment.show(manager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG);
|
||||
@@ -94,7 +93,7 @@ public final class ShowAdminsBottomSheetDialog extends BottomSheetDialogFragment
|
||||
}
|
||||
|
||||
private GroupId getGroupId() {
|
||||
return ParcelableGroupId.get(requireArguments().getParcelable(KEY_GROUP_ID));
|
||||
return requireArguments().getParcelable(KEY_GROUP_ID);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
||||
@@ -3747,7 +3747,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
if (blockedGroupIds.isNotEmpty()) {
|
||||
val groupIds: List<GroupId.V1> = blockedGroupIds.filterNotNull().mapNotNull { raw ->
|
||||
try {
|
||||
GroupId.v1(raw)
|
||||
raw?.let { GroupId.v1(it) }
|
||||
} catch (e: BadGroupIdException) {
|
||||
Log.w(TAG, "[applyBlockedUpdate] Bad GV1 ID!")
|
||||
null
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package org.thoughtcrime.securesms.groups;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public final class ParcelableGroupId implements Parcelable {
|
||||
|
||||
private final GroupId groupId;
|
||||
|
||||
public static ParcelableGroupId from(@Nullable GroupId groupId) {
|
||||
return new ParcelableGroupId(groupId);
|
||||
}
|
||||
|
||||
public static @Nullable GroupId get(@Nullable ParcelableGroupId parcelableGroupId) {
|
||||
if (parcelableGroupId == null) {
|
||||
return null;
|
||||
}
|
||||
return parcelableGroupId.groupId;
|
||||
}
|
||||
|
||||
ParcelableGroupId(@Nullable GroupId groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (groupId != null) {
|
||||
dest.writeString(groupId.toString());
|
||||
} else {
|
||||
dest.writeString(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<ParcelableGroupId> CREATOR = new Creator<ParcelableGroupId>() {
|
||||
@Override
|
||||
public ParcelableGroupId createFromParcel(Parcel in) {
|
||||
return new ParcelableGroupId(GroupId.parseNullableOrThrow(in.readString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelableGroupId[] newArray(int size) {
|
||||
return new ParcelableGroupId[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.LiveGroup;
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId;
|
||||
import org.thoughtcrime.securesms.groups.v2.GroupDescriptionUtil;
|
||||
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
||||
|
||||
@@ -46,7 +45,7 @@ public final class GroupDescriptionDialog extends DialogFragment {
|
||||
|
||||
private static void show(@NonNull FragmentManager fragmentManager, @Nullable GroupId groupId, @Nullable String title, @Nullable String description, boolean linkify) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelable(ARGUMENT_GROUP_ID, ParcelableGroupId.from(groupId));
|
||||
arguments.putParcelable(ARGUMENT_GROUP_ID, groupId);
|
||||
arguments.putString(ARGUMENT_TITLE, title);
|
||||
arguments.putString(ARGUMENT_DESCRIPTION, description);
|
||||
arguments.putBoolean(ARGUMENT_LINKIFY, linkify);
|
||||
@@ -62,7 +61,7 @@ public final class GroupDescriptionDialog extends DialogFragment {
|
||||
View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.group_description_dialog, null, false);
|
||||
String argumentTitle = requireArguments().getString(ARGUMENT_TITLE, null);
|
||||
String argumentDescription = requireArguments().getString(ARGUMENT_DESCRIPTION, null);
|
||||
GroupId argumentGroupId = ParcelableGroupId.get(requireArguments().getParcelable(ARGUMENT_GROUP_ID));
|
||||
GroupId argumentGroupId = requireArguments().getParcelable(ARGUMENT_GROUP_ID);
|
||||
boolean linkify = requireArguments().getBoolean(ARGUMENT_LINKIFY, false);
|
||||
LiveGroup liveGroup = argumentGroupId != null ? new LiveGroup(argumentGroupId) : null;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.text.InputType;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -33,7 +32,6 @@ import org.thoughtcrime.securesms.avatar.Avatars;
|
||||
import org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment;
|
||||
import org.thoughtcrime.securesms.databinding.CreateProfileFragmentBinding;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId;
|
||||
import org.thoughtcrime.securesms.keyvalue.PhoneNumberPrivacyValues;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.mediasend.Media;
|
||||
@@ -306,8 +304,7 @@ public class CreateProfileFragment extends LoggingFragment {
|
||||
|
||||
private void startAvatarSelection() {
|
||||
if (viewModel.isGroup()) {
|
||||
Parcelable groupId = ParcelableGroupId.from(viewModel.getGroupId());
|
||||
SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), CreateProfileFragmentDirections.actionCreateProfileFragmentToAvatarPicker((ParcelableGroupId) groupId, viewModel.getAvatarMedia()));
|
||||
SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), CreateProfileFragmentDirections.actionCreateProfileFragmentToAvatarPicker(viewModel.getGroupId(), viewModel.getAvatarMedia()));
|
||||
} else {
|
||||
SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), CreateProfileFragmentDirections.actionCreateProfileFragmentToAvatarPicker(null, null));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.LiveGroup
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.util.livedata.Store
|
||||
|
||||
/**
|
||||
@@ -38,9 +37,9 @@ class GroupStorySettingsViewModel(private val groupId: GroupId) : ViewModel() {
|
||||
return repository.getConversationData(groupId).observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
class Factory(private val parcelableGroupId: ParcelableGroupId) : ViewModelProvider.Factory {
|
||||
class Factory(private val groupId: GroupId) : ViewModelProvider.Factory {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return modelClass.cast(GroupStorySettingsViewModel(ParcelableGroupId.get(parcelableGroupId)!!)) as T
|
||||
return modelClass.cast(GroupStorySettingsViewModel(groupId)) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchAdapter
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchPagedDataSourceRepository
|
||||
import org.thoughtcrime.securesms.groups.ParcelableGroupId
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.mediasend.v2.stories.ChooseGroupStoryBottomSheet
|
||||
import org.thoughtcrime.securesms.mediasend.v2.stories.ChooseStoryTypeBottomSheet
|
||||
@@ -71,7 +70,7 @@ class StoriesPrivacySettingsFragment :
|
||||
storyListener = { _, story, _ ->
|
||||
when {
|
||||
story.recipient.isMyStory -> findNavController().safeNavigate(StoriesPrivacySettingsFragmentDirections.actionStoryPrivacySettingsToMyStorySettings())
|
||||
story.recipient.isGroup -> findNavController().safeNavigate(StoriesPrivacySettingsFragmentDirections.actionStoryPrivacySettingsToGroupStorySettings(ParcelableGroupId.from(story.recipient.requireGroupId())))
|
||||
story.recipient.isGroup -> findNavController().safeNavigate(StoriesPrivacySettingsFragmentDirections.actionStoryPrivacySettingsToGroupStorySettings(story.recipient.requireGroupId()))
|
||||
else -> findNavController().safeNavigate(StoriesPrivacySettingsFragmentDirections.actionStoryPrivacySettingsToPrivateStorySettings(story.recipient.requireDistributionListId()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="true" />
|
||||
|
||||
<argument
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="true" />
|
||||
|
||||
<argument
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim">
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="true" />
|
||||
|
||||
<argument
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="true" />
|
||||
|
||||
<argument
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="false" />
|
||||
</action>
|
||||
</fragment>
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
<argument
|
||||
android:name="group_id"
|
||||
app:argType="org.thoughtcrime.securesms.groups.ParcelableGroupId"
|
||||
app:argType="org.thoughtcrime.securesms.groups.GroupId"
|
||||
app:nullable="false" />
|
||||
|
||||
</fragment>
|
||||
|
||||
Reference in New Issue
Block a user