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

@ -7,28 +7,44 @@
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <uses-feature
<uses-feature android:name="android.hardware.wifi" android:required="false" /> android:name="android.hardware.touchscreen"
<uses-feature android:name="android.hardware.gamepad" android:required="false" /> android:required="false" />
<uses-feature android:name="android.hardware.usb.host" android:required="false" /> <uses-feature
<uses-feature android:name="android.software.leanback" android:required="false" /> 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 <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:banner="@drawable/atv_banner" android:banner="@drawable/atv_banner"
android:theme="@style/AppTheme" > android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<!-- Samsung multi-window support --> <!-- Samsung multi-window support -->
<uses-library android:name="com.sec.android.app.multiwindow" android:required="false" /> <uses-library
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> android:name="com.sec.android.app.multiwindow"
android:required="false" />
<meta-data
android:name="com.sec.android.support.multiwindow"
android:value="true" />
<activity <activity
android:name=".PcView" android:name=".PcView"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"> android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" /> <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
@ -37,30 +53,30 @@
</activity> </activity>
<activity <activity
android:name=".AppView" android:name=".AppView"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection" > android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.limelight.PcView" /> android:value="com.limelight.PcView" />
</activity> </activity>
<activity <activity
android:name=".preferences.StreamSettings" android:name=".preferences.StreamSettings"
android:label="Streaming Settings" > android:label="Streaming Settings">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.limelight.PcView" /> android:value="com.limelight.PcView" />
</activity> </activity>
<activity <activity
android:name=".preferences.AddComputerManually" android:name=".preferences.AddComputerManually"
android:label="Add Computer Manually" > android:label="Add Computer Manually">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.limelight.PcView" /> android:value="com.limelight.PcView" />
</activity> </activity>
<activity <activity
android:name=".Game" android:name=".Game"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:theme="@style/StreamTheme" android:theme="@style/StreamTheme">
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection" >
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.limelight.AppView" /> android:value="com.limelight.AppView" />
@ -75,6 +91,8 @@
<service <service
android:name=".binding.input.driver.UsbDriverService" android:name=".binding.input.driver.UsbDriverService"
android:label="Usb Driver Service" /> android:label="Usb Driver Service" />
<activity android:name=".HelpActivity"></activity>
</application> </application>
</manifest> </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.AdapterFragment;
import com.limelight.ui.AdapterFragmentCallbacks; import com.limelight.ui.AdapterFragmentCallbacks;
import com.limelight.utils.Dialog; import com.limelight.utils.Dialog;
import com.limelight.utils.HelpLauncher;
import com.limelight.utils.ServerHelper; import com.limelight.utils.ServerHelper;
import com.limelight.utils.ShortcutHelper; import com.limelight.utils.ShortcutHelper;
import com.limelight.utils.UiHelper; import com.limelight.utils.UiHelper;
@ -111,6 +112,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
// Setup the list view // Setup the list view
ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton); ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton);
ImageButton addComputerButton = (ImageButton) findViewById(R.id.manuallyAddPc); ImageButton addComputerButton = (ImageButton) findViewById(R.id.manuallyAddPc);
ImageButton helpButton = (ImageButton) findViewById(R.id.helpButton);
settingsButton.setOnClickListener(new OnClickListener() { settingsButton.setOnClickListener(new OnClickListener() {
@Override @Override
@ -125,6 +127,12 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
startActivity(i); startActivity(i);
} }
}); });
helpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HelpLauncher.launchSetupGuide(PcView.this);
}
});
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.replace(R.id.pcFragmentContainer, new AdapterFragment()) .replace(R.id.pcFragmentContainer, new AdapterFragment())

View File

