platform/android: Add menu options to capture a screenshot as the library preview image
Former-commit-id: 59d0858d93cb2681bb3e4230c44858a2fe28f208 Former-commit-id: 41b094d2f7971c3ef9e53234bd0c65e56ef99e20
This commit is contained in:
parent
d1bf01d562
commit
91c3b5321a
|
@ -369,7 +369,9 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
||||||
} else {
|
} else {
|
||||||
int romId = getIntent().getIntExtra("romId", -1);
|
int romId = getIntent().getIntExtra("romId", -1);
|
||||||
if (-1 != romId) {
|
if (-1 != romId) {
|
||||||
this.romMetadata = RomManager.getInstance(this).getRomMetadata(romId);
|
RomManager romManager = RomManager.getInstance(this);
|
||||||
|
romManager.updateLastPlayed(romId);
|
||||||
|
this.romMetadata = romManager.getRomMetadata(romId);
|
||||||
|
|
||||||
byte[] romData;
|
byte[] romData;
|
||||||
try {
|
try {
|
||||||
|
@ -404,6 +406,9 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
||||||
case R.id.action_save_snapshot:
|
case R.id.action_save_snapshot:
|
||||||
doSaveSnapshot();
|
doSaveSnapshot();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_set_library_image:
|
||||||
|
doSaveScreenshotToLibrary();
|
||||||
|
return true;
|
||||||
case R.id.action_settings:
|
case R.id.action_settings:
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -436,6 +441,20 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
pauseEmulation();
|
pauseEmulation();
|
||||||
|
|
||||||
|
if (this.romMetadata != null) {
|
||||||
|
if (this.romMetadata.getScreenshot() == null) {
|
||||||
|
// Save current screenshot
|
||||||
|
Bitmap screenshot = Bitmap.createBitmap(
|
||||||
|
emulator.getFrameBuffer(),
|
||||||
|
240,
|
||||||
|
160,
|
||||||
|
Bitmap.Config.RGB_565);
|
||||||
|
|
||||||
|
RomManager.getInstance(this).updateScreenshot(this.romMetadata.getId(), screenshot);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
killThreads();
|
killThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +473,26 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
||||||
audioPlayer.play();
|
audioPlayer.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doSaveScreenshotToLibrary() {
|
||||||
|
if (!isEmulatorRunning() || null == this.romMetadata) {
|
||||||
|
Toast.makeText(this, "No game is running!", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pauseEmulation();
|
||||||
|
|
||||||
|
Bitmap screenshot = Bitmap.createBitmap(
|
||||||
|
emulator.getFrameBuffer(),
|
||||||
|
240,
|
||||||
|
160,
|
||||||
|
Bitmap.Config.RGB_565);
|
||||||
|
|
||||||
|
RomManager.getInstance(this).updateScreenshot(this.romMetadata.getId(), screenshot);
|
||||||
|
|
||||||
|
|
||||||
|
resumeEmulation();
|
||||||
|
}
|
||||||
|
|
||||||
public void doSaveSnapshot() {
|
public void doSaveSnapshot() {
|
||||||
if (!isEmulatorRunning()) {
|
if (!isEmulatorRunning()) {
|
||||||
Toast.makeText(this, "No game is running!", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "No game is running!", Toast.LENGTH_LONG).show();
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class RomListActivity extends AppCompatActivity {
|
||||||
case R.id.action_play:
|
case R.id.action_play:
|
||||||
romManager.updateLastPlayed(entry.getId());
|
romManager.updateLastPlayed(entry.getId());
|
||||||
Util.startEmulator(this, this.bios, entry.getId());
|
Util.startEmulator(this, this.bios, entry.getId());
|
||||||
|
this.itemAdapter.notifyDataSetChanged();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_delete:
|
case R.id.action_delete:
|
||||||
romManager.deleteRomMetadata(itemAdapter.getItem(menuInfo.position));
|
romManager.deleteRomMetadata(itemAdapter.getItem(menuInfo.position));
|
||||||
|
@ -214,6 +215,7 @@ public class RomListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
Log.d(TAG, "found bitmap");
|
Log.d(TAG, "found bitmap");
|
||||||
romManager.updateScreenshot(romId, bitmap);
|
romManager.updateScreenshot(romId, bitmap);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case REQUEST_IMPORT_SAVE:
|
case REQUEST_IMPORT_SAVE:
|
||||||
try {
|
try {
|
||||||
|
@ -234,6 +236,7 @@ public class RomListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.itemAdapter.notifyDataSetChanged();
|
||||||
mGridView.setAdapter(new RomListItemAdapter(this, romManager.getAllRomMetaData()));
|
mGridView.setAdapter(new RomListItemAdapter(this, romManager.getAllRomMetaData()));
|
||||||
mGridView.invalidate();
|
mGridView.invalidate();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:keepScreenOn="true"
|
||||||
android:background="@color/gbaBackground"
|
android:background="@color/gbaBackground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:keepScreenOn="true"
|
||||||
android:background="@color/gbaBackground"
|
android:background="@color/gbaBackground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
|
@ -30,10 +30,15 @@
|
||||||
<!-- </menu>-->
|
<!-- </menu>-->
|
||||||
<!-- </item>-->
|
<!-- </item>-->
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_set_library_image"
|
||||||
|
android:icon="@android:drawable/ic_menu_camera"
|
||||||
|
android:title="@string/action_set_library_image" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_settings"
|
||||||
android:orderInCategory="100"
|
|
||||||
android:menuCategory="system"
|
android:menuCategory="system"
|
||||||
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_settings"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<string name="action_set_screenshot">Set Image</string>
|
<string name="action_set_screenshot">Set Image</string>
|
||||||
|
|
||||||
<string name="action_delete">Delete</string>
|
<string name="action_delete">Delete</string>
|
||||||
|
<string name="action_set_library_image"> Take screenshot for library view </string>
|
||||||
|
|
||||||
<string name="title_activity_snapshot">Snapshot Manager</string>
|
<string name="title_activity_snapshot">Snapshot Manager</string>
|
||||||
|
|
||||||
|
|
Reference in a new issue