mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
Auto merge of #21439 - carloabelli:issue21401, r=paulrouget
Fix Android back button behavior Pressing the back button should call mServoView.goBack if possible. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [X] These changes fix #21401 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21439) <!-- Reviewable:end -->
This commit is contained in:
commit
e2e7796a0c
1 changed files with 11 additions and 1 deletions
|
@ -37,7 +37,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
EditText mUrlField;
|
||||
ProgressBar mProgressBar;
|
||||
TextView mIdleText;
|
||||
|
||||
boolean mCanGoBack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -52,6 +52,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
mUrlField = findViewById(R.id.urlfield);
|
||||
mProgressBar = findViewById(R.id.progressbar);
|
||||
mIdleText = findViewById(R.id.redrawing);
|
||||
mCanGoBack = false;
|
||||
|
||||
mBackButton.setEnabled(false);
|
||||
mFwdButton.setEnabled(false);
|
||||
|
@ -152,6 +153,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
public void onHistoryChanged(boolean canGoBack, boolean canGoForward) {
|
||||
mBackButton.setEnabled(canGoBack);
|
||||
mFwdButton.setEnabled(canGoForward);
|
||||
mCanGoBack = canGoBack;
|
||||
}
|
||||
|
||||
public void onRedrawing(boolean redrawing) {
|
||||
|
@ -173,4 +175,12 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mCanGoBack) {
|
||||
mServoView.goBack();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue