Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a link to Add-ons in the Settings #1656

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
191 changes: 93 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,98 @@
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: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_constraintBottom_toBottomOf="@id/whatsNewButton"
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"
android:layout_marginTop="10dp"
app:icon="@drawable/ic_whats_new"
app:layout_constraintEnd_toEndOf="@id/ff_logo_settings"
app:layout_constraintStart_toStartOf="@id/ff_logo_settings"
app:layout_constraintTop_toBottomOf="@id/scrollView2" />

<ScrollView
android:id="@+id/scrollView2"
Expand All @@ -124,7 +133,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 +216,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
23 changes: 23 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 Expand Up @@ -498,6 +512,15 @@
<!-- Phone window decoration -->
<item name="android:statusBarColor">@color/midnight</item>
<item name="android:navigationBarColor">@color/midnight</item>

<!-- Basic colors for Material buttons and other elements -->
<item name="colorOnSurface">@color/fog</item>
<item name="colorSurface">@color/asphalt</item>
<item name="colorOnContainer">@color/fog</item>
<item name="colorContainer">@color/asphalt</item>
<item name="colorOnSecondaryContainer">@color/fog</item>
<item name="colorSecondaryContainer">@color/azure</item>

</style>

<style name="Widget.FastScroll" parent="android:Widget.Material.FastScroll"/>
Expand Down
Loading