mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Trivial code cleanups.
This commit is contained in:
@@ -76,7 +76,8 @@ public class ImageViewModel extends DbViewModel implements EventListener {
|
||||
|
||||
@Inject
|
||||
ImageViewModel(Application application, AttachmentReader attachmentReader,
|
||||
EventBus eventBus, @DatabaseExecutor Executor dbExecutor,LifecycleManager lifecycleManager,
|
||||
EventBus eventBus, @DatabaseExecutor Executor dbExecutor,
|
||||
LifecycleManager lifecycleManager,
|
||||
TransactionManager db,
|
||||
AndroidExecutor androidExecutor,
|
||||
@IoExecutor Executor ioExecutor) {
|
||||
|
||||
@@ -10,12 +10,13 @@ import android.widget.ImageView;
|
||||
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.android.activity.BaseActivity;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -24,6 +25,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class ConfirmAvatarDialogFragment extends DialogFragment {
|
||||
|
||||
final static String TAG = ConfirmAvatarDialogFragment.class.getName();
|
||||
@@ -46,13 +48,13 @@ public class ConfirmAvatarDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context ctx) {
|
||||
public void onAttach(Context ctx) {
|
||||
super.onAttach(ctx);
|
||||
((BaseActivity) requireActivity()).getActivityComponent().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Bundle args = requireArguments();
|
||||
String argUri = requireNonNull(args.getString(ARG_URI));
|
||||
uri = Uri.parse(argUri);
|
||||
|
||||
@@ -4,6 +4,9 @@ import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.identity.AuthorInfo;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
class OwnIdentityInfo {
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.util.LogUtils;
|
||||
import org.briarproject.briar.android.attachment.UnsupportedMimeTypeException;
|
||||
import org.briarproject.briar.android.attachment.media.ImageCompressor;
|
||||
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
||||
@@ -34,6 +33,7 @@ import static java.util.Arrays.asList;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getSupportedImageContentTypes;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
|
||||
@NotNullByDefault
|
||||
class SettingsViewModel extends AndroidViewModel {
|
||||
@@ -91,7 +91,7 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
ownIdentityInfo.postValue(
|
||||
new OwnIdentityInfo(localAuthor, authorInfo));
|
||||
} catch (DbException e) {
|
||||
LogUtils.logException(LOG, WARNING, e);
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
try {
|
||||
trySetAvatar(uri);
|
||||
} catch (IOException e) {
|
||||
LogUtils.logException(LOG, WARNING, e);
|
||||
logException(LOG, WARNING, e);
|
||||
setAvatarFailed.postEvent(true);
|
||||
}
|
||||
});
|
||||
@@ -118,15 +118,14 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
InputStream is = contentResolver.openInputStream(uri);
|
||||
if (is == null) throw new IOException(
|
||||
"ContentResolver returned null when opening InputStream");
|
||||
InputStream compressed = imageCompressor
|
||||
.compressImage(is, contentType);
|
||||
InputStream compressed = imageCompressor.compressImage(is, contentType);
|
||||
|
||||
dbExecutor.execute(() -> {
|
||||
try {
|
||||
avatarManager.addAvatar(ImageCompressor.MIME_TYPE, compressed);
|
||||
loadOwnIdentityInfo();
|
||||
} catch (IOException | DbException e) {
|
||||
LogUtils.logException(LOG, WARNING, e);
|
||||
logException(LOG, WARNING, e);
|
||||
setAvatarFailed.postEvent(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -228,8 +228,7 @@ class PrivateGroupManagerImpl extends BdfIncomingMessageHook
|
||||
meta.put(KEY_PARENT_MSG_ID, m.getParent());
|
||||
addMessageMetadata(meta, m);
|
||||
GroupId g = m.getMessage().getGroupId();
|
||||
clientHelper.addLocalMessage(txn, m.getMessage(), meta, true,
|
||||
false);
|
||||
clientHelper.addLocalMessage(txn, m.getMessage(), meta, true, false);
|
||||
// track message
|
||||
setPreviousMsgId(txn, g, m.getMessage().getId());
|
||||
messageTracker.trackOutgoingMessage(txn, m.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user