Android: Add option to manually inject a path into the game list
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package com.github.stenzek.duckstation;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@ -209,6 +211,13 @@ public class GameDirectoriesActivity extends AppCompatActivity {
|
||||
findViewById(R.id.fab).setOnClickListener((v) -> startAddGameDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_edit_game_directories, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
@ -216,6 +225,14 @@ public class GameDirectoriesActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getItemId() == R.id.add_directory) {
|
||||
startAddGameDirectory();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.add_path) {
|
||||
startAddPath();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@ -273,6 +290,25 @@ public class GameDirectoriesActivity extends AppCompatActivity {
|
||||
REQUEST_ADD_DIRECTORY_TO_GAME_LIST);
|
||||
}
|
||||
|
||||
private void startAddPath() {
|
||||
final EditText text = new EditText(this);
|
||||
text.setSingleLine();
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.edit_game_directories_add_path)
|
||||
.setMessage(R.string.edit_game_directories_add_path_summary)
|
||||
.setView(text)
|
||||
.setPositiveButton("Add", (dialog, which) -> {
|
||||
final String path = text.getText().toString();
|
||||
if (!path.isEmpty()) {
|
||||
addSearchDirectory(GameDirectoriesActivity.this, path, true);
|
||||
mDirectoryListAdapter.reload();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
Reference in New Issue
Block a user