mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Null safety cleanups.
This commit is contained in:
@@ -70,6 +70,7 @@ import static android.support.v4.app.NotificationCompat.PRIORITY_LOW;
|
||||
import static android.support.v4.app.NotificationCompat.PRIORITY_MIN;
|
||||
import static android.support.v4.app.NotificationCompat.VISIBILITY_SECRET;
|
||||
import static android.support.v4.content.ContextCompat.getColor;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
|
||||
import static org.briarproject.bramble.util.StringUtils.toHexString;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
@@ -119,8 +120,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
||||
this.androidExecutor = androidExecutor;
|
||||
this.clock = clock;
|
||||
appContext = app.getApplicationContext();
|
||||
notificationManager = (NotificationManager)
|
||||
appContext.getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager = (NotificationManager) requireNonNull(
|
||||
appContext.getSystemService(NOTIFICATION_SERVICE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,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.os.Build.VERSION.SDK_INT;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
||||
@@ -177,8 +178,8 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
b.setNegativeButton(R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss());
|
||||
b.setOnDismissListener(dialog -> {
|
||||
CheckBox checkBox =
|
||||
((AlertDialog) dialog).findViewById(R.id.checkbox);
|
||||
CheckBox checkBox = requireNonNull(
|
||||
((AlertDialog) dialog).findViewById(R.id.checkbox));
|
||||
if (checkBox.isChecked())
|
||||
briarController.doNotAskAgainForDozeWhiteListing();
|
||||
});
|
||||
|
||||
@@ -221,7 +221,6 @@ abstract class BaseControllerImpl extends DbControllerImpl
|
||||
text = HtmlUtils.clean(blogManager.getPostText(m), ARTICLE);
|
||||
textCache.put(m, text);
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,13 +92,11 @@ public class BlogFragment extends BaseFragment
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
Bundle args = requireNonNull(getArguments());
|
||||
byte[] b = args.getByteArray(GROUP_ID);
|
||||
if (b == null) throw new IllegalStateException("No group ID in args");
|
||||
groupId = new GroupId(b);
|
||||
groupId = new GroupId(requireNonNull(args.getByteArray(GROUP_ID)));
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_blog, container, false);
|
||||
|
||||
adapter = new BlogPostAdapter(requireNonNull(getActivity()), this,
|
||||
adapter = new BlogPostAdapter(requireActivity(), this,
|
||||
getFragmentManager());
|
||||
list = v.findViewById(R.id.postList);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
@@ -269,7 +267,7 @@ public class BlogFragment extends BaseFragment
|
||||
}
|
||||
|
||||
private void setToolbarTitle(Author a) {
|
||||
getActivity().setTitle(a.getName());
|
||||
requireActivity().setTitle(a.getName());
|
||||
}
|
||||
|
||||
private void loadSharedContacts() {
|
||||
@@ -311,7 +309,7 @@ public class BlogFragment extends BaseFragment
|
||||
|
||||
private void setToolbarSubTitle(int total, int online) {
|
||||
ActionBar actionBar =
|
||||
((BriarActivity) getActivity()).getSupportActionBar();
|
||||
((BriarActivity) requireActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setSubtitle(
|
||||
getString(R.string.shared_with, total, online));
|
||||
@@ -336,9 +334,8 @@ public class BlogFragment extends BaseFragment
|
||||
snackbar.getView().setBackgroundResource(R.color.briar_primary);
|
||||
if (scroll) {
|
||||
View.OnClickListener onClick = v -> list.smoothScrollToPosition(0);
|
||||
snackbar.setActionTextColor(ContextCompat
|
||||
.getColor(getContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
snackbar.setActionTextColor(ContextCompat.getColor(requireContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
snackbar.setAction(R.string.blogs_blog_post_scroll_to, onClick);
|
||||
}
|
||||
snackbar.show();
|
||||
@@ -347,7 +344,7 @@ public class BlogFragment extends BaseFragment
|
||||
private void showDeleteDialog() {
|
||||
DialogInterface.OnClickListener okListener =
|
||||
(dialog, which) -> deleteBlog();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(),
|
||||
R.style.BriarDialogTheme);
|
||||
builder.setTitle(getString(R.string.blogs_remove_blog));
|
||||
builder.setMessage(
|
||||
@@ -362,7 +359,7 @@ public class BlogFragment extends BaseFragment
|
||||
new UiResultExceptionHandler<Void, DbException>(this) {
|
||||
@Override
|
||||
public void onResultUi(Void result) {
|
||||
Toast.makeText(getActivity(),
|
||||
Toast.makeText(requireActivity(),
|
||||
R.string.blogs_blog_removed, LENGTH_SHORT)
|
||||
.show();
|
||||
finish();
|
||||
|
||||
@@ -35,7 +35,6 @@ import javax.inject.Inject;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_WRITE_BLOG_POST;
|
||||
@@ -78,14 +77,14 @@ public class FeedFragment extends BaseFragment implements
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
requireNonNull(getActivity()).setTitle(R.string.blogs_button);
|
||||
requireActivity().setTitle(R.string.blogs_button);
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_blog, container, false);
|
||||
|
||||
adapter =
|
||||
new BlogPostAdapter(getActivity(), this, getFragmentManager());
|
||||
adapter = new BlogPostAdapter(requireActivity(), this,
|
||||
getFragmentManager());
|
||||
|
||||
layoutManager = new LinearLayoutManager(getActivity());
|
||||
layoutManager = new LinearLayoutManager(requireActivity());
|
||||
list = v.findViewById(R.id.postList);
|
||||
list.setLayoutManager(layoutManager);
|
||||
list.setAdapter(adapter);
|
||||
@@ -176,19 +175,19 @@ public class FeedFragment extends BaseFragment implements
|
||||
if (personalBlog == null) return false;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_write_blog_post:
|
||||
Intent i1 =
|
||||
new Intent(getActivity(), WriteBlogPostActivity.class);
|
||||
Intent i1 = new Intent(requireActivity(),
|
||||
WriteBlogPostActivity.class);
|
||||
i1.putExtra(GROUP_ID, personalBlog.getId().getBytes());
|
||||
startActivityForResult(i1, REQUEST_WRITE_BLOG_POST);
|
||||
return true;
|
||||
case R.id.action_rss_feeds_import:
|
||||
Intent i2 =
|
||||
new Intent(getActivity(), RssFeedImportActivity.class);
|
||||
Intent i2 = new Intent(requireActivity(),
|
||||
RssFeedImportActivity.class);
|
||||
startActivity(i2);
|
||||
return true;
|
||||
case R.id.action_rss_feeds_manage:
|
||||
Intent i3 =
|
||||
new Intent(getActivity(), RssFeedManageActivity.class);
|
||||
Intent i3 = new Intent(requireActivity(),
|
||||
RssFeedManageActivity.class);
|
||||
i3.putExtra(GROUP_ID, personalBlog.getId().getBytes());
|
||||
startActivity(i3);
|
||||
return true;
|
||||
@@ -230,10 +229,11 @@ public class FeedFragment extends BaseFragment implements
|
||||
|
||||
@Override
|
||||
public void onAuthorClick(BlogPostItem post) {
|
||||
if (getContext() == null) return;
|
||||
Intent i = new Intent(getContext(), BlogActivity.class);
|
||||
i.putExtra(GROUP_ID, post.getGroupId().getBytes());
|
||||
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
||||
getContext().startActivity(i);
|
||||
requireContext().startActivity(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,9 +252,8 @@ public class FeedFragment extends BaseFragment implements
|
||||
s.getView().setBackgroundResource(R.color.briar_primary);
|
||||
if (scroll) {
|
||||
OnClickListener onClick = v -> list.smoothScrollToPosition(0);
|
||||
s.setActionTextColor(ContextCompat
|
||||
.getColor(getContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
s.setActionTextColor(ContextCompat.getColor(requireContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
s.setAction(R.string.blogs_blog_post_scroll_to, onClick);
|
||||
}
|
||||
s.show();
|
||||
|
||||
@@ -2,8 +2,11 @@ package org.briarproject.briar.android.blog;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.R;
|
||||
@@ -13,11 +16,13 @@ import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener
|
||||
|
||||
import static org.briarproject.briar.android.blog.BasePostFragment.POST_ID;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class ReblogActivity extends BriarActivity implements
|
||||
BaseFragmentListener {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
@@ -51,7 +51,6 @@ import javax.inject.Inject;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeSceneTransitionAnimation;
|
||||
import static android.support.v4.view.ViewCompat.getTransitionName;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||
@@ -106,13 +105,13 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
requireNonNull(getActivity()).setTitle(R.string.contact_list_button);
|
||||
requireActivity().setTitle(R.string.contact_list_button);
|
||||
|
||||
View contentView = inflater.inflate(R.layout.list, container, false);
|
||||
|
||||
OnContactClickListener<ContactListItem> onContactClickListener =
|
||||
(view, item) -> {
|
||||
Intent i = new Intent(getActivity(),
|
||||
Intent i = new Intent(requireActivity(),
|
||||
ConversationActivity.class);
|
||||
ContactId contactId = item.getContact().getId();
|
||||
i.putExtra(CONTACT_ID, contactId.getInt());
|
||||
@@ -130,16 +129,17 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
Pair.create(holder.bulb,
|
||||
getTransitionName(holder.bulb));
|
||||
ActivityOptionsCompat options =
|
||||
makeSceneTransitionAnimation(getActivity(),
|
||||
makeSceneTransitionAnimation(requireActivity(),
|
||||
avatar, bulb);
|
||||
ActivityCompat.startActivity(getActivity(), i,
|
||||
ActivityCompat.startActivity(requireActivity(), i,
|
||||
options.toBundle());
|
||||
} else {
|
||||
// work-around for android bug #224270
|
||||
startActivity(i);
|
||||
}
|
||||
};
|
||||
adapter = new ContactListAdapter(getContext(), onContactClickListener);
|
||||
adapter = new ContactListAdapter(requireContext(),
|
||||
onContactClickListener);
|
||||
list = contentView.findViewById(R.id.list);
|
||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
list.setAdapter(adapter);
|
||||
@@ -161,8 +161,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
||||
// Handle presses on the action bar items
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add_contact:
|
||||
Intent intent =
|
||||
new Intent(getContext(), ContactExchangeActivity.class);
|
||||
Intent intent = new Intent(requireContext(),
|
||||
ContactExchangeActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
default:
|
||||
|
||||
@@ -69,11 +69,11 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
||||
View contentView = inflater.inflate(R.layout.list, container, false);
|
||||
|
||||
list = contentView.findViewById(R.id.list);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
list.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_contact_list);
|
||||
list.setEmptyText(getString(R.string.no_contacts_selector));
|
||||
list.setEmptyAction(getString(R.string.no_contacts_selector_action));
|
||||
adapter = getAdapter(requireNonNull(getContext()), this);
|
||||
adapter = getAdapter(requireContext(), this);
|
||||
list.setAdapter(adapter);
|
||||
|
||||
// restore selected contacts if available
|
||||
|
||||
@@ -39,9 +39,8 @@ public class AliasDialogFragment extends AppCompatDialogFragment {
|
||||
|
||||
setStyle(STYLE_NO_TITLE, R.style.BriarDialogTheme);
|
||||
|
||||
BriarActivity a = (BriarActivity) requireNonNull(getActivity());
|
||||
a.getActivityComponent().inject(this);
|
||||
viewModel = ViewModelProviders.of(getActivity(), viewModelFactory)
|
||||
((BriarActivity) requireActivity()).getActivityComponent().inject(this);
|
||||
viewModel = ViewModelProviders.of(requireActivity(), viewModelFactory)
|
||||
.get(ConversationViewModel.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -502,7 +502,6 @@ public class ConversationActivity extends BriarActivity
|
||||
* <p>
|
||||
* Attention: Call this only after contactName has been initialized.
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private List<ConversationItem> createItems(
|
||||
Collection<ConversationMessageHeader> headers) {
|
||||
List<ConversationItem> items = new ArrayList<>(headers.size());
|
||||
|
||||
@@ -57,8 +57,7 @@ public class ImageFragment extends Fragment {
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
BaseActivity a = (BaseActivity) requireNonNull(getActivity());
|
||||
a.getActivityComponent().inject(this);
|
||||
((BaseActivity) requireActivity()).getActivityComponent().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,8 +77,8 @@ public class ImageFragment extends Fragment {
|
||||
View v = inflater.inflate(R.layout.fragment_image, container,
|
||||
false);
|
||||
|
||||
viewModel = ViewModelProviders.of(requireNonNull(getActivity()),
|
||||
viewModelFactory).get(ImageViewModel.class);
|
||||
viewModel = ViewModelProviders.of(requireActivity(), viewModelFactory)
|
||||
.get(ImageViewModel.class);
|
||||
|
||||
photoView = v.findViewById(R.id.photoView);
|
||||
photoView.setScaleLevels(1, 2, 4);
|
||||
|
||||
@@ -44,7 +44,6 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||
@@ -93,24 +92,23 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
requireNonNull(getActivity()).setTitle(R.string.forums_button);
|
||||
requireActivity().setTitle(R.string.forums_button);
|
||||
|
||||
View contentView =
|
||||
inflater.inflate(R.layout.fragment_forum_list, container,
|
||||
false);
|
||||
|
||||
adapter = new ForumListAdapter(getActivity());
|
||||
adapter = new ForumListAdapter(requireActivity());
|
||||
|
||||
list = contentView.findViewById(R.id.forumList);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
list.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
snackbar = Snackbar.make(list, "", LENGTH_INDEFINITE);
|
||||
snackbar.getView().setBackgroundResource(R.color.briar_primary);
|
||||
snackbar.setAction(R.string.show, this);
|
||||
snackbar.setActionTextColor(ContextCompat
|
||||
.getColor(getActivity(), R.color.briar_button_text_positive));
|
||||
snackbar.setActionTextColor(ContextCompat.getColor(requireContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
|
||||
return contentView;
|
||||
}
|
||||
@@ -148,8 +146,8 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
// Handle presses on the action bar items
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_create_forum:
|
||||
Intent intent =
|
||||
new Intent(getContext(), CreateForumActivity.class);
|
||||
Intent intent = new Intent(requireContext(),
|
||||
CreateForumActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
default:
|
||||
@@ -270,7 +268,7 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// snackbar click
|
||||
Intent i = new Intent(getContext(), ForumInvitationActivity.class);
|
||||
Intent i = new Intent(requireContext(), ForumInvitationActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.briarproject.briar.android.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
@@ -26,6 +25,8 @@ import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class ScreenFilterDialogFragment extends DialogFragment {
|
||||
@@ -58,26 +59,20 @@ public class ScreenFilterDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) throw new IllegalStateException();
|
||||
((BaseActivity) activity).getActivityComponent().inject(this);
|
||||
((BaseActivity) requireActivity()).getActivityComponent().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) throw new IllegalStateException();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity,
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(),
|
||||
R.style.BriarDialogThemeNoFilter);
|
||||
builder.setTitle(R.string.screen_filter_title);
|
||||
Bundle args = getArguments();
|
||||
if (args == null) throw new IllegalStateException();
|
||||
ArrayList<String> appNames = args.getStringArrayList("appNames");
|
||||
Bundle args = requireNonNull(getArguments());
|
||||
ArrayList<String> appNames =
|
||||
requireNonNull(args.getStringArrayList("appNames"));
|
||||
ArrayList<String> packageNames =
|
||||
args.getStringArrayList("packageNames");
|
||||
if (appNames == null || packageNames == null)
|
||||
throw new IllegalStateException();
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
requireNonNull(args.getStringArrayList("packageNames"));
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
// See https://stackoverflow.com/a/24720976/6314875
|
||||
@SuppressLint("InflateParams")
|
||||
View dialogView = inflater.inflate(R.layout.dialog_screen_filter, null);
|
||||
|
||||
@@ -76,7 +76,6 @@ public class ContactChooserFragment extends BaseFragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
View contentView = inflater.inflate(R.layout.list, container, false);
|
||||
|
||||
OnContactClickListener<ContactListItem> onContactClickListener =
|
||||
@@ -85,11 +84,11 @@ public class ContactChooserFragment extends BaseFragment {
|
||||
Contact c2 = item.getContact();
|
||||
showMessageScreen(c1, c2);
|
||||
};
|
||||
adapter = new ContactListAdapter(requireNonNull(getActivity()),
|
||||
adapter = new ContactListAdapter(requireActivity(),
|
||||
onContactClickListener);
|
||||
|
||||
list = contentView.findViewById(R.id.list);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
list.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
list.setAdapter(adapter);
|
||||
list.setEmptyText(R.string.no_contacts);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import static android.hardware.Camera.Parameters.FOCUS_MODE_MACRO;
|
||||
import static android.hardware.Camera.Parameters.SCENE_MODE_AUTO;
|
||||
import static android.hardware.Camera.Parameters.SCENE_MODE_BARCODE;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
@@ -127,7 +128,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
}
|
||||
setDisplayOrientation(getScreenRotationDegrees());
|
||||
// Use barcode scene mode if it's available
|
||||
Parameters params = camera.getParameters();
|
||||
Parameters params = requireNonNull(camera).getParameters();
|
||||
params = setSceneMode(camera, params);
|
||||
if (SCENE_MODE_BARCODE.equals(params.getSceneMode())) {
|
||||
// If the scene mode enabled the flash, try to disable it
|
||||
@@ -164,8 +165,9 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
* See {@link Camera#setDisplayOrientation(int)}.
|
||||
*/
|
||||
private int getScreenRotationDegrees() {
|
||||
WindowManager wm =
|
||||
(WindowManager) getContext().getSystemService(WINDOW_SERVICE);
|
||||
WindowManager wm = (WindowManager)
|
||||
getContext().getSystemService(WINDOW_SERVICE);
|
||||
if (wm == null) return 0;
|
||||
Display d = wm.getDefaultDisplay();
|
||||
switch (d.getRotation()) {
|
||||
case Surface.ROTATION_0:
|
||||
|
||||
@@ -71,9 +71,7 @@ public class ContactExchangeErrorFragment extends BaseFragment {
|
||||
|
||||
// buttons
|
||||
Button tryAgain = v.findViewById(R.id.tryAgainButton);
|
||||
tryAgain.setOnClickListener(view -> {
|
||||
if (getActivity() != null) getActivity().onBackPressed();
|
||||
});
|
||||
tryAgain.setOnClickListener(view -> requireActivity().onBackPressed());
|
||||
Button cancel = v.findViewById(R.id.cancelButton);
|
||||
cancel.setOnClickListener(view -> finish());
|
||||
return v;
|
||||
|
||||
@@ -42,6 +42,7 @@ import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.STATE_ON;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_BLUETOOTH_DISCOVERABLE;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PERMISSION_CAMERA_LOCATION;
|
||||
@@ -96,14 +97,13 @@ public abstract class KeyAgreementActivity extends BriarActivity implements
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.activity_fragment_container_toolbar);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
if (state == null) {
|
||||
showInitialFragment(IntroFragment.newInstance());
|
||||
}
|
||||
@@ -202,7 +202,8 @@ public abstract class KeyAgreementActivity extends BriarActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int request, int result, Intent data) {
|
||||
public void onActivityResult(int request, int result,
|
||||
@Nullable Intent data) {
|
||||
if (request == REQUEST_BLUETOOTH_DISCOVERABLE) {
|
||||
if (result == RESULT_CANCELED) {
|
||||
setBluetoothState(BluetoothState.REFUSED);
|
||||
|
||||
@@ -53,7 +53,6 @@ import static android.view.View.VISIBLE;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
@@ -139,8 +138,7 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
requireNonNull(getActivity())
|
||||
.setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);
|
||||
requireActivity().setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);
|
||||
cameraView.setPreviewConsumer(new QrCodeDecoder(this));
|
||||
}
|
||||
|
||||
@@ -191,7 +189,7 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
@UiThread
|
||||
private void logCameraExceptionAndFinish(CameraException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
Toast.makeText(getActivity(), R.string.camera_error,
|
||||
Toast.makeText(requireActivity(), R.string.camera_error,
|
||||
LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
@@ -262,7 +260,7 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
LOG.log(WARNING, "QR Code Invalid", e);
|
||||
reset();
|
||||
Toast.makeText(getActivity(), R.string.qr_code_invalid,
|
||||
Toast.makeText(requireActivity(), R.string.qr_code_invalid,
|
||||
LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
@@ -353,7 +351,7 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
|
||||
@NotNullByDefault
|
||||
|
||||
@@ -17,7 +17,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_NEXT;
|
||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_NONE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.bramble.util.StringUtils.toUtf8;
|
||||
import static org.briarproject.briar.android.util.UiUtils.setError;
|
||||
@@ -45,7 +44,7 @@ public class AuthorNameFragment extends SetupFragment {
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_title));
|
||||
requireActivity().setTitle(getString(R.string.setup_title));
|
||||
View v = inflater.inflate(R.layout.fragment_setup_author_name,
|
||||
container, false);
|
||||
authorNameWrapper = v.findViewById(R.id.nickname_entry_wrapper);
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.briarproject.briar.android.login.PowerView.OnCheckedChangedListener;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
||||
import static org.briarproject.briar.android.util.UiUtils.getDozeWhitelistingIntent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
|
||||
@@ -49,7 +48,7 @@ public class DozeFragment extends SetupFragment
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_doze_title));
|
||||
requireActivity().setTitle(getString(R.string.setup_doze_title));
|
||||
setHasOptionsMenu(false);
|
||||
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
|
||||
false);
|
||||
@@ -100,8 +99,7 @@ public class DozeFragment extends SetupFragment
|
||||
|
||||
@SuppressLint("BatteryLife")
|
||||
private void askForDozeWhitelisting() {
|
||||
if (getContext() == null) return;
|
||||
Intent i = getDozeWhitelistingIntent(getContext());
|
||||
Intent i = getDozeWhitelistingIntent(requireContext());
|
||||
startActivityForResult(i, REQUEST_DOZE_WHITELISTING);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
||||
import static org.briarproject.briar.android.util.UiUtils.setError;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class PasswordFragment extends SetupFragment {
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_password_intro));
|
||||
requireActivity().setTitle(getString(R.string.setup_password_intro));
|
||||
View v = inflater.inflate(R.layout.fragment_setup_password, container,
|
||||
false);
|
||||
|
||||
@@ -115,8 +114,9 @@ public class PasswordFragment extends SetupFragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
IBinder token = passwordEntry.getWindowToken();
|
||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).hideSoftInputFromWindow(token, 0);
|
||||
InputMethodManager im = (InputMethodManager)
|
||||
requireContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (im != null) im.hideSoftInputFromWindow(token, 0);
|
||||
setupController.setPassword(passwordEntry.getText().toString());
|
||||
if (setupController.needToShowDozeFragment()) {
|
||||
setupController.showDozeFragment();
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
|
||||
|
||||
@UiThread
|
||||
@@ -42,13 +43,12 @@ abstract class PowerView extends ConstraintLayout {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public PowerView(Context context, @Nullable AttributeSet attrs,
|
||||
int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) requireNonNull(
|
||||
context.getSystemService(LAYOUT_INFLATER_SERVICE));
|
||||
View v = inflater.inflate(R.layout.power_view, this, true);
|
||||
|
||||
textView = v.findViewById(R.id.textView);
|
||||
|
||||
@@ -40,7 +40,7 @@ abstract class SetupFragment extends BaseFragment implements TextWatcher,
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_help) {
|
||||
showOnboardingDialog(getContext(), getHelpText());
|
||||
showOnboardingDialog(requireContext(), getHelpText());
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener;
|
||||
@@ -223,7 +222,7 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
drawerLayout.closeDrawer(START);
|
||||
clearBackStack();
|
||||
if (item.getItemId() == R.id.nav_btn_lock) {
|
||||
@@ -325,7 +324,6 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
if (item != null) item.setVisible(visible);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void showExpiryWarning(ExpiryWarning expiry) {
|
||||
int daysUntilExpiry = getDaysUntilExpiry();
|
||||
if (daysUntilExpiry < 0) signOut();
|
||||
|
||||
@@ -53,23 +53,23 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
}
|
||||
|
||||
private void updatePreferences() {
|
||||
pm = getActivity().getPackageManager();
|
||||
pm = requireActivity().getPackageManager();
|
||||
|
||||
lockPref = (SwitchPreference) findPreference(KEY_LOCK);
|
||||
panicAppPref = (ListPreference) findPreference(KEY_PANIC_APP);
|
||||
purgePref = (SwitchPreference) findPreference(KEY_PURGE);
|
||||
|
||||
// check for connect/disconnect intents from panic trigger apps
|
||||
if (checkForDisconnectIntent(getActivity())) {
|
||||
if (checkForDisconnectIntent(requireActivity())) {
|
||||
LOG.info("Received DISCONNECT intent from Panic Trigger App.");
|
||||
// the necessary action should have been performed by the check
|
||||
getActivity().finish();
|
||||
requireActivity().finish();
|
||||
} else {
|
||||
// check if we got a connect intent from a not yet connected app
|
||||
String packageName = getConnectIntentSender(getActivity());
|
||||
String packageName = getConnectIntentSender(requireActivity());
|
||||
if (!TextUtils.isEmpty((packageName)) &&
|
||||
!TextUtils.equals(packageName,
|
||||
getTriggerPackageName(getActivity()))) {
|
||||
getTriggerPackageName(requireActivity()))) {
|
||||
|
||||
// A new panic trigger app asks us to connect
|
||||
LOG.info("Received CONNECT intent from new Panic Trigger App.");
|
||||
@@ -97,13 +97,13 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
|
||||
panicAppPref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String packageName = (String) newValue;
|
||||
setTriggerPackageName(getActivity(), packageName);
|
||||
setTriggerPackageName(requireActivity(), packageName);
|
||||
showPanicApp(packageName);
|
||||
|
||||
if (packageName.equals(PACKAGE_NAME_NONE)) {
|
||||
purgePref.setChecked(false);
|
||||
purgePref.setEnabled(false);
|
||||
getActivity().setResult(RESULT_CANCELED);
|
||||
requireActivity().setResult(RESULT_CANCELED);
|
||||
} else {
|
||||
purgePref.setEnabled(true);
|
||||
}
|
||||
@@ -117,8 +117,8 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
intent.setData(Uri.parse(
|
||||
"market://details?id=info.guardianproject.ripple"));
|
||||
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||
if (intent.resolveActivity(getActivity().getPackageManager())
|
||||
!= null) {
|
||||
PackageManager pm = requireActivity().getPackageManager();
|
||||
if (intent.resolveActivity(pm) != null) {
|
||||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
@@ -134,7 +134,7 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
updatePreferences();
|
||||
showPanicApp(getTriggerPackageName(getActivity()));
|
||||
showPanicApp(getTriggerPackageName(requireActivity()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,7 +184,7 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
purgePref.setEnabled(true);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// revert back to no app, just to be safe
|
||||
setTriggerPackageName(getActivity(), PACKAGE_NAME_NONE);
|
||||
setTriggerPackageName(requireActivity(), PACKAGE_NAME_NONE);
|
||||
showPanicApp(PACKAGE_NAME_NONE);
|
||||
}
|
||||
}
|
||||
@@ -192,16 +192,16 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
|
||||
private void showOptInDialog() {
|
||||
DialogInterface.OnClickListener okListener = (dialog, which) -> {
|
||||
setTriggerPackageName(getActivity());
|
||||
showPanicApp(getTriggerPackageName(getActivity()));
|
||||
getActivity().setResult(RESULT_OK);
|
||||
setTriggerPackageName(requireActivity());
|
||||
showPanicApp(getTriggerPackageName(requireActivity()));
|
||||
requireActivity().setResult(RESULT_OK);
|
||||
};
|
||||
DialogInterface.OnClickListener cancelListener = (dialog, which) -> {
|
||||
getActivity().setResult(RESULT_CANCELED);
|
||||
getActivity().finish();
|
||||
requireActivity().setResult(RESULT_CANCELED);
|
||||
requireActivity().finish();
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(),
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(),
|
||||
R.style.BriarDialogTheme);
|
||||
builder.setTitle(getString(R.string.dialog_title_connect_panic_app));
|
||||
|
||||
@@ -226,7 +226,7 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
|
||||
@Nullable
|
||||
private String getCallingPackageName() {
|
||||
ComponentName componentName = getActivity().getCallingActivity();
|
||||
ComponentName componentName = requireActivity().getCallingActivity();
|
||||
String packageName = null;
|
||||
if (componentName != null) {
|
||||
packageName = componentName.getPackageName();
|
||||
|
||||
@@ -177,7 +177,6 @@ class CreateGroupControllerImpl extends ContactSelectorControllerImpl
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
handler.onResult(null);
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
|
||||
@@ -50,9 +50,9 @@ public class CreateGroupFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_create_group, container,
|
||||
false);
|
||||
nameEntry = v.findViewById(R.id.name);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.briarproject.briar.android.contactselection.SelectableContactItem;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@@ -42,7 +41,7 @@ public class GroupInviteFragment extends ContactSelectorFragment {
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requireNonNull(getActivity()).setTitle(R.string.groups_invite_members);
|
||||
requireActivity().setTitle(R.string.groups_invite_members);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,6 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@@ -71,12 +70,11 @@ public class GroupListFragment extends BaseFragment implements
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
requireNonNull(getActivity()).setTitle(R.string.groups_button);
|
||||
requireActivity().setTitle(R.string.groups_button);
|
||||
|
||||
View v = inflater.inflate(R.layout.list, container, false);
|
||||
|
||||
adapter = new GroupListAdapter(getActivity(), this);
|
||||
adapter = new GroupListAdapter(requireActivity(), this);
|
||||
list = v.findViewById(R.id.list);
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_group_list);
|
||||
list.setEmptyText(R.string.groups_list_empty);
|
||||
@@ -87,8 +85,8 @@ public class GroupListFragment extends BaseFragment implements
|
||||
snackbar = Snackbar.make(list, "", LENGTH_INDEFINITE);
|
||||
snackbar.getView().setBackgroundResource(R.color.briar_primary);
|
||||
snackbar.setAction(R.string.show, this);
|
||||
snackbar.setActionTextColor(ContextCompat
|
||||
.getColor(getActivity(), R.color.briar_button_text_positive));
|
||||
snackbar.setActionTextColor(ContextCompat.getColor(requireContext(),
|
||||
R.color.briar_button_text_positive));
|
||||
|
||||
return v;
|
||||
}
|
||||
@@ -121,7 +119,8 @@ public class GroupListFragment extends BaseFragment implements
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add_group:
|
||||
Intent i = new Intent(getContext(), CreateGroupActivity.class);
|
||||
Intent i = new Intent(requireContext(),
|
||||
CreateGroupActivity.class);
|
||||
startActivity(i);
|
||||
return true;
|
||||
default:
|
||||
@@ -239,7 +238,7 @@ public class GroupListFragment extends BaseFragment implements
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(getContext(), GroupInvitationActivity.class);
|
||||
Intent i = new Intent(requireContext(), GroupInvitationActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ public class RevealContactsActivity extends ContactSelectorActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void onCreate(@Nullable Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static android.view.inputmethod.InputMethodManager.SHOW_FORCED;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.acra.ACRAConstants.EXTRA_REPORT_FILE;
|
||||
@@ -130,8 +131,7 @@ public class DevReportActivity extends BaseCrashReportDialog
|
||||
report = findViewById(R.id.report_content);
|
||||
progress = findViewById(R.id.progress_wheel);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
getDelegate().getSupportActionBar().setTitle(
|
||||
requireNonNull(getDelegate().getSupportActionBar()).setTitle(
|
||||
isFeedback() ? R.string.feedback_title :
|
||||
R.string.crash_report_title);
|
||||
userCommentView.setHint(isFeedback() ? R.string.enter_feedback :
|
||||
@@ -152,8 +152,9 @@ public class DevReportActivity extends BaseCrashReportDialog
|
||||
reviewing = true;
|
||||
reportForm.setVisibility(VISIBLE);
|
||||
requestReport.setVisibility(INVISIBLE);
|
||||
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
|
||||
.showSoftInput(userCommentView, SHOW_FORCED);
|
||||
InputMethodManager im = (InputMethodManager)
|
||||
getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (im != null) im.showSoftInput(userCommentView, SHOW_FORCED);
|
||||
});
|
||||
findViewById(R.id.declineButton).setOnClickListener(v -> closeReport());
|
||||
chevron.setOnClickListener(v -> {
|
||||
|
||||
@@ -67,6 +67,7 @@ import static android.provider.Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
import static android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_LTR;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
@@ -189,21 +190,19 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
language.setOnPreferenceChangeListener(this);
|
||||
theme.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (getActivity() != null) {
|
||||
// activate new theme
|
||||
setTheme(getActivity(), (String) newValue);
|
||||
// bring up parent activity, so it can change its theme as well
|
||||
// upstream bug: https://issuetracker.google.com/issues/38352704
|
||||
Intent intent =
|
||||
new Intent(getActivity(), NavDrawerActivity.class);
|
||||
intent.setFlags(
|
||||
FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
// bring this activity back to the foreground
|
||||
intent = new Intent(getActivity(), getActivity().getClass());
|
||||
startActivity(intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
// activate new theme
|
||||
setTheme(requireActivity(), (String) newValue);
|
||||
// bring up parent activity, so it can change its theme as well
|
||||
// upstream bug: https://issuetracker.google.com/issues/38352704
|
||||
Intent intent = new Intent(requireActivity(),
|
||||
NavDrawerActivity.class);
|
||||
intent.setFlags(FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
// bring this activity back to the foreground
|
||||
intent = new Intent(requireActivity(),
|
||||
requireActivity().getClass());
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
return true;
|
||||
});
|
||||
enableBluetooth.setOnPreferenceChangeListener(this);
|
||||
@@ -247,7 +246,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
ColorDrawable divider = new ColorDrawable(
|
||||
ContextCompat.getColor(getContext(), R.color.divider));
|
||||
ContextCompat.getColor(requireContext(), R.color.divider));
|
||||
setDivider(divider);
|
||||
return view;
|
||||
}
|
||||
@@ -487,8 +486,9 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
pref.setWidgetLayoutResource(0);
|
||||
pref.setSummary(summary);
|
||||
pref.setOnPreferenceClickListener(clickedPref -> {
|
||||
String packageName = requireContext().getPackageName();
|
||||
Intent intent = new Intent(ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
.putExtra(EXTRA_APP_PACKAGE, getContext().getPackageName())
|
||||
.putExtra(EXTRA_APP_PACKAGE, packageName)
|
||||
.putExtra(EXTRA_CHANNEL_ID, channelId);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
@@ -571,19 +571,18 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
private void languageChanged(String newValue) {
|
||||
AlertDialog.Builder builder =
|
||||
new AlertDialog.Builder(getActivity());
|
||||
new AlertDialog.Builder(requireActivity());
|
||||
builder.setTitle(R.string.pref_language_title);
|
||||
builder.setMessage(R.string.pref_language_changed);
|
||||
builder.setPositiveButton(R.string.sign_out_button,
|
||||
(dialogInterface, i) -> {
|
||||
language.setValue(newValue);
|
||||
Intent intent = new Intent(getContext(),
|
||||
NavDrawerActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(INTENT_SIGN_OUT, true);
|
||||
getActivity().startActivity(intent);
|
||||
getActivity().finish();
|
||||
});
|
||||
builder.setPositiveButton(R.string.sign_out_button, (dialog, i) -> {
|
||||
language.setValue(newValue);
|
||||
Intent intent = new Intent(requireContext(),
|
||||
NavDrawerActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(INTENT_SIGN_OUT, true);
|
||||
requireActivity().startActivity(intent);
|
||||
requireActivity().finish();
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setCancelable(false);
|
||||
builder.show();
|
||||
@@ -634,7 +633,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
super.onActivityResult(request, result, data);
|
||||
if (request == REQUEST_RINGTONE && result == RESULT_OK) {
|
||||
Settings s = new Settings();
|
||||
Uri uri = data.getParcelableExtra(EXTRA_RINGTONE_PICKED_URI);
|
||||
Uri uri = requireNonNull(data).getParcelableExtra(
|
||||
EXTRA_RINGTONE_PICKED_URI);
|
||||
if (uri == null) {
|
||||
// The user chose silence
|
||||
s.putBoolean(PREF_NOTIFY_SOUND, false);
|
||||
@@ -647,12 +647,12 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
s.put(PREF_NOTIFY_RINGTONE_URI, "");
|
||||
} else {
|
||||
// The user chose a ringtone other than the default
|
||||
Ringtone r = RingtoneManager.getRingtone(getContext(), uri);
|
||||
Ringtone r = RingtoneManager.getRingtone(requireContext(), uri);
|
||||
if (r == null) {
|
||||
Toast.makeText(getContext(), R.string.cannot_load_ringtone,
|
||||
LENGTH_SHORT).show();
|
||||
Toast.makeText(requireContext(),
|
||||
R.string.cannot_load_ringtone, LENGTH_SHORT).show();
|
||||
} else {
|
||||
String name = r.getTitle(getContext());
|
||||
String name = r.getTitle(requireContext());
|
||||
s.putBoolean(PREF_NOTIFY_SOUND, true);
|
||||
s.put(PREF_NOTIFY_RINGTONE_NAME, name);
|
||||
s.put(PREF_NOTIFY_RINGTONE_URI, uri.toString());
|
||||
|
||||
@@ -77,7 +77,6 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void onCreate(@Nullable Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
|
||||
@@ -218,17 +218,17 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
|
||||
}
|
||||
|
||||
void showSoftKeyboard() {
|
||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) requireNonNull(o);
|
||||
imm.showSoftInput(editText, SHOW_IMPLICIT);
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (imm != null) imm.showSoftInput(editText, SHOW_IMPLICIT);
|
||||
}
|
||||
|
||||
void hideSoftKeyboard() {
|
||||
if (emojiPopup.isShowing()) emojiPopup.dismiss();
|
||||
IBinder token = editText.getWindowToken();
|
||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) requireNonNull(o);
|
||||
imm.hideSoftInputFromWindow(token, 0);
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (imm != null) imm.hideSoftInputFromWindow(token, 0);
|
||||
}
|
||||
|
||||
interface TextInputListener {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.briarproject.briar.android.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.util.AttributeSet;
|
||||
@@ -11,52 +10,58 @@ import android.view.animation.AlphaAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@NotNullByDefault
|
||||
public class QrCodeView extends FrameLayout {
|
||||
|
||||
private final ImageView qrCodeImageView;
|
||||
private boolean fullscreen = false;
|
||||
private FullscreenListener listener;
|
||||
private final ImageView qrCodeImageView;
|
||||
private boolean fullscreen = false;
|
||||
@Nullable
|
||||
private FullscreenListener listener;
|
||||
|
||||
public QrCodeView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.qr_code_view, this, true);
|
||||
qrCodeImageView = findViewById(R.id.qr_code);
|
||||
ImageView fullscreenButton = findViewById(R.id.fullscreen_button);
|
||||
fullscreenButton.setOnClickListener(v -> {
|
||||
fullscreen = !fullscreen;
|
||||
if (!fullscreen) {
|
||||
fullscreenButton.setImageResource(
|
||||
R.drawable.ic_fullscreen_black_48dp);
|
||||
} else {
|
||||
fullscreenButton.setImageResource(
|
||||
R.drawable.ic_fullscreen_exit_black_48dp);
|
||||
}
|
||||
if (listener != null)
|
||||
listener.setFullscreen(fullscreen);
|
||||
}
|
||||
);
|
||||
}
|
||||
public QrCodeView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater inflater = (LayoutInflater) requireNonNull(
|
||||
context.getSystemService(LAYOUT_INFLATER_SERVICE));
|
||||
inflater.inflate(R.layout.qr_code_view, this, true);
|
||||
qrCodeImageView = findViewById(R.id.qr_code);
|
||||
ImageView fullscreenButton = findViewById(R.id.fullscreen_button);
|
||||
fullscreenButton.setOnClickListener(v -> {
|
||||
fullscreen = !fullscreen;
|
||||
if (!fullscreen) {
|
||||
fullscreenButton.setImageResource(
|
||||
R.drawable.ic_fullscreen_black_48dp);
|
||||
} else {
|
||||
fullscreenButton.setImageResource(
|
||||
R.drawable.ic_fullscreen_exit_black_48dp);
|
||||
}
|
||||
if (listener != null)
|
||||
listener.setFullscreen(fullscreen);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public void setQrCode(Bitmap qrCode) {
|
||||
qrCodeImageView.setImageBitmap(qrCode);
|
||||
// Simple fade-in animation
|
||||
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
||||
anim.setDuration(200);
|
||||
qrCodeImageView.startAnimation(anim);
|
||||
}
|
||||
@UiThread
|
||||
public void setQrCode(Bitmap qrCode) {
|
||||
qrCodeImageView.setImageBitmap(qrCode);
|
||||
// Simple fade-in animation
|
||||
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
||||
anim.setDuration(200);
|
||||
qrCodeImageView.startAnimation(anim);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public void setFullscreenListener(FullscreenListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
@UiThread
|
||||
public void setFullscreenListener(FullscreenListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public interface FullscreenListener {
|
||||
void setFullscreen(boolean fullscreen);
|
||||
}
|
||||
public interface FullscreenListener {
|
||||
void setFullscreen(boolean fullscreen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ import javax.annotation.Nullable;
|
||||
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@UiThread
|
||||
public class TextAvatarView extends FrameLayout {
|
||||
|
||||
@@ -28,8 +31,8 @@ public class TextAvatarView extends FrameLayout {
|
||||
public TextAvatarView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) requireNonNull(
|
||||
context.getSystemService(LAYOUT_INFLATER_SERVICE));
|
||||
inflater.inflate(R.layout.text_avatar_view, this, true);
|
||||
character = findViewById(R.id.textAvatarView);
|
||||
background = findViewById(R.id.avatarBackground);
|
||||
|
||||
@@ -16,6 +16,9 @@ import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
public class UnreadMessageButton extends FrameLayout {
|
||||
@@ -37,8 +40,8 @@ public class UnreadMessageButton extends FrameLayout {
|
||||
int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) requireNonNull(
|
||||
context.getSystemService(LAYOUT_INFLATER_SERVICE));
|
||||
inflater.inflate(R.layout.unread_message_button, this, true);
|
||||
|
||||
fab = findViewById(R.id.fab);
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -13,13 +13,18 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class LinkDialogFragment extends DialogFragment {
|
||||
|
||||
private static final String TAG = LinkDialogFragment.class.getName();
|
||||
@@ -37,18 +42,18 @@ public class LinkDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
url = getArguments().getString("url");
|
||||
url = requireNonNull(getArguments()).getString("url");
|
||||
|
||||
setStyle(STYLE_NO_TITLE, R.style.BriarDialogTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_link_dialog, container,
|
||||
false);
|
||||
|
||||
@@ -57,7 +62,7 @@ public class LinkDialogFragment extends DialogFragment {
|
||||
|
||||
// prepare normal intent or intent chooser
|
||||
Intent i = new Intent(ACTION_VIEW, Uri.parse(url));
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
PackageManager pm = requireContext().getPackageManager();
|
||||
List activities = pm.queryIntentActivities(i, MATCH_DEFAULT_ONLY);
|
||||
boolean choice = activities.size() > 1;
|
||||
Intent intent = choice ? Intent.createChooser(i,
|
||||
|
||||
@@ -42,6 +42,7 @@ import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_AUTH;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_RESPONSES;
|
||||
@@ -453,15 +454,13 @@ class IntroduceeProtocolEngine
|
||||
localAuthor.getId());
|
||||
|
||||
// add the keys to the new contact
|
||||
//noinspection ConstantConditions
|
||||
keys = keyManager
|
||||
.addContact(txn, c.getId(), new SecretKey(s.getMasterKey()),
|
||||
timestamp, s.getLocal().alice, false);
|
||||
keys = keyManager.addContact(txn, c.getId(),
|
||||
new SecretKey(requireNonNull(s.getMasterKey())),
|
||||
timestamp, s.getLocal().alice, false);
|
||||
|
||||
// add signed transport properties for the contact
|
||||
//noinspection ConstantConditions
|
||||
transportPropertyManager.addRemoteProperties(txn, c.getId(),
|
||||
s.getRemote().transportProperties);
|
||||
requireNonNull(s.getRemote().transportProperties));
|
||||
|
||||
// Broadcast IntroductionSucceededEvent, because contact got added
|
||||
IntroductionSucceededEvent e = new IntroductionSucceededEvent(c);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.security.GeneralSecurityException;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_ACTIVATE_MAC;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_ALICE_MAC_KEY;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_AUTH_MAC;
|
||||
@@ -71,13 +72,12 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public SecretKey deriveMasterKey(IntroduceeSession s)
|
||||
throws GeneralSecurityException {
|
||||
return deriveMasterKey(
|
||||
s.getLocal().ephemeralPublicKey,
|
||||
s.getLocal().ephemeralPrivateKey,
|
||||
s.getRemote().ephemeralPublicKey,
|
||||
requireNonNull(s.getLocal().ephemeralPublicKey),
|
||||
requireNonNull(s.getLocal().ephemeralPrivateKey),
|
||||
requireNonNull(s.getRemote().ephemeralPublicKey),
|
||||
s.getLocal().alice
|
||||
);
|
||||
}
|
||||
@@ -109,7 +109,6 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public byte[] authMac(SecretKey macKey, IntroduceeSession s,
|
||||
AuthorId localAuthorId) {
|
||||
// the macKey is not yet available in the session at this point
|
||||
@@ -129,10 +128,9 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void verifyAuthMac(byte[] mac, IntroduceeSession s,
|
||||
AuthorId localAuthorId) throws GeneralSecurityException {
|
||||
verifyAuthMac(mac, new SecretKey(s.getRemote().macKey),
|
||||
verifyAuthMac(mac, new SecretKey(requireNonNull(s.getRemote().macKey)),
|
||||
s.getIntroducer().getId(), localAuthorId, s.getLocal(),
|
||||
s.getRemote().author.getId(), s.getRemote());
|
||||
}
|
||||
@@ -148,7 +146,6 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private byte[] getAuthMacInputs(AuthorId introducerId,
|
||||
AuthorId localAuthorId, Common local, AuthorId remoteAuthorId,
|
||||
Common remote) {
|
||||
@@ -156,13 +153,15 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
localAuthorId,
|
||||
local.acceptTimestamp,
|
||||
local.ephemeralPublicKey,
|
||||
clientHelper.toDictionary(local.transportProperties)
|
||||
clientHelper.toDictionary(requireNonNull(
|
||||
local.transportProperties))
|
||||
);
|
||||
BdfList remoteInfo = BdfList.of(
|
||||
remoteAuthorId,
|
||||
remote.acceptTimestamp,
|
||||
remote.ephemeralPublicKey,
|
||||
clientHelper.toDictionary(remote.transportProperties)
|
||||
clientHelper.toDictionary(requireNonNull(
|
||||
remote.transportProperties))
|
||||
);
|
||||
BdfList macList = BdfList.of(
|
||||
introducerId,
|
||||
@@ -187,10 +186,9 @@ class IntroductionCryptoImpl implements IntroductionCrypto {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void verifySignature(byte[] signature, IntroduceeSession s)
|
||||
throws GeneralSecurityException {
|
||||
SecretKey macKey = new SecretKey(s.getRemote().macKey);
|
||||
SecretKey macKey = new SecretKey(requireNonNull(s.getRemote().macKey));
|
||||
verifySignature(macKey, s.getRemote().author.getPublicKey(), signature);
|
||||
}
|
||||
|
||||
|
||||
@@ -1309,13 +1309,10 @@ public class IntroductionIntegrationTest
|
||||
Message m = ch.getMessage(id);
|
||||
BdfList body = ch.getMessageAsList(id);
|
||||
if (type == ACCEPT) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseAcceptMessage(m, body);
|
||||
} else if (type == DECLINE) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseDeclineMessage(m, body);
|
||||
} else if (type == AUTH) {
|
||||
//noinspection ConstantConditions
|
||||
return c0.getMessageParser().parseAuthMessage(m, body);
|
||||
} else throw new AssertionError("Not implemented");
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ public class PrivateGroupManagerIntegrationTest
|
||||
addGroup();
|
||||
|
||||
// create and add test message with no previousMsgId
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
GroupMessage msg = groupMessageFactory
|
||||
.createGroupMessage(groupId0, clock.currentTimeMillis(), null,
|
||||
author0, "test", null);
|
||||
|
||||
Reference in New Issue
Block a user