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 {
|
||||
int romId = getIntent().getIntExtra("romId", -1);
|
||||
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;
|
||||
try {
|
||||
|
@ -404,6 +406,9 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
|||
case R.id.action_save_snapshot:
|
||||
doSaveSnapshot();
|
||||
return true;
|
||||
case R.id.action_set_library_image:
|
||||
doSaveScreenshotToLibrary();
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
|
@ -436,6 +441,20 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
|||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -454,6 +473,26 @@ public class EmulatorActivity extends AppCompatActivity implements View.OnClickL
|
|||
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() {
|
||||
if (!isEmulatorRunning()) {
|
||||
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:
|
||||
romManager.updateLastPlayed(entry.getId());
|
||||
Util.startEmulator(this, this.bios, entry.getId());
|
||||
this.itemAdapter.notifyDataSetChanged();
|
||||
return true;
|
||||
case R.id.action_delete:
|
||||
romManager.deleteRomMetadata(itemAdapter.getItem(menuInfo.position));
|
||||
|
@ -214,6 +215,7 @@ public class RomListActivity extends AppCompatActivity {
|
|||
|
||||
Log.d(TAG, "found bitmap");
|
||||
romManager.updateScreenshot(romId, bitmap);
|
||||
|
||||
break;
|
||||
case REQUEST_IMPORT_SAVE:
|
||||
try {
|
||||
|
@ -234,6 +236,7 @@ public class RomListActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
|
||||
this.itemAdapter.notifyDataSetChanged();
|
||||
mGridView.setAdapter(new RomListItemAdapter(this, romManager.getAllRomMetaData()));
|
||||
mGridView.invalidate();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:keepScreenOn="true"
|
||||
android:background="@color/gbaBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:keepScreenOn="true"
|
||||
android:background="@color/gbaBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
|
|
@ -27,13 +27,18 @@
|
|||
android:orderInCategory="101"
|
||||
android:title="@string/action_view_snapshot"
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
<!-- </menu>-->
|
||||
<!-- </item>-->
|
||||
<!-- </menu>-->
|
||||
<!-- </item>-->
|
||||
|
||||
<item
|
||||
android:id="@+id/action_set_library_image"
|
||||
android:icon="@android:drawable/ic_menu_camera"
|
||||
android:title="@string/action_set_library_image" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:menuCategory="system"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<string name="action_set_screenshot">Set Image</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>
|
||||
|
||||
|
|
Reference in a new issue