Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
Expand All @@ -16,6 +17,7 @@
import com.limelight.LimeLog;
import com.limelight.R;
import com.limelight.binding.input.ControllerHandler;
import com.limelight.preferences.PreferenceConfiguration;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -57,13 +59,16 @@ public void run() {

private Button buttonConfigure = null;

private Button buttonShowHide = null;

private List<VirtualControllerElement> elements = new ArrayList<>();

public VirtualController(final ControllerHandler controllerHandler, FrameLayout layout, final Context context) {
this.controllerHandler = controllerHandler;
this.frame_layout = layout;
this.context = context;
this.handler = new Handler(Looper.getMainLooper());
PreferenceConfiguration prefConfig = PreferenceConfiguration.readPreferences(context);

buttonConfigure = new Button(context);
buttonConfigure.setAlpha(0.25f);
Expand Down Expand Up @@ -96,12 +101,38 @@ public void onClick(View v) {
}
});

if(prefConfig.showToggleControllerButton) {
buttonShowHide = new Button(context);
buttonShowHide.setAlpha(0.25f);
buttonShowHide.setFocusable(false);
buttonShowHide.setBackgroundResource(R.drawable.ic_toggle);
buttonShowHide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (currentMode == ControllerMode.Active) {
if (isControllerVisible()) {
hide();
} else {
show();
}
}
else {
String message = "Exit configuration mode to toggle!";
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
}
});
}
}

Handler getHandler() {
return handler;
}

private boolean isControllerVisible() {
return buttonConfigure.getVisibility() == View.VISIBLE;
}

public void hide() {
for (VirtualControllerElement element : elements) {
element.setVisibility(View.INVISIBLE);
Expand All @@ -125,6 +156,9 @@ public void removeElements() {
elements.clear();

frame_layout.removeView(buttonConfigure);
if (buttonShowHide != null) {
frame_layout.removeView(buttonShowHide);
}
}

public void setOpacity(int opacity) {
Expand Down Expand Up @@ -163,6 +197,14 @@ public void refreshLayout() {
params.topMargin = 15;
frame_layout.addView(buttonConfigure, params);

if (buttonShowHide != null) {
FrameLayout.LayoutParams buttonShowHideParams = new FrameLayout.LayoutParams(buttonSize, buttonSize);
buttonShowHideParams.gravity = Gravity.BOTTOM;
buttonShowHideParams.leftMargin = 15;
buttonShowHideParams.bottomMargin = 15;
frame_layout.addView(buttonShowHide, buttonShowHideParams);
}

// Start with the default layout
VirtualControllerConfigurationLoader.createDefaultLayout(this, context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum AnalogStickForScrolling {
private static final String ONSCREEN_CONTROLLER_PREF_STRING = "checkbox_show_onscreen_controls";
private static final String ONLY_L3_R3_PREF_STRING = "checkbox_only_show_L3R3";
private static final String SHOW_GUIDE_BUTTON_PREF_STRING = "checkbox_show_guide_button";
private static final String SHOW_TOGGLE_CONTROLLER_BUTTON_PREF_STRING = "checkbox_show_toggle_controller_button";
private static final String LEGACY_DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop";
private static final String ENABLE_HDR_PREF_STRING = "checkbox_enable_hdr";
private static final String ENABLE_PIP_PREF_STRING = "checkbox_enable_pip";
Expand Down Expand Up @@ -85,6 +86,7 @@ public enum AnalogStickForScrolling {
private static final boolean ONSCREEN_CONTROLLER_DEFAULT = false;
private static final boolean ONLY_L3_R3_DEFAULT = false;
private static final boolean SHOW_GUIDE_BUTTON_DEFAULT = true;
private static final boolean SHOW_TOGGLE_CONTROLLER_BUTTON_DEFAULT = true;
private static final boolean DEFAULT_ENABLE_HDR = false;
private static final boolean DEFAULT_ENABLE_PIP = false;
private static final boolean DEFAULT_ENABLE_PERF_OVERLAY = false;
Expand Down Expand Up @@ -133,6 +135,7 @@ public enum AnalogStickForScrolling {
public boolean onscreenController;
public boolean onlyL3R3;
public boolean showGuideButton;
public boolean showToggleControllerButton;
public boolean enableHdr;
public boolean enablePip;
public boolean enablePerfOverlay;
Expand Down Expand Up @@ -581,6 +584,7 @@ else if (audioConfig.equals("51")) {
config.onscreenController = prefs.getBoolean(ONSCREEN_CONTROLLER_PREF_STRING, ONSCREEN_CONTROLLER_DEFAULT);
config.onlyL3R3 = prefs.getBoolean(ONLY_L3_R3_PREF_STRING, ONLY_L3_R3_DEFAULT);
config.showGuideButton = prefs.getBoolean(SHOW_GUIDE_BUTTON_PREF_STRING, SHOW_GUIDE_BUTTON_DEFAULT);
config.showToggleControllerButton = prefs.getBoolean(SHOW_TOGGLE_CONTROLLER_BUTTON_PREF_STRING, SHOW_TOGGLE_CONTROLLER_BUTTON_DEFAULT);
config.enableHdr = prefs.getBoolean(ENABLE_HDR_PREF_STRING, DEFAULT_ENABLE_HDR) && !isShieldAtvFirmwareWithBrokenHdr();
config.enablePip = prefs.getBoolean(ENABLE_PIP_PREF_STRING, DEFAULT_ENABLE_PIP);
config.enablePerfOverlay = prefs.getBoolean(ENABLE_PERF_OVERLAY_STRING, DEFAULT_ENABLE_PERF_OVERLAY);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_toggle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z"/>

</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@
<string name="summary_only_l3r3">Hide all virtual buttons except L3 and R3</string>
<string name="title_show_guide_button">Show Guide Button</string>
<string name="summary_show_guide_button">Show the guide button on screen</string>
<string name="title_show_toggle_controller_button">Show Toggle Button</string>
<string name="summary_show_toggle_controller_button">Show the toggle button for the on-screen controls</string>
<string name="title_reset_osc">Clear saved on-screen controls layout</string>
<string name="summary_reset_osc">Resets all on-screen controls to their default size and position</string>
<string name="dialog_title_reset_osc">Reset Layout</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
android:key="checkbox_show_guide_button"
android:summary="@string/summary_show_guide_button"
android:title="@string/title_show_guide_button" />
<CheckBoxPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:dependency="checkbox_show_onscreen_controls"
android:key="checkbox_show_toggle_controller_button"
android:summary="@string/summary_show_toggle_controller_button"
android:title="@string/title_show_toggle_controller_button" />
<com.limelight.preferences.SeekBarPreference
android:key="seekbar_osc_opacity"
android:dependency="checkbox_show_onscreen_controls"
Expand Down