mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Merge branch '742-use-unique-request-ids-across-the-app' into 'master'
Use unique request codes across the app Closes #742 See merge request !470
This commit is contained in:
@@ -28,6 +28,7 @@ import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
||||
|
||||
@SuppressLint("Registered")
|
||||
public abstract class BriarActivity extends BaseActivity {
|
||||
@@ -36,8 +37,6 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
public static final String GROUP_ID = "briar.GROUP_ID";
|
||||
public static final String GROUP_NAME = "briar.GROUP_NAME";
|
||||
|
||||
public static final int REQUEST_PASSWORD = 1;
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarActivity.class.getName());
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.briarproject.briar.android.activity;
|
||||
|
||||
public interface RequestCodes {
|
||||
|
||||
int REQUEST_PASSWORD = 1;
|
||||
int REQUEST_BLUETOOTH = 2;
|
||||
int REQUEST_INTRODUCTION = 3;
|
||||
int REQUEST_GROUP_INVITE = 4;
|
||||
int REQUEST_SHARE_FORUM = 5;
|
||||
int REQUEST_WRITE_BLOG_POST = 6;
|
||||
int REQUEST_SHARE_BLOG = 7;
|
||||
int REQUEST_RINGTONE = 8;
|
||||
|
||||
}
|
||||
@@ -22,9 +22,6 @@ import javax.inject.Inject;
|
||||
public class BlogActivity extends BriarActivity
|
||||
implements BaseFragmentListener {
|
||||
|
||||
static final int REQUEST_WRITE_POST = 2;
|
||||
static final int REQUEST_SHARE = 3;
|
||||
|
||||
@Inject
|
||||
BlogController blogController;
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_SHARE;
|
||||
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_WRITE_POST;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_SHARE_BLOG;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_WRITE_BLOG_POST;
|
||||
import static org.briarproject.briar.android.controller.SharingController.SharingListener;
|
||||
|
||||
@UiThread
|
||||
@@ -145,13 +145,13 @@ public class BlogFragment extends BaseFragment
|
||||
Intent i = new Intent(getActivity(),
|
||||
WriteBlogPostActivity.class);
|
||||
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||
startActivityForResult(i, REQUEST_WRITE_POST);
|
||||
startActivityForResult(i, REQUEST_WRITE_BLOG_POST);
|
||||
return true;
|
||||
case R.id.action_blog_share:
|
||||
Intent i2 = new Intent(getActivity(), ShareBlogActivity.class);
|
||||
i2.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
|
||||
i2.putExtra(GROUP_ID, groupId.getBytes());
|
||||
startActivityForResult(i2, REQUEST_SHARE);
|
||||
startActivityForResult(i2, REQUEST_SHARE_BLOG);
|
||||
return true;
|
||||
case R.id.action_blog_sharing_status:
|
||||
Intent i3 = new Intent(getActivity(),
|
||||
@@ -172,10 +172,10 @@ public class BlogFragment extends BaseFragment
|
||||
public void onActivityResult(int request, int result, Intent data) {
|
||||
super.onActivityResult(request, result, data);
|
||||
|
||||
if (request == REQUEST_WRITE_POST && result == RESULT_OK) {
|
||||
if (request == REQUEST_WRITE_BLOG_POST && result == RESULT_OK) {
|
||||
displaySnackbar(R.string.blogs_blog_post_created, true);
|
||||
loadBlogPosts(true);
|
||||
} else if (request == REQUEST_SHARE && result == RESULT_OK) {
|
||||
} else if (request == REQUEST_SHARE_BLOG && result == RESULT_OK) {
|
||||
displaySnackbar(R.string.blogs_sharing_snackbar, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import javax.inject.Inject;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_WRITE_POST;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_WRITE_BLOG_POST;
|
||||
|
||||
@UiThread
|
||||
@MethodsNotNullByDefault
|
||||
@@ -96,7 +96,7 @@ public class FeedFragment extends BaseFragment implements
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
// The BlogPostAddedEvent arrives when the controller is not listening
|
||||
if (requestCode == REQUEST_WRITE_POST && resultCode == RESULT_OK) {
|
||||
if (requestCode == REQUEST_WRITE_BLOG_POST && resultCode == RESULT_OK) {
|
||||
showSnackBar(R.string.blogs_blog_post_created);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class FeedFragment extends BaseFragment implements
|
||||
Intent i1 =
|
||||
new Intent(getActivity(), WriteBlogPostActivity.class);
|
||||
i1.putExtra(GROUP_ID, personalBlog.getId().getBytes());
|
||||
startActivityForResult(i1, REQUEST_WRITE_POST);
|
||||
startActivityForResult(i1, REQUEST_WRITE_BLOG_POST);
|
||||
return true;
|
||||
case R.id.action_rss_feeds_import:
|
||||
Intent i2 =
|
||||
|
||||
@@ -103,6 +103,7 @@ import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_INTRODUCTION;
|
||||
import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_NAMESPACE;
|
||||
import static org.briarproject.briar.android.util.UiUtils.getAvatarTransitionName;
|
||||
import static org.briarproject.briar.android.util.UiUtils.getBulbTransitionName;
|
||||
@@ -117,7 +118,6 @@ public class ConversationActivity extends BriarActivity
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
private static final int REQUEST_CODE_INTRODUCTION = 2;
|
||||
private static final String SHOW_ONBOARDING_INTRODUCTION =
|
||||
"showOnboardingIntroduction";
|
||||
|
||||
@@ -209,7 +209,7 @@ public class ConversationActivity extends BriarActivity
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
super.onActivityResult(request, result, data);
|
||||
|
||||
if (request == REQUEST_CODE_INTRODUCTION && result == RESULT_OK) {
|
||||
if (request == REQUEST_INTRODUCTION && result == RESULT_OK) {
|
||||
Snackbar snackbar = Snackbar.make(list, R.string.introduction_sent,
|
||||
Snackbar.LENGTH_SHORT);
|
||||
snackbar.getView().setBackgroundResource(R.color.briar_primary);
|
||||
@@ -259,7 +259,7 @@ public class ConversationActivity extends BriarActivity
|
||||
if (contactId == null) return false;
|
||||
Intent intent = new Intent(this, IntroductionActivity.class);
|
||||
intent.putExtra(CONTACT_ID, contactId.getInt());
|
||||
startActivityForResult(intent, REQUEST_CODE_INTRODUCTION);
|
||||
startActivityForResult(intent, REQUEST_INTRODUCTION);
|
||||
return true;
|
||||
case R.id.action_social_remove_person:
|
||||
askToRemoveContact();
|
||||
|
||||
@@ -37,6 +37,7 @@ import javax.inject.Inject;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_SHARE_FORUM;
|
||||
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_POST_BODY_LENGTH;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@@ -45,8 +46,6 @@ public class ForumActivity extends
|
||||
ThreadListActivity<Forum, ThreadItemAdapter<ForumItem>, ForumItem, ForumPostHeader>
|
||||
implements ForumListener {
|
||||
|
||||
private static final int REQUEST_FORUM_SHARED = 3;
|
||||
|
||||
@Inject
|
||||
ForumController forumController;
|
||||
|
||||
@@ -107,7 +106,7 @@ public class ForumActivity extends
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
super.onActivityResult(request, result, data);
|
||||
|
||||
if (request == REQUEST_FORUM_SHARED && result == RESULT_OK) {
|
||||
if (request == REQUEST_SHARE_FORUM && result == RESULT_OK) {
|
||||
displaySnackbarShort(R.string.forum_shared_snackbar);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +131,7 @@ public class ForumActivity extends
|
||||
Intent i2 = new Intent(this, ShareForumActivity.class);
|
||||
i2.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
|
||||
i2.putExtra(GROUP_ID, groupId.getBytes());
|
||||
startActivityForResult(i2, REQUEST_FORUM_SHARED);
|
||||
startActivityForResult(i2, REQUEST_SHARE_FORUM);
|
||||
return true;
|
||||
case R.id.action_forum_sharing_status:
|
||||
Intent i3 = new Intent(this, ForumSharingStatusActivity.class);
|
||||
|
||||
@@ -25,6 +25,7 @@ import javax.inject.Inject;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_BLUETOOTH;
|
||||
import static org.briarproject.briar.android.invitation.ConfirmationCodeView.ConfirmationState.CONNECTED;
|
||||
import static org.briarproject.briar.android.invitation.ConfirmationCodeView.ConfirmationState.DETAILS;
|
||||
import static org.briarproject.briar.android.invitation.ConfirmationCodeView.ConfirmationState.WAIT_FOR_CONTACT;
|
||||
@@ -32,8 +33,6 @@ import static org.briarproject.briar.android.invitation.ConfirmationCodeView.Con
|
||||
public class AddContactActivity extends BriarActivity
|
||||
implements InvitationListener {
|
||||
|
||||
static final int REQUEST_BLUETOOTH = 1;
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AddContactActivity.class.getName());
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.briarproject.briar.R;
|
||||
|
||||
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
||||
import static org.briarproject.briar.android.invitation.AddContactActivity.REQUEST_BLUETOOTH;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_BLUETOOTH;
|
||||
|
||||
class ChooseIdentityView extends AddContactView implements OnClickListener {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.briarproject.briar.R;
|
||||
|
||||
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
||||
import static org.briarproject.briar.android.invitation.AddContactActivity.REQUEST_BLUETOOTH;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_BLUETOOTH;
|
||||
|
||||
class ErrorView extends AddContactView implements OnClickListener {
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_GROUP_INVITE;
|
||||
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_BODY_LENGTH;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@@ -46,8 +47,6 @@ public class GroupActivity extends
|
||||
ThreadListActivity<PrivateGroup, GroupMessageAdapter, GroupMessageItem, GroupMessageHeader>
|
||||
implements GroupListener, OnClickListener {
|
||||
|
||||
private final static int REQUEST_INVITE = 2;
|
||||
|
||||
@Inject
|
||||
GroupController controller;
|
||||
|
||||
@@ -176,7 +175,7 @@ public class GroupActivity extends
|
||||
case R.id.action_group_invite:
|
||||
Intent i3 = new Intent(this, GroupInviteActivity.class);
|
||||
i3.putExtra(GROUP_ID, groupId.getBytes());
|
||||
startActivityForResult(i3, REQUEST_INVITE);
|
||||
startActivityForResult(i3, REQUEST_GROUP_INVITE);
|
||||
return true;
|
||||
case R.id.action_group_leave:
|
||||
showLeaveGroupDialog();
|
||||
@@ -190,7 +189,7 @@ public class GroupActivity extends
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
if (request == REQUEST_INVITE && result == RESULT_OK) {
|
||||
if (request == REQUEST_GROUP_INVITE && result == RESULT_OK) {
|
||||
displaySnackbarShort(R.string.groups_invitation_sent);
|
||||
} else super.onActivityResult(request, result, data);
|
||||
}
|
||||
|
||||
@@ -45,13 +45,13 @@ import static android.media.RingtoneManager.TYPE_NOTIFICATION;
|
||||
import static android.provider.Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_RINGTONE;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class SettingsFragment extends PreferenceFragmentCompat
|
||||
implements EventListener, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final int REQUEST_RINGTONE = 2;
|
||||
public static final String SETTINGS_NAMESPACE = "android-ui";
|
||||
public static final String PREF_NOTIFY_GROUP = "notifyGroupMessages";
|
||||
public static final String PREF_NOTIFY_BLOG = "notifyBlogPosts";
|
||||
|
||||
Reference in New Issue
Block a user