Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Final Testing Phase!] External apk test #871

Merged
merged 37 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4bdf02d
IT WORKS!!!!!!!!!!!!!!!!!!!!!
jakepurple13 Jul 12, 2023
203264e
Gotta double check the notifications but everything does in fact seem…
jakepurple13 Jul 14, 2023
950d4db
Everything seems to be working! Still gotta check notifications BUUUU…
jakepurple13 Jul 14, 2023
dc8590b
Setting more of the ExtensionListScreen.kt up. Still need to handle i…
jakepurple13 Jul 18, 2023
f548baa
Cleaning things up...some sources aren't working anymore with this ne…
jakepurple13 Jul 18, 2023
f6dde24
UPDATING TO KOTLIN 1.9.0!!!
jakepurple13 Jul 19, 2023
7c23963
Figured out what was breaking some sources. QuickJs and Zipline need …
jakepurple13 Jul 19, 2023
1597a60
Fixed bottom sheet navigation weird thingy
jakepurple13 Jul 19, 2023
d5537fb
Fixing build
jakepurple13 Jul 19, 2023
a8bf93d
Adding small additional things
jakepurple13 Jul 19, 2023
8ebeaf2
Adding small additional things
jakepurple13 Jul 19, 2023
05971e6
Making the navigationrail scrollable!
jakepurple13 Jul 19, 2023
86eb786
Added more to get working. Got Tachiyomi Bridge to show up in the Ota…
jakepurple13 Jul 21, 2023
d1a9303
Moving some padding
jakepurple13 Jul 21, 2023
b35cf31
Fixing GlobalSearch bottom sheet click
jakepurple13 Jul 21, 2023
c40630b
Got downloading and installing working! Now to show when there is an …
jakepurple13 Jul 24, 2023
c53808c
Hopefully update works?
jakepurple13 Jul 24, 2023
61cb17c
Small animation
jakepurple13 Jul 24, 2023
281e894
Creating a CurrentSourceRepository
jakepurple13 Jul 25, 2023
aaf026b
Filtering based on source type
jakepurple13 Jul 25, 2023
188286d
Updating so that favorites will show uninstalled sources
jakepurple13 Jul 25, 2023
c6383c1
Getting notifications to show uninstalled sources
jakepurple13 Jul 25, 2023
ae7781a
small update
jakepurple13 Jul 25, 2023
32ea8cf
A check to see if we should reload extensions
jakepurple13 Jul 25, 2023
710b6a0
Checking for uninstalled source in lists
jakepurple13 Jul 25, 2023
2302154
Error catching
jakepurple13 Jul 26, 2023
53d82cc
Small cleanup
jakepurple13 Jul 26, 2023
421a07a
Showing versions
jakepurple13 Jul 26, 2023
9f523d0
Removing some prints
jakepurple13 Jul 26, 2023
cfb42ba
New notification id
jakepurple13 Jul 26, 2023
4470520
Fixing the external sources not updating source list
jakepurple13 Jul 27, 2023
2b27d13
Updating to latest compose
jakepurple13 Jul 27, 2023
305bd2c
Small cleanup
jakepurple13 Jul 27, 2023
e9f6ea8
Small cleanup
jakepurple13 Jul 28, 2023
67059a4
version update
jakepurple13 Jul 28, 2023
ccfb681
updating libs
jakepurple13 Jul 31, 2023
31469ef
Fixing tv build
jakepurple13 Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 47 additions & 2 deletions Models/src/main/java/com/programmersbox/models/ApiService.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.programmersbox.models

import android.app.Application
import android.content.pm.PackageInfo
import android.graphics.drawable.Drawable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import java.io.Serializable

