Compare commits

...

5 Commits

Author SHA1 Message Date
Cameron Gutman 4968dcc558 Version 8.3 2019-09-14 20:23:46 -07:00
Cameron Gutman 6d66d1371f Fix TV view padding on Android Q 2019-09-14 20:14:31 -07:00
Cameron Gutman b87ca71103 Treat all InputDevices as external on the Tinker Board 2019-09-14 20:08:26 -07:00
Cameron Gutman c251cd2e8f Fix control stream connection error on multi-homed hosts 2019-09-14 14:11:14 -07:00
Cameron Gutman 593616d2d9 Fix layout transitions on foldable devices 2019-09-08 11:11:02 -07:00
10 changed files with 122 additions and 32 deletions
+2 -2
View File
@@ -7,8 +7,8 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionName "8.2" versionName "8.3"
versionCode = 199 versionCode = 200
} }
flavorDimensions "root" flavorDimensions "root"
+23 -2
View File
@@ -26,6 +26,7 @@ import android.app.Service;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.Build; import android.os.Build;
@@ -96,8 +97,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
try { try {
appGridAdapter = new AppGridAdapter(AppView.this, appGridAdapter = new AppGridAdapter(AppView.this,
PreferenceConfiguration.readPreferences(AppView.this).listMode, PreferenceConfiguration.readPreferences(AppView.this),
PreferenceConfiguration.readPreferences(AppView.this).smallIconMode,
computer, localBinder.getUniqueId()); computer, localBinder.getUniqueId());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -147,6 +147,27 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
} }
}; };
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// If appGridAdapter is initialized, let it know about the configuration change.
// If not, it will pick it up when it initializes.
if (appGridAdapter != null) {
// Update the app grid adapter to create grid items with the correct layout
appGridAdapter.updateLayoutWithPreferences(this, PreferenceConfiguration.readPreferences(this));
try {
// Reinflate the app grid itself to pick up the layout change
getFragmentManager().beginTransaction()
.replace(R.id.appFragmentContainer, new AdapterFragment())
.commitAllowingStateLoss();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
}
private void startComputerUpdates() { private void startComputerUpdates() {
// Don't start polling if we're not bound or in the foreground // Don't start polling if we're not bound or in the foreground
if (managerBinder == null || !inForeground) { if (managerBinder == null || !inForeground) {
+4 -3
View File
@@ -126,6 +126,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
// Set default preferences if we've never been run // Set default preferences if we've never been run
PreferenceManager.setDefaultValues(this, R.xml.preferences, false); PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
// Set the correct layout for the PC grid
pcGridAdapter.updateLayoutWithPreferences(this, PreferenceConfiguration.readPreferences(this));
// Setup the list view // Setup the list view
ImageButton settingsButton = findViewById(R.id.settingsButton); ImageButton settingsButton = findViewById(R.id.settingsButton);
ImageButton addComputerButton = findViewById(R.id.manuallyAddPc); ImageButton addComputerButton = findViewById(R.id.manuallyAddPc);
@@ -223,9 +226,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
bindService(new Intent(PcView.this, ComputerManagerService.class), serviceConnection, bindService(new Intent(PcView.this, ComputerManagerService.class), serviceConnection,
Service.BIND_AUTO_CREATE); Service.BIND_AUTO_CREATE);
pcGridAdapter = new PcGridAdapter(this, pcGridAdapter = new PcGridAdapter(this, PreferenceConfiguration.readPreferences(this));
PreferenceConfiguration.readPreferences(this).listMode,
PreferenceConfiguration.readPreferences(this).smallIconMode);
initializeViews(); initializeViews();
} }
@@ -335,6 +335,13 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
} }
private static boolean isExternal(InputDevice dev) { private static boolean isExternal(InputDevice dev) {
// The ASUS Tinker Board inaccurately reports Bluetooth gamepads as internal,
// causing shouldIgnoreBack() to believe it should pass through back as a
// navigation event for any attached gamepads.
if (Build.MODEL.equals("Tinker Board")) {
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Landroid/view/InputDevice;->isExternal()Z is officially public on Android Q // Landroid/view/InputDevice;->isExternal()Z is officially public on Android Q
return dev.isExternal(); return dev.isExternal();
@@ -1,6 +1,6 @@
package com.limelight.grid; package com.limelight.grid;
import android.app.Activity; import android.content.Context;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
@@ -13,6 +13,7 @@ import com.limelight.grid.assets.DiskAssetLoader;
import com.limelight.grid.assets.MemoryAssetLoader; import com.limelight.grid.assets.MemoryAssetLoader;
import com.limelight.grid.assets.NetworkAssetLoader; import com.limelight.grid.assets.NetworkAssetLoader;
import com.limelight.nvstream.http.ComputerDetails; import com.limelight.nvstream.http.ComputerDetails;
import com.limelight.preferences.PreferenceConfiguration;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@@ -23,15 +24,37 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
private static final int SMALL_WIDTH_DP = 100; private static final int SMALL_WIDTH_DP = 100;
private static final int LARGE_WIDTH_DP = 150; private static final int LARGE_WIDTH_DP = 150;
private final CachedAppAssetLoader loader; private final ComputerDetails computer;
private final String uniqueId;
public AppGridAdapter(Activity activity, boolean listMode, boolean small, ComputerDetails computer, String uniqueId) { private CachedAppAssetLoader loader;
super(activity, listMode ? R.layout.simple_row : (small ? R.layout.app_grid_item_small : R.layout.app_grid_item));
int dpi = activity.getResources().getDisplayMetrics().densityDpi; public AppGridAdapter(Context context, PreferenceConfiguration prefs, ComputerDetails computer, String uniqueId) {
super(context, getLayoutIdForPreferences(prefs));
this.computer = computer;
this.uniqueId = uniqueId;
updateLayoutWithPreferences(context, prefs);
}
private static int getLayoutIdForPreferences(PreferenceConfiguration prefs) {
if (prefs.listMode) {
return R.layout.simple_row;
}
else if (prefs.smallIconMode) {
return R.layout.app_grid_item_small;
}
else {
return R.layout.app_grid_item;
}
}
public void updateLayoutWithPreferences(Context context, PreferenceConfiguration prefs) {
int dpi = context.getResources().getDisplayMetrics().densityDpi;
int dp; int dp;
if (small) { if (prefs.smallIconMode) {
dp = SMALL_WIDTH_DP; dp = SMALL_WIDTH_DP;
} }
else { else {
@@ -45,10 +68,18 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
} }
LimeLog.info("Art scaling divisor: " + scalingDivisor); LimeLog.info("Art scaling divisor: " + scalingDivisor);
if (loader != null) {
// Cancel operations on the old loader
cancelQueuedOperations();
}
this.loader = new CachedAppAssetLoader(computer, scalingDivisor, this.loader = new CachedAppAssetLoader(computer, scalingDivisor,
new NetworkAssetLoader(context, uniqueId), new NetworkAssetLoader(context, uniqueId),
new MemoryAssetLoader(), new MemoryAssetLoader(),
new DiskAssetLoader(context)); new DiskAssetLoader(context));
// This will trigger the view to reload with the new layout
setLayoutId(getLayoutIdForPreferences(prefs));
} }
public void cancelQueuedOperations() { public void cancelQueuedOperations() {
@@ -10,22 +10,32 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.limelight.R; import com.limelight.R;
import com.limelight.preferences.PreferenceConfiguration;
import java.util.ArrayList; import java.util.ArrayList;
public abstract class GenericGridAdapter<T> extends BaseAdapter { public abstract class GenericGridAdapter<T> extends BaseAdapter {
protected final Context context; protected final Context context;
protected final int layoutId; private int layoutId;
protected final ArrayList<T> itemList = new ArrayList<>(); final ArrayList<T> itemList = new ArrayList<>();
protected final LayoutInflater inflater; private final LayoutInflater inflater;
public GenericGridAdapter(Context context, int layoutId) { GenericGridAdapter(Context context, int layoutId) {
this.context = context; this.context = context;
this.layoutId = layoutId; this.layoutId = layoutId;
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
void setLayoutId(int layoutId) {
if (layoutId != this.layoutId) {
this.layoutId = layoutId;
// Force the view to be redrawn with the new layout
notifyDataSetInvalidated();
}
}
public void clear() { public void clear() {
itemList.clear(); itemList.clear();
} }
@@ -10,14 +10,32 @@ import com.limelight.PcView;
import com.limelight.R; import com.limelight.R;
import com.limelight.nvstream.http.ComputerDetails; import com.limelight.nvstream.http.ComputerDetails;
import com.limelight.nvstream.http.PairingManager; import com.limelight.nvstream.http.PairingManager;
import com.limelight.preferences.PreferenceConfiguration;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> { public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> {
public PcGridAdapter(Context context, boolean listMode, boolean small) { public PcGridAdapter(Context context, PreferenceConfiguration prefs) {
super(context, listMode ? R.layout.simple_row : (small ? R.layout.pc_grid_item_small : R.layout.pc_grid_item)); super(context, getLayoutIdForPreferences(prefs));
}
private static int getLayoutIdForPreferences(PreferenceConfiguration prefs) {
if (prefs.listMode) {
return R.layout.simple_row;
}
else if (prefs.smallIconMode) {
return R.layout.pc_grid_item_small;
}
else {
return R.layout.pc_grid_item;
}
}
public void updateLayoutWithPreferences(Context context, PreferenceConfiguration prefs) {
// This will trigger the view to reload with the new layout
setLayoutId(getLayoutIdForPreferences(prefs));
} }
public void addComputer(PcView.ComputerObject computer) { public void addComputer(PcView.ComputerObject computer) {
@@ -68,17 +68,6 @@ public class UiHelper {
View rootView = activity.findViewById(android.R.id.content); View rootView = activity.findViewById(android.R.id.content);
UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE); UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
{
// Increase view padding on TVs
float scale = activity.getResources().getDisplayMetrics().density;
int verticalPaddingPixels = (int) (TV_VERTICAL_PADDING_DP*scale + 0.5f);
int horizontalPaddingPixels = (int) (TV_HORIZONTAL_PADDING_DP*scale + 0.5f);
rootView.setPadding(horizontalPaddingPixels, verticalPaddingPixels,
horizontalPaddingPixels, verticalPaddingPixels);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Allow this non-streaming activity to layout under notches. // Allow this non-streaming activity to layout under notches.
// //
@@ -89,7 +78,16 @@ public class UiHelper {
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
// Increase view padding on TVs
float scale = activity.getResources().getDisplayMetrics().density;
int verticalPaddingPixels = (int) (TV_VERTICAL_PADDING_DP*scale + 0.5f);
int horizontalPaddingPixels = (int) (TV_HORIZONTAL_PADDING_DP*scale + 0.5f);
rootView.setPadding(horizontalPaddingPixels, verticalPaddingPixels,
horizontalPaddingPixels, verticalPaddingPixels);
}
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Draw under the status bar on Android Q devices // Draw under the status bar on Android Q devices
// Using getDecorView() here breaks the translucent status/navigation bar when gestures are disabled // Using getDecorView() here breaks the translucent status/navigation bar when gestures are disabled
@@ -0,0 +1,4 @@
- Fixed various UI bugs on foldable Android devices
- Fixed connecting to a PC with multiple network connections
- Fixed overscan padding on Android TV 10
- Fixed gamepad back buttons not working on the ASUS Tinker Board