Integrate help buttons into dialogs and the PcView

This commit is contained in:
Cameron Gutman 2016-11-05 19:51:43 -07:00
parent 1b5330323c
commit d68b2382cf
10 changed files with 242 additions and 81 deletions

View File

@ -8,27 +8,43 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.gamepad" android:required="false" />
<uses-feature android:name="android.hardware.usb.host" android:required="false" />
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
<uses-feature
android:name="android.hardware.gamepad"
android:required="false" />
<uses-feature
android:name="android.hardware.usb.host"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:banner="@drawable/atv_banner"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<!-- Samsung multi-window support -->
<uses-library android:name="com.sec.android.app.multiwindow" android:required="false" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />
<uses-library
android:name="com.sec.android.app.multiwindow"
android:required="false" />
<meta-data
android:name="com.sec.android.support.multiwindow"
android:value="true" />
<activity
android:name=".PcView"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
@ -58,9 +74,9 @@
</activity>
<activity
android:name=".Game"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
android:screenOrientation="sensorLandscape"
android:theme="@style/StreamTheme"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection" >
android:theme="@style/StreamTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.limelight.AppView" />
@ -75,6 +91,8 @@
<service
android:name=".binding.input.driver.UsbDriverService"
android:label="Usb Driver Service" />
<activity android:name=".HelpActivity"></activity>
</application>
</manifest>

View File

@ -0,0 +1,19 @@
package com.limelight;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class HelpActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
setContentView(webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(getIntent().getData().toString());
}
}

View File

@ -23,6 +23,7 @@ import com.limelight.preferences.StreamSettings;
import com.limelight.ui.AdapterFragment;
import com.limelight.ui.AdapterFragmentCallbacks;
import com.limelight.utils.Dialog;
import com.limelight.utils.HelpLauncher;
import com.limelight.utils.ServerHelper;
import com.limelight.utils.ShortcutHelper;
import com.limelight.utils.UiHelper;
@ -111,6 +112,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
// Setup the list view
ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton);
ImageButton addComputerButton = (ImageButton) findViewById(R.id.manuallyAddPc);
ImageButton helpButton = (ImageButton) findViewById(R.id.helpButton);
settingsButton.setOnClickListener(new OnClickListener() {
@Override
@ -125,6 +127,12 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
startActivity(i);
}
});
helpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HelpLauncher.launchSetupGuide(PcView.this);
}
});
getFragmentManager().beginTransaction()
.replace(R.id.pcFragmentContainer, new AdapterFragment())

View File

@ -5,6 +5,9 @@ import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Button;
import com.limelight.R;
public class Dialog implements Runnable {
private final String title;
@ -55,7 +58,7 @@ public class Dialog implements Runnable {
alert.setCancelable(false);
alert.setCanceledOnTouchOutside(false);
alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
alert.setButton(AlertDialog.BUTTON_POSITIVE, activity.getResources().getText(android.R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
synchronized (rundownDialogs) {
rundownDialogs.remove(Dialog.this);
@ -67,6 +70,31 @@ public class Dialog implements Runnable {
}
}
});
alert.setButton(AlertDialog.BUTTON_NEUTRAL, activity.getResources().getText(R.string.help), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
synchronized (rundownDialogs) {
rundownDialogs.remove(Dialog.this);
alert.dismiss();
}
if (endAfterDismiss) {
activity.finish();
}
HelpLauncher.launchTroubleshooting(activity);
}
});
alert.setOnShowListener(new DialogInterface.OnShowListener(){
@Override
public void onShow(DialogInterface dialog) {
// Set focus to the OK button by default
Button button = alert.getButton(AlertDialog.BUTTON_POSITIVE);
button.setFocusable(true);
button.setFocusableInTouchMode(true);
button.requestFocus();
}
});
synchronized (rundownDialogs) {
rundownDialogs.add(this);

View File

@ -0,0 +1,35 @@
package com.limelight.utils;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.limelight.HelpActivity;
public class HelpLauncher {
private static void launchUrl(Context context, String url) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
// Try to launch the default browser
try {
context.startActivity(i);
} catch (ActivityNotFoundException e) {
// This platform has no browser (possibly a leanback device)
// We'll launch our WebView activity
i = new Intent(context, HelpActivity.class);
i.setData(Uri.parse(url));
context.startActivity(i);
}
}
public static void launchSetupGuide(Context context) {
launchUrl(context, "https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide");
}
public static void launchTroubleshooting(Context context) {
launchUrl(context, "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting");
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="256dp"
android:height="256dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

View File

@ -8,11 +8,20 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PcView" >
<RelativeLayout
android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/settingsButton"
android:layout_toEndOf="@+id/settingsButton">
<RelativeLayout
android:id="@+id/no_pc_found_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<ProgressBar
@ -33,17 +42,7 @@
android:text="@string/searching_pc"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/manuallyAddPc"
android:layout_toStartOf="@+id/manuallyAddPc"
android:layout_toRightOf="@+id/settingsButton"
android:layout_toEndOf="@+id/settingsButton"/>
</RelativeLayout>
<ImageButton
android:id="@+id/settingsButton"
@ -51,23 +50,33 @@
android:layout_height="65dp"
android:cropToPadding="false"
android:scaleType="fitXY"
android:nextFocusDown="@+id/pcGridView"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_settings"
style="?android:attr/borderlessButtonStyle"/>
<ImageButton
android:id="@+id/helpButton"
android:layout_width="70dp"
android:layout_height="65dp"
android:cropToPadding="false"
android:scaleType="fitXY"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="@id/settingsButton"
android:src="@drawable/ic_help"
style="?android:attr/borderlessButtonStyle"/>
<ImageButton
android:id="@+id/manuallyAddPc"
android:layout_width="70dp"
android:layout_height="65dp"
android:cropToPadding="false"
android:scaleType="fitXY"
android:nextFocusDown="@+id/pcGridView"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="@id/helpButton"
android:src="@drawable/ic_add"
style="?android:attr/borderlessButtonStyle"/>

View File

@ -8,6 +8,19 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PcView" >
<RelativeLayout
android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="@+id/settingsButton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:id="@+id/no_pc_found_layout"
android:layout_width="wrap_content"
@ -33,17 +46,7 @@
android:text="@string/searching_pc"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_toLeftOf="@+id/manuallyAddPc"
android:layout_toStartOf="@+id/manuallyAddPc"
android:layout_toRightOf="@+id/settingsButton"
android:layout_toEndOf="@+id/settingsButton"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
<ImageButton
android:id="@+id/settingsButton"
@ -57,6 +60,18 @@
android:src="@drawable/ic_settings"
style="?android:attr/borderlessButtonStyle"/>
<ImageButton
android:id="@+id/helpButton"
android:layout_width="70dp"
android:layout_height="65dp"
android:cropToPadding="false"
android:scaleType="fitXY"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/settingsButton"
android:layout_toEndOf="@+id/settingsButton"
android:src="@drawable/ic_help"
style="?android:attr/borderlessButtonStyle"/>
<ImageButton
android:id="@+id/manuallyAddPc"
android:layout_width="70dp"

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_help"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.limelight.HelpActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>

View File

@ -64,6 +64,7 @@
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="lost_connection">Lost connection to PC</string>
<string name="help">Help</string>
<!-- AppList activity -->
<string name="title_applist">Apps on</string>