Merge pull request #10358 from Simonx22/android-back-button

Android: remove save icon and add up button
This commit is contained in:
JMC47 2022-01-07 22:25:02 -05:00 committed by GitHub
commit 94ad33c42c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 39 deletions

View File

@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -94,6 +93,9 @@ public class CheatsActivity extends AppCompatActivity
onSelectedCheatChanged(mViewModel.getSelectedCheat().getValue()); onSelectedCheatChanged(mViewModel.getSelectedCheat().getValue());
mViewModel.getOpenDetailsViewEvent().observe(this, this::openDetailsView); mViewModel.getOpenDetailsViewEvent().observe(this, this::openDetailsView);
// show up button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
@ -105,18 +107,6 @@ public class CheatsActivity extends AppCompatActivity
return true; return true;
} }
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if (item.getItemId() == R.id.menu_save_exit)
{
finish();
return true;
}
return false;
}
@Override @Override
protected void onStop() protected void onStop()
{ {
@ -179,6 +169,13 @@ public class CheatsActivity extends AppCompatActivity
} }
} }
@Override
public boolean onSupportNavigateUp()
{
onBackPressed();
return true;
}
private void openDetailsView(boolean open) private void openDetailsView(boolean open)
{ {
if (open) if (open)

View File

@ -75,6 +75,9 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
mPresenter = new SettingsActivityPresenter(this, getSettings()); mPresenter = new SettingsActivityPresenter(this, getSettings());
mPresenter.onCreate(savedInstanceState, menuTag, gameID, revision, isWii, this); mPresenter.onCreate(savedInstanceState, menuTag, gameID, revision, isWii, this);
// show up button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
@ -86,12 +89,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
return true; return true;
} }
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
return mPresenter.handleOptionsItem(item.getItemId());
}
@Override @Override
protected void onSaveInstanceState(@NonNull Bundle outState) protected void onSaveInstanceState(@NonNull Bundle outState)
{ {
@ -294,6 +291,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
mPresenter.onExtensionSettingChanged(menuTag, value); mPresenter.onExtensionSettingChanged(menuTag, value);
} }
@Override
public boolean onSupportNavigateUp()
{
onBackPressed();
return true;
}
private SettingsFragment getFragment() private SettingsFragment getFragment()
{ {
return (SettingsFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG); return (SettingsFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);

View File

@ -120,17 +120,6 @@ public final class SettingsActivityPresenter
} }
} }
public boolean handleOptionsItem(int itemId)
{
if (itemId == R.id.menu_save_exit)
{
mView.finish();
return true;
}
return false;
}
public void onSettingChanged() public void onSettingChanged()
{ {
mShouldSave = true; mShouldSave = true;

View File

@ -1,11 +1,3 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu 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"/>
<item
android:id="@+id/menu_save_exit"
android:title="@string/preferences_save_exit"
android:icon="@drawable/ic_quicksave"
app:showAsAction="ifRoom"/>
</menu>