-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Use legacy User-Agent by default, add more settings #440
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8390dab
Developer settings for User-Agent
felipeerias aa5ef64
Log message
felipeerias 55646e1
Additional browser names in User-Agent for compatibility
felipeerias 8c96b72
Update the UA mode when the setting changes
felipeerias 985dc14
Don't reload when the "UA mode" setting changes
felipeerias 0f0ff82
Revert "Additional browser names in User-Agent for compatibility"
felipeerias 49ad443
Show a warning after changing the default User-Agent
felipeerias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
package com.igalia.wolvic.ui.widgets.settings; | ||
|
||
import android.content.Context; | ||
import android.graphics.Point; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
|
||
|
@@ -16,8 +17,10 @@ | |
import com.igalia.wolvic.browser.SettingsStore; | ||
import com.igalia.wolvic.browser.engine.SessionStore; | ||
import com.igalia.wolvic.databinding.OptionsDeveloperBinding; | ||
import com.igalia.wolvic.ui.views.settings.RadioGroupSetting; | ||
import com.igalia.wolvic.ui.views.settings.SwitchSetting; | ||
import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate; | ||
import com.igalia.wolvic.ui.widgets.WidgetPlacement; | ||
|
||
class DeveloperOptionsView extends SettingsView { | ||
|
||
|
@@ -76,6 +79,13 @@ protected void updateUI() { | |
|
||
mBinding.localAddonSwitch.setOnCheckedChangeListener(mLocalAddonListener); | ||
setLocalAddon(SettingsStore.getInstance(getContext()).isLocalAddonAllowed(), false); | ||
|
||
mBinding.wolvicUserAgentSwitch.setOnCheckedChangeListener(mUseWolvicUAListener); | ||
setUseWolvicUA(SettingsStore.getInstance(getContext()).getUseWolvicUA(), false); | ||
|
||
int uaMode = SettingsStore.getInstance(getContext()).getUaMode(); | ||
mBinding.uaRadio.setOnCheckedChangeListener(mUaModeListener); | ||
setUaMode(mBinding.uaRadio.getIdForValue(uaMode), false); | ||
} | ||
|
||
private SwitchSetting.OnCheckedChangeListener mRemoteDebuggingListener = (compoundButton, value, doApply) -> { | ||
|
@@ -106,6 +116,13 @@ protected void updateUI() { | |
setLocalAddon(value, doApply); | ||
}; | ||
|
||
private SwitchSetting.OnCheckedChangeListener mUseWolvicUAListener = (compoundButton, enabled, apply) -> | ||
setUseWolvicUA(enabled, true); | ||
|
||
private RadioGroupSetting.OnCheckedChangeListener mUaModeListener = (radioGroup, checkedId, doApply) -> { | ||
setUaMode(checkedId, true); | ||
}; | ||
|
||
private OnClickListener mResetListener = (view) -> { | ||
boolean restart = false; | ||
if (mBinding.remoteDebuggingSwitch.isChecked() != SettingsStore.REMOTE_DEBUGGING_DEFAULT) { | ||
|
@@ -139,6 +156,14 @@ protected void updateUI() { | |
setLocalAddon(SettingsStore.LOCAL_ADDON_ALLOWED, true); | ||
} | ||
|
||
if (mBinding.wolvicUserAgentSwitch.isChecked() != SettingsStore.USE_WOLVIC_UA_DEFAULT) { | ||
setUseWolvicUA(SettingsStore.USE_WOLVIC_UA_DEFAULT, true); | ||
} | ||
|
||
if (!mBinding.uaRadio.getValueForId(mBinding.uaRadio.getCheckedRadioButtonId()).equals(SettingsStore.UA_MODE_DEFAULT)) { | ||
setUaMode(mBinding.uaRadio.getIdForValue(SettingsStore.UA_MODE_DEFAULT), true); | ||
} | ||
|
||
if (restart) { | ||
showRestartDialog(); | ||
} | ||
|
@@ -219,9 +244,38 @@ private void setLocalAddon(boolean value, boolean doApply) { | |
} | ||
} | ||
|
||
private void setUseWolvicUA(boolean value, boolean doApply) { | ||
mBinding.wolvicUserAgentSwitch.setOnCheckedChangeListener(null); | ||
mBinding.wolvicUserAgentSwitch.setValue(value, false); | ||
mBinding.wolvicUserAgentSwitch.setOnCheckedChangeListener(mUseWolvicUAListener); | ||
|
||
if (doApply) { | ||
SettingsStore.getInstance(getContext()).setUseWolvicUA(value); | ||
|
||
if (value != SettingsStore.USE_WOLVIC_UA_DEFAULT) { | ||
showAlert(getContext().getString(R.string.developer_options_wolvic_user_agent_warning_title), | ||
getContext().getString(R.string.developer_options_wolvic_user_agent_warning_body)); | ||
} | ||
} | ||
} | ||
|
||
private void setUaMode(int checkId, boolean doApply) { | ||
mBinding.uaRadio.setOnCheckedChangeListener(null); | ||
mBinding.uaRadio.setChecked(checkId, doApply); | ||
mBinding.uaRadio.setOnCheckedChangeListener(mUaModeListener); | ||
|
||
SettingsStore.getInstance(getContext()).setUaMode((Integer) mBinding.uaRadio.getValueForId(checkId)); | ||
} | ||
|
||
@Override | ||
public Point getDimensions() { | ||
return new Point(WidgetPlacement.dpDimension(getContext(), R.dimen.settings_dialog_width), | ||
WidgetPlacement.dpDimension(getContext(), R.dimen.developer_options_height)); | ||
} | ||
|
||
@Override | ||
protected SettingViewType getType() { | ||
return SettingViewType.LANGUAGE_VOICE; | ||
return SettingViewType.DEVELOPER; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a little issue that I saw when changing the dialog, it seems too small for its own PR but I can open one if needed. |
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the relationship of this with anything else.
Is it something that was missing? Does it fix any particular issue? If that's the case it should go in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the dialog a bit taller, which is needed after adding the two settings for the User-Agent.
The alternative was to keep the dialog with the same height, but that looks worse: