From 089a144e0c18363870f3986327d12ed131f770f2 Mon Sep 17 00:00:00 2001 From: Felipe Erias Date: Fri, 6 Dec 2024 21:20:59 +0900 Subject: [PATCH] Add a link to Add-ons in the Settings Add a button to open the Add-ons page from the Settings, since that is a pretty obvious place to find this functionality. To avoid messing up the layout of the honeycomb buttons, I've moved the "What's New" button closer to the version details. After some experimentation, I've placed two small buttons on the right side of the Settings window, linking to the Feedback and News pages. The background of the What's New button becomes highlighted when the details of the new version are available (this replaces the little blue dot that we had before). I have also simplified the implementation of the hidden shortcut to show the version details. Now it is just a matter of clicking on the app logo or the app name. Finally, I have also simplified the layout in the Settings window by removing an unneeded LinearLayout and using the parent ConstraintLayout instead. --- .../ui/widgets/settings/SettingsWidget.java | 56 +++--- app/src/main/res/layout/settings.xml | 190 +++++++++--------- app/src/main/res/values/dimen.xml | 1 + app/src/main/res/values/non_L10n.xml | 3 + app/src/main/res/values/styles.xml | 14 ++ 5 files changed, 139 insertions(+), 125 deletions(-) diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/settings/SettingsWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/settings/SettingsWidget.java index 3f98e0f1d8..612dfa214c 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/settings/SettingsWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/settings/SettingsWidget.java @@ -15,9 +15,8 @@ import android.text.Html; import android.util.AttributeSet; import android.util.Log; -import android.view.GestureDetector; +import android.util.Pair; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -42,6 +41,7 @@ import com.igalia.wolvic.ui.widgets.UIWidget; import com.igalia.wolvic.ui.widgets.WidgetPlacement; import com.igalia.wolvic.ui.widgets.WindowWidget; +import com.igalia.wolvic.ui.widgets.Windows; import com.igalia.wolvic.ui.widgets.dialogs.ClearUserDataDialogWidget; import com.igalia.wolvic.ui.widgets.dialogs.RestartDialogWidget; import com.igalia.wolvic.ui.widgets.dialogs.UIDialog; @@ -74,22 +74,11 @@ public class SettingsWidget extends UIDialog implements SettingsView.Delegate { private SettingsView.SettingViewType mOpenDialog; private SettingsViewModel mSettingsViewModel; private boolean mAreMozillaAccountsDisabled; + private final Pair mVersionDetail = new Pair<>( + "versionCode " + BuildConfig.VERSION_CODE, + BuildConfig.GIT_HASH + " (AC " + Build.version + ")"); + private boolean mIsFirstVersionDetail; - class VersionGestureListener extends GestureDetector.SimpleOnGestureListener { - - private boolean mIsHash; - - @Override - public boolean onDown (MotionEvent e) { - mBinding.buildText.setText(mIsHash ? - "versionCode " + BuildConfig.VERSION_CODE : - BuildConfig.GIT_HASH + " (AC " + Build.version + ")"); - - mIsHash = !mIsHash; - - return true; - } - } public SettingsWidget(Context aContext) { super(aContext); @@ -193,18 +182,19 @@ public void updateUI() { Html.FROM_HTML_MODE_LEGACY)); } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); + Log.e(LOGTAG, "Error when getting package info:" + e.getMessage()); + mBinding.versionText.setText(R.string.app_name); } - mBinding.buildText.setText("versionCode " + BuildConfig.VERSION_CODE); + mIsFirstVersionDetail = false; + mBinding.buildText.setText(mVersionDetail.first); - final GestureDetector gd = new GestureDetector(getContext(), new VersionGestureListener()); - mBinding.settingsMasthead.setOnTouchListener((view, motionEvent) -> { - if (gd.onTouchEvent(motionEvent)) { - return true; - } - return view.performClick(); - }); + OnClickListener updateVersionDetail = v -> { + mIsFirstVersionDetail = !mIsFirstVersionDetail; + mBinding.buildText.setText(mIsFirstVersionDetail ? mVersionDetail.first : mVersionDetail.second); + }; + mBinding.ffLogoSettings.setOnClickListener(updateVersionDetail); + mBinding.versionText.setOnClickListener(updateVersionDetail); if (DeviceType.getStoreType() == DeviceType.StoreType.MAINLAND_CHINA) { mBinding.chinaLicenseNumber.setOnClickListener(v -> { @@ -225,6 +215,14 @@ public void updateUI() { }); } + mBinding.addonsButton.setOnClickListener(view -> { + if (mAudio != null) { + mAudio.playSound(AudioEngine.Sound.CLICK); + } + mWidgetManager.getFocusedWindow().showPanel(Windows.ContentType.ADDONS); + onDismiss(); + }); + mBinding.helpButton.setOnClickListener(view -> { if (mAudio != null) { mAudio.playSound(AudioEngine.Sound.CLICK); @@ -264,9 +262,13 @@ public void updateUI() { SettingsStore.getInstance(getContext()).setRemotePropsVersionName(BuildConfig.VERSION_NAME); RemoteProperties props = mSettingsViewModel.getProps().getValue().get(BuildConfig.VERSION_NAME); + String whatsNewUrl; if (props != null) { - mWidgetManager.openNewTabForeground(props.getWhatsNewUrl()); + whatsNewUrl = props.getWhatsNewUrl(); + } else { + whatsNewUrl = getContext().getString(R.string.home_page_url); } + mWidgetManager.openNewTabForeground(whatsNewUrl); onDismiss(); }); diff --git a/app/src/main/res/layout/settings.xml b/app/src/main/res/layout/settings.xml index bcb9209081..6b987a058a 100644 --- a/app/src/main/res/layout/settings.xml +++ b/app/src/main/res/layout/settings.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> - + + - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/ff_logo_settings" /> + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/buildText"> + + - - - - - diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index 2ec690d259..94b05d2eba 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -75,6 +75,7 @@ 680dp 490dp 125dp + 24dp 100dp diff --git a/app/src/main/res/values/non_L10n.xml b/app/src/main/res/values/non_L10n.xml index 31bcd227e3..ed4632ffc7 100644 --- a/app/src/main/res/values/non_L10n.xml +++ b/app/src/main/res/values/non_L10n.xml @@ -225,6 +225,9 @@ uúüûùūůų ìíiïîįī + + https://wolvic.com/ + https://wolvic.com/en/feedback/index.html?version=%1$s&device=%2$d diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 39ff367ece..ae24bd325c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -305,6 +305,20 @@ true + +