mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Merge branch 'illustration-revamp' into 'master'
Illustration revamp See merge request briar/briar!1722
This commit is contained in:
@@ -76,7 +76,7 @@ public class FeedFragment extends BaseFragment
|
||||
list = v.findViewById(R.id.postList);
|
||||
list.setLayoutManager(layoutManager);
|
||||
list.setAdapter(adapter);
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_blog);
|
||||
list.setEmptyImage(R.drawable.il_empty_state_blogs);
|
||||
list.setEmptyText(R.string.blogs_feed_empty_state);
|
||||
list.setEmptyAction(R.string.blogs_feed_empty_state_action);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ContactListFragment extends BaseFragment
|
||||
list = contentView.findViewById(R.id.list);
|
||||
list.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
list.setAdapter(adapter);
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_contact_list);
|
||||
list.setEmptyImage(R.drawable.il_empty_state_contact_list);
|
||||
list.setEmptyText(getString(R.string.no_contacts));
|
||||
list.setEmptyAction(getString(R.string.no_contacts_action));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.view.View.GONE;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
import static org.briarproject.briar.android.util.UiUtils.onSingleLinkClick;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@@ -70,8 +70,11 @@ public class AddNearbyContactErrorFragment extends BaseFragment {
|
||||
TextView explanation = v.findViewById(R.id.errorMessage);
|
||||
Bundle args = getArguments();
|
||||
String errorMessage = args == null ? null : args.getString(ERROR_MSG);
|
||||
if (errorMessage == null) explanation.setVisibility(GONE);
|
||||
else explanation.setText(args.getString(ERROR_MSG));
|
||||
if (errorMessage == null) {
|
||||
explanation.setText(getString(R.string.add_contact_error_two_way));
|
||||
} else {
|
||||
explanation.setText(args.getString(ERROR_MSG));
|
||||
}
|
||||
|
||||
// make feedback link clickable
|
||||
TextView sendFeedback = v.findViewById(R.id.sendFeedback);
|
||||
@@ -100,6 +103,12 @@ public class AddNearbyContactErrorFragment extends BaseFragment {
|
||||
viewModel.stopListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.errorIcon));
|
||||
}
|
||||
|
||||
private void triggerFeedback() {
|
||||
UiUtils.triggerFeedback(requireContext());
|
||||
finish();
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
@@ -19,8 +18,6 @@ import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class AddNearbyContactIntroFragment extends BaseFragment {
|
||||
@@ -34,8 +31,6 @@ public class AddNearbyContactIntroFragment extends BaseFragment {
|
||||
private AddNearbyContactViewModel viewModel;
|
||||
private AddNearbyContactPermissionManager permissionManager;
|
||||
|
||||
private ScrollView scrollView;
|
||||
|
||||
private final ActivityResultLauncher<String[]> permissionLauncher =
|
||||
registerForActivityResult(new RequestMultiplePermissions(), r -> {
|
||||
permissionManager.onRequestPermissionResult(r);
|
||||
@@ -67,10 +62,8 @@ public class AddNearbyContactIntroFragment extends BaseFragment {
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_keyagreement_id, container,
|
||||
false);
|
||||
scrollView = v.findViewById(R.id.scrollView);
|
||||
View button = v.findViewById(R.id.continueButton);
|
||||
button.setOnClickListener(view -> {
|
||||
viewModel.stopDiscovery();
|
||||
@@ -98,8 +91,6 @@ public class AddNearbyContactIntroFragment extends BaseFragment {
|
||||
permissionManager.resetPermissions();
|
||||
// Reset plugins in case they were assigned when we weren't signed-in
|
||||
viewModel.resetPlugins();
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package org.briarproject.briar.android.contact.add.remote;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -33,12 +30,12 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.bramble.api.contact.HandshakeLinkConstants.LINK_REGEX;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
import static org.briarproject.briar.android.util.UiUtils.observeOnce;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class LinkExchangeFragment extends BaseFragment
|
||||
implements OnGlobalLayoutListener {
|
||||
public class LinkExchangeFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = LinkExchangeFragment.class.getName();
|
||||
|
||||
@@ -92,29 +89,13 @@ public class LinkExchangeFragment extends BaseFragment
|
||||
|
||||
observeOnce(viewModel.getHandshakeLink(), this,
|
||||
this::onHandshakeLinkLoaded);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
ScrollView scrollView = (ScrollView) v;
|
||||
// we need to wait for views to be laid out to get the heights
|
||||
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(this);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
ScrollView scrollView = (ScrollView) requireView();
|
||||
View layout = scrollView.getChildAt(0);
|
||||
int scrollBy = layout.getHeight() - scrollView.getHeight();
|
||||
if (scrollBy > 0) {
|
||||
// smoothScrollTo() is too fast due to the transition animation
|
||||
ObjectAnimator animator = ObjectAnimator
|
||||
.ofInt(scrollView, "scrollY", scrollBy);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
}
|
||||
layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
private void onHandshakeLinkLoaded(String link) {
|
||||
|
||||
@@ -8,8 +8,6 @@ import android.text.Editable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
@@ -23,6 +21,7 @@ import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
import org.briarproject.briar.android.fragment.BaseFragment;
|
||||
import org.briarproject.briar.android.view.BriarButton;
|
||||
import org.briarproject.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.nullsafety.ParametersNotNullByDefault;
|
||||
|
||||
@@ -35,13 +34,12 @@ import androidx.appcompat.app.AlertDialog.Builder;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.bramble.util.StringUtils.utf8IsTooLong;
|
||||
import static org.briarproject.briar.android.util.UiUtils.getDialogIcon;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -57,8 +55,6 @@ public class NicknameFragment extends BaseFragment {
|
||||
|
||||
private TextInputLayout contactNameLayout;
|
||||
private TextInputEditText contactNameInput;
|
||||
private Button addButton;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
@@ -95,14 +91,18 @@ public class NicknameFragment extends BaseFragment {
|
||||
contactNameLayout = v.findViewById(R.id.contactNameLayout);
|
||||
contactNameInput = v.findViewById(R.id.contactNameInput);
|
||||
|
||||
addButton = v.findViewById(R.id.addButton);
|
||||
BriarButton addButton = v.findViewById(R.id.addButton);
|
||||
addButton.setOnClickListener(view -> onAddButtonClicked());
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
@@ -131,9 +131,6 @@ public class NicknameFragment extends BaseFragment {
|
||||
String name = getNicknameOrNull();
|
||||
if (name == null) return; // invalid nickname
|
||||
|
||||
addButton.setVisibility(INVISIBLE);
|
||||
progressBar.setVisibility(VISIBLE);
|
||||
|
||||
LifecycleOwner owner = getViewLifecycleOwner();
|
||||
viewModel.getAddContactResult().observe(owner, result -> {
|
||||
if (result == null) return;
|
||||
@@ -214,7 +211,7 @@ public class NicknameFragment extends BaseFragment {
|
||||
private void showWarningDialog(String name1, String name2) {
|
||||
Context ctx = requireContext();
|
||||
Builder b = new Builder(ctx, R.style.BriarDialogTheme);
|
||||
b.setIcon(getDialogIcon(ctx, R.drawable.alerts_and_states_error));
|
||||
b.setIcon(getDialogIcon(ctx, R.drawable.ic_error));
|
||||
b.setTitle(getString(R.string.duplicate_link_dialog_title));
|
||||
b.setMessage(
|
||||
getString(R.string.duplicate_link_dialog_text_3, name1, name2));
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -72,6 +73,7 @@ public class BluetoothIntroFragment extends Fragment {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.introImageView));
|
||||
conditionManager.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
||||
|
||||
list = contentView.findViewById(R.id.list);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_contact_list);
|
||||
list.setEmptyImage(R.drawable.il_empty_state_contact_list);
|
||||
list.setEmptyText(getString(R.string.no_contacts_selector));
|
||||
list.setEmptyAction(getString(R.string.no_contacts_selector_action));
|
||||
adapter = getAdapter(requireContext(), this);
|
||||
|
||||
@@ -22,12 +22,11 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static android.view.View.GONE;
|
||||
import static androidx.core.widget.ImageViewCompat.setImageTintList;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
/**
|
||||
* A fragment to be used at the end of a user flow
|
||||
@@ -61,7 +60,6 @@ public class FinalFragment extends Fragment {
|
||||
return f;
|
||||
}
|
||||
|
||||
private NestedScrollView scrollView;
|
||||
protected Button buttonView;
|
||||
protected final OnBackPressedCallback onBackPressedCallback =
|
||||
new OnBackPressedCallback(true) {
|
||||
@@ -79,7 +77,6 @@ public class FinalFragment extends Fragment {
|
||||
View v = inflater
|
||||
.inflate(R.layout.fragment_final, container, false);
|
||||
|
||||
scrollView = (NestedScrollView) v;
|
||||
ImageView iconView = v.findViewById(R.id.iconView);
|
||||
TextView titleView = v.findViewById(R.id.titleView);
|
||||
TextView textView = v.findViewById(R.id.textView);
|
||||
@@ -88,9 +85,12 @@ public class FinalFragment extends Fragment {
|
||||
Bundle args = requireArguments();
|
||||
titleView.setText(args.getInt(ARG_TITLE));
|
||||
iconView.setImageResource(args.getInt(ARG_ICON));
|
||||
int color = getResources().getColor(args.getInt(ARG_ICON_TINT));
|
||||
ColorStateList tint = ColorStateList.valueOf(color);
|
||||
ImageViewCompat.setImageTintList(iconView, tint);
|
||||
int tintRes = args.getInt(ARG_ICON_TINT);
|
||||
if (tintRes != 0) {
|
||||
int color = getResources().getColor(tintRes);
|
||||
ColorStateList tint = ColorStateList.valueOf(color);
|
||||
setImageTintList(iconView, tint);
|
||||
}
|
||||
int textRes = args.getInt(ARG_TEXT);
|
||||
if (textRes == 0) {
|
||||
textView.setVisibility(GONE);
|
||||
@@ -122,8 +122,7 @@ public class FinalFragment extends Fragment {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.iconView));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -27,12 +26,12 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.content.pm.ApplicationInfo.FLAG_TEST_ONLY;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.transition.TransitionManager.beginDelayedTransition;
|
||||
import static com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -48,7 +47,6 @@ public class HotspotIntroFragment extends Fragment {
|
||||
private Button startButton;
|
||||
private ProgressBar progressBar;
|
||||
private TextView progressTextView;
|
||||
private ScrollView scrollView;
|
||||
|
||||
private final AbstractConditionManager conditionManager = SDK_INT < 29 ?
|
||||
new ConditionManager(this, this::onPermissionUpdate) :
|
||||
@@ -73,7 +71,6 @@ public class HotspotIntroFragment extends Fragment {
|
||||
startButton = v.findViewById(R.id.startButton);
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
progressTextView = v.findViewById(R.id.progressTextView);
|
||||
scrollView = v.findViewById(R.id.scrollView);
|
||||
|
||||
startButton.setOnClickListener(this::onButtonClick);
|
||||
|
||||
@@ -86,8 +83,7 @@ public class HotspotIntroFragment extends Fragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
conditionManager.onStart();
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
private void onButtonClick(View view) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class LoginUtils {
|
||||
static AlertDialog createKeyStrengthenerErrorDialog(Context ctx) {
|
||||
AlertDialog.Builder builder =
|
||||
new AlertDialog.Builder(ctx, R.style.BriarDialogTheme);
|
||||
builder.setIcon(getDialogIcon(ctx, R.drawable.alerts_and_states_error));
|
||||
builder.setIcon(getDialogIcon(ctx, R.drawable.ic_error));
|
||||
builder.setTitle(R.string.dialog_title_cannot_check_password);
|
||||
builder.setMessage(R.string.dialog_message_cannot_check_password);
|
||||
builder.setPositiveButton(R.string.ok, null);
|
||||
|
||||
@@ -29,8 +29,7 @@ public class ErrorFragment extends FinalFragment {
|
||||
ErrorFragment f = new ErrorFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_TITLE, title);
|
||||
args.putInt(ARG_ICON, R.drawable.alerts_and_states_error);
|
||||
args.putInt(ARG_ICON_TINT, R.color.briar_red_500);
|
||||
args.putInt(ARG_ICON, R.drawable.ic_error);
|
||||
args.putInt(ARG_TEXT, text);
|
||||
f.setArguments(args);
|
||||
return f;
|
||||
|
||||
@@ -186,8 +186,7 @@ public class MailboxActivity extends BriarActivity {
|
||||
tag = ErrorFragment.TAG;
|
||||
} else if (s instanceof MailboxPairingState.Paired) {
|
||||
f = FinalFragment.newInstance(R.string.mailbox_setup_paired_title,
|
||||
R.drawable.ic_check_circle_outline,
|
||||
R.color.briar_brand_green,
|
||||
R.drawable.ic_check_circle, 0,
|
||||
R.string.mailbox_setup_paired_description);
|
||||
tag = FinalFragment.TAG;
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.briarproject.briar.android.mailbox;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -21,7 +20,6 @@ import org.briarproject.nullsafety.ParametersNotNullByDefault;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
@@ -33,8 +31,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.core.content.ContextCompat.getColor;
|
||||
import static androidx.core.widget.ImageViewCompat.setImageTintList;
|
||||
import static androidx.transition.TransitionManager.beginDelayedTransition;
|
||||
import static org.briarproject.bramble.api.mailbox.MailboxConstants.API_CLIENT_TOO_OLD;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
@@ -141,24 +137,20 @@ public class MailboxStatusFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void onMailboxStateChanged(MailboxStatus status) {
|
||||
@ColorRes int tintRes;
|
||||
@DrawableRes int iconRes;
|
||||
String title;
|
||||
String message = null;
|
||||
if (status.hasProblem(System.currentTimeMillis())) {
|
||||
tintRes = R.color.briar_red_500;
|
||||
title = getString(R.string.mailbox_status_failure_title);
|
||||
iconRes = R.drawable.alerts_and_states_error;
|
||||
iconRes = R.drawable.ic_error;
|
||||
showUnlinkWarning = false;
|
||||
wizardButton.setVisibility(VISIBLE);
|
||||
} else if (status.getAttemptsSinceSuccess() > 0) {
|
||||
iconRes = R.drawable.ic_help_outline_white;
|
||||
iconRes = R.drawable.ic_exclamation_mark;
|
||||
title = getString(R.string.mailbox_status_problem_title);
|
||||
tintRes = R.color.briar_orange_500;
|
||||
showUnlinkWarning = false;
|
||||
wizardButton.setVisibility(VISIBLE);
|
||||
} else if (status.getMailboxCompatibility() < 0) {
|
||||
tintRes = R.color.briar_red_500;
|
||||
if (status.getMailboxCompatibility() == API_CLIENT_TOO_OLD) {
|
||||
title = getString(R.string.mailbox_status_app_too_old_title);
|
||||
message =
|
||||
@@ -169,19 +161,16 @@ public class MailboxStatusFragment extends Fragment {
|
||||
message = getString(
|
||||
R.string.mailbox_status_mailbox_too_old_message);
|
||||
}
|
||||
iconRes = R.drawable.alerts_and_states_error;
|
||||
iconRes = R.drawable.ic_error;
|
||||
showUnlinkWarning = true;
|
||||
wizardButton.setVisibility(GONE);
|
||||
} else {
|
||||
iconRes = R.drawable.ic_check_circle_outline;
|
||||
iconRes = R.drawable.ic_check_circle;
|
||||
title = getString(R.string.mailbox_status_connected_title);
|
||||
tintRes = R.color.briar_brand_green;
|
||||
showUnlinkWarning = true;
|
||||
wizardButton.setVisibility(GONE);
|
||||
}
|
||||
imageView.setImageResource(iconRes);
|
||||
int color = getColor(requireContext(), tintRes);
|
||||
setImageTintList(imageView, ColorStateList.valueOf(color));
|
||||
statusTitleView.setText(title);
|
||||
if (message == null) {
|
||||
statusMessageView.setVisibility(GONE);
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.nullsafety.MethodsNotNullByDefault;
|
||||
@@ -21,8 +20,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -36,7 +35,6 @@ public class SetupDownloadFragment extends Fragment {
|
||||
private MailboxViewModel viewModel;
|
||||
|
||||
private CameraPermissionManager permissionManager;
|
||||
private ScrollView scrollView;
|
||||
|
||||
private final ActivityResultLauncher<String[]> permissionLauncher =
|
||||
registerForActivityResult(new RequestMultiplePermissions(), r -> {
|
||||
@@ -62,7 +60,6 @@ public class SetupDownloadFragment extends Fragment {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_mailbox_setup_download,
|
||||
container, false);
|
||||
scrollView = v.findViewById(R.id.scrollView);
|
||||
|
||||
permissionManager = new CameraPermissionManager(requireActivity(),
|
||||
permissionLauncher::launch);
|
||||
@@ -80,8 +77,7 @@ public class SetupDownloadFragment extends Fragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
requireActivity().setTitle(R.string.mailbox_setup_title);
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
// Permissions may have been granted manually while we were stopped
|
||||
permissionManager.resetPermissions();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.nullsafety.MethodsNotNullByDefault;
|
||||
@@ -19,8 +18,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -33,8 +32,6 @@ public class SetupIntroFragment extends Fragment {
|
||||
|
||||
private MailboxViewModel viewModel;
|
||||
|
||||
private ScrollView scrollView;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -51,7 +48,6 @@ public class SetupIntroFragment extends Fragment {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_mailbox_setup_intro,
|
||||
container, false);
|
||||
scrollView = v.findViewById(R.id.scrollView);
|
||||
Button button = v.findViewById(R.id.continueButton);
|
||||
button.setOnClickListener(view -> viewModel.showDownloadFragment());
|
||||
return v;
|
||||
@@ -61,8 +57,7 @@ public class SetupIntroFragment extends Fragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
requireActivity().setTitle(R.string.mailbox_setup_title);
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class GroupListFragment extends BaseFragment implements
|
||||
|
||||
adapter = new GroupListAdapter(this);
|
||||
list = v.findViewById(R.id.list);
|
||||
list.setEmptyImage(R.drawable.ic_empty_state_group_list);
|
||||
list.setEmptyImage(R.drawable.il_empty_state_group_list);
|
||||
list.setEmptyText(R.string.groups_list_empty);
|
||||
list.setEmptyAction(R.string.groups_list_empty_action);
|
||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.widget.OnboardingFullDialogFragment;
|
||||
@@ -20,8 +19,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -33,7 +32,6 @@ public class ChooserFragment extends Fragment {
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private RemovableDriveViewModel viewModel;
|
||||
private ScrollView scrollView;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -51,8 +49,6 @@ public class ChooserFragment extends Fragment {
|
||||
View v = inflater.inflate(R.layout.fragment_transfer_data_chooser,
|
||||
container, false);
|
||||
|
||||
scrollView = (ScrollView) v;
|
||||
|
||||
Button buttonLearnMore = v.findViewById(R.id.buttonLearnMore);
|
||||
buttonLearnMore.setOnClickListener(e -> showLearnMoreDialog());
|
||||
|
||||
@@ -75,8 +71,7 @@ public class ChooserFragment extends Fragment {
|
||||
// as we only support one per ViewModel instance
|
||||
requireActivity().supportFinishAfterTransition();
|
||||
} else {
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ public class ErrorFragment extends FinalFragment {
|
||||
ErrorFragment f = new ErrorFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_TITLE, title);
|
||||
args.putInt(ARG_ICON, R.drawable.alerts_and_states_error);
|
||||
args.putInt(ARG_ICON_TINT, R.color.briar_red_500);
|
||||
args.putInt(ARG_ICON, R.drawable.ic_error);
|
||||
args.putInt(ARG_TEXT, text);
|
||||
f.setArguments(args);
|
||||
return f;
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
@@ -26,10 +25,10 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
import static org.briarproject.briar.android.util.UiUtils.launchActivityToOpenFile;
|
||||
|
||||
@RequiresApi(19)
|
||||
@@ -50,7 +49,6 @@ public class ReceiveFragment extends Fragment {
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private RemovableDriveViewModel viewModel;
|
||||
private ScrollView scrollView;
|
||||
private Button button;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@@ -72,7 +70,6 @@ public class ReceiveFragment extends Fragment {
|
||||
View v = inflater.inflate(R.layout.fragment_transfer_data_receive,
|
||||
container, false);
|
||||
|
||||
scrollView = (ScrollView) v;
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
button = v.findViewById(R.id.fileButton);
|
||||
button.setOnClickListener(view ->
|
||||
@@ -93,8 +90,7 @@ public class ReceiveFragment extends Fragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
requireActivity().setTitle(R.string.removable_drive_title_receive);
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -31,13 +30,13 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.view.View.FOCUS_DOWN;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@RequiresApi(19)
|
||||
@MethodsNotNullByDefault
|
||||
@@ -55,7 +54,6 @@ public class SendFragment extends Fragment {
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private RemovableDriveViewModel viewModel;
|
||||
private ScrollView scrollView;
|
||||
private TextView introTextView;
|
||||
private Button button;
|
||||
private ProgressBar progressBar;
|
||||
@@ -78,7 +76,6 @@ public class SendFragment extends Fragment {
|
||||
View v = inflater.inflate(R.layout.fragment_transfer_data_send,
|
||||
container, false);
|
||||
|
||||
scrollView = (ScrollView) v;
|
||||
introTextView = v.findViewById(R.id.introTextView);
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
button = v.findViewById(R.id.fileButton);
|
||||
@@ -107,8 +104,7 @@ public class SendFragment extends Fragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
requireActivity().setTitle(R.string.removable_drive_title_send);
|
||||
// Scroll down in case the screen is small, so the button is visible
|
||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.imageView));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,8 @@ import javax.inject.Inject;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class CrashFragment extends BaseFragment {
|
||||
@@ -55,4 +57,9 @@ public class CrashFragment extends BaseFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
hideViewOnSmallScreen(requireView().findViewById(R.id.errorIcon));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.app.KeyguardManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Debug;
|
||||
@@ -84,6 +85,8 @@ import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
||||
import static android.text.format.DateUtils.YEAR_IN_MILLIS;
|
||||
import static android.view.KeyEvent.ACTION_DOWN;
|
||||
import static android.view.KeyEvent.KEYCODE_ENTER;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
|
||||
@@ -499,6 +502,17 @@ public class UiUtils {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static void hideViewOnSmallScreen(View view) {
|
||||
boolean small = isSmallScreenRelativeToFontSize(view.getContext());
|
||||
view.setVisibility(small ? GONE : VISIBLE);
|
||||
}
|
||||
|
||||
public static boolean isSmallScreenRelativeToFontSize(Context ctx) {
|
||||
Configuration config = ctx.getResources().getConfiguration();
|
||||
if (config.fontScale == 0f) return true;
|
||||
return config.screenHeightDp / config.fontScale < 600;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the exception and shows a Toast to the user.
|
||||
* <p>
|
||||
|
||||
@@ -47,7 +47,8 @@ public class BriarButton extends FrameLayout {
|
||||
attributes.recycle();
|
||||
|
||||
ContextThemeWrapper wrapper = new ContextThemeWrapper(context, style);
|
||||
button = new AppCompatButton(wrapper, null, style);
|
||||
button = isInEditMode() ? new AppCompatButton(context) :
|
||||
new AppCompatButton(wrapper, null, style);
|
||||
button.setText(text);
|
||||
addView(button);
|
||||
progressBar = findViewById(R.id.briar_button_progress_bar);
|
||||
|
||||
Reference in New Issue
Block a user