mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-03 14:50:49 +00:00
Remove primary client, remove play store default source, add additional flows for adding sources
This commit is contained in:
parent
f78ca6c7ed
commit
837609abb9
6 changed files with 69 additions and 52 deletions
|
@ -536,7 +536,15 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
"BROWSE_PLUGINS" -> {
|
"BROWSE_PLUGINS" -> {
|
||||||
navigate(_fragBrowser, "https://plugins.grayjay.app");
|
navigate(_fragBrowser, BrowserFragment.NavigateOptions("https://plugins.grayjay.app/", mapOf(
|
||||||
|
Pair("grayjay") { req ->
|
||||||
|
StateApp.instance.contextOrNull?.let {
|
||||||
|
if(it is MainActivity) {
|
||||||
|
it.handleUrlAll(req.url.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -25,6 +26,7 @@ import com.futo.platformplayer.views.adapters.DisabledSourceView
|
||||||
import com.futo.platformplayer.views.adapters.EnabledSourceAdapter
|
import com.futo.platformplayer.views.adapters.EnabledSourceAdapter
|
||||||
import com.futo.platformplayer.views.adapters.EnabledSourceViewHolder
|
import com.futo.platformplayer.views.adapters.EnabledSourceViewHolder
|
||||||
import com.futo.platformplayer.views.adapters.ItemMoveCallback
|
import com.futo.platformplayer.views.adapters.ItemMoveCallback
|
||||||
|
import com.futo.platformplayer.views.buttons.BigButton
|
||||||
import com.futo.platformplayer.views.sources.SourceUnderConstructionView
|
import com.futo.platformplayer.views.sources.SourceUnderConstructionView
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
@ -86,6 +88,14 @@ class SourcesFragment : MainFragment() {
|
||||||
_containerDisabledViews = findViewById(R.id.container_disabled_views);
|
_containerDisabledViews = findViewById(R.id.container_disabled_views);
|
||||||
_containerConstruction = findViewById(R.id.container_construction);
|
_containerConstruction = findViewById(R.id.container_construction);
|
||||||
|
|
||||||
|
if(StatePlatform.instance.getAvailableClients().isEmpty()) {
|
||||||
|
findViewById<LinearLayout>(R.id.no_sources).isVisible = true;
|
||||||
|
findViewById<LinearLayout>(R.id.plugin_disclaimer).isVisible = false;
|
||||||
|
}
|
||||||
|
findViewById<BigButton>(R.id.button_add_sources).onClick.subscribe {
|
||||||
|
fragment.startActivity(Intent(context, AddSourceOptionsActivity::class.java));
|
||||||
|
};
|
||||||
|
|
||||||
for(inConstructSource in StatePlugins.instance.getSourcesUnderConstruction(context))
|
for(inConstructSource in StatePlugins.instance.getSourcesUnderConstruction(context))
|
||||||
_containerConstruction.addView(SourceUnderConstructionView(context, inConstructSource.key, inConstructSource.value));
|
_containerConstruction.addView(SourceUnderConstructionView(context, inConstructSource.key, inConstructSource.value));
|
||||||
|
|
||||||
|
@ -111,8 +121,6 @@ class SourcesFragment : MainFragment() {
|
||||||
|
|
||||||
adapterSourcesEnabled.notifyItemMoved(fromPosition, toPosition);
|
adapterSourcesEnabled.notifyItemMoved(fromPosition, toPosition);
|
||||||
onEnabledChanged(enabledSources);
|
onEnabledChanged(enabledSources);
|
||||||
if(toPosition == 0)
|
|
||||||
onPrimaryChanged(enabledSources.first());
|
|
||||||
|
|
||||||
StatePlatform.instance.setPlatformOrder(enabledSources.map { it.name });
|
StatePlatform.instance.setPlatformOrder(enabledSources.map { it.name });
|
||||||
};
|
};
|
||||||
|
@ -133,8 +141,6 @@ class SourcesFragment : MainFragment() {
|
||||||
|
|
||||||
updateContainerVisibility();
|
updateContainerVisibility();
|
||||||
onEnabledChanged(enabledSources);
|
onEnabledChanged(enabledSources);
|
||||||
if(index == 0)
|
|
||||||
onPrimaryChanged(enabledSources.first());
|
|
||||||
|
|
||||||
if(enabledSources.size <= 1)
|
if(enabledSources.size <= 1)
|
||||||
setCanRemove(false);
|
setCanRemove(false);
|
||||||
|
@ -221,9 +227,6 @@ class SourcesFragment : MainFragment() {
|
||||||
_adapterSourcesEnabled.canRemove = canRemove;
|
_adapterSourcesEnabled.canRemove = canRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onPrimaryChanged(client: IPlatformClient) {
|
|
||||||
StatePlatform.instance.selectPrimaryClient(client.id);
|
|
||||||
}
|
|
||||||
private fun onEnabledChanged(clients: List<IPlatformClient>) {
|
private fun onEnabledChanged(clients: List<IPlatformClient>) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
StatePlatform.instance.selectClients(*clients.map { it.id }.toTypedArray());
|
StatePlatform.instance.selectClients(*clients.map { it.id }.toTypedArray());
|
||||||
|
|
|
@ -94,11 +94,6 @@ class StatePlatform {
|
||||||
private val _liveEventClientPool = PlatformMultiClientPool("LiveEvents", 1); //Used exclusively for live events
|
private val _liveEventClientPool = PlatformMultiClientPool("LiveEvents", 1); //Used exclusively for live events
|
||||||
|
|
||||||
|
|
||||||
private val _primaryClientPersistent = FragmentedStorage.get<StringStorage>("primaryClient");
|
|
||||||
private var _primaryClientObj : IPlatformClient? = null;
|
|
||||||
val primaryClient : IPlatformClient get() = _primaryClientObj ?: throw IllegalStateException("PlatformState not yet initialized");
|
|
||||||
|
|
||||||
|
|
||||||
private val _icons : HashMap<String, ImageVariable> = HashMap();
|
private val _icons : HashMap<String, ImageVariable> = HashMap();
|
||||||
|
|
||||||
val hasClients: Boolean get() = _availableClients.size > 0;
|
val hasClients: Boolean get() = _availableClients.size > 0;
|
||||||
|
@ -207,20 +202,6 @@ class StatePlatform {
|
||||||
.filter { id -> _availableClients.any { it.id == id } }
|
.filter { id -> _availableClients.any { it.id == id } }
|
||||||
.toTypedArray();
|
.toTypedArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val primary = _primaryClientPersistent.value;
|
|
||||||
if(primary.isEmpty() || primary == StateDeveloper.DEV_ID) {
|
|
||||||
selectPrimaryClient(enabled.firstOrNull() ?: _availableClients.first().id);
|
|
||||||
} else if(!_availableClients.any { it.id == primary }) {
|
|
||||||
selectPrimaryClient(_availableClients.firstOrNull()?.id!!);
|
|
||||||
} else {
|
|
||||||
selectPrimaryClient(primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!enabled.any { it == primaryClient.id }) {
|
|
||||||
enabled = enabled.concat(primaryClient.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
selectClients(*enabled);
|
selectClients(*enabled);
|
||||||
};
|
};
|
||||||
|
@ -323,8 +304,6 @@ class StatePlatform {
|
||||||
newClient.initialize();
|
newClient.initialize();
|
||||||
_enabledClients.add(newClient);
|
_enabledClients.add(newClient);
|
||||||
}
|
}
|
||||||
if (_primaryClientObj == client)
|
|
||||||
_primaryClientObj = newClient;
|
|
||||||
|
|
||||||
_availableClients.removeIf { it.id == id };
|
_availableClients.removeIf { it.id == id };
|
||||||
_availableClients.add(newClient);
|
_availableClients.add(newClient);
|
||||||
|
@ -365,17 +344,6 @@ class StatePlatform {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects the primary client, meaning the first target for requests.
|
|
||||||
* At the moment, since multi-client requests are not yet implemented, this is the goto client.
|
|
||||||
*/
|
|
||||||
fun selectPrimaryClient(id: String) {
|
|
||||||
synchronized(_clientsLock) {
|
|
||||||
_primaryClientObj = getClient(id);
|
|
||||||
_primaryClientPersistent.setAndSave(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getHome(): IPager<IPlatformContent> {
|
fun getHome(): IPager<IPlatformContent> {
|
||||||
Logger.i(TAG, "Platform - getHome");
|
Logger.i(TAG, "Platform - getHome");
|
||||||
var clientIdsOngoing = mutableListOf<String>();
|
var clientIdsOngoing = mutableListOf<String>();
|
||||||
|
@ -448,14 +416,12 @@ class StatePlatform {
|
||||||
toAwait.map { PlaceholderPager(5, { PlatformContentPlaceholder(it.first.id) }) });
|
toAwait.map { PlaceholderPager(5, { PlatformContentPlaceholder(it.first.id) }) });
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getHomePrimary(): IPager<IPlatformContent> {
|
|
||||||
return primaryClient.getHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Search
|
//Search
|
||||||
fun searchSuggestions(query: String): Array<String> {
|
fun searchSuggestions(query: String): Array<String> {
|
||||||
Logger.i(TAG, "Platform - searchSuggestions");
|
Logger.i(TAG, "Platform - searchSuggestions");
|
||||||
return primaryClient.searchSuggestions(query);
|
//TODO: hasSearchSuggestions
|
||||||
|
return getEnabledClients().firstOrNull()?.searchSuggestions(query) ?: arrayOf();
|
||||||
}
|
}
|
||||||
|
|
||||||
fun search(query: String, type: String? = null, sort: String? = null, filters: Map<String, List<String>> = mapOf(), clientIds: List<String>? = null): IPager<IPlatformContent> {
|
fun search(query: String, type: String? = null, sort: String? = null, filters: Map<String, List<String>> = mapOf(), clientIds: List<String>? = null): IPager<IPlatformContent> {
|
||||||
|
@ -887,7 +853,6 @@ class StatePlatform {
|
||||||
synchronized(_clientsLock) {
|
synchronized(_clientsLock) {
|
||||||
val enabledExisting = _enabledClients.filter { it is DevJSClient };
|
val enabledExisting = _enabledClients.filter { it is DevJSClient };
|
||||||
val isEnabled = !enabledExisting.isEmpty()
|
val isEnabled = !enabledExisting.isEmpty()
|
||||||
val isPrimary = _primaryClientObj is DevJSClient;
|
|
||||||
|
|
||||||
for (enabled in enabledExisting) {
|
for (enabled in enabledExisting) {
|
||||||
enabled.disable();
|
enabled.disable();
|
||||||
|
@ -902,11 +867,7 @@ class StatePlatform {
|
||||||
devId = newClient.devID;
|
devId = newClient.devID;
|
||||||
try {
|
try {
|
||||||
StateDeveloper.instance.initializeDev(devId!!);
|
StateDeveloper.instance.initializeDev(devId!!);
|
||||||
if (isPrimary) {
|
if (isEnabled) {
|
||||||
_primaryClientObj = newClient;
|
|
||||||
_enabledClients.add(0, newClient);
|
|
||||||
newClient.initialize();
|
|
||||||
} else if (isEnabled) {
|
|
||||||
_enabledClients.add(newClient);
|
_enabledClients.add(newClient);
|
||||||
newClient.initialize();
|
newClient.initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,40 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="20dp">
|
android:paddingEnd="20dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/no_sources"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="10dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:srcCompat="@drawable/ic_error"
|
||||||
|
app:tint="#FFF" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#FFF"
|
||||||
|
android:textSize="12dp"
|
||||||
|
android:fontFamily="@font/inter_light"
|
||||||
|
android:text="@string/no_sources_installed"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="8dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/container_enabled"
|
android:id="@+id/container_enabled"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -91,6 +125,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/plugin_disclaimer"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp">
|
android:layout_marginBottom="10dp">
|
||||||
|
@ -113,6 +148,15 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.futo.platformplayer.views.buttons.BigButton
|
||||||
|
android:id="@+id/button_add_sources"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:buttonIcon="@drawable/ic_explore"
|
||||||
|
app:buttonText="Add Sources"
|
||||||
|
app:buttonSubText="Install new sources to see more content."
|
||||||
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@
|
||||||
<string name="videos">Videos</string>
|
<string name="videos">Videos</string>
|
||||||
<string name="clear_history">Clear history</string>
|
<string name="clear_history">Clear history</string>
|
||||||
<string name="nothing_to_import">Nothing to import</string>
|
<string name="nothing_to_import">Nothing to import</string>
|
||||||
|
<string name="no_sources_installed">You have no sources installed, please add sources to use the app as intended.</string>
|
||||||
<string name="enabling_lots_of_sources_can_reduce_the_loading_speed_of_your_application">Enabling lots of sources can reduce the loading speed of your application.</string>
|
<string name="enabling_lots_of_sources_can_reduce_the_loading_speed_of_your_application">Enabling lots of sources can reduce the loading speed of your application.</string>
|
||||||
<string name="support">Support</string>
|
<string name="support">Support</string>
|
||||||
<string name="membership">Membership</string>
|
<string name="membership">Membership</string>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"SOURCES_EMBEDDED": {
|
"SOURCES_EMBEDDED": {
|
||||||
"1c291164-294c-4c2d-800d-7bc6d31d0019": "sources/peertube/PeerTubeConfig.json"
|
|
||||||
},
|
},
|
||||||
"SOURCES_EMBEDDED_DEFAULT": ["1c291164-294c-4c2d-800d-7bc6d31d0019"],
|
"SOURCES_EMBEDDED_DEFAULT": [],
|
||||||
"SOURCES_UNDER_CONSTRUCTION": {}
|
"SOURCES_UNDER_CONSTRUCTION": {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue