mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Clean up hardcoded platform names
The same kind of change as the changes made in the previous commit, but this change is more involved, in particular because of how SyncProgramsJobService was using display names as keys.
This commit is contained in:
parent
5b8fe1e748
commit
cbc4989095
@ -85,7 +85,7 @@ public class SyncChannelJobService extends JobService
|
||||
}
|
||||
else
|
||||
{
|
||||
subscriptions = TvUtil.createUniversalSubscriptions();
|
||||
subscriptions = TvUtil.createUniversalSubscriptions(context);
|
||||
for (HomeScreenChannel subscription : subscriptions)
|
||||
{
|
||||
long channelId = createChannel(subscription);
|
||||
|
@ -96,7 +96,8 @@ public class SyncProgramsJobService extends JobService
|
||||
Channel channel = TvUtil.getChannelById(context, channelId);
|
||||
for (Platform platform : Platform.values())
|
||||
{
|
||||
if (channel != null && channel.getDisplayName().equals(platform.getHeaderName()))
|
||||
if (channel != null &&
|
||||
channel.getAppLinkIntentUri().equals(AppLinkHelper.buildBrowseUri(platform)))
|
||||
{
|
||||
getGamesByPlatform(platform);
|
||||
syncPrograms(channelId);
|
||||
|
@ -349,7 +349,7 @@ public final class TvMainActivity extends FragmentActivity
|
||||
mGameRows.add(row);
|
||||
|
||||
// Create a header for this row.
|
||||
HeaderItem header = new HeaderItem(platform.toInt(), platform.getHeaderName());
|
||||
HeaderItem header = new HeaderItem(platform.toInt(), getString(platform.getHeaderName()));
|
||||
|
||||
// Create the row, passing it the filled adapter and the header, and give it to the master adapter.
|
||||
return new ListRow(header, row);
|
||||
|
@ -1,21 +1,25 @@
|
||||
package org.dolphinemu.dolphinemu.ui.platform;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
|
||||
/**
|
||||
* Enum to represent platform (eg GameCube, Wii).
|
||||
*/
|
||||
public enum Platform
|
||||
{
|
||||
GAMECUBE(0, "GameCube Games"),
|
||||
WII(1, "Wii Games"),
|
||||
WIIWARE(2, "WiiWare Games");
|
||||
GAMECUBE(0, R.string.platform_gamecube, "GameCube Games"),
|
||||
WII(1, R.string.platform_wii, "Wii Games"),
|
||||
WIIWARE(2, R.string.platform_wiiware, "WiiWare Games");
|
||||
|
||||
private final int value;
|
||||
private final String headerName;
|
||||
private final int headerName;
|
||||
private final String idString;
|
||||
|
||||
Platform(int value, String headerName)
|
||||
Platform(int value, int headerName, String idString)
|
||||
{
|
||||
this.value = value;
|
||||
this.headerName = headerName;
|
||||
this.idString = idString;
|
||||
}
|
||||
|
||||
public static Platform fromInt(int i)
|
||||
@ -40,8 +44,13 @@ public enum Platform
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getHeaderName()
|
||||
public int getHeaderName()
|
||||
{
|
||||
return headerName;
|
||||
}
|
||||
|
||||
public String getIdString()
|
||||
{
|
||||
return idString;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import android.net.Uri;
|
||||
|
||||
import androidx.annotation.StringDef;
|
||||
|
||||
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -29,9 +31,9 @@ public class AppLinkHelper
|
||||
.build();
|
||||
}
|
||||
|
||||
public static Uri buildBrowseUri(String subscriptionName)
|
||||
public static Uri buildBrowseUri(Platform platform)
|
||||
{
|
||||
return Uri.parse(URI_VIEW).buildUpon().appendPath(subscriptionName).build();
|
||||
return Uri.parse(URI_VIEW).buildUpon().appendPath(platform.getIdString()).build();
|
||||
}
|
||||
|
||||
public static AppLinkAction extractAction(Uri uri)
|
||||
|
@ -251,20 +251,20 @@ public class TvUtil
|
||||
/**
|
||||
* Generates all subscriptions for homescreen channels.
|
||||
*/
|
||||
public static List<HomeScreenChannel> createUniversalSubscriptions()
|
||||
public static List<HomeScreenChannel> createUniversalSubscriptions(Context context)
|
||||
{
|
||||
return new ArrayList<>(createPlatformSubscriptions());
|
||||
return new ArrayList<>(createPlatformSubscriptions(context));
|
||||
}
|
||||
|
||||
private static List<HomeScreenChannel> createPlatformSubscriptions()
|
||||
private static List<HomeScreenChannel> createPlatformSubscriptions(Context context)
|
||||
{
|
||||
List<HomeScreenChannel> subs = new ArrayList<>();
|
||||
for (Platform platform : Platform.values())
|
||||
{
|
||||
subs.add(new HomeScreenChannel(
|
||||
platform.getHeaderName(),
|
||||
platform.getHeaderName(),
|
||||
AppLinkHelper.buildBrowseUri(platform.getHeaderName()).toString()));
|
||||
context.getString(platform.getHeaderName()),
|
||||
context.getString(platform.getHeaderName()),
|
||||
AppLinkHelper.buildBrowseUri(platform).toString()));
|
||||
}
|
||||
return subs;
|
||||
}
|
||||
|
@ -334,6 +334,9 @@
|
||||
<string name="continue_anyway">Continue Anyway</string>
|
||||
|
||||
<!-- Game Grid Screen-->
|
||||
<string name="platform_gamecube">GameCube Games</string>
|
||||
<string name="platform_wii">Wii Games</string>
|
||||
<string name="platform_wiiware">WiiWare Games</string>
|
||||
<string name="add_directory_title">Add Folder to Library</string>
|
||||
<string name="grid_menu_settings">Settings</string>
|
||||
<string name="grid_menu_refresh">Refresh Library</string>
|
||||
|
Loading…
Reference in New Issue
Block a user