mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-18 02:22:59 +00:00
Add HDR state to app data in shortcut trampoline
This commit is contained in:
parent
e27129fc48
commit
0ac83e1cf7
@ -23,16 +23,12 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class ShortcutTrampoline extends Activity {
|
public class ShortcutTrampoline extends Activity {
|
||||||
private String uuidString;
|
private String uuidString;
|
||||||
private String appIdString;
|
private NvApp app;
|
||||||
private String appNameString;
|
|
||||||
private ArrayList<Intent> intentStack = new ArrayList<>();
|
private ArrayList<Intent> intentStack = new ArrayList<>();
|
||||||
|
|
||||||
private ComputerDetails computer;
|
private ComputerDetails computer;
|
||||||
private SpinnerDialog blockingLoadSpinner;
|
private SpinnerDialog blockingLoadSpinner;
|
||||||
|
|
||||||
public final static String APP_NAME_EXTRA = "AppName";
|
|
||||||
public final static String APP_ID_EXTRA = "AppId";
|
|
||||||
|
|
||||||
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
||||||
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName className, IBinder binder) {
|
public void onServiceConnected(ComponentName className, IBinder binder) {
|
||||||
@ -103,10 +99,9 @@ public class ShortcutTrampoline extends Activity {
|
|||||||
if (details.state == ComputerDetails.State.ONLINE && details.pairState == PairingManager.PairState.PAIRED) {
|
if (details.state == ComputerDetails.State.ONLINE && details.pairState == PairingManager.PairState.PAIRED) {
|
||||||
|
|
||||||
// Launch game if provided app ID, otherwise launch app view
|
// Launch game if provided app ID, otherwise launch app view
|
||||||
if (appIdString != null && appIdString.length() > 0) {
|
if (app != null) {
|
||||||
if (details.runningGameId == 0 || details.runningGameId == Integer.parseInt(appIdString)) {
|
if (details.runningGameId == 0 || details.runningGameId == app.getAppId()) {
|
||||||
intentStack.add(ServerHelper.createStartIntent(ShortcutTrampoline.this,
|
intentStack.add(ServerHelper.createStartIntent(ShortcutTrampoline.this, app, details, managerBinder));
|
||||||
new NvApp(appNameString, Integer.parseInt(appIdString), false), details, managerBinder));
|
|
||||||
|
|
||||||
// Close this activity
|
// Close this activity
|
||||||
finish();
|
finish();
|
||||||
@ -116,8 +111,7 @@ public class ShortcutTrampoline extends Activity {
|
|||||||
} else {
|
} else {
|
||||||
// Create the start intent immediately, so we can safely unbind the managerBinder
|
// Create the start intent immediately, so we can safely unbind the managerBinder
|
||||||
// below before we return.
|
// below before we return.
|
||||||
final Intent startIntent = ServerHelper.createStartIntent(ShortcutTrampoline.this,
|
final Intent startIntent = ServerHelper.createStartIntent(ShortcutTrampoline.this, app, details, managerBinder);
|
||||||
new NvApp(appNameString, Integer.parseInt(appIdString), false), details, managerBinder);
|
|
||||||
|
|
||||||
UiHelper.displayQuitConfirmationDialog(ShortcutTrampoline.this, new Runnable() {
|
UiHelper.displayQuitConfirmationDialog(ShortcutTrampoline.this, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -200,7 +194,7 @@ public class ShortcutTrampoline extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected boolean validateInput() {
|
protected boolean validateInput(String uuidString, String appIdString) {
|
||||||
// Validate UUID
|
// Validate UUID
|
||||||
if (uuidString == null) {
|
if (uuidString == null) {
|
||||||
Dialog.displayDialog(ShortcutTrampoline.this,
|
Dialog.displayDialog(ShortcutTrampoline.this,
|
||||||
@ -242,13 +236,16 @@ public class ShortcutTrampoline extends Activity {
|
|||||||
|
|
||||||
UiHelper.notifyNewRootView(this);
|
UiHelper.notifyNewRootView(this);
|
||||||
|
|
||||||
|
String appIdString = getIntent().getStringExtra(Game.EXTRA_APP_ID);
|
||||||
uuidString = getIntent().getStringExtra(AppView.UUID_EXTRA);
|
uuidString = getIntent().getStringExtra(AppView.UUID_EXTRA);
|
||||||
appIdString = getIntent().getStringExtra(APP_ID_EXTRA);
|
|
||||||
|
|
||||||
// Optional - may be null
|
if (validateInput(uuidString, appIdString)) {
|
||||||
appNameString = getIntent().getStringExtra(APP_NAME_EXTRA);
|
if (appIdString != null && !appIdString.isEmpty()) {
|
||||||
|
app = new NvApp(getIntent().getStringExtra(Game.EXTRA_APP_NAME),
|
||||||
|
Integer.parseInt(appIdString),
|
||||||
|
getIntent().getBooleanExtra(Game.EXTRA_APP_HDR, false));
|
||||||
|
}
|
||||||
|
|
||||||
if (validateInput()) {
|
|
||||||
// Bind to the computer manager service
|
// Bind to the computer manager service
|
||||||
bindService(new Intent(this, ComputerManagerService.class), serviceConnection,
|
bindService(new Intent(this, ComputerManagerService.class), serviceConnection,
|
||||||
Service.BIND_AUTO_CREATE);
|
Service.BIND_AUTO_CREATE);
|
||||||
|
@ -4,8 +4,10 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.limelight.AppView;
|
||||||
import com.limelight.Game;
|
import com.limelight.Game;
|
||||||
import com.limelight.R;
|
import com.limelight.R;
|
||||||
|
import com.limelight.ShortcutTrampoline;
|
||||||
import com.limelight.binding.PlatformBinding;
|
import com.limelight.binding.PlatformBinding;
|
||||||
import com.limelight.computers.ComputerManagerService;
|
import com.limelight.computers.ComputerManagerService;
|
||||||
import com.limelight.nvstream.http.ComputerDetails;
|
import com.limelight.nvstream.http.ComputerDetails;
|
||||||
@ -25,6 +27,25 @@ public class ServerHelper {
|
|||||||
return computer.activeAddress;
|
return computer.activeAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent createPcShortcutIntent(Activity parent, ComputerDetails computer) {
|
||||||
|
Intent i = new Intent(parent, ShortcutTrampoline.class);
|
||||||
|
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
||||||
|
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
||||||
|
i.setAction(Intent.ACTION_DEFAULT);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Intent createAppShortcutIntent(Activity parent, ComputerDetails computer, NvApp app) {
|
||||||
|
Intent i = new Intent(parent, ShortcutTrampoline.class);
|
||||||
|
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
||||||
|
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
||||||
|
i.putExtra(Game.EXTRA_APP_NAME, app.getAppName());
|
||||||
|
i.putExtra(Game.EXTRA_APP_ID, ""+app.getAppId());
|
||||||
|
i.putExtra(Game.EXTRA_APP_HDR, app.isHdrSupported());
|
||||||
|
i.setAction(Intent.ACTION_DEFAULT);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public static Intent createStartIntent(Activity parent, NvApp app, ComputerDetails computer,
|
public static Intent createStartIntent(Activity parent, NvApp app, ComputerDetails computer,
|
||||||
ComputerManagerService.ComputerManagerBinder managerBinder) {
|
ComputerManagerService.ComputerManagerBinder managerBinder) {
|
||||||
Intent intent = new Intent(parent, Game.class);
|
Intent intent = new Intent(parent, Game.class);
|
||||||
|
@ -97,13 +97,8 @@ public class ShortcutHelper {
|
|||||||
|
|
||||||
public void createAppViewShortcut(ComputerDetails computer, boolean forceAdd, boolean newlyPaired) {
|
public void createAppViewShortcut(ComputerDetails computer, boolean forceAdd, boolean newlyPaired) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
Intent i = new Intent(context, ShortcutTrampoline.class);
|
|
||||||
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
|
||||||
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
|
||||||
i.setAction(Intent.ACTION_DEFAULT);
|
|
||||||
|
|
||||||
ShortcutInfo sinfo = new ShortcutInfo.Builder(context, computer.uuid)
|
ShortcutInfo sinfo = new ShortcutInfo.Builder(context, computer.uuid)
|
||||||
.setIntent(i)
|
.setIntent(ServerHelper.createPcShortcutIntent(context, computer))
|
||||||
.setShortLabel(computer.name)
|
.setShortLabel(computer.name)
|
||||||
.setLongLabel(computer.name)
|
.setLongLabel(computer.name)
|
||||||
.setIcon(Icon.createWithResource(context, R.mipmap.ic_pc_scut))
|
.setIcon(Icon.createWithResource(context, R.mipmap.ic_pc_scut))
|
||||||
@ -149,13 +144,6 @@ public class ShortcutHelper {
|
|||||||
public boolean createPinnedGameShortcut(ComputerDetails computer, NvApp app, Bitmap iconBits) {
|
public boolean createPinnedGameShortcut(ComputerDetails computer, NvApp app, Bitmap iconBits) {
|
||||||
if (sm.isRequestPinShortcutSupported()) {
|
if (sm.isRequestPinShortcutSupported()) {
|
||||||
Icon appIcon;
|
Icon appIcon;
|
||||||
Intent i = new Intent(context, ShortcutTrampoline.class);
|
|
||||||
|
|
||||||
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
|
||||||
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
|
||||||
i.putExtra(ShortcutTrampoline.APP_NAME_EXTRA, app.getAppName());
|
|
||||||
i.putExtra(ShortcutTrampoline.APP_ID_EXTRA, ""+app.getAppId());
|
|
||||||
i.setAction(Intent.ACTION_DEFAULT);
|
|
||||||
|
|
||||||
if (iconBits != null) {
|
if (iconBits != null) {
|
||||||
appIcon = Icon.createWithAdaptiveBitmap(iconBits);
|
appIcon = Icon.createWithAdaptiveBitmap(iconBits);
|
||||||
@ -164,7 +152,7 @@ public class ShortcutHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortcutInfo sInfo = new ShortcutInfo.Builder(context, getShortcutIdForGame(computer, app))
|
ShortcutInfo sInfo = new ShortcutInfo.Builder(context, getShortcutIdForGame(computer, app))
|
||||||
.setIntent(i)
|
.setIntent(ServerHelper.createAppShortcutIntent(context, computer, app))
|
||||||
.setShortLabel(app.getAppName() + " (" + computer.name + ")")
|
.setShortLabel(app.getAppName() + " (" + computer.name + ")")
|
||||||
.setIcon(appIcon)
|
.setIcon(appIcon)
|
||||||
.build();
|
.build();
|
||||||
|
@ -65,15 +65,11 @@ public class TvChannelHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent i = new Intent(context, ShortcutTrampoline.class);
|
|
||||||
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
|
||||||
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
|
||||||
i.setAction(Intent.ACTION_DEFAULT);
|
|
||||||
ChannelBuilder builder = new ChannelBuilder()
|
ChannelBuilder builder = new ChannelBuilder()
|
||||||
.setType(TvContract.Channels.TYPE_PREVIEW)
|
.setType(TvContract.Channels.TYPE_PREVIEW)
|
||||||
.setDisplayName(computer.name)
|
.setDisplayName(computer.name)
|
||||||
.setInternalProviderId(computer.uuid)
|
.setInternalProviderId(computer.uuid)
|
||||||
.setAppLinkIntent(i);
|
.setAppLinkIntent(ServerHelper.createPcShortcutIntent(context, computer));
|
||||||
|
|
||||||
Long channelId = getChannelId(computer.uuid);
|
Long channelId = getChannelId(computer.uuid);
|
||||||
if (channelId != null) {
|
if (channelId != null) {
|
||||||
@ -125,28 +121,19 @@ public class TvChannelHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviewProgramBuilder builder = new PreviewProgramBuilder();
|
|
||||||
Intent i = new Intent(context, ShortcutTrampoline.class);
|
|
||||||
|
|
||||||
i.putExtra(AppView.NAME_EXTRA, computer.name);
|
|
||||||
i.putExtra(AppView.UUID_EXTRA, computer.uuid);
|
|
||||||
i.putExtra(ShortcutTrampoline.APP_NAME_EXTRA, app.getAppName());
|
|
||||||
i.putExtra(ShortcutTrampoline.APP_ID_EXTRA, ""+app.getAppId());
|
|
||||||
i.setAction(Intent.ACTION_DEFAULT);
|
|
||||||
|
|
||||||
Uri resourceURI = PosterContentProvider.createBoxArtUri(computer.uuid, ""+app.getAppId());
|
|
||||||
|
|
||||||
Long channelId = getChannelId(computer.uuid);
|
Long channelId = getChannelId(computer.uuid);
|
||||||
if (channelId == null) {
|
if (channelId == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setChannelId(channelId)
|
PreviewProgramBuilder builder = new PreviewProgramBuilder()
|
||||||
|
.setChannelId(channelId)
|
||||||
.setType(TYPE_GAME)
|
.setType(TYPE_GAME)
|
||||||
.setTitle(app.getAppName())
|
.setTitle(app.getAppName())
|
||||||
.setPosterArtAspectRatio(ASPECT_RATIO_MOVIE_POSTER)
|
.setPosterArtAspectRatio(ASPECT_RATIO_MOVIE_POSTER)
|
||||||
.setPosterArtUri(resourceURI)
|
.setPosterArtUri(PosterContentProvider.createBoxArtUri(computer.uuid, ""+app.getAppId()))
|
||||||
.setIntent(i)
|
.setIntent(ServerHelper.createAppShortcutIntent(context, computer, app))
|
||||||
.setInternalProviderId(""+app.getAppId())
|
.setInternalProviderId(""+app.getAppId())
|
||||||
// Weight should increase each time we run the game
|
// Weight should increase each time we run the game
|
||||||
.setWeight((int)((System.currentTimeMillis() - 1500000000000L) / 1000));
|
.setWeight((int)((System.currentTimeMillis() - 1500000000000L) / 1000));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user