From 38c347552b679235dbf62211a549383693ed2bb0 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 27 Sep 2022 15:36:35 -0300 Subject: [PATCH 01/18] Add UiUtils for hiding illustrations on small screens --- .../briarproject/briar/android/util/UiUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java index baa893964..76b843659 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java @@ -8,6 +8,7 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.location.LocationManager; @@ -90,6 +91,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; @@ -549,6 +552,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. *

From f42cf00c35138376f84bec52e9b7dd3b262a2fdb Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 19 Oct 2022 14:43:41 -0300 Subject: [PATCH 02/18] Fix BriarButton rendering in AS EditMode loses the style, but at least there's a preview now --- .../java/org/briarproject/briar/android/view/BriarButton.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/view/BriarButton.java b/briar-android/src/main/java/org/briarproject/briar/android/view/BriarButton.java index 944cb8587..77e4c2cbc 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/view/BriarButton.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/BriarButton.java @@ -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); From f4dd3c4f061c0b6591ce2b0e246fb311d4ea8686 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 27 Sep 2022 15:37:57 -0300 Subject: [PATCH 03/18] Replace illustration for receiving data from removable drive --- .../artwork/il_transfer_data_receive.svg | 47 +++++++ .../il_transfer_data_receive_night.svg | 47 +++++++ .../artwork/transfer_data_receive.svg | 36 ----- .../removabledrive/ReceiveFragment.java | 8 +- .../il_transfer_data_receive.xml | 109 ++++++++++++++++ .../res/drawable/ic_transfer_data_receive.xml | 15 --- .../res/drawable/il_transfer_data_receive.xml | 109 ++++++++++++++++ .../layout/fragment_transfer_data_receive.xml | 123 +++++++++--------- 8 files changed, 379 insertions(+), 115 deletions(-) create mode 100644 briar-android/artwork/il_transfer_data_receive.svg create mode 100644 briar-android/artwork/il_transfer_data_receive_night.svg delete mode 100644 briar-android/artwork/transfer_data_receive.svg create mode 100644 briar-android/src/main/res/drawable-night/il_transfer_data_receive.xml delete mode 100644 briar-android/src/main/res/drawable/ic_transfer_data_receive.xml create mode 100644 briar-android/src/main/res/drawable/il_transfer_data_receive.xml diff --git a/briar-android/artwork/il_transfer_data_receive.svg b/briar-android/artwork/il_transfer_data_receive.svg new file mode 100644 index 000000000..38a725152 --- /dev/null +++ b/briar-android/artwork/il_transfer_data_receive.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/briar-android/artwork/il_transfer_data_receive_night.svg b/briar-android/artwork/il_transfer_data_receive_night.svg new file mode 100644 index 000000000..4686c69ea --- /dev/null +++ b/briar-android/artwork/il_transfer_data_receive_night.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/briar-android/artwork/transfer_data_receive.svg b/briar-android/artwork/transfer_data_receive.svg deleted file mode 100644 index 2280b7453..000000000 --- a/briar-android/artwork/transfer_data_receive.svg +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/ReceiveFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/ReceiveFragment.java index c927d26ab..b5b022a41 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/ReceiveFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/ReceiveFragment.java @@ -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 diff --git a/briar-android/src/main/res/drawable-night/il_transfer_data_receive.xml b/briar-android/src/main/res/drawable-night/il_transfer_data_receive.xml new file mode 100644 index 000000000..ecaab1575 --- /dev/null +++ b/briar-android/src/main/res/drawable-night/il_transfer_data_receive.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/briar-android/src/main/res/drawable/ic_transfer_data_receive.xml b/briar-android/src/main/res/drawable/ic_transfer_data_receive.xml deleted file mode 100644 index 87d43457f..000000000 --- a/briar-android/src/main/res/drawable/ic_transfer_data_receive.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/briar-android/src/main/res/drawable/il_transfer_data_receive.xml b/briar-android/src/main/res/drawable/il_transfer_data_receive.xml new file mode 100644 index 000000000..a303a0890 --- /dev/null +++ b/briar-android/src/main/res/drawable/il_transfer_data_receive.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml b/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml index 71f87ee87..3911756c6 100644 --- a/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml +++ b/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml @@ -1,71 +1,78 @@ - + android:orientation="vertical"> - + android:layout_height="0dp" + android:layout_weight="1"> - + - + - + -