mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Improve shortcut handling when the list is full
This commit is contained in:
parent
d5863e1bef
commit
fc629db653
@ -248,13 +248,17 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
|
|
||||||
uuidString = getIntent().getStringExtra(UUID_EXTRA);
|
uuidString = getIntent().getStringExtra(UUID_EXTRA);
|
||||||
|
|
||||||
shortcutHelper.reportShortcutUsed(uuidString);
|
String computerName = getIntent().getStringExtra(NAME_EXTRA);
|
||||||
|
|
||||||
String labelText = getResources().getString(R.string.title_applist)+" "+getIntent().getStringExtra(NAME_EXTRA);
|
String labelText = getResources().getString(R.string.title_applist)+" "+computerName;
|
||||||
TextView label = (TextView) findViewById(R.id.appListText);
|
TextView label = (TextView) findViewById(R.id.appListText);
|
||||||
setTitle(labelText);
|
setTitle(labelText);
|
||||||
label.setText(labelText);
|
label.setText(labelText);
|
||||||
|
|
||||||
|
// Add a launcher shortcut for this PC (forced, since this is user interaction)
|
||||||
|
shortcutHelper.createAppViewShortcut(uuidString, computerName, uuidString, true);
|
||||||
|
shortcutHelper.reportShortcutUsed(uuidString);
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -24,6 +24,7 @@ import com.limelight.preferences.PreferenceConfiguration;
|
|||||||
import com.limelight.ui.GameGestures;
|
import com.limelight.ui.GameGestures;
|
||||||
import com.limelight.ui.StreamView;
|
import com.limelight.ui.StreamView;
|
||||||
import com.limelight.utils.Dialog;
|
import com.limelight.utils.Dialog;
|
||||||
|
import com.limelight.utils.ShortcutHelper;
|
||||||
import com.limelight.utils.SpinnerDialog;
|
import com.limelight.utils.SpinnerDialog;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
@ -97,6 +98,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
private boolean grabComboDown = false;
|
private boolean grabComboDown = false;
|
||||||
private StreamView streamView;
|
private StreamView streamView;
|
||||||
|
|
||||||
|
private ShortcutHelper shortcutHelper;
|
||||||
|
|
||||||
private EnhancedDecoderRenderer decoderRenderer;
|
private EnhancedDecoderRenderer decoderRenderer;
|
||||||
|
|
||||||
private WifiManager.WifiLock wifiLock;
|
private WifiManager.WifiLock wifiLock;
|
||||||
@ -123,11 +126,15 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
public static final String EXTRA_APP_ID = "AppId";
|
public static final String EXTRA_APP_ID = "AppId";
|
||||||
public static final String EXTRA_UNIQUEID = "UniqueId";
|
public static final String EXTRA_UNIQUEID = "UniqueId";
|
||||||
public static final String EXTRA_STREAMING_REMOTE = "Remote";
|
public static final String EXTRA_STREAMING_REMOTE = "Remote";
|
||||||
|
public static final String EXTRA_PC_UUID = "UUID";
|
||||||
|
public static final String EXTRA_PC_NAME = "PcName";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
shortcutHelper = new ShortcutHelper(this);
|
||||||
|
|
||||||
String locale = PreferenceConfiguration.readPreferences(this).language;
|
String locale = PreferenceConfiguration.readPreferences(this).language;
|
||||||
if (!locale.equals(PreferenceConfiguration.DEFAULT_LANGUAGE)) {
|
if (!locale.equals(PreferenceConfiguration.DEFAULT_LANGUAGE)) {
|
||||||
Configuration config = new Configuration(getResources().getConfiguration());
|
Configuration config = new Configuration(getResources().getConfiguration());
|
||||||
@ -193,12 +200,18 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
int appId = Game.this.getIntent().getIntExtra(EXTRA_APP_ID, StreamConfiguration.INVALID_APP_ID);
|
int appId = Game.this.getIntent().getIntExtra(EXTRA_APP_ID, StreamConfiguration.INVALID_APP_ID);
|
||||||
String uniqueId = Game.this.getIntent().getStringExtra(EXTRA_UNIQUEID);
|
String uniqueId = Game.this.getIntent().getStringExtra(EXTRA_UNIQUEID);
|
||||||
boolean remote = Game.this.getIntent().getBooleanExtra(EXTRA_STREAMING_REMOTE, false);
|
boolean remote = Game.this.getIntent().getBooleanExtra(EXTRA_STREAMING_REMOTE, false);
|
||||||
|
String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
|
||||||
|
String pcName = Game.this.getIntent().getStringExtra(EXTRA_PC_NAME);
|
||||||
|
|
||||||
if (appId == StreamConfiguration.INVALID_APP_ID) {
|
if (appId == StreamConfiguration.INVALID_APP_ID) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a launcher shortcut for this PC (forced, since this is user interaction)
|
||||||
|
shortcutHelper.createAppViewShortcut(uuid, pcName, uuid, true);
|
||||||
|
shortcutHelper.reportShortcutUsed(uuid);
|
||||||
|
|
||||||
// Initialize the MediaCodec helper before creating the decoder
|
// Initialize the MediaCodec helper before creating the decoder
|
||||||
MediaCodecHelper.initializeWithContext(this);
|
MediaCodecHelper.initializeWithContext(this);
|
||||||
|
|
||||||
|
@ -357,9 +357,6 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
// Invalidate reachability information after pairing to force
|
// Invalidate reachability information after pairing to force
|
||||||
// a refresh before reading pair state again
|
// a refresh before reading pair state again
|
||||||
managerBinder.invalidateStateForComputer(computer.uuid);
|
managerBinder.invalidateStateForComputer(computer.uuid);
|
||||||
|
|
||||||
// Add a launcher shortcut for this PC
|
|
||||||
shortcutHelper.createAppViewShortcut(computer.uuid.toString(), computer);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Should be no other values
|
// Should be no other values
|
||||||
@ -612,7 +609,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
|
|
||||||
// Add a launcher shortcut for this PC
|
// Add a launcher shortcut for this PC
|
||||||
if (details.pairState == PairState.PAIRED) {
|
if (details.pairState == PairState.PAIRED) {
|
||||||
shortcutHelper.createAppViewShortcut(details.uuid.toString(), details);
|
shortcutHelper.createAppViewShortcut(details.uuid.toString(), details, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingEntry != null) {
|
if (existingEntry != null) {
|
||||||
|
@ -34,6 +34,8 @@ public class ServerHelper {
|
|||||||
intent.putExtra(Game.EXTRA_UNIQUEID, managerBinder.getUniqueId());
|
intent.putExtra(Game.EXTRA_UNIQUEID, managerBinder.getUniqueId());
|
||||||
intent.putExtra(Game.EXTRA_STREAMING_REMOTE,
|
intent.putExtra(Game.EXTRA_STREAMING_REMOTE,
|
||||||
computer.reachability != ComputerDetails.Reachability.LOCAL);
|
computer.reachability != ComputerDetails.Reachability.LOCAL);
|
||||||
|
intent.putExtra(Game.EXTRA_PC_UUID, computer.uuid.toString());
|
||||||
|
intent.putExtra(Game.EXTRA_PC_NAME, computer.name);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,17 +87,17 @@ public class ShortcutHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAppViewShortcut(String id, ComputerDetails details) {
|
public void createAppViewShortcut(String id, String computerName, String computerUuid, boolean forceAdd) {
|
||||||
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, AppViewShortcutTrampoline.class);
|
Intent i = new Intent(context, AppViewShortcutTrampoline.class);
|
||||||
i.putExtra(AppView.NAME_EXTRA, details.name);
|
i.putExtra(AppView.NAME_EXTRA, computerName);
|
||||||
i.putExtra(AppView.UUID_EXTRA, details.uuid.toString());
|
i.putExtra(AppView.UUID_EXTRA, computerUuid);
|
||||||
i.setAction(Intent.ACTION_DEFAULT);
|
i.setAction(Intent.ACTION_DEFAULT);
|
||||||
|
|
||||||
ShortcutInfo sinfo = new ShortcutInfo.Builder(context, id)
|
ShortcutInfo sinfo = new ShortcutInfo.Builder(context, id)
|
||||||
.setIntent(i)
|
.setIntent(i)
|
||||||
.setShortLabel(details.name)
|
.setShortLabel(computerName)
|
||||||
.setLongLabel(details.name)
|
.setLongLabel(computerName)
|
||||||
.setIcon(Icon.createWithResource(context, R.mipmap.ic_pc_scut))
|
.setIcon(Icon.createWithResource(context, R.mipmap.ic_pc_scut))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -112,12 +112,21 @@ public class ShortcutHelper {
|
|||||||
// NOTE: This CAN'T be an else on the above if, because it's
|
// NOTE: This CAN'T be an else on the above if, because it's
|
||||||
// possible that we have an existing shortcut but it's not a dynamic one.
|
// possible that we have an existing shortcut but it's not a dynamic one.
|
||||||
if (!isExistingDynamicShortcut(id)) {
|
if (!isExistingDynamicShortcut(id)) {
|
||||||
reapShortcutsForDynamicAdd();
|
// To avoid a random carousel of shortcuts popping in and out based on polling status,
|
||||||
sm.addDynamicShortcuts(Collections.singletonList(sinfo));
|
// we only add shortcuts if it's not at the limit or the user made a conscious action
|
||||||
|
// to interact with this PC.
|
||||||
|
if (forceAdd || sm.getDynamicShortcuts().size() < sm.getMaxShortcutCountPerActivity()) {
|
||||||
|
reapShortcutsForDynamicAdd();
|
||||||
|
sm.addDynamicShortcuts(Collections.singletonList(sinfo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createAppViewShortcut(String id, ComputerDetails details, boolean forceAdd) {
|
||||||
|
createAppViewShortcut(id, details.name, details.uuid.toString(), forceAdd);
|
||||||
|
}
|
||||||
|
|
||||||
public void disableShortcut(String id, CharSequence reason) {
|
public void disableShortcut(String id, CharSequence reason) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
ShortcutInfo sinfo = getInfoForId(id);
|
ShortcutInfo sinfo = getInfoForId(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user