interface ApiService : Serializable {
Expand Down Expand Up @@ -78,4 +85,42 @@ interface ApiService : Serializable {
fun <T> Flow<T>.dispatchIo() = this.flowOn(Dispatchers.IO)
}

val sourceFlow = MutableStateFlow<ApiService?>(null)
interface ApiServicesCatalog {
fun createSources(): List<ApiService>
val name: String
}

interface ExternalApiServicesCatalog : ApiServicesCatalog {
suspend fun initialize(app: Application)

fun getSources(): List<SourceInformation>
override fun createSources(): List<ApiService> = getSources().map { it.apiService }

val hasRemoteSources: Boolean
suspend fun getRemoteSources(): List<RemoteSources> = emptyList()

fun shouldReload(packageName: String, packageInfo: PackageInfo): Boolean = false
}

data class RemoteSources(
val name: String,
val packageName: String,
val version: String,
val iconUrl: String,
val downloadLink: String,
val sources: List<Sources>,
)

data class Sources(
val name: String,
val baseUrl: String,
val version: String
)

data class SourceInformation(
val apiService: ApiService,
val name: String,
val icon: Drawable?,
val packageName: String,
val catalog: ApiServicesCatalog? = null
)
2 changes: 2 additions & 0 deletions Models/src/main/java/com/programmersbox/models/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data class ItemModel(
val source: ApiService
) : Serializable {
val extras = mutableMapOf<String, Any>()
val otherExtras = mutableMapOf<String, Any>()
fun toInfoModel() = source.getItemInfoFlow(this)
}

Expand All @@ -36,6 +37,7 @@ data class ChapterModel(
var uploadedTime: Long? = null
fun getChapterInfo() = source.getChapterInfoFlow(this)
val extras = mutableMapOf<String, Any>()
val otherExtras = mutableMapOf<String, Any>()
}

class NormalLink(var normal: Normal? = null)
Expand Down
7 changes: 6 additions & 1 deletion UIViews/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id("otaku-library")
id("androidx.navigation.safeargs.kotlin")
id("kotlinx-serialization")
id("com.google.protobuf") version "0.9.3"
id("com.google.protobuf") version "0.9.4"
alias(libs.plugins.ksp)
}

Expand Down Expand Up @@ -111,8 +111,13 @@ dependencies {

implementation(libs.bundles.protobuf)

implementation(libs.bundles.ktorLibs)

//Multiplatform
implementation(projects.imageloader)

//Extension Loader
api(projects.sharedutils.extensionloader)
}

