Skip to content

Commit

Permalink
Add a link to Add-ons in the Settings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
felipeerias committed Dec 17, 2024
1 parent 5e0f7a8 commit 089a144
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String, String> 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);
Expand Down Expand Up @@ -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 -> {
Expand All @@ -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);
Expand Down Expand Up @@ -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();
});

Expand Down
190 changes: 92 additions & 98 deletions app/src/main/res/layout/settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
Expand Down Expand Up @@ -28,90 +29,97 @@
android:layout_marginTop="50dp"
android:src="@drawable/ic_icon_back"
android:drawableTint="@color/fog_void_tint"
android:tint="@color/fog_void_tint"
android:background="@drawable/media_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/settingsMasthead"
<ImageView
android:id="@+id/ff_logo_settings"
android:layout_width="130dp"
android:layout_height="84dp"
android:layout_gravity="center"
android:layout_marginTop="23dp"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@drawable/ff_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/versionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="23dp"
android:clickable="true"
android:contextClickable="false"
android:focusable="true"
android:gravity="center_horizontal"
android:orientation="vertical"
android:contentDescription="Wolvic logo"
android:fontFamily="sans-serif"
android:gravity="center"
android:minHeight="@dimen/settings_outline_button_height"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="@dimen/text_big_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/ff_logo_settings"
android:layout_width="130dp"
android:layout_height="84dp"
android:layout_gravity="center"
android:clickable="false"
android:scaleType="fitCenter"
android:src="@drawable/ff_logo" />

<TextView
android:id="@+id/versionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:textColor="@color/white"
android:text="@string/app_name"
android:textSize="@dimen/text_big_size" />

<TextView
android:id="@+id/surveyLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/settings_send_your_feedback"
android:textColorHighlight="@android:color/transparent"
android:textColorLink="@color/azure"
android:textColor="@color/azure"
android:autoLink="all"
android:textStyle="bold"
android:textSize="@dimen/text_smaller_size"
app:visibleGone="@{DeviceType.getStoreType() != DeviceType.StoreType.MAINLAND_CHINA}" />

<TextView
android:id="@+id/chinaLicenseNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/rCN_license_number"
android:textColor="@color/azure"
android:textColorHighlight="@android:color/transparent"
android:textColorLink="@color/azure"
android:textSize="@dimen/text_medium_size"
android:textStyle="bold"
app:visibleGone="@{DeviceType.getStoreType() == DeviceType.StoreType.MAINLAND_CHINA}" />

<TextView
android:id="@+id/buildText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/settings_version_developer"
android:textColor="@color/white"
android:textSize="@dimen/text_smaller_size" />
</LinearLayout>
app:layout_constraintTop_toBottomOf="@id/ff_logo_settings" />

<TextView
android:id="@+id/chinaLicenseNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/rCN_license_number"
android:textColor="@color/azure"
android:textColorHighlight="@android:color/transparent"
android:textColorLink="@color/azure"
android:textSize="@dimen/text_medium_size"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/versionText"
app:visibleGone="@{DeviceType.getStoreType() == DeviceType.StoreType.MAINLAND_CHINA}"
tools:text="(China license number)" />

<com.google.android.material.button.MaterialButton
android:id="@+id/surveyLink"
style="@style/SettingsLinkButtonStyle"
android:layout_marginTop="8dp"
android:src="@drawable/baseline_contact_support_24"
android:text="@string/settings_send_your_feedback"
android:theme="@style/FxR.Dark"
app:icon="@drawable/baseline_contact_support_24"
app:layout_constraintEnd_toEndOf="@id/scrollView2"
app:layout_constraintTop_toBottomOf="@id/scrollView2"
app:visibleGone="@{DeviceType.getStoreType() != DeviceType.StoreType.MAINLAND_CHINA}" />

<TextView
android:id="@+id/buildText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:minHeight="@dimen/settings_outline_button_height"
android:text="@string/settings_version_developer"
android:textColor="@color/white"
android:textSize="@dimen/text_smaller_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chinaLicenseNumber" />

<com.google.android.material.button.MaterialButton
android:id="@+id/whatsNewButton"
style="@style/SettingsLinkButtonStyle"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@{settingsmodel.isWhatsNewVisible?@color/azure:@color/asphalt}"
android:src="@drawable/ic_whats_new"
android:text="@string/settings_whats_new"
android:theme="@style/FxR.Dark"
app:icon="@drawable/ic_whats_new"
app:layout_constraintBaseline_toBaselineOf="@id/buildText"
app:layout_constraintEnd_toEndOf="@id/scrollView2" />

<ScrollView
android:id="@+id/scrollView2"
Expand All @@ -124,7 +132,7 @@
android:scrollbars="none"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/settingsMasthead">
app:layout_constraintTop_toBottomOf="@id/buildText">

<HorizontalScrollView
android:layout_width="wrap_content"
Expand Down Expand Up @@ -207,33 +215,19 @@
app:honeycombButtonText="@string/settings_controller_options"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

<com.igalia.wolvic.ui.views.HoneycombButton
android:id="@+id/addonsButton"
style="?attr/honeycombButtonStyle"
app:honeycombButtonIcon="@drawable/ic_icon_addons"
app:honeycombButtonText="@string/url_addons_title"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

<com.igalia.wolvic.ui.views.HoneycombButton
android:id="@+id/helpButton"
style="?attr/honeycombButtonStyle"
app:honeycombButtonIcon="@drawable/ic_settings_help"
app:honeycombButtonText="@string/settings_help"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

<RelativeLayout
android:layout_width="136dp"
android:layout_height="136dp"
android:layout_marginEnd="-10dp">
<com.igalia.wolvic.ui.views.HoneycombButton
android:id="@+id/whatsNewButton"
style="?attr/honeycombButtonStyle"
app:honeycombButtonIcon="@drawable/ic_whats_new"
app:honeycombButtonText="@string/settings_whats_new"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="6dp"
android:layout_height="6dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="58dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:background="@drawable/downloads_badge"
app:visibleGone="@{settingsmodel.isWhatsNewVisible}"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</HorizontalScrollView>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<dimen name="settings_width">680dp</dimen>
<dimen name="settings_height">490dp</dimen>
<dimen name="settings_main_button_text_width">125dp</dimen>
<dimen name="settings_outline_button_height">24dp</dimen>

<!-- Lang Selector -->
<dimen name="lang_selector_narrow_col_item_width">100dp</dimen>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
<string name="keyboard_nl_NL_popup_u" translatable="false">uúüûùūůų</string>
<string name="keyboard_nl_NL_popup_i" translatable="false">ìíiïîįī</string>

<!-- Homepage link -->
<string name="home_page_url" translatable="false">https://wolvic.com/</string>

<!-- Settings Survey link -->
<string name="feedback_link" translatable="false">https://wolvic.com/en/feedback/index.html?version=%1$s&amp;device=%2$d</string>

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@
<item name="android:clickable">true</item>
</style>

<style name="SettingsLinkButtonStyle" parent="Widget.Material3.Button.Icon">
<item name="android:insetBottom">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:layout_height">@dimen/settings_outline_button_height</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:minWidth">116dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">@dimen/text_smaller_size</item>
<item name="iconSize">14dp</item>
<item name="textAllCaps">false</item>
</style>

<style name="tabsButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
Expand Down

0 comments on commit 089a144

Please sign in to comment.