mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Better URL handling support. Prompt user to set Grayjay as a default handler for certain URLs.
This commit is contained in:
parent
f15eb9bf9e
commit
2ee3c30b0e
8 changed files with 204 additions and 39 deletions
|
@ -133,6 +133,50 @@
|
|||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="polycentric" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="youtu.be" />
|
||||
<data android:host="www.you.be" />
|
||||
<data android:host="youtube.com" />
|
||||
<data android:host="www.youtube.com" />
|
||||
<data android:host="m.youtube.com" />
|
||||
<data android:host="rumble.com" />
|
||||
<data android:host="kick.com" />
|
||||
<data android:host="nebula.tv" />
|
||||
<data android:host="odysee.com" />
|
||||
<data android:host="patreon.com" />
|
||||
<data android:host="soundcloud.com" />
|
||||
<data android:host="twitch.tv" />
|
||||
<data android:pathPrefix="/" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<data android:mimeType="text/plain" />
|
||||
|
||||
<data android:host="youtu.be" />
|
||||
<data android:host="www.you.be" />
|
||||
<data android:host="youtube.com" />
|
||||
<data android:host="www.youtube.com" />
|
||||
<data android:host="m.youtube.com" />
|
||||
<data android:host="rumble.com" />
|
||||
<data android:host="kick.com" />
|
||||
<data android:host="nebula.tv" />
|
||||
<data android:host="odysee.com" />
|
||||
<data android:host="patreon.com" />
|
||||
<data android:host="soundcloud.com" />
|
||||
<data android:host="twitch.tv" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -111,7 +111,15 @@ class Settings : FragmentedStorageFileJson() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@FormField(R.string.link_handling, FieldForm.BUTTON, R.string.allow_grayjay_to_handle_links, -1)
|
||||
@FormFieldButton(R.drawable.ic_link)
|
||||
fun manageLinks() {
|
||||
try {
|
||||
SettingsActivity.getActivity()?.let { UIDialogs.showUrlHandlingPrompt(it) }
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to show url handling prompt", e)
|
||||
}
|
||||
}
|
||||
|
||||
@FormField(R.string.language, "group", -1, 0)
|
||||
var language = LanguageSettings();
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.futo.platformplayer
|
|||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
|
@ -91,6 +93,42 @@ class UIDialogs {
|
|||
}.toTypedArray());
|
||||
}
|
||||
|
||||
fun showUrlHandlingPrompt(context: Context, onYes: (() -> Unit)? = null) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.dialog_url_handling, null)
|
||||
builder.setView(view)
|
||||
|
||||
val dialog = builder.create()
|
||||
registerDialogOpened(dialog)
|
||||
|
||||
view.findViewById<TextView>(R.id.button_no).apply {
|
||||
this.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
view.findViewById<LinearLayout>(R.id.button_yes).apply {
|
||||
this.setOnClickListener {
|
||||
try {
|
||||
val intent = Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||
val uri = Uri.fromParts("package", context.packageName, null)
|
||||
intent.data = uri
|
||||
context.startActivity(intent)
|
||||
} catch (e: Throwable) {
|
||||
toast(context, context.getString(R.string.failed_to_show_settings))
|
||||
}
|
||||
|
||||
onYes?.invoke()
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.setOnDismissListener {
|
||||
registerDialogClosed(dialog)
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
fun showAutomaticBackupDialog(context: Context, skipRestoreCheck: Boolean = false, onClosed: (()->Unit)? = null) {
|
||||
val dialogAction: ()->Unit = {
|
||||
|
@ -107,7 +145,8 @@ class UIDialogs {
|
|||
}, UIDialogs.ActionStyle.DANGEROUS),
|
||||
UIDialogs.Action(context.getString(R.string.restore), {
|
||||
UIDialogs.showAutomaticRestoreDialog(context, StateApp.instance.scope);
|
||||
}, UIDialogs.ActionStyle.PRIMARY));
|
||||
}, UIDialogs.ActionStyle.PRIMARY)
|
||||
);
|
||||
else {
|
||||
dialogAction();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.futo.platformplayer.states
|
||||
|
||||
import android.content.Context
|
||||
import com.futo.platformplayer.UIDialogs
|
||||
import com.futo.platformplayer.api.http.ManagedHttpClient
|
||||
import com.futo.platformplayer.constructs.Event0
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
|
@ -256,9 +257,6 @@ class StateAnnouncement {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun registerDidYouKnow() {
|
||||
val random = Random();
|
||||
val message: String? = when (random.nextInt(4 * 18 + 1)) {
|
||||
|
@ -294,6 +292,23 @@ class StateAnnouncement {
|
|||
}
|
||||
}
|
||||
|
||||
fun registerDefaultHandlerAnnouncement() {
|
||||
registerAnnouncement(
|
||||
"default-url-handler",
|
||||
"Allow Grayjay to open URLs",
|
||||
"Click here to allow Grayjay to open URLs",
|
||||
AnnouncementType.SESSION_RECURRING,
|
||||
null,
|
||||
null,
|
||||
"Allow"
|
||||
) {
|
||||
UIDialogs.showUrlHandlingPrompt(StateApp.instance.context) {
|
||||
instance.neverAnnouncement("default-url-handler")
|
||||
instance.onAnnouncementChanged.emit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var _instance: StateAnnouncement? = null;
|
||||
val instance: StateAnnouncement
|
||||
|
|
|
@ -543,6 +543,7 @@ class StateApp {
|
|||
);
|
||||
}
|
||||
|
||||
StateAnnouncement.instance.registerDefaultHandlerAnnouncement();
|
||||
StateAnnouncement.instance.registerDidYouKnow();
|
||||
Logger.i(TAG, "MainApp Started: Finished");
|
||||
}
|
||||
|
|
86
app/src/main/res/layout/dialog_url_handling.xml
Normal file
86
app/src/main/res/layout/dialog_url_handling.xml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:background="@color/gray_1d">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/allow_grayjay_to_handle_specific_urls"
|
||||
android:textSize="14dp"
|
||||
android:textColor="@color/white"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp" />
|
||||
<TextView
|
||||
android:id="@+id/dialog_text_details"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="#AAAAAA"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:text="@string/allow_grayjay_to_handle_specific_urls_please_set_it_as_default_in_the_app_settings"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:textSize="12dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical|end"
|
||||
android:layout_marginTop="14dp"
|
||||
android:layout_marginBottom="28dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no"
|
||||
android:textSize="14dp"
|
||||
android:textColor="@color/primary"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:layout_marginEnd="16dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_yes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/background_button_primary"
|
||||
android:layout_marginEnd="28dp"
|
||||
android:clickable="true">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/yes"
|
||||
android:textSize="14dp"
|
||||
android:textColor="@color/white"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingStart="28dp"
|
||||
android:paddingEnd="28dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -292,6 +292,8 @@
|
|||
<string name="clear_external_downloads_directory">Clear external Downloads directory</string>
|
||||
<string name="change_external_general_directory">Change external General directory</string>
|
||||
<string name="change_tabs_visible_on_the_home_screen">Change tabs visible on the home screen</string>
|
||||
<string name="link_handling">Link Handling</string>
|
||||
<string name="allow_grayjay_to_handle_links">Allow Grayjay to handle links</string>
|
||||
<string name="change_the_external_directory_for_general_files">Change the external directory for general files</string>
|
||||
<string name="clear_the_external_storage_for_download_files">Clear the external storage for download files</string>
|
||||
<string name="change_the_external_storage_for_download_files">Change the external storage for download files</string>
|
||||
|
@ -678,6 +680,10 @@
|
|||
<string name="plus_tax">" + Tax"</string>
|
||||
<string name="new_playlist">New playlist</string>
|
||||
<string name="add_to_new_playlist">Add to new playlist</string>
|
||||
<string name="url_handling">URL Handling</string>
|
||||
<string name="allow_grayjay_to_handle_specific_urls">Allow Grayjay to handle specific URLs?</string>
|
||||
<string name="allow_grayjay_to_handle_specific_urls_please_set_it_as_default_in_the_app_settings">When you click \'Yes\', the Grayjay app settings will open.\n\nThere, navigate to:\n1. "Open by default" or "Set as default" section.\nYou might find this option directly or under \'Advanced\' settings, depending on your device.\n\n2. Choose \'Open supported links\' for Grayjay.\n\n(some devices have this listed under \'Default Apps\' in the main settings followed by selecting Grayjay for relevant categories)</string>
|
||||
<string name="failed_to_show_settings">Failed to show settings</string>
|
||||
<string-array name="home_screen_array">
|
||||
<item>Recommendations</item>
|
||||
<item>Subscriptions</item>
|
||||
|
|
|
@ -6,39 +6,5 @@
|
|||
|
||||
<application>
|
||||
<receiver android:name=".receivers.InstallReceiver" />
|
||||
|
||||
<activity android:name=".activities.MainActivity">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="youtu.be" />
|
||||
<data android:host="www.you.be" />
|
||||
<data android:host="youtube.com" />
|
||||
<data android:host="www.youtube.com" />
|
||||
<data android:host="m.youtube.com" />
|
||||
<data android:host="rumble.com" />
|
||||
<data android:pathPrefix="/" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<data android:mimeType="text/plain" />
|
||||
|
||||
<data android:host="youtube.com" />
|
||||
<data android:host="m.youtube.com" />
|
||||
<data android:host="you.be" />
|
||||
<data android:host="www.you.be" />
|
||||
<data android:host="rumble.com" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
Loading…
Add table
Reference in a new issue