Skip to content

Commit

Permalink
Merge branch 'release/v0.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa1115910 committed Dec 6, 2023
2 parents c58204f + e6f1e38 commit 968b217
Show file tree
Hide file tree
Showing 114 changed files with 3,793 additions and 772 deletions.
10 changes: 9 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ body:
label: 遇到问题的视频 avid 或 bvid
placeholder: av170001
- type: textarea
id: additional-context
id: additional-logs
attributes:
label: 相关日志
description: |
你可以在 `设置` > `更多设置` > `查看日志` 中查看已保存的日志,扫码即可下载获取(在同一网络环境下)
在日志列表中可找到自动生成的崩溃日志,或可在功能遇到问题(例如加载失败)后手动创建日志文件
上传文件时请务必等待文件上传完成后再提交 issue
- type: textarea
id: additional-content
attributes:
label: 附加信息
description: 添加你认为有必要的信息,例如出现问题的相关视频等等
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.

14 changes: 8 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ dependencies {
implementation(libs.koin.android)
implementation(libs.koin.compose)
implementation(libs.kotlinx.serialization)
implementation(libs.ktor.cio)
implementation(libs.ktor.client.cio)
implementation(libs.koin.core)
implementation(libs.ktor.content.negotiation)
implementation(libs.ktor.core)
implementation(libs.ktor.encoding)
implementation(libs.ktor.okhttp)
implementation(libs.ktor.serialization.kotlinx)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.encoding)
implementation(libs.ktor.client.okhttp)
implementation(libs.ktor.client.serialization.kotlinx)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.core)
implementation(libs.logging)
implementation(libs.material)
implementation(libs.qrcode)
Expand Down
90 changes: 90 additions & 0 deletions app/schemas/dev.aaa1115910.bv.dao.AppDatabase/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "c33e0c010c4133482ddbbdce8d56428c",
"entities": [
{
"tableName": "search_history",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `keyword` TEXT NOT NULL, `search_date` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "keyword",
"columnName": "keyword",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "searchDate",
"columnName": "search_date",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "user",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uid` INTEGER NOT NULL, `username` TEXT NOT NULL, `avatar` TEXT NOT NULL, `auth` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "username",
"columnName": "username",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "avatar",
"columnName": "avatar",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "auth",
"columnName": "auth",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c33e0c010c4133482ddbbdce8d56428c')"
]
}
}
15 changes: 15 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

Expand All @@ -11,6 +13,9 @@
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />

<application
android:name=".BVApp"
Expand All @@ -21,6 +26,16 @@
android:supportsRtl="true"
android:theme="@style/Theme.BV"
tools:ignore="UnusedAttribute">
<activity
android:name=".activities.settings.LogsActivity"
android:exported="false"
android:label="@string/title_activity_logs"
android:theme="@style/Theme.BV" />
<activity
android:name=".activities.user.UserSwitchActivity"
android:exported="true"
android:label="@string/title_activity_user_switch"
android:theme="@style/Theme.BV" />
<activity
android:name=".activities.video.VideoPlayerV3Activity"
android:exported="true"
Expand Down
45 changes: 41 additions & 4 deletions app/src/main/kotlin/dev/aaa1115910/bv/BVApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.aaa1115910.bv
import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.preferencesDataStore
Expand All @@ -15,15 +16,21 @@ import dev.aaa1115910.biliapi.repositories.AuthRepository
import dev.aaa1115910.biliapi.repositories.ChannelRepository
import dev.aaa1115910.biliapi.repositories.FavoriteRepository
import dev.aaa1115910.biliapi.repositories.HistoryRepository
import dev.aaa1115910.biliapi.repositories.IndexRepository
import dev.aaa1115910.biliapi.repositories.LoginRepository
import dev.aaa1115910.biliapi.repositories.RecommendVideoRepository
import dev.aaa1115910.biliapi.repositories.SearchRepository
import dev.aaa1115910.biliapi.repositories.SeasonRepository
import dev.aaa1115910.biliapi.repositories.VideoDetailRepository
import dev.aaa1115910.biliapi.repositories.VideoPlayRepository
import dev.aaa1115910.bv.dao.AppDatabase
import dev.aaa1115910.bv.entity.AuthData
import dev.aaa1115910.bv.entity.db.UserDB
import dev.aaa1115910.bv.network.HttpServer
import dev.aaa1115910.bv.repository.UserRepository
import dev.aaa1115910.bv.repository.VideoInfoRepository
import dev.aaa1115910.bv.screen.user.UserSwitchViewModel
import dev.aaa1115910.bv.util.LogCatcherUtil
import dev.aaa1115910.bv.util.Prefs
import dev.aaa1115910.bv.viewmodel.PlayerViewModel
import dev.aaa1115910.bv.viewmodel.TagViewModel
Expand All @@ -33,9 +40,9 @@ import dev.aaa1115910.bv.viewmodel.home.AnimeViewModel
import dev.aaa1115910.bv.viewmodel.home.DynamicViewModel
import dev.aaa1115910.bv.viewmodel.home.PopularViewModel
import dev.aaa1115910.bv.viewmodel.home.RecommendViewModel
import dev.aaa1115910.bv.viewmodel.index.AnimeIndexViewModel
import dev.aaa1115910.bv.viewmodel.login.AppQrLoginViewModel
import dev.aaa1115910.bv.viewmodel.login.SmsLoginViewModel
import dev.aaa1115910.bv.viewmodel.login.WebQrLoginViewModel
import dev.aaa1115910.bv.viewmodel.search.SearchInputViewModel
import dev.aaa1115910.bv.viewmodel.search.SearchResultViewModel
import dev.aaa1115910.bv.viewmodel.user.FavoriteViewModel
Expand All @@ -44,6 +51,7 @@ import dev.aaa1115910.bv.viewmodel.user.FollowingSeasonViewModel
import dev.aaa1115910.bv.viewmodel.user.HistoryViewModel
import dev.aaa1115910.bv.viewmodel.user.UpInfoViewModel
import dev.aaa1115910.bv.viewmodel.video.VideoDetailViewModel
import kotlinx.coroutines.runBlocking
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.androidx.viewmodel.dsl.viewModel
Expand Down Expand Up @@ -76,12 +84,15 @@ class BVApp : Application() {
modules(appModule)
}
firebaseAnalytics = Firebase.analytics
LogCatcherUtil.installLogCatcher()
initRepository()
initProxy()
instance = this
updateMigration()
HttpServer.startServer()
}

private fun initRepository() {
fun initRepository() {
val channelRepository by koinApplication.koin.inject<ChannelRepository>()
channelRepository.initDefaultChannel(Prefs.accessToken, Prefs.buvid)

Expand All @@ -108,6 +119,30 @@ class BVApp : Application() {
}
}
}

private fun updateMigration() {
val lastVersionCode = Prefs.lastVersionCode
if (lastVersionCode >= BuildConfig.VERSION_CODE) return
Log.i("BVApp", "updateMigration from $lastVersionCode")
if (lastVersionCode < 576) {
// 从 Prefs 中读取登录数据写入 UserDB
if (Prefs.isLogin) {
runBlocking {
val existedUser = getAppDatabase().userDao().findUserByUid(Prefs.uid)
if (existedUser == null) {
val user = UserDB(
uid = Prefs.uid,
username = "Unknown",
avatar = "",
auth = AuthData.fromPrefs().toJson()
)
getAppDatabase().userDao().insert(user)
}
}
}
}
Prefs.lastVersionCode = BuildConfig.VERSION_CODE
}
}

val appModule = module {
Expand All @@ -124,11 +159,11 @@ val appModule = module {
single { VideoDetailRepository(get(), get(), get()) }
single { SeasonRepository(get()) }
single { dev.aaa1115910.biliapi.repositories.UserRepository(get(), get()) }
single { IndexRepository() }
viewModel { DynamicViewModel(get(), get()) }
viewModel { RecommendViewModel(get()) }
viewModel { PopularViewModel(get()) }
viewModel { WebQrLoginViewModel(get(), get()) }
viewModel { AppQrLoginViewModel(get(), get(), get()) }
viewModel { AppQrLoginViewModel(get(), get()) }
viewModel { SmsLoginViewModel(get(), get()) }
viewModel { PlayerViewModel(get()) }
viewModel { UserViewModel(get()) }
Expand All @@ -143,6 +178,8 @@ val appModule = module {
viewModel { TagViewModel() }
viewModel { VideoPlayerV3ViewModel(get(), get()) }
viewModel { VideoDetailViewModel(get()) }
viewModel { UserSwitchViewModel(get()) }
viewModel { AnimeIndexViewModel(get()) }
}

val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "Settings")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.aaa1115910.bv.activities.settings

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import dev.aaa1115910.bv.screen.settings.LogsScreen
import dev.aaa1115910.bv.ui.theme.BVTheme

class LogsActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BVTheme {
LogsScreen()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.aaa1115910.bv.activities.user

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import dev.aaa1115910.bv.screen.user.UserSwitchScreen
import dev.aaa1115910.bv.ui.theme.BVTheme

class UserSwitchActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BVTheme {
UserSwitchScreen()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import dev.aaa1115910.bv.screen.VideoPlayerScreen
import dev.aaa1115910.bv.ui.theme.BVTheme
import dev.aaa1115910.bv.util.fInfo
import dev.aaa1115910.bv.viewmodel.PlayerViewModel
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import org.koin.androidx.viewmodel.ext.android.viewModel

class VideoPlayerActivity : ComponentActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import dev.aaa1115910.bv.ui.theme.BVTheme
import dev.aaa1115910.bv.util.Prefs
import dev.aaa1115910.bv.util.fInfo
import dev.aaa1115910.bv.viewmodel.VideoPlayerV3ViewModel
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import org.koin.androidx.viewmodel.ext.android.viewModel

class VideoPlayerV3Activity : ComponentActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package dev.aaa1115910.bv.component
*/

import android.annotation.SuppressLint
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -50,7 +49,7 @@ import androidx.tv.foundation.ExperimentalTvFoundationApi
* @param content the content that is present within the group and can use focus-group modifier
* extensions.
*/
@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)
@OptIn(ExperimentalComposeUiApi::class)
@ExperimentalTvFoundationApi
@Deprecated("Use focusRestorer instead")
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.material.icons.rounded.Done
import androidx.compose.material.icons.rounded.Favorite
import androidx.compose.material.icons.rounded.FavoriteBorder
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -79,10 +78,7 @@ fun FavoriteButton(
)
}

@OptIn(
ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class,
ExperimentalTvMaterial3Api::class
)
@OptIn(ExperimentalLayoutApi::class, ExperimentalTvMaterial3Api::class)
@Composable
private fun FavoriteDialog(
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import dev.aaa1115910.bv.entity.VideoCodec
import dev.aaa1115910.bv.repository.VideoListItem
import dev.aaa1115910.bv.util.fInfo
import dev.aaa1115910.bv.util.toast
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
Expand Down
Loading

0 comments on commit 968b217

Please sign in to comment.