Added FCast guide and other casting help options.

This commit is contained in:
Koen 2023-11-30 09:56:40 +01:00
parent baad342aec
commit 948f5a2a6d
10 changed files with 424 additions and 8 deletions

View file

@ -210,5 +210,9 @@
android:name=".activities.QRCaptureActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.FutoVideo.NoActionBar" />
<activity
android:name=".activities.FCastGuideActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.FutoVideo.NoActionBar" />
</application>
</manifest>

View file

@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.util.Log
import android.util.TypedValue
import android.view.Gravity
import android.view.LayoutInflater
@ -18,7 +17,6 @@ import com.futo.platformplayer.casting.StateCasting
import com.futo.platformplayer.dialogs.*
import com.futo.platformplayer.engine.exceptions.PluginException
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.states.StateAnnouncement
import com.futo.platformplayer.states.StateApp
import com.futo.platformplayer.states.StateBackup
import com.futo.platformplayer.stores.v2.ManagedStore
@ -344,6 +342,13 @@ class UIDialogs {
}
}
fun showCastingTutorialDialog(context: Context) {
val dialog = CastingHelpDialog(context);
registerDialogOpened(dialog);
dialog.setOnDismissListener { registerDialogClosed(dialog) };
dialog.show();
}
fun showCastingAddDialog(context: Context) {
val dialog = CastingAddDialog(context);
registerDialogOpened(dialog);

View file

@ -0,0 +1,108 @@
package com.futo.platformplayer.activities
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.Html
import android.widget.ImageButton
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.futo.platformplayer.R
import com.futo.platformplayer.UIDialogs
import com.futo.platformplayer.dialogs.CastingHelpDialog
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.setNavigationBarColorAndIcons
import com.futo.platformplayer.states.StateApp
import com.futo.platformplayer.views.buttons.BigButton
class FCastGuideActivity : AppCompatActivity() {
override fun attachBaseContext(newBase: Context?) {
super.attachBaseContext(StateApp.instance.getLocaleContext(newBase))
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fcast_guide);
setNavigationBarColorAndIcons();
findViewById<TextView>(R.id.text_explanation).apply {
val guideText = """
<h3>1. Install FCast Receiver:</h3>
<p>- Open Play Store, FireStore, or FCast website on your TV/desktop.<br>
- Search for "FCast Receiver", install and open it.</p>
<br>
<h3>2. Prepare the Grayjay App:</h3>
<p>- Ensure it's connected to the same network as the FCast Receiver.</p>
<br>
<h3>3. Initiate Casting from Grayjay:</h3>
<p>- Click the cast button in Grayjay.</p>
<br>
<h3>4. Connect to FCast Receiver:</h3>
<p>- Wait for your device to show in the list or add it manually with its IP address.</p>
<br>
<h3>5. Confirm Connection:</h3>
<p>- Click "OK" to confirm your device selection.</p>
<br>
<h3>6. Start Casting:</h3>
<p>- Press "start" next to the device you've added.</p>
<br>
<h3>7. Play Your Video:</h3>
<p>- Start any video in Grayjay to cast.</p>
<br>
<h3>Finding Your IP Address:</h3>
<p><b>On FCast Receiver (Android):</b> Displayed on the main screen.<br>
<b>On Windows:</b> Use 'ipconfig' in Command Prompt.<br>
<b>On Linux:</b> Use 'hostname -I' or 'ip addr' in Terminal.<br>
<b>On MacOS:</b> System Preferences > Network.</p>
""".trimIndent()
text = Html.fromHtml(guideText, Html.FROM_HTML_MODE_COMPACT)
}
findViewById<ImageButton>(R.id.button_back).setOnClickListener {
UIDialogs.showCastingTutorialDialog(this)
finish()
}
findViewById<BigButton>(R.id.button_close).onClick.subscribe {
UIDialogs.showCastingTutorialDialog(this)
finish()
}
findViewById<BigButton>(R.id.button_website).onClick.subscribe {
try {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://fcast.org/"))
startActivity(browserIntent);
} catch (e: Throwable) {
Logger.i(TAG, "Failed to open browser.", e)
}
}
findViewById<BigButton>(R.id.button_technical).onClick.subscribe {
try {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://gitlab.com/futo-org/fcast/-/wikis/Protocol-version-1"))
startActivity(browserIntent);
} catch (e: Throwable) {
Logger.i(TAG, "Failed to open browser.", e)
}
}
}
override fun onBackPressed() {
UIDialogs.showCastingTutorialDialog(this)
finish()
}
companion object {
private const val TAG = "FCastGuideActivity";
}
}

View file

