From e56624d92e90ef5b17c16b4d37203e869693a367 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Wed, 2 Oct 2019 17:54:26 +0200 Subject: [PATCH 1/7] URL text hint truncates Quick and dirt fix for this, better URL UI handling in 1.5 --- .../vrbrowser/ui/views/NavigationURLBar.java | 22 +++++++++++++++---- app/src/main/res/layout/navigation_url.xml | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 9883a4e38..c084b65af 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -412,23 +412,37 @@ private void showContextButtons(boolean aEnabled) { mBookmarkButton.setVisibility(GONE); mUAModeButton.setVisibility(GONE); } + + updateUrlPadding(); } public void showVoiceSearch(boolean enabled) { if (enabled) { - mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), 100), mURL.getPaddingBottom()); - mMicrophoneButton.setImageResource(R.drawable.ic_icon_microphone); mMicrophoneButton.setTooltip(getResources().getString(R.string.voice_search_tooltip)); mMicrophoneButton.setOnClickListener(mMicrophoneListener); } else if (mURL.hasFocus()){ - mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), 40), mURL.getPaddingBottom()); - mMicrophoneButton.setImageResource(R.drawable.ic_icon_clear); mMicrophoneButton.setTooltip(getResources().getString(R.string.clear_tooltip)); mMicrophoneButton.setOnClickListener(mClearListener); } + + updateUrlPadding(); + } + + private void updateUrlPadding() { + int paddingRight = 25; + if (mUAModeButton.getVisibility() == VISIBLE) { + paddingRight += 25; + } + if (mBookmarkButton.getVisibility() == VISIBLE) { + paddingRight += 25; + } + if (mMicrophoneButton.getVisibility() == VISIBLE) { + paddingRight += 25; + } + mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), paddingRight), mURL.getPaddingBottom()); } private void syncViews() { diff --git a/app/src/main/res/layout/navigation_url.xml b/app/src/main/res/layout/navigation_url.xml index b79ed1f27..7deb81aa9 100644 --- a/app/src/main/res/layout/navigation_url.xml +++ b/app/src/main/res/layout/navigation_url.xml @@ -12,7 +12,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/url_background" - android:ellipsize="none" + android:ellipsize="end" android:ems="10" android:fadingEdgeLength="30dp" android:gravity="center_vertical" From 8f5e2731c911d22761b135496ab21e943d717c15 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Wed, 2 Oct 2019 18:04:25 +0200 Subject: [PATCH 2/7] Language settings panels fixes --- .../ui/widgets/settings/LanguageOptionsView.java | 8 ++++++++ .../vrbrowser/ui/widgets/settings/SettingsView.java | 4 ++-- .../vrbrowser/ui/widgets/settings/SettingsWidget.java | 5 ++--- app/src/main/res/layout/options_header.xml | 1 - app/src/main/res/values/dimen.xml | 10 ++++++---- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java index 6a628ca44..4729445ab 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Point; import android.preference.PreferenceManager; import android.view.LayoutInflater; @@ -16,6 +17,7 @@ import org.mozilla.vrbrowser.databinding.OptionsLanguageBinding; import org.mozilla.vrbrowser.ui.adapters.Language; import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; +import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; import org.mozilla.vrbrowser.utils.LocaleUtils; import org.mozilla.vrbrowser.utils.ViewUtils; @@ -123,4 +125,10 @@ private void setDisplayLanguage() { } }; + @Override + public Point getDimensions() { + return new Point( WidgetPlacement.dpDimension(getContext(), R.dimen.language_options_width), + WidgetPlacement.dpDimension(getContext(), R.dimen.language_options_height)); + } + } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java index 3cb4edb3c..51a41d527 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java @@ -82,8 +82,8 @@ public boolean isEditing() { protected void onGlobalFocusChanged(View oldFocus, View newFocus) {} public Point getDimensions() { - return new Point( WidgetPlacement.dpDimension(getContext(), R.dimen.developer_options_width), - WidgetPlacement.dpDimension(getContext(), R.dimen.developer_options_height)); + return new Point( WidgetPlacement.dpDimension(getContext(), R.dimen.options_width), + WidgetPlacement.dpDimension(getContext(), R.dimen.options_height)); } protected boolean reset() { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java index c5081b4f9..8d10eaff3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java @@ -32,7 +32,6 @@ import org.mozilla.vrbrowser.ui.widgets.dialogs.RestartDialogWidget; import org.mozilla.vrbrowser.ui.widgets.dialogs.UIDialog; import org.mozilla.vrbrowser.ui.widgets.prompts.AlertPromptWidget; -import org.mozilla.vrbrowser.utils.SystemUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -186,9 +185,9 @@ private void initialize(Context aContext) { mAudio = AudioEngine.fromContext(aContext); - mViewMarginH = mWidgetPlacement.width - WidgetPlacement.dpDimension(getContext(), R.dimen.developer_options_width); + mViewMarginH = mWidgetPlacement.width - WidgetPlacement.dpDimension(getContext(), R.dimen.options_width); mViewMarginH = WidgetPlacement.convertDpToPixel(getContext(), mViewMarginH); - mViewMarginV = mWidgetPlacement.height - WidgetPlacement.dpDimension(getContext(), R.dimen.developer_options_height); + mViewMarginV = mWidgetPlacement.height - WidgetPlacement.dpDimension(getContext(), R.dimen.options_height); mViewMarginV = WidgetPlacement.convertDpToPixel(getContext(), mViewMarginV); } diff --git a/app/src/main/res/layout/options_header.xml b/app/src/main/res/layout/options_header.xml index 048386290..913906698 100644 --- a/app/src/main/res/layout/options_header.xml +++ b/app/src/main/res/layout/options_header.xml @@ -69,7 +69,6 @@ style="@style/settingsDescriptionText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="5dp" android:gravity="center" android:text="@{description}" tools:text="Setting description" /> diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index d0d4441e5..e58abe662 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -129,9 +129,11 @@ 40dp 4.5 - - 585dp - 385dp + + 585dp + 385dp + + 120dp 40dp @@ -245,7 +247,7 @@ 585dp - 490dp + 360dp 585dp From 06bb3147c5c60052d94eceadfabc4d20726d45bd Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Thu, 3 Oct 2019 14:28:00 +0200 Subject: [PATCH 3/7] Tooltip fixes --- .../mozilla/vrbrowser/ui/views/UIButton.java | 11 +++++-- .../vrbrowser/ui/widgets/TrayWidget.java | 5 ++- .../main/res/layout/library_notification.xml | 17 +++++----- app/src/main/res/layout/tooltip.xml | 8 +++-- app/src/main/res/layout/tooltip_tray.xml | 31 +++++++++++++++++++ app/src/main/res/layout/tray.xml | 7 ++++- app/src/main/res/values/attrs.xml | 2 ++ app/src/main/res/values/dimen.xml | 10 ++++-- 8 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 app/src/main/res/layout/tooltip_tray.xml diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java index 5ccd27024..3191b381f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java @@ -9,14 +9,15 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; -import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.MotionEvent; import androidx.annotation.IdRes; +import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.appcompat.widget.AppCompatImageButton; @@ -49,6 +50,7 @@ private enum State { private State mState; private int mTooltipDelay; private float mTooltipDensity; + private @LayoutRes int mTooltipLayout; private boolean mCurvedTooltip = true; private ViewUtils.TooltipPosition mTooltipPosition; @@ -71,11 +73,14 @@ public UIButton(Context context, AttributeSet attrs, int defStyleAttr) { mNotificationModeTintColorListRes = attributes.getResourceId(R.styleable.UIButton_notificationModeTintColorList, 0); mTooltipDelay = attributes.getInt(R.styleable.UIButton_tooltipDelay, getResources().getInteger(R.integer.tooltip_delay)); mTooltipPosition = ViewUtils.TooltipPosition.fromId(attributes.getInt(R.styleable.UIButton_tooltipPosition, ViewUtils.TooltipPosition.BOTTOM.ordinal())); - mTooltipDensity = attributes.getFloat(R.styleable.UIButton_tooltipDensity, getContext().getResources().getDisplayMetrics().density); + TypedValue densityValue = new TypedValue(); + getResources().getValue(R.dimen.tooltip_default_density, densityValue, true); + mTooltipDensity = attributes.getFloat(R.styleable.UIButton_tooltipDensity, densityValue.getFloat()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { TypedArray arr = context.obtainStyledAttributes(attrs, new int [] {android.R.attr.tooltipText}); mTooltipText = arr.getString(0); } + mTooltipLayout = attributes.getResourceId(R.styleable.UIButton_tooltipLayout, R.layout.tooltip); attributes.recycle(); mBackground = getBackground(); @@ -234,7 +239,7 @@ public void run() { } if (mTooltipView == null) { - mTooltipView = new TooltipWidget(getContext()); + mTooltipView = new TooltipWidget(getContext(), mTooltipLayout); } mTooltipView.setCurvedMode(mCurvedTooltip); mTooltipView.setText(getTooltip()); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java index 88290aaea..1d87a0510 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java @@ -28,7 +28,6 @@ import org.mozilla.vrbrowser.telemetry.TelemetryWrapper; import org.mozilla.vrbrowser.ui.views.UIButton; import org.mozilla.vrbrowser.ui.widgets.settings.SettingsWidget; -import org.mozilla.vrbrowser.utils.SystemUtils; import java.util.ArrayList; import java.util.Arrays; @@ -483,9 +482,9 @@ public void run() { mLibraryNotification.getPlacement().parentHandle = getHandle(); mLibraryNotification.getPlacement().anchorY = 0.0f; mLibraryNotification.getPlacement().translationX = (offsetViewBounds.left + mBookmarksButton.getWidth() / 2.0f) * ratio; - mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 60) * ratio); + mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 35) * ratio); mLibraryNotification.getPlacement().translationZ = 25.0f; - mLibraryNotification.getPlacement().density = 3.0f; + mLibraryNotification.getPlacement().density = WidgetPlacement.floatDimension(getContext(), R.dimen.tray_tooltip_density); mLibraryNotification.setText(R.string.bookmarks_saved_notification); mLibraryNotification.setCurvedMode(false); mLibraryNotification.show(UIWidget.CLEAR_FOCUS); diff --git a/app/src/main/res/layout/library_notification.xml b/app/src/main/res/layout/library_notification.xml index e6a2302da..f59ae568e 100644 --- a/app/src/main/res/layout/library_notification.xml +++ b/app/src/main/res/layout/library_notification.xml @@ -4,20 +4,23 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + android:layout_gravity="center"> + android:background="@drawable/library_notification_background"> @@ -16,7 +18,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" - android:textSize="@dimen/text_huge_size" + android:textSize="@dimen/tooltip_default_text_size" android:maxLines="1" android:singleLine="true" android:textColor="@color/smoke" @@ -24,6 +26,6 @@ android:shadowDx="2.0" android:shadowDy="2.0" android:shadowRadius="0.5" - tools:text="Text" /> + tools:text="Lorem Ipsum" /> \ No newline at end of file diff --git a/app/src/main/res/layout/tooltip_tray.xml b/app/src/main/res/layout/tooltip_tray.xml new file mode 100644 index 000000000..dbca1c350 --- /dev/null +++ b/app/src/main/res/layout/tooltip_tray.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/tray.xml b/app/src/main/res/layout/tray.xml index 20df19ee2..5cfc3b7f8 100644 --- a/app/src/main/res/layout/tray.xml +++ b/app/src/main/res/layout/tray.xml @@ -15,8 +15,9 @@ android:id="@+id/privateButton" style="@style/trayButtonStartTheme" app:tooltipPosition="top" - app:tooltipDensity="@dimen/tray_tooltip_density" android:tooltipText="@string/private_browsing_enter_tooltip" + app:tooltipDensity="@dimen/tray_tooltip_density" + app:tooltipLayout="@layout/tooltip_tray" android:src="@drawable/ic_icon_tray_private_browsing_v2"/> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 1c159db98..69392faa7 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -24,6 +24,7 @@ + @@ -34,6 +35,7 @@ + diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index e58abe662..4a25621d8 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -127,7 +127,10 @@ 1.2 206dp 40dp - 4.5 + 4.0 + 20dp + 10dp + 22sp 585dp @@ -207,7 +210,6 @@ 16sp 10dp 8dp - 13sp 22dp @@ -236,6 +238,10 @@ 0.02 1000 + 25dp + 15dp + 24sp + 3.0 145dp From dfbb765d7cddc0fa4805677467bf6f9172324a92 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Thu, 3 Oct 2019 15:24:10 +0200 Subject: [PATCH 4/7] Languages and display settings style updates --- .../widgets/settings/LanguageOptionsView.java | 36 +++++++++++++---- app/src/main/res/layout/options_language.xml | 39 +++++++++++++++++-- app/src/main/res/values/strings.xml | 6 +-- app/src/main/res/values/styles.xml | 8 ++-- 4 files changed, 70 insertions(+), 19 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java index 4729445ab..04498518f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java @@ -8,9 +8,15 @@ import android.content.Context; import android.content.SharedPreferences; import android.graphics.Point; +import android.graphics.Typeface; import android.preference.PreferenceManager; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.StyleSpan; import android.view.LayoutInflater; +import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.databinding.DataBindingUtil; import org.mozilla.vrbrowser.R; @@ -19,7 +25,6 @@ import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; import org.mozilla.vrbrowser.utils.LocaleUtils; -import org.mozilla.vrbrowser.utils.ViewUtils; import java.util.List; @@ -87,9 +92,7 @@ protected void onDismiss() { }; private void setVoiceLanguage() { - String voiceLanguageString = LocaleUtils.getVoiceSearchLanguageString(getContext()); - String text = getContext().getResources().getString(R.string.language_options_voice_search_language, voiceLanguageString); - mBinding.voiceSearchLanguageButton.setDescription(ViewUtils.getSpannedText(text)); + mBinding.voiceSearchLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getVoiceSearchLanguageString(getContext())), TextView.BufferType.SPANNABLE); } private void setContentLanguage() { @@ -98,13 +101,30 @@ private void setContentLanguage() { if (preferredLanguages.size() > 0) { text = preferredLanguages.get(0).getName(); } - mBinding.contentLanguageButton.setDescription(ViewUtils.getSpannedText(getContext().getResources().getString(R.string.language_options_content_language, text))); + mBinding.contentLanguageDescription.setText(getSpannedLanguageText(text)); } private void setDisplayLanguage() { - String displayLanguageString = LocaleUtils.getDisplayCurrentLanguageString(); - String text = getContext().getResources().getString(R.string.language_options_display_language, displayLanguageString); - mBinding.displayLanguageButton.setDescription(ViewUtils.getSpannedText(text)); + mBinding.displayLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getDisplayCurrentLanguageString())); + } + + private int getLanguageIndex(@NonNull String text) { + if (text.contains("(")) { + return text.indexOf("("); + } + + if (text.contains("[")) { + return text.indexOf("["); + } + + return text.length() - 1; + } + + private SpannableStringBuilder getSpannedLanguageText(@NonNull String language) { + int end = getLanguageIndex(language); + SpannableStringBuilder spanned = new SpannableStringBuilder(language); + spanned.setSpan(new StyleSpan(Typeface.BOLD), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + return spanned; } private OnClickListener mContentListener = v -> mDelegate.showView(mContentLanguage); diff --git a/app/src/main/res/layout/options_language.xml b/app/src/main/res/layout/options_language.xml index 03fb0366b..ac46d3213 100644 --- a/app/src/main/res/layout/options_language.xml +++ b/app/src/main/res/layout/options_language.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> @@ -58,7 +59,17 @@ android:layout_height="wrap_content" android:onClick="@{(view) -> voiceSearchClickListener.onClick(view)}" app:buttonText="@string/settings_button_edit" - app:description="@string/language_options_voice_search_language" /> + app:description="@string/language_options_voice_search_language_title" /> + + + app:description="@string/language_options_content_language_title" /> + + + app:description="@string/language_options_display_language_title" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cddfa3dd6..c479c34b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -755,13 +755,13 @@ Reset All Language Settings -   %1$s]]> + Voice Search Language: -   %1$s]]> + Preferred Language for Displaying Websites: -   %1$s]]> + Display Language for App: Preferred Language(s) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 04e8b7aeb..c21924ed6 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -212,10 +212,10 @@ From f074c05d427a41149e2cb849c085422dce8c3f46 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Thu, 3 Oct 2019 15:49:34 +0200 Subject: [PATCH 5/7] Vertical separators for the tray --- app/src/main/res/layout/tray.xml | 18 +++++++++++------- app/src/main/res/layout/vertical_separator.xml | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/layout/vertical_separator.xml diff --git a/app/src/main/res/layout/tray.xml b/app/src/main/res/layout/tray.xml index 5cfc3b7f8..d5d674f88 100644 --- a/app/src/main/res/layout/tray.xml +++ b/app/src/main/res/layout/tray.xml @@ -12,22 +12,24 @@ android:orientation="horizontal"> + android:src="@drawable/ic_icon_tray_newwindow"/> + android:src="@drawable/ic_icon_tray_private_browsing_v2"/> + + + + + + + + + + + + From 487a846f3ae070de60eb91203de1b5534406b201 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 4 Oct 2019 16:55:30 +0200 Subject: [PATCH 6/7] Responsive library layout --- .../vrbrowser/ui/adapters/BindingAdapters.java | 9 +++++++++ .../vrbrowser/ui/adapters/BookmarkAdapter.java | 13 +++++++++++++ .../vrbrowser/ui/adapters/HistoryAdapter.java | 12 ++++++++++++ .../mozilla/vrbrowser/ui/views/BookmarksView.java | 9 +++++++++ .../org/mozilla/vrbrowser/ui/views/HistoryView.java | 9 +++++++++ .../mozilla/vrbrowser/ui/widgets/TrayWidget.java | 2 +- app/src/main/res/layout/bookmark_item.xml | 8 +++++++- app/src/main/res/layout/history_item.xml | 9 ++++++++- app/src/main/res/values/dimen.xml | 1 + 9 files changed, 69 insertions(+), 3 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BindingAdapters.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BindingAdapters.java index 208405cb0..8e0c23b36 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BindingAdapters.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BindingAdapters.java @@ -6,8 +6,10 @@ import android.text.SpannableString; import android.text.style.ImageSpan; import android.view.View; +import android.view.ViewGroup; import android.widget.TextView; +import androidx.annotation.Dimension; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.databinding.BindingAdapter; @@ -65,4 +67,11 @@ public static void setSpannableString(@NonNull TextView textView, Drawable drawa spannableString.setSpan(span, spannableString.toString().indexOf("@"), spannableString.toString().indexOf("@")+1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); textView.setText(spannableString); } + + @BindingAdapter("layout_height") + public static void setLayoutHeight(@NonNull View view, @NonNull @Dimension float dimen) { + ViewGroup.LayoutParams params = view.getLayoutParams(); + params.height = (int)dimen; + view.setLayoutParams(params); + } } \ No newline at end of file diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BookmarkAdapter.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BookmarkAdapter.java index 009aa8fed..706cba343 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BookmarkAdapter.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/BookmarkAdapter.java @@ -38,6 +38,7 @@ public class BookmarkAdapter extends RecyclerView.Adapter bookmarkList) { if (mBookmarkList == null) { mBookmarkList = bookmarkList; @@ -116,8 +126,10 @@ public BookmarkViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int view BookmarkItemBinding binding = DataBindingUtil .inflate(LayoutInflater.from(parent.getContext()), R.layout.bookmark_item, parent, false); + binding.setCallback(mBookmarkItemCallback); binding.setIsHovered(false); + binding.setIsNarrow(mIsNarrowLayout); binding.layout.setOnHoverListener((view, motionEvent) -> { int ev = motionEvent.getActionMasked(); switch (ev) { @@ -184,6 +196,7 @@ public BookmarkViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int view @Override public void onBindViewHolder(@NonNull BookmarkViewHolder holder, int position) { holder.binding.setItem(mBookmarkList.get(position)); + holder.binding.setIsNarrow(mIsNarrowLayout); holder.binding.executePendingBindings(); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/HistoryAdapter.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/HistoryAdapter.java index f8787a47e..ae197e568 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/HistoryAdapter.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/HistoryAdapter.java @@ -43,6 +43,7 @@ public class HistoryAdapter extends RecyclerView.Adapter historyList) { if (mHistoryList == null) { mHistoryList = historyList; @@ -131,6 +141,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int parent, false); binding.setCallback(mHistoryItemCallback); binding.setIsHovered(false); + binding.setIsNarrow(mIsNarrowLayout); binding.layout.setOnHoverListener((view, motionEvent) -> { int ev = motionEvent.getActionMasked(); switch (ev) { @@ -210,6 +221,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi if (holder instanceof HistoryItemViewHolder) { HistoryItemViewHolder item = (HistoryItemViewHolder) holder; item.binding.setItem(mHistoryList.get(position)); + item.binding.setIsNarrow(mIsNarrowLayout); item.binding.executePendingBindings(); } else if (holder instanceof HistoryItemViewHeaderHolder) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java index 15c553aa4..1ca6f3b79 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java @@ -20,6 +20,7 @@ import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.audio.AudioEngine; import org.mozilla.vrbrowser.browser.BookmarksStore; +import org.mozilla.vrbrowser.browser.SettingsStore; import org.mozilla.vrbrowser.browser.engine.SessionStack; import org.mozilla.vrbrowser.browser.engine.SessionStore; import org.mozilla.vrbrowser.databinding.BookmarksBinding; @@ -153,6 +154,14 @@ private void showBookmarks(List aBookmarks) { mBinding.executePendingBindings(); } + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + double width = Math.ceil(getWidth()/getContext().getResources().getDisplayMetrics().density); + mBookmarkAdapter.setNarrow(width < SettingsStore.WINDOW_WIDTH_DEFAULT); + } + // BookmarksStore.BookmarksViewListener @Override public void onBookmarksUpdated() { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java index 851f947b0..cc2bad970 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java @@ -20,6 +20,7 @@ import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.browser.HistoryStore; +import org.mozilla.vrbrowser.browser.SettingsStore; import org.mozilla.vrbrowser.browser.engine.SessionStack; import org.mozilla.vrbrowser.browser.engine.SessionStore; import org.mozilla.vrbrowser.databinding.HistoryBinding; @@ -199,6 +200,14 @@ private void showHistory(List historyItems) { mBinding.executePendingBindings(); } + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + double width = Math.ceil(getWidth()/getContext().getResources().getDisplayMetrics().density); + mHistoryAdapter.setNarrow(width < SettingsStore.WINDOW_WIDTH_DEFAULT); + } + // HistoryStore.HistoryListener @Override public void onHistoryUpdated() { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java index 1d87a0510..780187792 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java @@ -482,7 +482,7 @@ public void run() { mLibraryNotification.getPlacement().parentHandle = getHandle(); mLibraryNotification.getPlacement().anchorY = 0.0f; mLibraryNotification.getPlacement().translationX = (offsetViewBounds.left + mBookmarksButton.getWidth() / 2.0f) * ratio; - mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 35) * ratio); + mLibraryNotification.getPlacement().translationY = ((offsetViewBounds.top - 60) * ratio); mLibraryNotification.getPlacement().translationZ = 25.0f; mLibraryNotification.getPlacement().density = WidgetPlacement.floatDimension(getContext(), R.dimen.tray_tooltip_density); mLibraryNotification.setText(R.string.bookmarks_saved_notification); diff --git a/app/src/main/res/layout/bookmark_item.xml b/app/src/main/res/layout/bookmark_item.xml index 0011f4334..25cdc679d 100644 --- a/app/src/main/res/layout/bookmark_item.xml +++ b/app/src/main/res/layout/bookmark_item.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools"> + + + + android:orientation="@{isNarrow ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"> + + @@ -15,11 +17,16 @@ + + + android:orientation="@{isNarrow ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"> 38dp + 64dp 18sp 20sp 16sp From a73cd20c7f0913fc9ae0472387df8dbb15831776 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 7 Oct 2019 10:35:42 +0200 Subject: [PATCH 7/7] Reverte of URL hint fix --- .../vrbrowser/ui/views/NavigationURLBar.java | 22 ++++--------------- app/src/main/res/layout/navigation_url.xml | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index c084b65af..9883a4e38 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -412,37 +412,23 @@ private void showContextButtons(boolean aEnabled) { mBookmarkButton.setVisibility(GONE); mUAModeButton.setVisibility(GONE); } - - updateUrlPadding(); } public void showVoiceSearch(boolean enabled) { if (enabled) { + mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), 100), mURL.getPaddingBottom()); + mMicrophoneButton.setImageResource(R.drawable.ic_icon_microphone); mMicrophoneButton.setTooltip(getResources().getString(R.string.voice_search_tooltip)); mMicrophoneButton.setOnClickListener(mMicrophoneListener); } else if (mURL.hasFocus()){ + mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), 40), mURL.getPaddingBottom()); + mMicrophoneButton.setImageResource(R.drawable.ic_icon_clear); mMicrophoneButton.setTooltip(getResources().getString(R.string.clear_tooltip)); mMicrophoneButton.setOnClickListener(mClearListener); } - - updateUrlPadding(); - } - - private void updateUrlPadding() { - int paddingRight = 25; - if (mUAModeButton.getVisibility() == VISIBLE) { - paddingRight += 25; - } - if (mBookmarkButton.getVisibility() == VISIBLE) { - paddingRight += 25; - } - if (mMicrophoneButton.getVisibility() == VISIBLE) { - paddingRight += 25; - } - mURL.setPadding(mURL.getPaddingStart(), mURL.getPaddingTop(), WidgetPlacement.convertDpToPixel(getContext(), paddingRight), mURL.getPaddingBottom()); } private void syncViews() { diff --git a/app/src/main/res/layout/navigation_url.xml b/app/src/main/res/layout/navigation_url.xml index 7deb81aa9..b79ed1f27 100644 --- a/app/src/main/res/layout/navigation_url.xml +++ b/app/src/main/res/layout/navigation_url.xml @@ -12,7 +12,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/url_background" - android:ellipsize="end" + android:ellipsize="none" android:ems="10" android:fadingEdgeLength="30dp" android:gravity="center_vertical"