-
-
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.
Add 'Add to a group' button to bottom sheet.
- Loading branch information
1 parent
7e934ef
commit e1bb773
Showing
17 changed files
with
505 additions
and
37 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
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
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
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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/org/thoughtcrime/securesms/groups/ui/addtogroup/AddToGroupRepository.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,59 @@ | ||
package org.thoughtcrime.securesms.groups.ui.addtogroup; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; | ||
import org.thoughtcrime.securesms.groups.GroupChangeBusyException; | ||
import org.thoughtcrime.securesms.groups.GroupChangeFailedException; | ||
import org.thoughtcrime.securesms.groups.GroupId; | ||
import org.thoughtcrime.securesms.groups.GroupInsufficientRightsException; | ||
import org.thoughtcrime.securesms.groups.GroupManager; | ||
import org.thoughtcrime.securesms.groups.GroupNotAMemberException; | ||
import org.thoughtcrime.securesms.groups.MembershipNotSuitableForV2Exception; | ||
import org.thoughtcrime.securesms.groups.ui.GroupChangeErrorCallback; | ||
import org.thoughtcrime.securesms.groups.ui.GroupChangeFailureReason; | ||
import org.thoughtcrime.securesms.logging.Log; | ||
import org.thoughtcrime.securesms.recipients.Recipient; | ||
import org.thoughtcrime.securesms.recipients.RecipientId; | ||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
final class AddToGroupRepository { | ||
|
||
private static final String TAG = Log.tag(AddToGroupRepository.class); | ||
|
||
private final Context context; | ||
|
||
AddToGroupRepository() { | ||
this.context = ApplicationDependencies.getApplication(); | ||
} | ||
|
||
public void add(@NonNull RecipientId recipientId, | ||
@NonNull Recipient groupRecipient, | ||
@NonNull GroupChangeErrorCallback error, | ||
@NonNull Runnable success) | ||
{ | ||
SignalExecutors.UNBOUNDED.execute(() -> { | ||
try { | ||
GroupId.Push pushGroupId = groupRecipient.requireGroupId().requirePush(); | ||
|
||
GroupManager.addMembers(context, pushGroupId, Collections.singletonList(recipientId)); | ||
|
||
success.run(); | ||
} catch (GroupInsufficientRightsException | GroupNotAMemberException e) { | ||
Log.w(TAG, e); | ||
error.onError(GroupChangeFailureReason.NO_RIGHTS); | ||
} catch (GroupChangeFailedException | GroupChangeBusyException | IOException e) { | ||
Log.w(TAG, e); | ||
error.onError(GroupChangeFailureReason.OTHER); | ||
} catch (MembershipNotSuitableForV2Exception e) { | ||
Log.w(TAG, e); | ||
error.onError(GroupChangeFailureReason.NOT_CAPABLE); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.