@ -23,6 +23,7 @@ class CastingAddDialog(context: Context?) : AlertDialog(context) {
private lateinit var _textError: TextView;
private lateinit var _buttonCancel: Button;
private lateinit var _buttonConfirm: LinearLayout;
private lateinit var _buttonTutorial: TextView;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
@ -35,6 +36,7 @@ class CastingAddDialog(context: Context?) : AlertDialog(context) {
_textError = findViewById(R.id.text_error);
_buttonCancel = findViewById(R.id.button_cancel);
_buttonConfirm = findViewById(R.id.button_confirm);
_buttonTutorial = findViewById(R.id.button_tutorial)
ArrayAdapter.createFromResource(context, R.array.casting_device_type_array, R.layout.spinner_item_simple).also { adapter ->
adapter.setDropDownViewResource(R.layout.spinner_dropdownitem_simple);
@ -102,6 +104,11 @@ class CastingAddDialog(context: Context?) : AlertDialog(context) {
StateCasting.instance.addRememberedDevice(castingDeviceInfo);
performDismiss();
};
_buttonTutorial.setOnClickListener {
UIDialogs.showCastingTutorialDialog(context)
dismiss()
}
}
override fun show() {

View file

@ -0,0 +1,63 @@
package com.futo.platformplayer.dialogs
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import com.futo.platformplayer.R
import com.futo.platformplayer.UIDialogs
import com.futo.platformplayer.activities.FCastGuideActivity
import com.futo.platformplayer.activities.PolycentricWhyActivity
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.views.buttons.BigButton
class CastingHelpDialog(context: Context?) : AlertDialog(context) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
setContentView(LayoutInflater.from(context).inflate(R.layout.dialog_casting_help, null));
findViewById<BigButton>(R.id.button_guide).onClick.subscribe {
context.startActivity(Intent(context, FCastGuideActivity::class.java))
}
findViewById<BigButton>(R.id.button_video).onClick.subscribe {
try {
//TODO: Replace the URL with the casting video URL
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://fcast.org/"))
context.startActivity(browserIntent);
} catch (e: Throwable) {
Logger.i(TAG, "Failed to open browser.", e)
}
}
findViewById<BigButton>(R.id.button_website).onClick.subscribe {
try {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://fcast.org/"))
context.startActivity(browserIntent);
} catch (e: Throwable) {
Logger.i(TAG, "Failed to open browser.", e)
}
}
findViewById<BigButton>(R.id.button_technical).onClick.subscribe {
try {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://gitlab.com/futo-org/fcast/-/wikis/Protocol-version-1"))
context.startActivity(browserIntent);
} catch (e: Throwable) {
Logger.i(TAG, "Failed to open browser.", e)
}
}
findViewById<BigButton>(R.id.button_close).onClick.subscribe {
dismiss()
UIDialogs.showCastingAddDialog(context)
}
}
companion object {
private val TAG = "CastingTutorialDialog";
}
}

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="97dp"
android:height="97dp"
android:viewportWidth="97"
android:viewportHeight="97">
<path
android:pathData="M20,0L77,0A20,20 0,0 1,97 20L97,77A20,20 0,0 1,77 97L20,97A20,20 0,0 1,0 77L0,20A20,20 0,0 1,20 0z"
android:fillColor="#D9D9D9"/>
<path
android:pathData="M17.03,67V30.636H42.598V38.591H26.902V44.841H41.036V52.796H26.902V67H17.03ZM80.178,44.273H70.164C70.093,43.444 69.904,42.693 69.596,42.018C69.3,41.343 68.886,40.763 68.353,40.278C67.832,39.78 67.199,39.402 66.453,39.141C65.707,38.869 64.861,38.733 63.914,38.733C62.257,38.733 60.854,39.135 59.706,39.94C58.57,40.745 57.706,41.899 57.114,43.403C56.534,44.906 56.244,46.711 56.244,48.818C56.244,51.044 56.54,52.908 57.132,54.411C57.735,55.903 58.605,57.027 59.742,57.785C60.878,58.53 62.245,58.903 63.843,58.903C64.755,58.903 65.571,58.791 66.293,58.566C67.016,58.329 67.643,57.992 68.175,57.554C68.708,57.116 69.14,56.589 69.472,55.974C69.815,55.346 70.046,54.642 70.164,53.861L80.178,53.932C80.06,55.471 79.628,57.039 78.882,58.637C78.136,60.223 77.077,61.691 75.704,63.041C74.343,64.378 72.656,65.455 70.644,66.272C68.631,67.089 66.293,67.497 63.63,67.497C60.292,67.497 57.297,66.781 54.646,65.349C52.006,63.916 49.917,61.809 48.378,59.028C46.851,56.246 46.087,52.843 46.087,48.818C46.087,44.77 46.869,41.361 48.431,38.591C49.994,35.809 52.101,33.708 54.752,32.288C57.404,30.855 60.363,30.139 63.63,30.139C65.926,30.139 68.039,30.453 69.969,31.08C71.898,31.708 73.591,32.625 75.047,33.832C76.503,35.028 77.675,36.502 78.563,38.254C79.45,40.005 79.989,42.012 80.178,44.273Z"
android:fillColor="#000000"/>
</vector>

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/black">
<ImageButton
android:id="@+id/button_back"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="10dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_back_thin_white_16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:gravity="center_vertical"
android:layout_marginTop="4dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
app:srcCompat="@drawable/ic_fcast" />
<TextView
android:id="@+id/text_polycentric"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fcast"
android:fontFamily="@font/inter_light"
android:includeFontPadding="false"
android:textSize="32dp"
android:layout_marginLeft="12dp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/text_description"
android:layout_width="match_parent"
android:layout_height="0dp"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:background="@drawable/background_videodetail_description"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="14dp"
android:layout_marginBottom="14dp"
android:paddingTop="3dp"
android:paddingBottom="5dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
app:layout_constraintTop_toBottomOf="@id/button_back"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/layout_buttons">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.futo.platformplayer.views.behavior.NonScrollingTextView
android:id="@+id/text_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="@color/white"
android:fontFamily="@font/inter_light"
android:background="@color/transparent"
android:textSize="14sp" />
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/fcast_website"
app:buttonSubText="@string/open_the_fcast_website"
app:buttonIcon="@drawable/ic_link" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_technical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/fcast_technical_documentation"
app:buttonSubText="@string/view_the_fcast_technical_documentation"
app:buttonIcon="@drawable/ic_wrench"
android:layout_marginTop="8dp" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/close"
app:buttonSubText="@string/go_back_to_casting_add_dialog"
app:buttonIcon="@drawable/ic_close"
android:layout_marginTop="8dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -8,13 +8,31 @@
android:background="@color/gray_1d"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/add_casting_device"
android:textSize="14dp"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular" />
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_casting_device"
android:textSize="14dp"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular" />
<TextView
android:id="@+id/button_tutorial"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Help"
android:textSize="14dp"
android:padding="8dp"
android:gravity="end|center_vertical"
android:textColor="@color/primary"
android:fontFamily="@font/inter_regular" />
</LinearLayout>
<Spinner
android:id="@+id/spinner_type"

View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray_1d"
android:padding="12dp">
<LinearLayout
android:id="@+id/layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/video"
app:buttonSubText="@string/view_a_video_about_how_to_cast"
app:buttonIcon="@drawable/ic_smart_display"
android:layout_marginTop="8dp"
app:buttonBackground="@drawable/background_big_button_black"
android:alpha="0.4" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_guide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="FCast Guide"
app:buttonSubText="@string/how_to_use_fcast_guide"
app:buttonIcon="@drawable/ic_code"
android:layout_marginTop="8dp"
app:buttonBackground="@drawable/background_big_button_black" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/fcast_website"
app:buttonSubText="@string/open_the_fcast_website"
app:buttonIcon="@drawable/ic_link"
android:layout_marginTop="8dp"
app:buttonBackground="@drawable/background_big_button_black" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_technical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/fcast_technical_documentation"
app:buttonSubText="@string/view_the_fcast_technical_documentation"
app:buttonIcon="@drawable/ic_wrench"
android:layout_marginTop="8dp"
app:buttonBackground="@drawable/background_big_button_black" />
<com.futo.platformplayer.views.buttons.BigButton
android:id="@+id/button_close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/close"
app:buttonSubText="@string/go_back_to_casting_add_dialog"
app:buttonIcon="@drawable/ic_close"
android:layout_marginTop="8dp"
app:buttonBackground="@drawable/background_big_button_black"/>
</LinearLayout>
</FrameLayout>

View file

@ -688,6 +688,16 @@
<string name="failed_to_show_settings">Failed to show settings</string>
<string name="play_store_version_does_not_support_default_url_handling">Play store version does not support default URL handling.</string>
<string name="these_are_all_commentcount_comments_you_have_made_in_grayjay">These are all {commentCount} comments you have made in Grayjay.</string>
<string name="tutorial">Tutorial</string>
<string name="go_back_to_casting_add_dialog">Go back to casting add dialog</string>
<string name="view_a_video_about_how_to_cast">View a video about how to cast</string>
<string name="view_the_fcast_technical_documentation">View the FCast technical documentation</string>
<string name="guide">Guide</string>
<string name="how_to_use_fcast_guide">How to use FCast guide</string>
<string name="fcast">FCast</string>
<string name="open_the_fcast_website">Open the FCast website</string>
<string name="fcast_website">FCast Website</string>
<string name="fcast_technical_documentation">FCast Technical Documentation</string>
<string-array name="home_screen_array">
<item>Recommendations</item>
<item>Subscriptions</item>