diff --git a/app/src/main/java/com/limelight/AppView.java b/app/src/main/java/com/limelight/AppView.java index bcaa8fcf..cd812f6f 100644 --- a/app/src/main/java/com/limelight/AppView.java +++ b/app/src/main/java/com/limelight/AppView.java @@ -33,8 +33,7 @@ import android.widget.Toast; import android.widget.AdapterView.AdapterContextMenuInfo; public class AppView extends Activity { - private GridView appGrid; - private AppGridAdapter appGridAdapter; + private AppGridAdapter appGridAdapter; private InetAddress ipAddress; private String uniqueId; private boolean remote; @@ -77,7 +76,7 @@ public class AppView extends Activity { } // Setup the list view - appGrid = (GridView)findViewById(R.id.appGridView); + GridView appGrid = (GridView) findViewById(R.id.appGridView); try { appGridAdapter = new AppGridAdapter(this, ipAddress, uniqueId); } catch (Exception e) { @@ -87,23 +86,22 @@ public class AppView extends Activity { } appGrid.setAdapter(appGridAdapter); appGrid.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView arg0, View arg1, int pos, - long id) { - AppObject app = (AppObject) appGridAdapter.getItem(pos); - if (app == null || app.app == null) { - return; - } - - // Only open the context menu if something is running, otherwise start it - if (getRunningAppId() != -1) { - openContextMenu(arg1); - } - else { - doStart(app.app); - } - } - }); + @Override + public void onItemClick(AdapterView arg0, View arg1, int pos, + long id) { + AppObject app = (AppObject) appGridAdapter.getItem(pos); + if (app == null || app.app == null) { + return; + } + + // Only open the context menu if something is running, otherwise start it + if (getRunningAppId() != -1) { + openContextMenu(arg1); + } else { + doStart(app.app); + } + } + }); registerForContextMenu(appGrid); } diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index abb2bf12..aaf9d617 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -395,7 +395,7 @@ public class Game extends Activity implements SurfaceHolder.Callback, } // Try the controller handler first - boolean handled = controllerHandler.handleButtonDown(keyCode, event); + boolean handled = controllerHandler.handleButtonDown(event); if (!handled) { // Try the keyboard handler short translated = keybTranslator.translate(event.getKeyCode()); @@ -438,7 +438,7 @@ public class Game extends Activity implements SurfaceHolder.Callback, } // Try the controller handler first - boolean handled = controllerHandler.handleButtonUp(keyCode, event); + boolean handled = controllerHandler.handleButtonUp(event); if (!handled) { // Try the keyboard handler short translated = keybTranslator.translate(event.getKeyCode()); diff --git a/app/src/main/java/com/limelight/PcView.java b/app/src/main/java/com/limelight/PcView.java index b0ec91c5..0dc20ca7 100644 --- a/app/src/main/java/com/limelight/PcView.java +++ b/app/src/main/java/com/limelight/PcView.java @@ -44,10 +44,8 @@ import android.widget.Toast; import android.widget.AdapterView.AdapterContextMenuInfo; public class PcView extends Activity { - private ImageButton settingsButton, addComputerButton; private RelativeLayout noPcFoundLayout; - private GridView pcGrid; - private PcGridAdapter pcGridAdapter; + private PcGridAdapter pcGridAdapter; private ComputerManagerService.ComputerManagerBinder managerBinder; private boolean freezeUpdates, runningPolling; private ServiceConnection serviceConnection = new ServiceConnection() { @@ -101,47 +99,43 @@ public class PcView extends Activity { PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Setup the list view - settingsButton = (ImageButton)findViewById(R.id.settingsButton); - addComputerButton = (ImageButton)findViewById(R.id.manuallyAddPc); + ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton); + ImageButton addComputerButton = (ImageButton) findViewById(R.id.manuallyAddPc); - pcGrid = (GridView)findViewById(R.id.pcGridView); + GridView pcGrid = (GridView) findViewById(R.id.pcGridView); pcGrid.setAdapter(pcGridAdapter); pcGrid.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView arg0, View arg1, int pos, - long id) { - ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(pos); + @Override + public void onItemClick(AdapterView arg0, View arg1, int pos, + long id) { + ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(pos); if (computer.details.reachability == ComputerDetails.Reachability.UNKNOWN) { // Do nothing - return; + } else if (computer.details.reachability == ComputerDetails.Reachability.OFFLINE) { + // Open the context menu if a PC is offline + openContextMenu(arg1); + } else if (computer.details.pairState != PairState.PAIRED) { + // Pair an unpaired machine by default + doPair(computer.details); + } else { + doAppList(computer.details); } - else if (computer.details.reachability == ComputerDetails.Reachability.OFFLINE) { - // Open the context menu if a PC is offline - openContextMenu(arg1); - } - else if (computer.details.pairState != PairState.PAIRED) { - // Pair an unpaired machine by default - doPair(computer.details); - } - else { - doAppList(computer.details); - } - } - }); + } + }); registerForContextMenu(pcGrid); settingsButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(new Intent(PcView.this, StreamSettings.class)); - } - }); + @Override + public void onClick(View v) { + startActivity(new Intent(PcView.this, StreamSettings.class)); + } + }); addComputerButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - Intent i = new Intent(PcView.this, AddComputerManually.class); - startActivity(i); - } - }); + @Override + public void onClick(View v) { + Intent i = new Intent(PcView.this, AddComputerManually.class); + startActivity(i); + } + }); noPcFoundLayout = (RelativeLayout) findViewById(R.id.no_pc_found_layout); if (pcGridAdapter.getCount() == 0) { diff --git a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java index b525c419..efa1f1e2 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -398,13 +398,13 @@ public class ControllerHandler { return true; } - public boolean handleButtonUp(int keyCode, KeyEvent event) { + public boolean handleButtonUp(KeyEvent event) { ControllerMapping mapping = getMappingForDevice(event.getDevice()); if (mapping == null) { return false; } - - keyCode = handleRemapping(mapping, event); + + int keyCode = handleRemapping(mapping, event); if (keyCode == 0) { return true; } @@ -521,13 +521,13 @@ public class ControllerHandler { return true; } - public boolean handleButtonDown(int keyCode, KeyEvent event) { + public boolean handleButtonDown(KeyEvent event) { ControllerMapping mapping = getMappingForDevice(event.getDevice()); if (mapping == null) { return false; } - - keyCode = handleRemapping(mapping, event); + + int keyCode = handleRemapping(mapping, event); if (keyCode == 0) { return true; } diff --git a/app/src/main/java/com/limelight/computers/ComputerManagerService.java b/app/src/main/java/com/limelight/computers/ComputerManagerService.java index 10d3c5f6..e1f9ea87 100644 --- a/app/src/main/java/com/limelight/computers/ComputerManagerService.java +++ b/app/src/main/java/com/limelight/computers/ComputerManagerService.java @@ -30,7 +30,7 @@ public class ComputerManagerService extends Service { private AtomicInteger dbRefCount = new AtomicInteger(0); private IdentityManager idManager; - private HashMap pollingThreads; + private final HashMap pollingThreads = new HashMap(); private ComputerManagerListener listener = null; private AtomicInteger activePolls = new AtomicInteger(0); @@ -355,8 +355,6 @@ public class ComputerManagerService extends Service { // Bind to the discovery service bindService(new Intent(this, DiscoveryService.class), discoveryServiceConnection, Service.BIND_AUTO_CREATE); - - pollingThreads = new HashMap(); // Lookup or generate this device's UID idManager = new IdentityManager(this); diff --git a/app/src/main/java/com/limelight/grid/AppGridAdapter.java b/app/src/main/java/com/limelight/grid/AppGridAdapter.java index 5149cc08..a9cbc243 100644 --- a/app/src/main/java/com/limelight/grid/AppGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/AppGridAdapter.java @@ -36,7 +36,7 @@ public class AppGridAdapter extends GenericGridAdapter { private String uniqueId; private LimelightCryptoProvider cryptoProvider; private SSLContext sslContext; - private HashMap pendingRequests = new HashMap(); + private final HashMap pendingRequests = new HashMap(); public AppGridAdapter(Context context, InetAddress address, String uniqueId) throws NoSuchAlgorithmException, KeyManagementException { super(context, R.layout.app_grid_item, R.drawable.image_loading); diff --git a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java index 4fa3f9d8..1882c59c 100644 --- a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java +++ b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java @@ -19,7 +19,7 @@ public class SeekBarPreference extends DialogPreference private static final String SCHEMA_URL = "http://schemas.android.com/apk/res/android"; private SeekBar seekBar; - private TextView splashText, valueText; + private TextView valueText; private Context context; private String dialogMessage, suffix; @@ -60,7 +60,7 @@ public class SeekBarPreference extends DialogPreference layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(6, 6, 6, 6); - splashText = new TextView(context); + TextView splashText = new TextView(context); splashText.setPadding(30, 10, 30, 10); if (dialogMessage != null) { splashText.setText(dialogMessage); @@ -149,10 +149,10 @@ public class SeekBarPreference extends DialogPreference if (shouldPersist()) { currentValue = seekBar.getProgress(); persistInt(seekBar.getProgress()); - callChangeListener(Integer.valueOf(seekBar.getProgress())); + callChangeListener(seekBar.getProgress()); } - ((AlertDialog) getDialog()).dismiss(); + getDialog().dismiss(); } }); } diff --git a/app/src/main/java/com/limelight/utils/UiHelper.java b/app/src/main/java/com/limelight/utils/UiHelper.java index 7b3e6fea..6eb22e3a 100644 --- a/app/src/main/java/com/limelight/utils/UiHelper.java +++ b/app/src/main/java/com/limelight/utils/UiHelper.java @@ -14,7 +14,7 @@ public class UiHelper { public static void notifyNewRootView(Activity activity) { - View rootView = (View) activity.findViewById(android.R.id.content); + View rootView = activity.findViewById(android.R.id.content); UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE); if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) diff --git a/app/src/main/res/layout/activity_game.xml b/app/src/main/res/layout/activity_game.xml index c64a8ab3..7f625494 100644 --- a/app/src/main/res/layout/activity_game.xml +++ b/app/src/main/res/layout/activity_game.xml @@ -2,7 +2,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#000" tools:context=".Game" >