protobuf {
Expand Down
7 changes: 5 additions & 2 deletions UIViews/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application>

<receiver
android:name=".DeleteNotificationReceiver"
android:name=".checkers.DeleteNotificationReceiver"
android:enabled="true"
android:exported="true" />
<receiver
android:name=".BootReceived"
android:name=".checkers.BootReceived"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,40 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Badge
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.contentColorFor
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
Expand Down Expand Up @@ -353,7 +382,7 @@ private fun DefaultHeader(
}
}
description?.let {
Divider(modifier = Modifier.padding(horizontal = 4.dp))
HorizontalDivider(modifier = Modifier.padding(horizontal = 4.dp))
Text(it, textAlign = TextAlign.Center)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
Expand All @@ -30,9 +31,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.BrowseGallery
import androidx.compose.material.icons.filled.Extension
import androidx.compose.material.icons.filled.History
import androidx.compose.material.icons.filled.List
import androidx.compose.material.icons.filled.Notifications
Expand Down Expand Up @@ -60,6 +64,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -87,9 +92,9 @@ import com.google.accompanist.navigation.material.ExperimentalMaterialNavigation
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberPermissionState
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.programmersbox.extensionloader.SourceRepository
import com.programmersbox.favoritesdatabase.ItemDatabase
import com.programmersbox.helpfulutils.notificationManager
import com.programmersbox.models.sourceFlow
import com.programmersbox.sharedutils.AppUpdate
import com.programmersbox.sharedutils.MainLogo
import com.programmersbox.sharedutils.updateAppCheck
Expand All @@ -106,6 +111,7 @@ import com.programmersbox.uiviews.notifications.NotificationsScreen
import com.programmersbox.uiviews.notifications.cancelNotification
import com.programmersbox.uiviews.recent.RecentView
import com.programmersbox.uiviews.settings.ComposeSettingsDsl
import com.programmersbox.uiviews.settings.ExtensionList
import com.programmersbox.uiviews.settings.GeneralSettings
import com.programmersbox.uiviews.settings.InfoSettings
import com.programmersbox.uiviews.settings.NotificationSettings
Expand Down Expand Up @@ -147,6 +153,9 @@ abstract class BaseMainActivity : AppCompatActivity() {

private val settingsHandling: SettingsHandling by inject()

private val sourceRepository by inject<SourceRepository>()
private val currentSourceRepository by inject<CurrentSourceRepository>()

protected abstract fun onCreate()

@Composable
Expand All @@ -161,7 +170,8 @@ abstract class BaseMainActivity : AppCompatActivity() {
@OptIn(
ExperimentalMaterialNavigationApi::class,
ExperimentalMaterial3Api::class,
ExperimentalMaterial3WindowSizeClassApi::class
ExperimentalMaterial3WindowSizeClassApi::class,
ExperimentalMaterialApi::class
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -176,6 +186,11 @@ abstract class BaseMainActivity : AppCompatActivity() {
remember { ChromeCustomTabsNavigator(this) }
)

val scope = rememberCoroutineScope()
BackHandler(bottomSheetNavigator.sheetState.isVisible) {
scope.launch { bottomSheetNavigator.sheetState.hide() }
}

val systemUiController = rememberSystemUiController()
val customPreferences = remember { ComposeSettingsDsl().apply(genericInfo.composeCustomPreferences(navController)) }

Expand Down Expand Up @@ -320,7 +335,8 @@ abstract class BaseMainActivity : AppCompatActivity() {
AppCompatResources.getDrawable(this@BaseMainActivity, logo.logoId)!!.toBitmap().asImageBitmap(),
null,
)
}
},
modifier = Modifier.verticalScroll(rememberScrollState())
) {
NavigationRailItem(
imageVector = Icons.Default.History,
Expand Down Expand Up @@ -378,6 +394,15 @@ abstract class BaseMainActivity : AppCompatActivity() {
customRoute = "_home"
)

NavigationRailItem(
imageVector = Icons.Default.Extension,
label = stringResource(R.string.extensions),
screen = Screen.ExtensionListScreen,
currentDestination = currentDestination,
navController = navController,
customRoute = "_home"
)

NavigationRailItem(
icon = {
BadgedBox(
Expand Down Expand Up @@ -572,6 +597,12 @@ abstract class BaseMainActivity : AppCompatActivity() {
)
}

composable(
Screen.ExtensionListScreen.route,
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Start) },
exitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End) },
) { ExtensionList() }

additionalSettings()

if (BuildConfig.DEBUG) {
Expand Down Expand Up @@ -611,6 +642,12 @@ abstract class BaseMainActivity : AppCompatActivity() {
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Up) },
exitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Down) }
) { FavoriteUi(logo) }

composable(
Screen.ExtensionListScreen.route + "_home",
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Up) },
exitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Down) }
) { ExtensionList() }
}

@OptIn(ExperimentalPermissionsApi::class)
Expand All @@ -633,7 +670,13 @@ abstract class BaseMainActivity : AppCompatActivity() {

private fun setup() {
lifecycleScope.launch {
genericInfo.toSource(currentService.orEmpty())?.let { sourceFlow.emit(it) }
if (currentService == null) {
val s = sourceRepository.list.randomOrNull()?.apiService
currentSourceRepository.emit(s)
currentService = s?.serviceName
} else {
sourceRepository.toSourceByApiServiceName(currentService.orEmpty())?.let { currentSourceRepository.emit(it.apiService) }
}
}

when (runBlocking { settingsHandling.systemThemeMode.firstOrNull() }) {
Expand Down
Loading
Loading