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