@ -5,6 +5,9 @@ import java.util.ArrayList;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.widget.Button;
import com.limelight.R;
public class Dialog implements Runnable { public class Dialog implements Runnable {
private final String title; private final String title;
@ -55,7 +58,7 @@ public class Dialog implements Runnable {
alert.setCancelable(false); alert.setCancelable(false);
alert.setCanceledOnTouchOutside(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) { public void onClick(DialogInterface dialog, int which) {
synchronized (rundownDialogs) { synchronized (rundownDialogs) {
rundownDialogs.remove(Dialog.this); 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) { synchronized (rundownDialogs) {
rundownDialogs.add(this); 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

@ -9,41 +9,40 @@
tools:context=".PcView" > tools:context=".PcView" >
<RelativeLayout <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
android:id="@+id/pcs_loading"
android:layout_width="75dp"
android:layout_height="75dp"
android:indeterminate="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pcs_loading"
android:layout_toEndOf="@+id/pcs_loading"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:text="@string/searching_pc"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/pcFragmentContainer" android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/manuallyAddPc"
android:layout_toStartOf="@+id/manuallyAddPc"
android:layout_toRightOf="@+id/settingsButton" android:layout_toRightOf="@+id/settingsButton"
android:layout_toEndOf="@+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_centerVertical="true"
android:layout_centerHorizontal="true">
<ProgressBar
android:id="@+id/pcs_loading"
android:layout_width="75dp"
android:layout_height="75dp"
android:indeterminate="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pcs_loading"
android:layout_toEndOf="@+id/pcs_loading"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:text="@string/searching_pc"/>
</RelativeLayout>
</RelativeLayout>
<ImageButton <ImageButton
android:id="@+id/settingsButton" android:id="@+id/settingsButton"
@ -51,23 +50,33 @@
android:layout_height="65dp" android:layout_height="65dp"
android:cropToPadding="false" android:cropToPadding="false"
android:scaleType="fitXY" android:scaleType="fitXY"
android:nextFocusDown="@+id/pcGridView"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@drawable/ic_settings" android:src="@drawable/ic_settings"
style="?android:attr/borderlessButtonStyle"/> 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 <ImageButton
android:id="@+id/manuallyAddPc" android:id="@+id/manuallyAddPc"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="65dp" android:layout_height="65dp"
android:cropToPadding="false" android:cropToPadding="false"
android:scaleType="fitXY" android:scaleType="fitXY"
android:nextFocusDown="@+id/pcGridView" android:layout_alignParentStart="true"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_below="@id/helpButton"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_add" android:src="@drawable/ic_add"
style="?android:attr/borderlessButtonStyle"/> style="?android:attr/borderlessButtonStyle"/>

View File

@ -9,41 +9,44 @@
tools:context=".PcView" > tools:context=".PcView" >
<RelativeLayout <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
android:id="@+id/pcs_loading"
android:layout_width="75dp"
android:layout_height="75dp"
android:indeterminate="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pcs_loading"
android:layout_toEndOf="@+id/pcs_loading"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:text="@string/searching_pc"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/pcFragmentContainer" android:id="@+id/pcFragmentContainer"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:layout_toLeftOf="@+id/manuallyAddPc" android:layout_below="@+id/settingsButton"
android:layout_toStartOf="@+id/manuallyAddPc" android:layout_alignParentLeft="true"
android:layout_toRightOf="@+id/settingsButton" android:layout_alignParentStart="true"
android:layout_toEndOf="@+id/settingsButton" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"/> >
<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
android:id="@+id/pcs_loading"
android:layout_width="75dp"
android:layout_height="75dp"
android:indeterminate="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pcs_loading"
android:layout_toEndOf="@+id/pcs_loading"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:text="@string/searching_pc"/>
</RelativeLayout>
</RelativeLayout>
<ImageButton <ImageButton
android:id="@+id/settingsButton" android:id="@+id/settingsButton"
@ -56,6 +59,18 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@drawable/ic_settings" android:src="@drawable/ic_settings"
style="?android:attr/borderlessButtonStyle"/> 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 <ImageButton
android:id="@+id/manuallyAddPc" android:id="@+id/manuallyAddPc"

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="yes">Yes</string>
<string name="no">No</string> <string name="no">No</string>
<string name="lost_connection">Lost connection to PC</string> <string name="lost_connection">Lost connection to PC</string>
<string name="help">Help</string>
<!-- AppList activity --> <!-- AppList activity -->
<string name="title_applist">Apps on</string> <string name="title_applist">Apps on</string>