refactor: MainActivity: do not use resource IDs in switch..case
This commit is contained in:
parent
a2c400de9b
commit
4e2f498c6c
|
@ -375,22 +375,22 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.id.main_menu_freeze_all:
|
if (itemId == R.id.main_menu_freeze_all) {
|
||||||
// This is the same as clicking on the batch freeze shortcut
|
// This is the same as clicking on the batch freeze shortcut
|
||||||
// so we just forward the request to DummyActivity
|
// so we just forward the request to DummyActivity
|
||||||
Intent intent = new Intent(DummyActivity.PUBLIC_FREEZE_ALL);
|
Intent intent = new Intent(DummyActivity.PUBLIC_FREEZE_ALL);
|
||||||
intent.setComponent(new ComponentName(this, DummyActivity.class));
|
intent.setComponent(new ComponentName(this, DummyActivity.class));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.main_menu_settings:
|
} else if (itemId == R.id.main_menu_settings) {
|
||||||
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putBinder("profile_service", mServiceWork.asBinder());
|
extras.putBinder("profile_service", mServiceWork.asBinder());
|
||||||
settingsIntent.putExtra("extras", extras);
|
settingsIntent.putExtra("extras", extras);
|
||||||
startActivity(settingsIntent);
|
startActivity(settingsIntent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.main_menu_create_freeze_all_shortcut:
|
} else if (itemId == R.id.main_menu_create_freeze_all_shortcut) {
|
||||||
Intent launchIntent = new Intent(DummyActivity.PUBLIC_FREEZE_ALL);
|
Intent launchIntent = new Intent(DummyActivity.PUBLIC_FREEZE_ALL);
|
||||||
launchIntent.setComponent(new ComponentName(this, DummyActivity.class));
|
launchIntent.setComponent(new ComponentName(this, DummyActivity.class));
|
||||||
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
@ -398,10 +398,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Icon.createWithResource(this, R.mipmap.ic_freeze),
|
Icon.createWithResource(this, R.mipmap.ic_freeze),
|
||||||
"shelter-freeze-all", getString(R.string.freeze_all_shortcut));
|
"shelter-freeze-all", getString(R.string.freeze_all_shortcut));
|
||||||
return true;
|
return true;
|
||||||
case R.id.main_menu_install_app_to_profile:
|
} else if (itemId == R.id.main_menu_install_app_to_profile) {
|
||||||
mSelectApk.launch(null);
|
mSelectApk.launch(null);
|
||||||
return true;
|
return true;
|
||||||
case R.id.main_menu_show_all:
|
} else if (itemId == R.id.main_menu_show_all) {
|
||||||
Runnable update = () -> {
|
Runnable update = () -> {
|
||||||
mShowAll = !item.isChecked();
|
mShowAll = !item.isChecked();
|
||||||
item.setChecked(mShowAll);
|
item.setChecked(mShowAll);
|
||||||
|
@ -420,14 +420,15 @@ public class MainActivity extends AppCompatActivity {
|
||||||
update.run();
|
update.run();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.main_menu_documents_ui:
|
} else if (itemId == R.id.main_menu_documents_ui) {
|
||||||
Intent documentsUiIntent = new Intent(Intent.ACTION_VIEW);
|
Intent documentsUiIntent = new Intent(Intent.ACTION_VIEW);
|
||||||
documentsUiIntent.setDataAndType(null, "vnd.android.document/root");
|
documentsUiIntent.setDataAndType(null, "vnd.android.document/root");
|
||||||
startActivity(documentsUiIntent);
|
startActivity(documentsUiIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onApkSelected(Uri uri) {
|
private void onApkSelected(Uri uri) {
|
||||||
if (uri == null) return;
|
if (uri == null) return;
|
||||||
|
|
Loading…
Reference in a new issue