mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 00:45:46 -04:00
Android: Implement disc changing via playlists
This commit is contained in:
@ -83,6 +83,10 @@ public class AndroidHostInterface {
|
||||
public native boolean isFastForwardEnabled();
|
||||
public native void setFastForwardEnabled(boolean enabled);
|
||||
|
||||
public native String[] getMediaPlaylistPaths();
|
||||
public native int getMediaPlaylistIndex();
|
||||
public native boolean setMediaPlaylistIndex(int index);
|
||||
|
||||
static {
|
||||
System.loadLibrary("duckstation-native");
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
|
||||
case 2: // Change Disc
|
||||
{
|
||||
onMenuClosed();
|
||||
showDiscChangeMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -482,6 +482,30 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
}
|
||||
}
|
||||
|
||||
private void showDiscChangeMenu() {
|
||||
final String[] paths = AndroidHostInterface.getInstance().getMediaPlaylistPaths();
|
||||
final int currentPath = AndroidHostInterface.getInstance().getMediaPlaylistIndex();
|
||||
if (paths == null)
|
||||
{
|
||||
onMenuClosed();
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
CharSequence[] items = new CharSequence[paths.length];
|
||||
for (int i = 0; i < paths.length; i++)
|
||||
items[i] = GameListEntry.getFileNameForPath(paths[i]);
|
||||
|
||||
builder.setSingleChoiceItems(items, currentPath, (dialogInterface, i) -> {
|
||||
AndroidHostInterface.getInstance().setMediaPlaylistIndex(i);
|
||||
dialogInterface.dismiss();
|
||||
onMenuClosed();
|
||||
});
|
||||
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Touchscreen controller overlay
|
||||
*/
|
||||
|
@ -9,7 +9,8 @@ import androidx.core.content.ContextCompat;
|
||||
public class GameListEntry {
|
||||
public enum EntryType {
|
||||
Disc,
|
||||
PSExe
|
||||
PSExe,
|
||||
Playlist
|
||||
}
|
||||
|
||||
public enum CompatibilityRating {
|
||||
@ -90,15 +91,17 @@ public class GameListEntry {
|
||||
return mCompatibilityRating;
|
||||
}
|
||||
|
||||
private String getSubTitle() {
|
||||
String sizeString = String.format("%.2f MB", (double) mSize / 1048576.0);
|
||||
String fileName;
|
||||
int lastSlash = mPath.lastIndexOf('/');
|
||||
if (lastSlash > 0 && lastSlash < mPath.length() - 1)
|
||||
fileName = mPath.substring(lastSlash + 1);
|
||||
public static String getFileNameForPath(String path) {
|
||||
int lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash > 0 && lastSlash < path.length() - 1)
|
||||
return path.substring(lastSlash + 1);
|
||||
else
|
||||
fileName = mPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
private String getSubTitle() {
|
||||
String fileName = getFileNameForPath(mPath);
|
||||
String sizeString = String.format("%.2f MB", (double) mSize / 1048576.0);
|
||||
return String.format("%s (%s)", fileName, sizeString);
|
||||
}
|
||||
|
||||
@ -134,6 +137,10 @@ public class GameListEntry {
|
||||
case PSExe:
|
||||
typeDrawableId = R.drawable.ic_emblem_system;
|
||||
break;
|
||||
|
||||
case Playlist:
|
||||
typeDrawableId = R.drawable.ic_baseline_playlist_play_24;
|
||||
break;
|
||||
}
|
||||
|
||||
((ImageView) view.findViewById(R.id.game_list_view_entry_type_icon))
|
||||
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4,10h12v2L4,12zM4,6h12v2L4,8zM4,14h8v2L4,16zM14,14v6l5,-3z"/>
|
||||
</vector>
|
Reference in New Issue
Block a user