-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef0f26b
commit 1290d0e
Showing
17 changed files
with
699 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/org/thoughtcrime/securesms/groups/GroupProtoUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.thoughtcrime.securesms.groups; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.WorkerThread; | ||
|
||
import com.google.protobuf.ByteString; | ||
|
||
import org.signal.storageservice.protos.groups.local.DecryptedPendingMember; | ||
import org.signal.zkgroup.util.UUIDUtil; | ||
import org.thoughtcrime.securesms.recipients.Recipient; | ||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations; | ||
|
||
import java.util.UUID; | ||
|
||
public final class GroupProtoUtil { | ||
|
||
private GroupProtoUtil() { | ||
} | ||
|
||
@WorkerThread | ||
public static Recipient pendingMemberToRecipient(@NonNull Context context, @NonNull DecryptedPendingMember pendingMember) { | ||
return uuidByteStringToRecipient(context, pendingMember.getUuid()); | ||
} | ||
|
||
@WorkerThread | ||
public static Recipient uuidByteStringToRecipient(@NonNull Context context, @NonNull ByteString uuidByteString) { | ||
UUID uuid = UUIDUtil.deserialize(uuidByteString.toByteArray()); | ||
|
||
if (uuid.equals(GroupsV2Operations.UNKNOWN_UUID)) { | ||
return Recipient.UNKNOWN; | ||
} | ||
|
||
return Recipient.externalPush(context, uuid, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...g/thoughtcrime/securesms/groups/ui/pendingmemberinvites/PendingMemberInvitesActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.thoughtcrime.securesms.groups.ui.pendingmemberinvites; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.widget.Toolbar; | ||
|
||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; | ||
import org.thoughtcrime.securesms.R; | ||
import org.thoughtcrime.securesms.groups.GroupId; | ||
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme; | ||
import org.thoughtcrime.securesms.util.DynamicTheme; | ||
|
||
public class PendingMemberInvitesActivity extends PassphraseRequiredActionBarActivity { | ||
|
||
private static final String GROUP_ID = "GROUP_ID"; | ||
|
||
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme(); | ||
|
||
public static Intent newIntent(@NonNull Context context, @NonNull GroupId.V2 groupId) { | ||
Intent intent = new Intent(context, PendingMemberInvitesActivity.class); | ||
intent.putExtra(GROUP_ID, groupId.toString()); | ||
return intent; | ||
} | ||
|
||
@Override | ||
protected void onPreCreate() { | ||
dynamicTheme.onCreate(this); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState, boolean ready) { | ||
super.onCreate(savedInstanceState, ready); | ||
setContentView(R.layout.group_pending_member_invites_activity); | ||
|
||
if (savedInstanceState == null) { | ||
getSupportFragmentManager().beginTransaction() | ||
.replace(R.id.container, PendingMemberInvitesFragment.newInstance(GroupId.parse(getIntent().getStringExtra(GROUP_ID)).requireV2())) | ||
.commitNow(); | ||
} | ||
|
||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
dynamicTheme.onResume(this); | ||
} | ||
|
||
@Override | ||
public boolean onSupportNavigateUp() { | ||
onBackPressed(); | ||
return true; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...g/thoughtcrime/securesms/groups/ui/pendingmemberinvites/PendingMemberInvitesFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.thoughtcrime.securesms.groups.ui.pendingmemberinvites; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.lifecycle.ViewModelProviders; | ||
|
||
import org.thoughtcrime.securesms.R; | ||
import org.thoughtcrime.securesms.groups.GroupId; | ||
import org.thoughtcrime.securesms.groups.ui.GroupMemberListView; | ||
|
||
import java.util.Objects; | ||
|
||
public class PendingMemberInvitesFragment extends Fragment { | ||
|
||
private static final String GROUP_ID = "GROUP_ID"; | ||
|
||
private PendingMemberInvitesViewModel viewModel; | ||
private GroupMemberListView youInvited; | ||
private GroupMemberListView othersInvited; | ||
private View youInvitedEmptyState; | ||
private View othersInvitedEmptyState; | ||
|
||
public static PendingMemberInvitesFragment newInstance(@NonNull GroupId.V2 groupId) { | ||
PendingMemberInvitesFragment fragment = new PendingMemberInvitesFragment(); | ||
Bundle args = new Bundle(); | ||
|
||
args.putString(GROUP_ID, groupId.toString()); | ||
fragment.setArguments(args); | ||
|
||
return fragment; | ||
} | ||
|
||
@Override | ||
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
View view = inflater.inflate(R.layout.group_pending_member_invites_fragment, container, false); | ||
|
||
youInvited = view.findViewById(R.id.members_you_invited); | ||
othersInvited = view.findViewById(R.id.members_others_invited); | ||
youInvitedEmptyState = view.findViewById(R.id.no_pending_from_you); | ||
othersInvitedEmptyState = view.findViewById(R.id.no_pending_from_others); | ||
|
||
return view; | ||
} | ||
|
||
@Override | ||
public void onActivityCreated(@Nullable Bundle savedInstanceState) { | ||
super.onActivityCreated(savedInstanceState); | ||
|
||
GroupId.V2 groupId = GroupId.parse(Objects.requireNonNull(requireArguments().getString(GROUP_ID))).requireV2(); | ||
|
||
PendingMemberInvitesViewModel.Factory factory = new PendingMemberInvitesViewModel.Factory(requireContext(), groupId); | ||
|
||
viewModel = ViewModelProviders.of(requireActivity(), factory).get(PendingMemberInvitesViewModel.class); | ||
|
||
viewModel.getWhoYouInvited().observe(getViewLifecycleOwner(), invitees -> { | ||
youInvited.setMembers(invitees); | ||
youInvitedEmptyState.setVisibility(invitees.isEmpty() ? View.VISIBLE : View.GONE); | ||
}); | ||
|
||
viewModel.getWhoOthersInvited().observe(getViewLifecycleOwner(), invitees -> { | ||
othersInvited.setMembers(invitees); | ||
othersInvitedEmptyState.setVisibility(invitees.isEmpty() ? View.VISIBLE : View.GONE); | ||
}); | ||
} | ||
} |
Oops, something went wrong.