JetPAck App StartUpを使った初期化を導入
This commit is contained in:
parent
2d2d5ce58c
commit
c1b631621f
|
@ -38,7 +38,7 @@ class GifDecoder(val callback : GifDecoderCallback) {
|
|||
var nRead = 0
|
||||
while(nRead < length) {
|
||||
val delta = bis.read(ba, offset + nRead, length - nRead)
|
||||
if(delta == - 1) throw error("unexpected End of Stream")
|
||||
if(delta == - 1) error("unexpected End of Stream")
|
||||
nRead += delta
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ apply plugin: 'kotlin-android'
|
|||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
|
||||
apply plugin: "io.gitlab.arturbosch.detekt"
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
android {
|
||||
|
||||
compileSdkVersion compile_sdk_version
|
||||
|
||||
// exoPlayer 2.9.0 以降は Java 8 compiler support を要求する
|
||||
// https://github.com/google/ExoPlayer/blob/release-v2/RELEASENOTES.md
|
||||
// Invoke-customs are only supported starting with Android O (--min-api 26)
|
||||
// Default interface methods are only supported starting with Android N (--min-api 24)
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
|
@ -45,10 +43,12 @@ android {
|
|||
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
]
|
||||
}
|
||||
buildFeatures {
|
||||
// 諸事情でまだcomposeを導入できない。詳細は依存関係の項に記載
|
||||
// compose true
|
||||
}
|
||||
|
||||
// kotlin 1.6.0にすると This version (1.0.5) of the Compose Compiler requires Kotlin version 1.5.31 but you appear to be using Kotlin version 1.6.0 which is not known to be compatible. と怒られる
|
||||
// buildFeatures {
|
||||
// compose true
|
||||
// }
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion compose_version
|
||||
}
|
||||
|
@ -241,7 +241,6 @@ dependencies {
|
|||
|
||||
implementation 'com.caverock:androidsvg-aar:1.4'
|
||||
|
||||
|
||||
// ViewModel
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||
// LiveData
|
||||
|
@ -268,9 +267,18 @@ dependencies {
|
|||
testImplementation "androidx.arch.core:core-testing:$arch_version"
|
||||
|
||||
|
||||
// composeはkotlin 1.5.31を要求するが
|
||||
// https://gist.github.com/tateisu/cbda451135d2b5c9b69f7ac4599f9833 の問題があるので1.5.31を使えない
|
||||
// 治るまでcompose導入を諦める
|
||||
def roomVersion = "2.3.0"
|
||||
implementation "androidx.room:room-runtime:$roomVersion"
|
||||
implementation "androidx.room:room-ktx:$roomVersion"
|
||||
kapt "androidx.room:room-compiler:$roomVersion"
|
||||
|
||||
def workVersion = "2.7.1"
|
||||
implementation "androidx.work:work-runtime:$workVersion"
|
||||
implementation "androidx.work:work-runtime-ktx:$workVersion"
|
||||
|
||||
implementation "androidx.startup:startup-runtime:1.1.0"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
|
||||
|
||||
// implementation "androidx.compose.ui:ui:$compose_version"
|
||||
// implementation "androidx.compose.material:material:$compose_version"
|
||||
// implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
|
||||
|
@ -278,18 +286,22 @@ dependencies {
|
|||
// implementation "androidx.compose.material:material-icons-extended:$compose_version"
|
||||
// androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
|
||||
// debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
// implementation 'androidx.activity:activity-compose:1.4.0-rc01'
|
||||
|
||||
// implementation "androidx.activity:activity-compose:1.4.0"
|
||||
// implementation "com.google.accompanist:accompanist-flowlayout:0.20.0"
|
||||
|
||||
// Koin main features for Android
|
||||
implementation "io.insert-koin:koin-android:$koin_version"
|
||||
implementation "io.insert-koin:koin-android-compat:$koin_version"
|
||||
implementation "io.insert-koin:koin-androidx-workmanager:$koin_version"
|
||||
// implementation "io.insert-koin:koin-androidx-navigation:$koin_version"
|
||||
// implementation "io.insert-koin:koin-androidx-compose:$koin_version"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
|
||||
detekt {
|
||||
// relative path from module path.
|
||||
basePath = projectDir
|
||||
|
|
|
@ -28,6 +28,7 @@ import jp.juggler.subwaytooter.action.accountRemove
|
|||
import jp.juggler.subwaytooter.api.*
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.notification.NotificationHelper
|
||||
import jp.juggler.subwaytooter.notification.PollingWorker
|
||||
import jp.juggler.subwaytooter.notification.PushSubscriptionHelper
|
||||
|
@ -260,7 +261,7 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
|
|||
}
|
||||
|
||||
App1.setActivityTheme(this)
|
||||
this.pref = App1.pref
|
||||
this.pref = appPref
|
||||
|
||||
initUI()
|
||||
|
||||
|
@ -706,9 +707,9 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
|
|||
account.movie_max_megabytes = etMovieSizeMax.text.toString().trim()
|
||||
account.image_max_megabytes = etMediaSizeMax.text.toString().trim()
|
||||
account.image_resize = (
|
||||
imageResizeItems.elementAtOrNull(spResizeImage.selectedItemPosition)?.config
|
||||
?: SavedAccount.defaultResizeConfig
|
||||
).spec
|
||||
imageResizeItems.elementAtOrNull(spResizeImage.selectedItemPosition)?.config
|
||||
?: SavedAccount.defaultResizeConfig
|
||||
).spec
|
||||
|
||||
account.push_policy =
|
||||
pushPolicyItems.elementAtOrNull(spPushPolicy.selectedItemPosition)?.id
|
||||
|
@ -1006,8 +1007,9 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
|
|||
?.also { result ->
|
||||
val jsonObject = result.jsonObject
|
||||
if (jsonObject != null) {
|
||||
resultAccount = TootParser(this@ActAccountSetting, account).account(jsonObject)
|
||||
?: return@runApiTask TootApiResult("TootAccount parse failed.")
|
||||
resultAccount =
|
||||
TootParser(this@ActAccountSetting, account).account(jsonObject)
|
||||
?: return@runApiTask TootApiResult("TootAccount parse failed.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1027,14 +1029,12 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
|
|||
profileBusy = true
|
||||
try {
|
||||
ivProfileAvatar.setImageUrl(
|
||||
App1.pref,
|
||||
Styler.calcIconRound(ivProfileAvatar.layoutParams),
|
||||
src.avatar_static,
|
||||
src.avatar
|
||||
)
|
||||
|
||||
ivProfileHeader.setImageUrl(
|
||||
App1.pref,
|
||||
0f,
|
||||
src.header_static,
|
||||
src.header
|
||||
|
@ -1304,8 +1304,9 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
|
|||
multipartBodyBuilder.build().toPatch()
|
||||
)?.also { result ->
|
||||
result.jsonObject?.let {
|
||||
resultAccount = TootParser(this@ActAccountSetting, account).account(it)
|
||||
?: return@runApiTask TootApiResult("TootAccount parse failed.")
|
||||
resultAccount =
|
||||
TootParser(this@ActAccountSetting, account).account(it)
|
||||
?: return@runApiTask TootApiResult("TootAccount parse failed.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1189,7 +1189,7 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
|
|||
|
||||
fun showCustomShareIcon(tv: TextView?, target: CustomShareTarget) {
|
||||
tv ?: return
|
||||
val cn = CustomShare.getCustomShareComponentName(pref, target)
|
||||
val cn = CustomShare.getCustomShareComponentName(target)
|
||||
val (label, icon) = CustomShare.getInfo(this, cn)
|
||||
tv.text = label ?: getString(R.string.not_selected)
|
||||
tv.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.appcompat.widget.SwitchCompat
|
||||
import com.jrummyapps.android.colorpicker.ColorPickerDialog
|
||||
import com.jrummyapps.android.colorpicker.ColorPickerDialogListener
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.table.HighlightWord
|
||||
import jp.juggler.util.*
|
||||
import org.jetbrains.anko.textColor
|
||||
|
@ -138,8 +139,8 @@ class ActHighlightWordEdit
|
|||
swSpeech = findViewById(R.id.swSpeech)
|
||||
swSpeech.setOnCheckedChangeListener(this)
|
||||
|
||||
setSwitchColor(App1.pref, swSound)
|
||||
setSwitchColor(App1.pref, swSpeech)
|
||||
setSwitchColor(appPref, swSound)
|
||||
setSwitchColor(appPref, swSpeech)
|
||||
|
||||
intArrayOf(
|
||||
R.id.btnTextColorEdit,
|
||||
|
|
|
@ -26,6 +26,7 @@ import jp.juggler.subwaytooter.api.entity.*
|
|||
import jp.juggler.subwaytooter.databinding.ActMediaViewerBinding
|
||||
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
||||
import jp.juggler.subwaytooter.drawable.MediaBackgroundDrawable
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.pref.put
|
||||
import jp.juggler.subwaytooter.util.ProgressResponseBody
|
||||
|
@ -338,7 +339,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
exoPlayer.volume = 0f
|
||||
}
|
||||
|
||||
val url = ta.getLargeUrl(App1.pref)
|
||||
val url = ta.getLargeUrl(appPref)
|
||||
if (url == null) {
|
||||
showError("missing media attachment url.")
|
||||
return
|
||||
|
@ -562,7 +563,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
|
||||
viewBinding.cbMute.visibility = View.INVISIBLE
|
||||
|
||||
val urlList = ta.getLargeUrlList(App1.pref)
|
||||
val urlList = ta.getLargeUrlList(appPref)
|
||||
if (urlList.isEmpty()) {
|
||||
showError("missing media attachment url.")
|
||||
return
|
||||
|
@ -628,7 +629,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
?: error("missing DownloadManager system service")
|
||||
|
||||
val url = if (ta is TootAttachment) {
|
||||
ta.getLargeUrl(App1.pref)
|
||||
ta.getLargeUrl(appPref)
|
||||
} else {
|
||||
null
|
||||
} ?: return
|
||||
|
@ -743,7 +744,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
private fun more(ta: TootAttachmentLike) {
|
||||
val ad = ActionsDialog()
|
||||
if (ta is TootAttachment) {
|
||||
val url = ta.getLargeUrl(App1.pref) ?: return
|
||||
val url = ta.getLargeUrl(appPref) ?: return
|
||||
ad.addAction(getString(R.string.open_in_browser)) { share(Intent.ACTION_VIEW, url) }
|
||||
ad.addAction(getString(R.string.share_url)) { share(Intent.ACTION_SEND, url) }
|
||||
ad.addAction(getString(R.string.copy_url)) { copy(url) }
|
||||
|
@ -823,7 +824,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
for (k in MediaBackgroundDrawable.Kind.values()) {
|
||||
ad.addAction(k.name) {
|
||||
val idx = k.toIndex()
|
||||
App1.pref.edit().put(PrefI.ipMediaBackground, idx).apply()
|
||||
appPref.edit().put(PrefI.ipMediaBackground, idx).apply()
|
||||
|
||||
viewBinding.pbvImage.background = MediaBackgroundDrawable(
|
||||
tileStep = tileStep,
|
||||
|
|
|
@ -4,9 +4,6 @@ import android.annotation.SuppressLint
|
|||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
|
@ -23,10 +20,12 @@ import com.bumptech.glide.load.model.GlideUrl
|
|||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.column.ColumnType
|
||||
import jp.juggler.subwaytooter.emoji.EmojiMap
|
||||
import jp.juggler.subwaytooter.global.Global
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.pref.pref
|
||||
import jp.juggler.subwaytooter.table.*
|
||||
import jp.juggler.subwaytooter.table.HighlightWord
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.util.CustomEmojiCache
|
||||
import jp.juggler.subwaytooter.util.CustomEmojiLister
|
||||
import jp.juggler.subwaytooter.util.ProgressResponseBody
|
||||
|
@ -61,20 +60,6 @@ class App1 : Application() {
|
|||
super.onTerminate()
|
||||
}
|
||||
|
||||
class DBOpenHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||
|
||||
override fun onCreate(db: SQLiteDatabase) {
|
||||
for (ti in tableList) {
|
||||
ti.onDBCreate(db)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
for (ti in tableList) {
|
||||
ti.onDBUpgrade(db, oldVersion, newVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -82,87 +67,6 @@ class App1 : Application() {
|
|||
|
||||
const val FILE_PROVIDER_AUTHORITY = "jp.juggler.subwaytooter.FileProvider"
|
||||
|
||||
internal const val DB_NAME = "app_db"
|
||||
|
||||
// 2017/4/25 v10 1=>2 SavedAccount に通知設定を追加
|
||||
// 2017/4/25 v10 1=>2 NotificationTracking テーブルを追加
|
||||
// 2017/4/29 v20 2=>5 MediaShown,ContentWarningのインデクスが間違っていたので貼り直す
|
||||
// 2017/4/29 v23 5=>6 MutedAppテーブルの追加、UserRelationテーブルの追加
|
||||
// 2017/5/01 v26 6=>7 AcctSetテーブルの追加
|
||||
// 2017/5/02 v32 7=>8 (この変更は取り消された)
|
||||
// 2017/5/02 v32 8=>9 AcctColor テーブルの追加
|
||||
// 2017/5/04 v33 9=>10 SavedAccountに項目追加
|
||||
// 2017/5/08 v41 10=>11 MutedWord テーブルの追加
|
||||
// 2017/5/17 v59 11=>12 PostDraft テーブルの追加
|
||||
// 2017/5/23 v68 12=>13 SavedAccountに項目追加
|
||||
// 2017/5/25 v69 13=>14 SavedAccountに項目追加
|
||||
// 2017/5/27 v73 14=>15 TagSetテーブルの追加
|
||||
// 2017/7/22 v99 15=>16 SavedAccountに項目追加
|
||||
// 2017/7/22 v106 16=>17 AcctColor に項目追加
|
||||
// 2017/9/23 v161 17=>18 SavedAccountに項目追加
|
||||
// 2017/9/23 v161 18=>19 ClientInfoテーブルを置き換える
|
||||
// 2017/12/01 v175 19=>20 UserRelation に項目追加
|
||||
// 2018/1/03 v197 20=>21 HighlightWord テーブルを追加
|
||||
// 2018/3/16 v226 21=>22 FavMuteテーブルを追加
|
||||
// 2018/4/17 v236 22=>23 SavedAccountテーブルに項目追加
|
||||
// 2018/4/20 v240 23=>24 SavedAccountテーブルに項目追加
|
||||
// 2018/5/16 v252 24=>25 SubscriptionServerKey テーブルを追加
|
||||
// 2018/5/16 v252 25=>26 SubscriptionServerKey テーブルを丸ごと変更
|
||||
// 2018/8/5 v264 26 => 27 SavedAccountテーブルに項目追加
|
||||
// 2018/8/17 v267 27 => 28 SavedAccountテーブルに項目追加
|
||||
// 2018/8/19 v267 28 => 29 (失敗)ContentWarningMisskey, MediaShownMisskey テーブルを追加
|
||||
// 2018/8/19 v268 29 => 30 ContentWarningMisskey, MediaShownMisskey, UserRelationMisskeyテーブルを追加
|
||||
// 2018/8/19 v268 30 => 31 (29)で失敗しておかしくなったContentWarningとMediaShownを作り直す
|
||||
// 2018/8/28 v279 31 => 32 UserRelation,UserRelationMisskey にendorsedを追加
|
||||
// 2018/8/28 v280 32 => 33 NotificationTracking テーブルの作り直し。SavedAccountに通知二種類を追加
|
||||
// 2018/10/31 v296 33 => 34 UserRelationMisskey に blocked_by を追加
|
||||
// 2018/10/31 v296 34 => 35 UserRelationMisskey に requested_by を追加
|
||||
// 2018/12/6 v317 35 => 36 ContentWarningテーブルの作り直し。
|
||||
// 2019/6/4 v351 36 => 37 SavedAccount テーブルに項目追加。
|
||||
// 2019/6/4 v351 37 => 38 SavedAccount テーブルに項目追加。
|
||||
// 2019/8/12 v362 38 => 39 SavedAccount テーブルに項目追加。
|
||||
// 2019/10/22 39 => 40 NotificationTracking テーブルに項目追加。
|
||||
// 2019/10/22 40 => 41 NotificationCache テーブルに項目追加。
|
||||
// 2019/10/23 41=> 42 SavedAccount テーブルに項目追加。
|
||||
// 2019/11/15 42=> 43 HighlightWord テーブルに項目追加。
|
||||
// 2019/12/17 43=> 44 SavedAccount テーブルに項目追加。
|
||||
// 2019/12/18 44=> 45 SavedAccount テーブルに項目追加。
|
||||
// 2019/12/18 44=> 46 SavedAccount テーブルに項目追加。
|
||||
// 2020/6/8 46 => 54 別ブランチで色々してた。このブランチには影響ないが onDowngrade()を実装してないので上げてしまう
|
||||
// 2020/7/19 54=>55 UserRelation テーブルに項目追加。
|
||||
// 2020/9/7 55=>56 SavedAccountテーブルにCOL_DOMAINを追加。
|
||||
// 2020/9/20 56=>57 SavedAccountテーブルに項目追加
|
||||
// 2020/9/20 57=>58 UserRelationテーブルに項目追加
|
||||
// 2021/2/10 58=>59 SavedAccountテーブルに項目追加
|
||||
// 2021/5/11 59=>60 SavedAccountテーブルに項目追加
|
||||
// 2021/5/23 60=>61 SavedAccountテーブルに項目追加
|
||||
|
||||
const val DB_VERSION = 61
|
||||
|
||||
val tableList = arrayOf(
|
||||
LogData,
|
||||
SavedAccount,
|
||||
ClientInfo,
|
||||
MediaShown,
|
||||
ContentWarning,
|
||||
NotificationTracking,
|
||||
NotificationCache,
|
||||
MutedApp,
|
||||
UserRelation,
|
||||
AcctSet,
|
||||
AcctColor,
|
||||
MutedWord,
|
||||
PostDraft,
|
||||
TagSet,
|
||||
HighlightWord,
|
||||
FavMute,
|
||||
SubscriptionServerKey
|
||||
)
|
||||
|
||||
private lateinit var db_open_helper: DBOpenHelper
|
||||
|
||||
val database: SQLiteDatabase get() = db_open_helper.writableDatabase
|
||||
|
||||
// private val APPROVED_CIPHER_SUITES = arrayOf(
|
||||
//
|
||||
// // 以下は okhttp 3 のデフォルト
|
||||
|
@ -226,7 +130,7 @@ class App1 : Application() {
|
|||
"SubwayTooter/${BuildConfig.VERSION_NAME} Android/${Build.VERSION.RELEASE}"
|
||||
|
||||
private fun getUserAgent(): String {
|
||||
val userAgentCustom = PrefS.spUserAgent(pref)
|
||||
val userAgentCustom = PrefS.spUserAgent(appPref)
|
||||
return when {
|
||||
userAgentCustom.isNotEmpty() && !reNotAllowedInUserAgent.matcher(userAgentCustom)
|
||||
.find() -> userAgentCustom
|
||||
|
@ -234,13 +138,12 @@ class App1 : Application() {
|
|||
}
|
||||
}
|
||||
|
||||
private val user_agent_interceptor = object : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request_with_user_agent = chain.request().newBuilder()
|
||||
private val user_agent_interceptor = Interceptor { chain ->
|
||||
chain.proceed(
|
||||
chain.request().newBuilder()
|
||||
.header("User-Agent", getUserAgent())
|
||||
.build()
|
||||
return chain.proceed(request_with_user_agent)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private var cookieManager: CookieManager? = null
|
||||
|
@ -290,8 +193,6 @@ class App1 : Application() {
|
|||
|
||||
lateinit var ok_http_client_media_viewer: OkHttpClient
|
||||
|
||||
lateinit var pref: SharedPreferences
|
||||
|
||||
// lateinit var task_executor : ThreadPoolExecutor
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
|
@ -323,55 +224,37 @@ class App1 : Application() {
|
|||
|
||||
initializeFont()
|
||||
|
||||
pref = appContext.pref()
|
||||
Global.prepare(appContext)
|
||||
|
||||
run {
|
||||
// We want at least 2 threads and at most 4 threads in the core pool,
|
||||
// preferring to have 1 less than the CPU count to avoid saturating
|
||||
// the CPU with background work
|
||||
|
||||
// We want at least 2 threads and at most 4 threads in the core pool,
|
||||
// preferring to have 1 less than the CPU count to avoid saturating
|
||||
// the CPU with background work
|
||||
// val CPU_COUNT = Runtime.getRuntime().availableProcessors()
|
||||
// val CORE_POOL_SIZE = max(2, min(CPU_COUNT - 1, 4))
|
||||
// val MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1
|
||||
// val KEEP_ALIVE_SECONDS = 30
|
||||
|
||||
// val CPU_COUNT = Runtime.getRuntime().availableProcessors()
|
||||
// val CORE_POOL_SIZE = max(2, min(CPU_COUNT - 1, 4))
|
||||
// val MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1
|
||||
// val KEEP_ALIVE_SECONDS = 30
|
||||
// // デフォルトだとキューはmax128で、溢れることがある
|
||||
// val sPoolWorkQueue = LinkedBlockingQueue<Runnable>(999)
|
||||
//
|
||||
// val sThreadFactory = object : ThreadFactory {
|
||||
// private val mCount = AtomicInteger(1)
|
||||
//
|
||||
// override fun newThread(r : Runnable) : Thread {
|
||||
// return Thread(r, "SubwayTooterTask #" + mCount.getAndIncrement())
|
||||
// }
|
||||
// }
|
||||
|
||||
// // デフォルトだとキューはmax128で、溢れることがある
|
||||
// val sPoolWorkQueue = LinkedBlockingQueue<Runnable>(999)
|
||||
//
|
||||
// val sThreadFactory = object : ThreadFactory {
|
||||
// private val mCount = AtomicInteger(1)
|
||||
//
|
||||
// override fun newThread(r : Runnable) : Thread {
|
||||
// return Thread(r, "SubwayTooterTask #" + mCount.getAndIncrement())
|
||||
// }
|
||||
// }
|
||||
|
||||
// task_executor = ThreadPoolExecutor(
|
||||
// CORE_POOL_SIZE // pool size
|
||||
// , MAXIMUM_POOL_SIZE // max pool size
|
||||
// , KEEP_ALIVE_SECONDS.toLong() // keep-alive-seconds
|
||||
// , TimeUnit.SECONDS // unit of keep-alive-seconds
|
||||
// , sPoolWorkQueue, sThreadFactory
|
||||
// )
|
||||
//
|
||||
// task_executor.allowCoreThreadTimeOut(true)
|
||||
}
|
||||
|
||||
log.d("prepareDB 1")
|
||||
db_open_helper = DBOpenHelper(appContext)
|
||||
|
||||
// if( BuildConfig.DEBUG){
|
||||
// SQLiteDatabase db = db_open_helper.getWritableDatabase();
|
||||
// db_open_helper.onCreate( db );
|
||||
// }
|
||||
|
||||
log.d("prepareDB 2")
|
||||
val now = System.currentTimeMillis()
|
||||
AcctSet.deleteOld(now)
|
||||
UserRelation.deleteOld(now)
|
||||
ContentWarning.deleteOld(now)
|
||||
MediaShown.deleteOld(now)
|
||||
// task_executor = ThreadPoolExecutor(
|
||||
// CORE_POOL_SIZE // pool size
|
||||
// , MAXIMUM_POOL_SIZE // max pool size
|
||||
// , KEEP_ALIVE_SECONDS.toLong() // keep-alive-seconds
|
||||
// , TimeUnit.SECONDS // unit of keep-alive-seconds
|
||||
// , sPoolWorkQueue, sThreadFactory
|
||||
// )
|
||||
//
|
||||
// task_executor.allowCoreThreadTimeOut(true)
|
||||
|
||||
// if( USE_OLD_EMOJIONE ){
|
||||
// if( typeface_emoji == null ){
|
||||
|
@ -405,7 +288,7 @@ class App1 : Application() {
|
|||
.build()
|
||||
|
||||
// 内蔵メディアビューア用のHTTP設定はタイムアウトを調整可能
|
||||
val mediaReadTimeout = max(3, PrefS.spMediaReadTimeout.toInt(pref))
|
||||
val mediaReadTimeout = max(3, PrefS.spMediaReadTimeout.toInt(appPref))
|
||||
ok_http_client_media_viewer = prepareOkHttp(mediaReadTimeout, mediaReadTimeout)
|
||||
.cache(cache)
|
||||
.build()
|
||||
|
@ -421,7 +304,7 @@ class App1 : Application() {
|
|||
|
||||
log.d("create AppState.")
|
||||
|
||||
state = AppState(appContext, handler, pref)
|
||||
state = AppState(appContext, handler, appPref)
|
||||
appStateX = state
|
||||
|
||||
// getAppState()を使える状態にしてからカラム一覧をロードする
|
||||
|
@ -534,7 +417,7 @@ class App1 : Application() {
|
|||
|
||||
prepare(activity.applicationContext, "setActivityTheme")
|
||||
|
||||
val theme_idx = PrefI.ipUiTheme(pref)
|
||||
val theme_idx = PrefI.ipUiTheme(appPref)
|
||||
activity.setTheme(
|
||||
if (forceDark || theme_idx == 1) {
|
||||
if (noActionBar) R.style.AppTheme_Dark_NoActionBar else R.style.AppTheme_Dark
|
||||
|
|
|
@ -39,7 +39,7 @@ object Styler {
|
|||
}
|
||||
|
||||
fun getVisibilityIconId(isMisskeyData: Boolean, visibility: TootVisibility): Int {
|
||||
val isMisskey = when (PrefI.ipVisibilityStyle(App1.pref)) {
|
||||
val isMisskey = when (PrefI.ipVisibilityStyle()) {
|
||||
PrefI.VS_MASTODON -> false
|
||||
PrefI.VS_MISSKEY -> true
|
||||
else -> isMisskeyData
|
||||
|
@ -87,7 +87,7 @@ object Styler {
|
|||
isMisskeyData: Boolean,
|
||||
visibility: TootVisibility
|
||||
): String {
|
||||
val isMisskey = when (PrefI.ipVisibilityStyle(App1.pref)) {
|
||||
val isMisskey = when (PrefI.ipVisibilityStyle()) {
|
||||
PrefI.VS_MASTODON -> false
|
||||
PrefI.VS_MISSKEY -> true
|
||||
else -> isMisskeyData
|
||||
|
@ -302,7 +302,7 @@ object Styler {
|
|||
val widthDp = dm.widthPixels / dm.density
|
||||
if (widthDp >= 640f && v.resources?.configuration?.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
val pad_lr = (0.5f + dpDelta * dm.density).toInt()
|
||||
when (PrefI.ipJustifyWindowContentPortrait(App1.pref)) {
|
||||
when (PrefI.ipJustifyWindowContentPortrait()) {
|
||||
PrefI.JWCP_START -> {
|
||||
v.setPaddingRelative(pad_lr, pad_t, pad_lr + dm.widthPixels / 2, pad_b)
|
||||
return
|
||||
|
@ -331,7 +331,7 @@ object Styler {
|
|||
log.d("fixHorizontalMargin: orientation=$orientationString, w=${widthDp}dp, h=${dm.heightPixels / dm.density}")
|
||||
|
||||
if (widthDp >= 640f && v.resources?.configuration?.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
when (PrefI.ipJustifyWindowContentPortrait(App1.pref)) {
|
||||
when (PrefI.ipJustifyWindowContentPortrait()) {
|
||||
PrefI.JWCP_START -> {
|
||||
lp.marginStart = 0
|
||||
lp.marginEnd = dm.widthPixels / 2
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package jp.juggler.subwaytooter.actmain
|
||||
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefL
|
||||
import jp.juggler.subwaytooter.column.fireShowColumnHeader
|
||||
import jp.juggler.subwaytooter.pref.PrefL
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
|
||||
// デフォルトの投稿先アカウントを探す。アカウント選択が必要な状況ならnull
|
||||
val ActMain.currentPostTarget: SavedAccount?
|
||||
|
@ -19,7 +18,7 @@ val ActMain.currentPostTarget: SavedAccount?
|
|||
},
|
||||
{ env ->
|
||||
|
||||
val dbId = PrefL.lpTabletTootDefaultAccount(App1.pref)
|
||||
val dbId = PrefL.lpTabletTootDefaultAccount()
|
||||
if (dbId != -1L) {
|
||||
val a = SavedAccount.loadAccount(this@currentPostTarget, dbId)
|
||||
if (a != null && !a.isPseudo) return a
|
||||
|
@ -48,7 +47,11 @@ val ActMain.currentPostTarget: SavedAccount?
|
|||
}
|
||||
})
|
||||
|
||||
fun ActMain.reloadAccountSetting(newAccounts: ArrayList<SavedAccount> = SavedAccount.loadAccountList(this)) {
|
||||
fun ActMain.reloadAccountSetting(
|
||||
newAccounts: ArrayList<SavedAccount> = SavedAccount.loadAccountList(
|
||||
this
|
||||
)
|
||||
) {
|
||||
for (column in appState.columnList) {
|
||||
val a = column.accessInfo
|
||||
if (!a.isNA) a.reloadSetting(this, newAccounts.find { it.acct == a.acct })
|
||||
|
|
|
@ -5,10 +5,15 @@ import android.graphics.Typeface
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.itemviewholder.ItemViewHolder
|
||||
import jp.juggler.subwaytooter.pref.*
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefF
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.pref.impl.StringPref
|
||||
import jp.juggler.subwaytooter.span.MyClickableSpan
|
||||
import jp.juggler.subwaytooter.util.CustomShare
|
||||
|
@ -220,7 +225,7 @@ fun ActMain.reloadColors() {
|
|||
MyClickableSpan.defaultLinkColor = PrefI.ipLinkColor(pref).notZero()
|
||||
?: attrColor(R.attr.colorLink)
|
||||
|
||||
CustomShare.reloadCache(this, pref)
|
||||
CustomShare.reloadCache(this)
|
||||
}
|
||||
|
||||
fun ActMain.showFooterColor() {
|
||||
|
@ -251,7 +256,9 @@ fun ActMain.showFooterColor() {
|
|||
btnQuickPostMenu.backgroundDrawable =
|
||||
getAdaptiveRippleDrawableRound(this, colorButtonBg, colorButtonFg)
|
||||
|
||||
val csl = ColorStateList.valueOf(footerButtonFgColor.notZero() ?: attrColor(R.attr.colorVectorDrawable))
|
||||
val csl = ColorStateList.valueOf(
|
||||
footerButtonFgColor.notZero() ?: attrColor(R.attr.colorVectorDrawable)
|
||||
)
|
||||
btnToot.imageTintList = csl
|
||||
btnMenu.imageTintList = csl
|
||||
btnQuickToot.imageTintList = csl
|
||||
|
@ -261,7 +268,8 @@ fun ActMain.showFooterColor() {
|
|||
vFooterDivider1.setBackgroundColor(c)
|
||||
vFooterDivider2.setBackgroundColor(c)
|
||||
|
||||
llColumnStrip.indicatorColor = footerTabIndicatorColor.notZero() ?: attrColor(R.attr.colorAccent)
|
||||
llColumnStrip.indicatorColor =
|
||||
footerTabIndicatorColor.notZero() ?: attrColor(R.attr.colorAccent)
|
||||
}
|
||||
|
||||
fun ActMain.closePopup() {
|
||||
|
|
|
@ -79,7 +79,7 @@ class SideMenuAdapter(
|
|||
)
|
||||
)
|
||||
val newRelease = releaseInfo?.jsonObject(
|
||||
if (PrefB.bpCheckBetaVersion(App1.pref)) "beta" else "stable"
|
||||
if (PrefB.bpCheckBetaVersion()) "beta" else "stable"
|
||||
)
|
||||
|
||||
val newVersion =
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.net.Uri
|
|||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import jp.juggler.subwaytooter.ActPost
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.api.ApiTask
|
||||
|
@ -15,6 +14,7 @@ import jp.juggler.subwaytooter.api.runApiTask
|
|||
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
||||
import jp.juggler.subwaytooter.dialog.DlgFocusPoint
|
||||
import jp.juggler.subwaytooter.dialog.DlgTextInput
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.util.AttachmentRequest
|
||||
import jp.juggler.subwaytooter.util.PostAttachment
|
||||
import jp.juggler.subwaytooter.view.MyNetworkImageView
|
||||
|
@ -59,7 +59,7 @@ fun ActPost.showMediaAttachmentOne(iv: MyNetworkImageView, idx: Int) {
|
|||
a == null || pa.status != PostAttachment.Status.Ok -> {
|
||||
iv.setDefaultImage(Styler.defaultColorIcon(this, R.drawable.ic_upload))
|
||||
iv.setErrorImage(Styler.defaultColorIcon(this, R.drawable.ic_clip))
|
||||
iv.setImageUrl(pref, Styler.calcIconRound(iv.layoutParams.width), null)
|
||||
iv.setImageUrl(Styler.calcIconRound(iv.layoutParams.width), null)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
@ -73,7 +73,7 @@ fun ActPost.showMediaAttachmentOne(iv: MyNetworkImageView, idx: Int) {
|
|||
}
|
||||
iv.setDefaultImage(Styler.defaultColorIcon(this, defaultIconId))
|
||||
iv.setErrorImage(Styler.defaultColorIcon(this, defaultIconId))
|
||||
iv.setImageUrl(pref, Styler.calcIconRound(iv.layoutParams.width), a.preview_url)
|
||||
iv.setImageUrl(Styler.calcIconRound(iv.layoutParams.width), a.preview_url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,11 @@ fun ActPost.addAttachment(
|
|||
attachmentList.size >= 4 -> showToast(false, R.string.attachment_too_many)
|
||||
account == null -> showToast(false, R.string.account_select_please)
|
||||
mimeType?.isEmpty() != false -> showToast(false, R.string.mime_type_missing)
|
||||
!attachmentUploader.isAcceptableMimeType(instance, mimeType, isReply) -> Unit // エラーメッセージ出力済み
|
||||
!attachmentUploader.isAcceptableMimeType(
|
||||
instance,
|
||||
mimeType,
|
||||
isReply
|
||||
) -> Unit // エラーメッセージ出力済み
|
||||
else -> {
|
||||
saveAttachmentList()
|
||||
val pa = PostAttachment(this)
|
||||
|
@ -275,7 +279,11 @@ fun ActPost.editAttachmentDescription(pa: PostAttachment) {
|
|||
val attachmentId = pa.attachment?.id ?: return
|
||||
val account = this@editAttachmentDescription.account ?: return
|
||||
launchMain {
|
||||
val (result, newAttachment) = attachmentUploader.setAttachmentDescription(account, attachmentId, text)
|
||||
val (result, newAttachment) = attachmentUploader.setAttachmentDescription(
|
||||
account,
|
||||
attachmentId,
|
||||
text
|
||||
)
|
||||
when (newAttachment) {
|
||||
null -> result?.error?.let { showToast(true, it) }
|
||||
else -> {
|
||||
|
|
|
@ -44,7 +44,7 @@ fun ActPost.showReplyTo() {
|
|||
decodeEmoji = true,
|
||||
mentionDefaultHostDomain = account ?: unknownHostAndDomain
|
||||
).decodeHTML(states.inReplyToText)
|
||||
ivReply.setImageUrl(pref, Styler.calcIconRound(ivReply.layoutParams), states.inReplyToImage)
|
||||
ivReply.setImageUrl(Styler.calcIconRound(ivReply.layoutParams), states.inReplyToImage)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,18 +38,17 @@ class DuplicateMap {
|
|||
}
|
||||
|
||||
when (o) {
|
||||
is TootReport,
|
||||
is TootStatus,
|
||||
is TootAccount,
|
||||
is TootAccountRef,
|
||||
is TootNotification,
|
||||
-> {
|
||||
val id = o.getOrderId()
|
||||
if (id.notDefaultOrConfirming) {
|
||||
if (idSet.contains(id)) return true
|
||||
idSet.add(id)
|
||||
}
|
||||
}
|
||||
is TootReport,
|
||||
is TootStatus,
|
||||
is TootAccountRef,
|
||||
is TootNotification,
|
||||
-> {
|
||||
val id = o.getOrderId()
|
||||
if (id.notDefaultOrConfirming) {
|
||||
if (idSet.contains(id)) return true
|
||||
idSet.add(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
|
@ -4,12 +4,11 @@ import android.content.Context
|
|||
import android.text.Spannable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.widget.TextView
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.MisskeyAccountDetailMap
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.subwaytooter.emoji.CustomEmoji
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.table.UserRelation
|
||||
import jp.juggler.subwaytooter.util.DecodeOptions
|
||||
|
@ -136,7 +135,11 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
ServiceType.MISSKEY -> {
|
||||
|
||||
this.custom_emojis =
|
||||
parseMapOrNull(CustomEmoji.decodeMisskey, parser.apDomain, src.jsonArray("emojis"))
|
||||
parseMapOrNull(
|
||||
CustomEmoji.decodeMisskey,
|
||||
parser.apDomain,
|
||||
src.jsonArray("emojis")
|
||||
)
|
||||
this.profile_emojis = null
|
||||
|
||||
this.username = src.stringOrThrow("username")
|
||||
|
@ -218,7 +221,8 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
// notestock はActivityPub 準拠のサービスなので、サーバ内IDというのは特にない
|
||||
this.id = EntityId.DEFAULT
|
||||
|
||||
this.username = src.stringOrThrow("display_name") // notestockはdisplay_nameとusernameが入れ替わってる?
|
||||
this.username =
|
||||
src.stringOrThrow("display_name") // notestockはdisplay_nameとusernameが入れ替わってる?
|
||||
this.display_name = src.stringOrThrow("username")
|
||||
|
||||
val tmpAcct = src.string("subject")?.let { Acct.parse(it) }
|
||||
|
@ -272,7 +276,8 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
else -> {
|
||||
|
||||
// 絵文字データは先に読んでおく
|
||||
this.custom_emojis = parseMapOrNull(CustomEmoji.decode, parser.apDomain, src.jsonArray("emojis"))
|
||||
this.custom_emojis =
|
||||
parseMapOrNull(CustomEmoji.decode, parser.apDomain, src.jsonArray("emojis"))
|
||||
|
||||
this.profile_emojis = when (val o = src["profile_emojis"]) {
|
||||
is JsonArray -> parseMapOrNull(::NicoProfileEmoji, o, TootStatus.log)
|
||||
|
@ -324,7 +329,8 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
this.apiHost = apiHost
|
||||
this.apDomain = apDomain
|
||||
|
||||
this.acct = Acct.parse(username, if (tmpAcct.contains('@')) apDomain else null)
|
||||
this.acct =
|
||||
Acct.parse(username, if (tmpAcct.contains('@')) apDomain else null)
|
||||
|
||||
this.followers_count = src.long("followers_count")
|
||||
this.following_count = src.long("following_count")
|
||||
|
@ -477,7 +483,6 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
fromProfileHeader: Boolean = false,
|
||||
suggestionSource: String? = null,
|
||||
): SpannableStringBuilder? {
|
||||
val pref = App1.pref
|
||||
val context = tv.context
|
||||
|
||||
var sb: SpannableStringBuilder? = null
|
||||
|
@ -491,15 +496,22 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
.append(suggestionSource)
|
||||
}
|
||||
|
||||
if (PrefB.bpDirectoryLastActive(pref) && last_status_at > 0L) {
|
||||
if (PrefB.bpDirectoryLastActive() && last_status_at > 0L) {
|
||||
prepareSb()
|
||||
.append(context.getString(R.string.last_active))
|
||||
.append(delm)
|
||||
.append(TootStatus.formatTime(context, last_status_at, bAllowRelative = true, onlyDate = true))
|
||||
.append(
|
||||
TootStatus.formatTime(
|
||||
context,
|
||||
last_status_at,
|
||||
bAllowRelative = true,
|
||||
onlyDate = true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (!fromProfileHeader) {
|
||||
if (PrefB.bpDirectoryTootCount(pref) &&
|
||||
if (PrefB.bpDirectoryTootCount() &&
|
||||
(statuses_count ?: 0L) > 0L
|
||||
) {
|
||||
prepareSb()
|
||||
|
@ -508,8 +520,8 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
.append(statuses_count.toString())
|
||||
}
|
||||
|
||||
if (PrefB.bpDirectoryFollowers(pref) &&
|
||||
!PrefB.bpHideFollowCount(pref) &&
|
||||
if (PrefB.bpDirectoryFollowers() &&
|
||||
!PrefB.bpHideFollowCount() &&
|
||||
(followers_count ?: 0L) > 0L
|
||||
) {
|
||||
prepareSb()
|
||||
|
@ -518,7 +530,7 @@ open class TootAccount(parser: TootParser, src: JsonObject) : HostAndDomain {
|
|||
.append(followers_count.toString())
|
||||
}
|
||||
|
||||
if (PrefB.bpDirectoryNote(pref) && note?.isNotEmpty() == true) {
|
||||
if (PrefB.bpDirectoryNote() && note?.isNotEmpty() == true) {
|
||||
val decodedNote = DecodeOptions(
|
||||
context,
|
||||
accessInfo,
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
import android.os.SystemClock
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.TootApiResult
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.util.LinkHelper
|
||||
import jp.juggler.subwaytooter.util.VersionString
|
||||
|
@ -54,7 +53,7 @@ object InstanceCapability {
|
|||
ai.isMisskey -> true
|
||||
else ->
|
||||
ti?.fedibird_capabilities?.contains("emoji_reaction") == true ||
|
||||
ti?.pleromaFeatures?.contains("pleroma_emoji_reactions") == true
|
||||
ti?.pleromaFeatures?.contains("pleroma_emoji_reactions") == true
|
||||
}
|
||||
|
||||
fun canMultipleReaction(ai: SavedAccount, ti: TootInstance? = TootInstance.getCached(ai)) =
|
||||
|
@ -212,9 +211,11 @@ class TootInstance(parser: TootParser, src: JsonObject) {
|
|||
|
||||
this.invites_enabled = src.boolean("invites_enabled")
|
||||
|
||||
this.fedibird_capabilities = src.jsonArray("fedibird_capabilities")?.stringList()?.toSet()
|
||||
this.fedibird_capabilities =
|
||||
src.jsonArray("fedibird_capabilities")?.stringList()?.toSet()
|
||||
this.pleromaFeatures =
|
||||
src.jsonObject("pleroma")?.jsonObject("metadata")?.jsonArray("features")?.stringList()?.toSet()
|
||||
src.jsonObject("pleroma")?.jsonObject("metadata")?.jsonArray("features")
|
||||
?.stringList()?.toSet()
|
||||
|
||||
this.configuration = src.jsonObject("configuration")
|
||||
}
|
||||
|
@ -403,8 +404,8 @@ class TootInstance(parser: TootParser, src: JsonObject) {
|
|||
|
||||
when {
|
||||
pair.first?.instanceType == InstanceType.Pixelfed &&
|
||||
!PrefB.bpEnablePixelfed(App1.pref) &&
|
||||
!req.allowPixelfed ->
|
||||
!PrefB.bpEnablePixelfed() &&
|
||||
!req.allowPixelfed ->
|
||||
Pair(
|
||||
null, TootApiResult("currently Pixelfed instance is not supported.")
|
||||
)
|
||||
|
|
|
@ -165,7 +165,7 @@ class TootReaction(
|
|||
}
|
||||
|
||||
private fun chooseUrl() = when {
|
||||
PrefB.bpDisableEmojiAnimation(App1.pref) -> staticUrl
|
||||
PrefB.bpDisableEmojiAnimation() -> staticUrl
|
||||
else -> url
|
||||
}
|
||||
|
||||
|
|
|
@ -1354,7 +1354,7 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
|
|||
formatDate(t, date_format2, omitZeroSecond = false, omitYear = true)
|
||||
}
|
||||
|
||||
if (bAllowRelative && PrefB.bpRelativeTimestamp(App1.pref)) {
|
||||
if (bAllowRelative && PrefB.bpRelativeTimestamp()) {
|
||||
|
||||
delta = abs(delta)
|
||||
|
||||
|
|
|
@ -11,13 +11,16 @@ import android.provider.BaseColumns
|
|||
import android.util.JsonReader
|
||||
import android.util.JsonToken
|
||||
import android.util.JsonWriter
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.AppState
|
||||
import jp.juggler.subwaytooter.api.entity.EntityId
|
||||
import jp.juggler.subwaytooter.column.Column
|
||||
import jp.juggler.subwaytooter.column.ColumnEncoder
|
||||
import jp.juggler.subwaytooter.column.getBackgroundImageDir
|
||||
import jp.juggler.subwaytooter.pref.*
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.subwaytooter.pref.PrefL
|
||||
import jp.juggler.subwaytooter.pref.impl.*
|
||||
import jp.juggler.subwaytooter.pref.put
|
||||
import jp.juggler.subwaytooter.table.*
|
||||
import jp.juggler.util.*
|
||||
import org.apache.commons.io.IOUtils
|
||||
|
@ -113,7 +116,7 @@ object AppDataExporter {
|
|||
writer.name(jsonKey)
|
||||
writer.beginArray()
|
||||
|
||||
App1.database.query(table, null, null, null, null, null, null)
|
||||
appDatabase.query(table, null, null, null, null, null, null)
|
||||
?.use { cursor ->
|
||||
val names = ArrayList<String>()
|
||||
val column_count = cursor.columnCount
|
||||
|
@ -162,7 +165,7 @@ object AppDataExporter {
|
|||
|
||||
@Throws(IOException::class)
|
||||
private fun importTable(reader: JsonReader, table: String, idMap: HashMap<Long, Long>?) {
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
if (table == SavedAccount.table) {
|
||||
SavedAccount.onDBDelete(db)
|
||||
SavedAccount.onDBCreate(db)
|
||||
|
@ -226,7 +229,8 @@ object AppDataExporter {
|
|||
}
|
||||
}
|
||||
reader.endObject()
|
||||
val new_id = db.insertWithOnConflict(table, null, cv, SQLiteDatabase.CONFLICT_REPLACE)
|
||||
val new_id =
|
||||
db.insertWithOnConflict(table, null, cv, SQLiteDatabase.CONFLICT_REPLACE)
|
||||
if (new_id == -1L) error("importTable: invalid row_id")
|
||||
idMap?.put(old_id, new_id)
|
||||
}
|
||||
|
|
|
@ -290,7 +290,6 @@ object ColumnEncoder {
|
|||
columnBgImage = src.string(KEY_COLUMN_BACKGROUND_IMAGE) ?: ""
|
||||
columnBgImageAlpha = src.optFloat(KEY_COLUMN_BACKGROUND_IMAGE_ALPHA, 1f)
|
||||
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (type) {
|
||||
|
||||
ColumnType.CONVERSATION,
|
||||
|
@ -369,6 +368,8 @@ object ColumnEncoder {
|
|||
ColumnType.DOMAIN_TIMELINE -> {
|
||||
instanceUri = src.optString(KEY_INSTANCE_URI)
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ fun Column.canReloadWhenRefreshTop(): Boolean = when (type) {
|
|||
// カラム操作的にリフレッシュを許容するかどうか
|
||||
fun Column.canRefreshTopBySwipe(): Boolean =
|
||||
canReloadWhenRefreshTop() ||
|
||||
when (type) {
|
||||
ColumnType.CONVERSATION,
|
||||
ColumnType.INSTANCE_INFORMATION,
|
||||
-> false
|
||||
else -> true
|
||||
}
|
||||
when (type) {
|
||||
ColumnType.CONVERSATION,
|
||||
ColumnType.INSTANCE_INFORMATION,
|
||||
-> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
// カラム操作的にリフレッシュを許容するかどうか
|
||||
fun Column.canRefreshBottomBySwipe(): Boolean = when (type) {
|
||||
|
@ -96,7 +96,8 @@ fun Column.getContentColor() = contentColor.notZero() ?: Column.defaultColorCont
|
|||
|
||||
fun Column.getAcctColor() = acctColor.notZero() ?: Column.defaultColorContentAcct
|
||||
|
||||
fun Column.getHeaderPageNumberColor() = headerFgColor.notZero() ?: Column.defaultColorHeaderPageNumber
|
||||
fun Column.getHeaderPageNumberColor() =
|
||||
headerFgColor.notZero() ?: Column.defaultColorHeaderPageNumber
|
||||
|
||||
fun Column.getHeaderNameColor() = headerFgColor.notZero() ?: Column.defaultColorHeaderName
|
||||
|
||||
|
@ -308,7 +309,6 @@ fun Column.startRefreshForPost(
|
|||
postedStatusId: EntityId,
|
||||
postedReplyId: EntityId?,
|
||||
) {
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (type) {
|
||||
ColumnType.HOME,
|
||||
ColumnType.LOCAL,
|
||||
|
@ -347,6 +347,8 @@ fun Column.startRefreshForPost(
|
|||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ class ColumnTask_Refresh(
|
|||
isCancelled -> false
|
||||
listTmp?.isNotEmpty() != true -> false
|
||||
willAddGap -> true
|
||||
else -> PrefB.bpForceGap(App1.pref)
|
||||
else -> PrefB.bpForceGap()
|
||||
}
|
||||
|
||||
if (doesAddGap()) {
|
||||
|
@ -310,7 +310,6 @@ class ColumnTask_Refresh(
|
|||
repeatReading: Boolean = false,
|
||||
): TootApiResult? {
|
||||
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (column.pagingType) {
|
||||
ColumnPagingType.None ->
|
||||
return TootApiResult(context.getString(R.string.end_of_list))
|
||||
|
@ -319,6 +318,8 @@ class ColumnTask_Refresh(
|
|||
if (column.idOld == null) {
|
||||
return TootApiResult(context.getString(R.string.end_of_list))
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
val addToHead = false
|
||||
|
@ -583,7 +584,6 @@ class ColumnTask_Refresh(
|
|||
repeatReading: Boolean = false,
|
||||
): TootApiResult? {
|
||||
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (column.pagingType) {
|
||||
ColumnPagingType.None ->
|
||||
return TootApiResult(context.getString(R.string.end_of_list))
|
||||
|
@ -592,6 +592,8 @@ class ColumnTask_Refresh(
|
|||
if (column.idOld == null) {
|
||||
return TootApiResult(context.getString(R.string.end_of_list))
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
val addToHead = false
|
||||
|
|
|
@ -272,7 +272,7 @@ fun ColumnViewHolder.onPageCreate(column: Column, pageIdx: Int, pageCount: Int)
|
|||
fun dip(dp: Int): Int = (activity.density * dp + 0.5f).toInt()
|
||||
val context = activity
|
||||
|
||||
val announcementsBgColor = PrefI.ipAnnouncementsBgColor(App1.pref).notZero()
|
||||
val announcementsBgColor = PrefI.ipAnnouncementsBgColor().notZero()
|
||||
?: context.attrColor(R.attr.colorSearchFormBackground)
|
||||
|
||||
btnAnnouncementsCutout.apply {
|
||||
|
@ -285,7 +285,7 @@ fun ColumnViewHolder.onPageCreate(column: Column, pageIdx: Int, pageCount: Int)
|
|||
setPadding(0, padV, 0, padV)
|
||||
}
|
||||
|
||||
val searchBgColor = PrefI.ipSearchBgColor(App1.pref).notZero()
|
||||
val searchBgColor = PrefI.ipSearchBgColor().notZero()
|
||||
?: context.attrColor(R.attr.colorSearchFormBackground)
|
||||
|
||||
llSearch.apply {
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.View
|
|||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.action.serverProfileDirectoryFromInstanceInformation
|
||||
import jp.juggler.subwaytooter.action.timeline
|
||||
|
@ -94,7 +93,7 @@ internal class ViewHolderHeaderInstance(
|
|||
btnEmail.isEnabledAlpha = false
|
||||
tvDescription.text = "?"
|
||||
tvShortDescription.text = "?"
|
||||
ivThumbnail.setImageUrl(App1.pref, 0f, null)
|
||||
ivThumbnail.setImageUrl(0f, null)
|
||||
tvLanguages.text = "?"
|
||||
tvInvitesEnabled.text = "?"
|
||||
btnContact.text = "?"
|
||||
|
@ -172,7 +171,7 @@ internal class ViewHolderHeaderInstance(
|
|||
it
|
||||
}
|
||||
}.notEmpty()
|
||||
ivThumbnail.setImageUrl(App1.pref, 0f, thumbnail, thumbnail)
|
||||
ivThumbnail.setImageUrl(0f, thumbnail, thumbnail)
|
||||
}
|
||||
|
||||
tvHandshake.text = if (handshake == null) {
|
||||
|
@ -181,30 +180,30 @@ internal class ViewHolderHeaderInstance(
|
|||
val sb = SpannableStringBuilder("${handshake.tlsVersion}, ${handshake.cipherSuite}")
|
||||
val certs = handshake.peerCertificates.joinToString("\n") { cert ->
|
||||
"\n============================\n" +
|
||||
if (cert is OpenSSLX509Certificate) {
|
||||
if (cert is OpenSSLX509Certificate) {
|
||||
|
||||
log.d(cert.toString())
|
||||
log.d(cert.toString())
|
||||
|
||||
"""
|
||||
"""
|
||||
Certificate : ${cert.type}
|
||||
subject : ${cert.subjectDN}
|
||||
subjectAlternativeNames : ${
|
||||
cert.subjectAlternativeNames
|
||||
?.joinToString(", ") {
|
||||
try {
|
||||
it?.last()
|
||||
} catch (ignored: Throwable) {
|
||||
it
|
||||
cert.subjectAlternativeNames
|
||||
?.joinToString(", ") {
|
||||
try {
|
||||
it?.last()
|
||||
} catch (ignored: Throwable) {
|
||||
it
|
||||
}
|
||||
?.toString() ?: "null"
|
||||
}
|
||||
?.toString() ?: "null"
|
||||
}
|
||||
}
|
||||
}
|
||||
issuer : ${cert.issuerX500Principal}
|
||||
end : ${cert.notAfter}
|
||||
""".trimIndent()
|
||||
} else {
|
||||
cert.javaClass.name + "\n" + cert.toString()
|
||||
}
|
||||
} else {
|
||||
cert.javaClass.name + "\n" + cert.toString()
|
||||
}
|
||||
}
|
||||
if (certs.isNotEmpty()) {
|
||||
sb.append('\n')
|
||||
|
|
|
@ -8,14 +8,21 @@ import android.text.Spanned
|
|||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.emoji.EmojiMap
|
||||
import jp.juggler.subwaytooter.action.*
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.action.followFromAnotherAccount
|
||||
import jp.juggler.subwaytooter.action.userProfileLocal
|
||||
import jp.juggler.subwaytooter.actmain.nextPosition
|
||||
import jp.juggler.subwaytooter.api.*
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.api.MisskeyAccountDetailMap
|
||||
import jp.juggler.subwaytooter.api.TootApiResult
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccount
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccountRef
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.api.runApiTask
|
||||
import jp.juggler.subwaytooter.column.*
|
||||
import jp.juggler.subwaytooter.dialog.DlgTextInput
|
||||
import jp.juggler.subwaytooter.emoji.EmojiMap
|
||||
import jp.juggler.subwaytooter.itemviewholder.DlgContextMenu
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
|
@ -26,7 +33,10 @@ import jp.juggler.subwaytooter.span.createSpan
|
|||
import jp.juggler.subwaytooter.table.AcctColor
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.table.UserRelation
|
||||
import jp.juggler.subwaytooter.util.*
|
||||
import jp.juggler.subwaytooter.util.DecodeOptions
|
||||
import jp.juggler.subwaytooter.util.NetworkEmojiInvalidator
|
||||
import jp.juggler.subwaytooter.util.openCustomTab
|
||||
import jp.juggler.subwaytooter.util.startMargin
|
||||
import jp.juggler.subwaytooter.view.MyLinkMovementMethod
|
||||
import jp.juggler.subwaytooter.view.MyNetworkImageView
|
||||
import jp.juggler.subwaytooter.view.MyTextView
|
||||
|
@ -310,10 +320,9 @@ internal class ViewHolderHeaderProfile(
|
|||
it.movementMethod = MyLinkMovementMethod
|
||||
}
|
||||
|
||||
ivBackground.setImageUrl(activity.pref, 0f, accessInfo.supplyBaseUrl(who.header_static))
|
||||
ivBackground.setImageUrl(0f, accessInfo.supplyBaseUrl(who.header_static))
|
||||
|
||||
ivAvatar.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(ivAvatar.layoutParams),
|
||||
accessInfo.supplyBaseUrl(who.avatar_static),
|
||||
accessInfo.supplyBaseUrl(who.avatar)
|
||||
|
@ -388,7 +397,6 @@ internal class ViewHolderHeaderProfile(
|
|||
|
||||
ivMoved.layoutParams.width = activity.avatarIconSize
|
||||
ivMoved.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(ivMoved.layoutParams),
|
||||
accessInfo.supplyBaseUrl(moved.avatar_static)
|
||||
)
|
||||
|
@ -538,7 +546,7 @@ internal class ViewHolderHeaderProfile(
|
|||
val ac = AcctColor.load(accessInfo, who)
|
||||
tv.text = when {
|
||||
AcctColor.hasNickname(ac) -> ac.nickname
|
||||
PrefB.bpShortAcctLocalUser(App1.pref) -> "@${who.acct.pretty}"
|
||||
PrefB.bpShortAcctLocalUser() -> "@${who.acct.pretty}"
|
||||
else -> "@${ac.nickname}"
|
||||
}
|
||||
|
||||
|
@ -578,7 +586,7 @@ internal class ViewHolderHeaderProfile(
|
|||
when {
|
||||
emoji == null ->
|
||||
append("locked")
|
||||
PrefB.bpUseTwemoji(App1.pref) ->
|
||||
PrefB.bpUseTwemoji() ->
|
||||
appendSpan("locked", emoji.createSpan(activity))
|
||||
else ->
|
||||
append(emoji.unifiedCode)
|
||||
|
@ -592,7 +600,7 @@ internal class ViewHolderHeaderProfile(
|
|||
when {
|
||||
emoji == null ->
|
||||
append("bot")
|
||||
PrefB.bpUseTwemoji(App1.pref) ->
|
||||
PrefB.bpUseTwemoji() ->
|
||||
appendSpan("bot", emoji.createSpan(activity))
|
||||
else ->
|
||||
append(emoji.unifiedCode)
|
||||
|
@ -605,7 +613,7 @@ internal class ViewHolderHeaderProfile(
|
|||
when {
|
||||
emoji == null ->
|
||||
append("suspended")
|
||||
PrefB.bpUseTwemoji(App1.pref) ->
|
||||
PrefB.bpUseTwemoji() ->
|
||||
appendSpan("suspended", emoji.createSpan(activity))
|
||||
else ->
|
||||
append(emoji.unifiedCode)
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.Window
|
|||
import android.view.WindowManager
|
||||
import android.widget.*
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.action.*
|
||||
|
@ -70,7 +69,6 @@ class DlgListMember(
|
|||
view.findViewById<View>(R.id.btnClose).setOnClickListener(this)
|
||||
|
||||
ivUser.setImageUrl(
|
||||
App1.pref,
|
||||
Styler.calcIconRound(ivUser.layoutParams),
|
||||
who.avatar_static,
|
||||
who.avatar
|
||||
|
@ -372,7 +370,11 @@ class DlgListMember(
|
|||
if (!bSuccess) revokeCheckedChanged(willRegistered)
|
||||
}
|
||||
} else {
|
||||
activity.listMemberDelete(listOwner, item.id, whoLocal) { willRegistered, bSuccess ->
|
||||
activity.listMemberDelete(
|
||||
listOwner,
|
||||
item.id,
|
||||
whoLocal
|
||||
) { willRegistered, bSuccess ->
|
||||
if (!bSuccess) revokeCheckedChanged(willRegistered)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.astuetz.PagerSlidingTabStrip
|
|||
import com.bumptech.glide.Glide
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.emoji.*
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.pref.put
|
||||
|
@ -101,8 +102,7 @@ class EmojiPicker(
|
|||
init {
|
||||
|
||||
// recentをロードする
|
||||
val pref = App1.pref
|
||||
val sv = PrefS.spEmojiPickerRecent(pref)
|
||||
val sv = PrefS.spEmojiPickerRecent()
|
||||
if (sv.isNotEmpty()) {
|
||||
try {
|
||||
for (item in sv.decodeJsonArray().objectList()) {
|
||||
|
@ -471,7 +471,7 @@ class EmojiPicker(
|
|||
}
|
||||
view.setTag(R.id.btnAbout, item)
|
||||
(view as? NetworkEmojiView)?.setEmoji(customEmojiMap[item.name]?.url)
|
||||
} else if (PrefB.bpUseTwemoji(App1.pref)) {
|
||||
} else if (PrefB.bpUseTwemoji()) {
|
||||
view = viewOld
|
||||
?: ImageView(activity).apply {
|
||||
layoutParams = AbsListView.LayoutParams(wh, wh)
|
||||
|
@ -542,13 +542,11 @@ class EmojiPicker(
|
|||
// name はスキントーン適用済みであること
|
||||
internal fun selected(emoji: EmojiBase) {
|
||||
|
||||
val pref = App1.pref
|
||||
|
||||
if (closeOnSelected) dialog.dismissSafe()
|
||||
|
||||
// Recentをロード(他インスタンスの絵文字を含む)
|
||||
val list: MutableList<JsonObject> = try {
|
||||
PrefS.spEmojiPickerRecent(pref).decodeJsonArray().objectList()
|
||||
PrefS.spEmojiPickerRecent().decodeJsonArray().objectList()
|
||||
} catch (_: Throwable) {
|
||||
emptyList()
|
||||
}.toMutableList()
|
||||
|
@ -591,7 +589,7 @@ class EmojiPicker(
|
|||
// 保存する
|
||||
try {
|
||||
val sv = list.toJsonArray().toString()
|
||||
App1.pref.edit().put(PrefS.spEmojiPickerRecent, sv).apply()
|
||||
appPref.edit().put(PrefS.spEmojiPickerRecent, sv).apply()
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package jp.juggler.subwaytooter.emoji
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.api.entity.Host
|
||||
import jp.juggler.subwaytooter.api.entity.Mappable
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.util.JsonArray
|
||||
import jp.juggler.util.JsonObject
|
||||
import jp.juggler.util.notEmpty
|
||||
|
@ -74,7 +73,7 @@ class CustomEmoji(
|
|||
get() = shortcode
|
||||
|
||||
fun chooseUrl() = when {
|
||||
PrefB.bpDisableEmojiAnimation(App1.pref) -> staticUrl
|
||||
PrefB.bpDisableEmojiAnimation() -> staticUrl
|
||||
else -> url
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package jp.juggler.subwaytooter.global
|
||||
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import jp.juggler.subwaytooter.table.*
|
||||
import jp.juggler.util.LogCategory
|
||||
|
||||
// 2017/4/25 v10 1=>2 SavedAccount に通知設定を追加
|
||||
// 2017/4/25 v10 1=>2 NotificationTracking テーブルを追加
|
||||
// 2017/4/29 v20 2=>5 MediaShown,ContentWarningのインデクスが間違っていたので貼り直す
|
||||
// 2017/4/29 v23 5=>6 MutedAppテーブルの追加、UserRelationテーブルの追加
|
||||
// 2017/5/01 v26 6=>7 AcctSetテーブルの追加
|
||||
// 2017/5/02 v32 7=>8 (この変更は取り消された)
|
||||
// 2017/5/02 v32 8=>9 AcctColor テーブルの追加
|
||||
// 2017/5/04 v33 9=>10 SavedAccountに項目追加
|
||||
// 2017/5/08 v41 10=>11 MutedWord テーブルの追加
|
||||
// 2017/5/17 v59 11=>12 PostDraft テーブルの追加
|
||||
// 2017/5/23 v68 12=>13 SavedAccountに項目追加
|
||||
// 2017/5/25 v69 13=>14 SavedAccountに項目追加
|
||||
// 2017/5/27 v73 14=>15 TagSetテーブルの追加
|
||||
// 2017/7/22 v99 15=>16 SavedAccountに項目追加
|
||||
// 2017/7/22 v106 16=>17 AcctColor に項目追加
|
||||
// 2017/9/23 v161 17=>18 SavedAccountに項目追加
|
||||
// 2017/9/23 v161 18=>19 ClientInfoテーブルを置き換える
|
||||
// 2017/12/01 v175 19=>20 UserRelation に項目追加
|
||||
// 2018/1/03 v197 20=>21 HighlightWord テーブルを追加
|
||||
// 2018/3/16 v226 21=>22 FavMuteテーブルを追加
|
||||
// 2018/4/17 v236 22=>23 SavedAccountテーブルに項目追加
|
||||
// 2018/4/20 v240 23=>24 SavedAccountテーブルに項目追加
|
||||
// 2018/5/16 v252 24=>25 SubscriptionServerKey テーブルを追加
|
||||
// 2018/5/16 v252 25=>26 SubscriptionServerKey テーブルを丸ごと変更
|
||||
// 2018/8/5 v264 26 => 27 SavedAccountテーブルに項目追加
|
||||
// 2018/8/17 v267 27 => 28 SavedAccountテーブルに項目追加
|
||||
// 2018/8/19 v267 28 => 29 (失敗)ContentWarningMisskey, MediaShownMisskey テーブルを追加
|
||||
// 2018/8/19 v268 29 => 30 ContentWarningMisskey, MediaShownMisskey, UserRelationMisskeyテーブルを追加
|
||||
// 2018/8/19 v268 30 => 31 (29)で失敗しておかしくなったContentWarningとMediaShownを作り直す
|
||||
// 2018/8/28 v279 31 => 32 UserRelation,UserRelationMisskey にendorsedを追加
|
||||
// 2018/8/28 v280 32 => 33 NotificationTracking テーブルの作り直し。SavedAccountに通知二種類を追加
|
||||
// 2018/10/31 v296 33 => 34 UserRelationMisskey に blocked_by を追加
|
||||
// 2018/10/31 v296 34 => 35 UserRelationMisskey に requested_by を追加
|
||||
// 2018/12/6 v317 35 => 36 ContentWarningテーブルの作り直し。
|
||||
// 2019/6/4 v351 36 => 37 SavedAccount テーブルに項目追加。
|
||||
// 2019/6/4 v351 37 => 38 SavedAccount テーブルに項目追加。
|
||||
// 2019/8/12 v362 38 => 39 SavedAccount テーブルに項目追加。
|
||||
// 2019/10/22 39 => 40 NotificationTracking テーブルに項目追加。
|
||||
// 2019/10/22 40 => 41 NotificationCache テーブルに項目追加。
|
||||
// 2019/10/23 41=> 42 SavedAccount テーブルに項目追加。
|
||||
// 2019/11/15 42=> 43 HighlightWord テーブルに項目追加。
|
||||
// 2019/12/17 43=> 44 SavedAccount テーブルに項目追加。
|
||||
// 2019/12/18 44=> 45 SavedAccount テーブルに項目追加。
|
||||
// 2019/12/18 44=> 46 SavedAccount テーブルに項目追加。
|
||||
// 2020/6/8 46 => 54 別ブランチで色々してた。このブランチには影響ないが onDowngrade()を実装してないので上げてしまう
|
||||
// 2020/7/19 54=>55 UserRelation テーブルに項目追加。
|
||||
// 2020/9/7 55=>56 SavedAccountテーブルにCOL_DOMAINを追加。
|
||||
// 2020/9/20 56=>57 SavedAccountテーブルに項目追加
|
||||
// 2020/9/20 57=>58 UserRelationテーブルに項目追加
|
||||
// 2021/2/10 58=>59 SavedAccountテーブルに項目追加
|
||||
// 2021/5/11 59=>60 SavedAccountテーブルに項目追加
|
||||
// 2021/5/23 60=>61 SavedAccountテーブルに項目追加
|
||||
|
||||
private const val DB_VERSION = 61
|
||||
private const val DB_NAME = "app_db"
|
||||
private val log = LogCategory("AppDatabase")
|
||||
|
||||
val tables = arrayOf(
|
||||
LogData,
|
||||
SavedAccount,
|
||||
ClientInfo,
|
||||
MediaShown,
|
||||
ContentWarning,
|
||||
NotificationTracking,
|
||||
NotificationCache,
|
||||
MutedApp,
|
||||
UserRelation,
|
||||
AcctSet,
|
||||
AcctColor,
|
||||
MutedWord,
|
||||
PostDraft,
|
||||
TagSet,
|
||||
HighlightWord,
|
||||
FavMute,
|
||||
SubscriptionServerKey
|
||||
)
|
||||
|
||||
private class DBOpenHelper(context: Context) :
|
||||
SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||
|
||||
override fun onCreate(db: SQLiteDatabase) {
|
||||
for (ti in tables) {
|
||||
ti.onDBCreate(db)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
for (ti in tables) {
|
||||
ti.onDBUpgrade(db, oldVersion, newVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface AppDatabaseHolder {
|
||||
val database: SQLiteDatabase
|
||||
}
|
||||
|
||||
class AppDatabaseHolderImpl(context: Context) : AppDatabaseHolder {
|
||||
private var openHelperNullable: DBOpenHelper? = null
|
||||
|
||||
override val database: SQLiteDatabase
|
||||
get() = openHelperNullable!!.writableDatabase
|
||||
|
||||
init {
|
||||
if (openHelperNullable == null) {
|
||||
log.d("create DBOpenHelper")
|
||||
openHelperNullable = DBOpenHelper(context.applicationContext)
|
||||
}
|
||||
|
||||
// if( BuildConfig.DEBUG){
|
||||
// SQLiteDatabase db = db_open_helper.getWritableDatabase();
|
||||
// db_open_helper.onCreate( db );
|
||||
// }
|
||||
|
||||
log.d("call deleteOld…")
|
||||
val now = System.currentTimeMillis()
|
||||
AcctSet.deleteOld(now)
|
||||
UserRelation.deleteOld(now)
|
||||
ContentWarning.deleteOld(now)
|
||||
MediaShown.deleteOld(now)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package jp.juggler.subwaytooter.global
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import jp.juggler.subwaytooter.pref.pref
|
||||
|
||||
interface AppPrefHolder {
|
||||
val pref: SharedPreferences
|
||||
}
|
||||
|
||||
class AppPrefHolderImpl(context: Context) : AppPrefHolder {
|
||||
override val pref = context.pref()
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package jp.juggler.subwaytooter.global
|
||||
|
||||
import android.content.Context
|
||||
import androidx.startup.Initializer
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.core.Koin
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.dsl.module
|
||||
import org.koin.mp.KoinPlatformTools
|
||||
|
||||
val appDatabase by lazy {
|
||||
getKoin().get<AppDatabaseHolder>().database
|
||||
}
|
||||
|
||||
val appPref by lazy {
|
||||
getKoin().get<AppPrefHolder>().pref
|
||||
}
|
||||
|
||||
fun getKoin(): Koin = KoinPlatformTools.defaultContext().get()
|
||||
|
||||
object Global {
|
||||
|
||||
private var isPrepared = false
|
||||
|
||||
fun prepare(context: Context): Global {
|
||||
if (!isPrepared) {
|
||||
synchronized(this) {
|
||||
if (!isPrepared) {
|
||||
isPrepared = true
|
||||
startKoin {
|
||||
androidContext(context)
|
||||
modules(module {
|
||||
single<AppDatabaseHolder> { AppDatabaseHolderImpl(get()) }
|
||||
single<AppPrefHolder> { AppPrefHolderImpl(get()) }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
class GlobalInitializer : Initializer<Global> {
|
||||
override fun dependencies(): MutableList<Class<out Initializer<*>>> {
|
||||
return mutableListOf()
|
||||
}
|
||||
|
||||
override fun create(context: Context): Global {
|
||||
return Global.prepare(context)
|
||||
}
|
||||
}
|
|
@ -568,7 +568,7 @@ class ItemViewHolder(
|
|||
ivCardImage = myNetworkImageView {
|
||||
contentDescription = context.getString(R.string.thumbnail)
|
||||
scaleType = when {
|
||||
PrefB.bpDontCropMediaThumb(App1.pref) -> ImageView.ScaleType.FIT_CENTER
|
||||
PrefB.bpDontCropMediaThumb() -> ImageView.ScaleType.FIT_CENTER
|
||||
else -> ImageView.ScaleType.CENTER_CROP
|
||||
}
|
||||
}.lparams(0, matchParent) {
|
||||
|
@ -689,7 +689,7 @@ class ItemViewHolder(
|
|||
actMain,
|
||||
matchParent,
|
||||
3f,
|
||||
justifyContent = when (PrefI.ipBoostButtonJustify(App1.pref)) {
|
||||
justifyContent = when (PrefI.ipBoostButtonJustify()) {
|
||||
0 -> JustifyContent.FLEX_START
|
||||
1 -> JustifyContent.CENTER
|
||||
else -> JustifyContent.FLEX_END
|
||||
|
|
|
@ -207,7 +207,7 @@ private fun ItemViewHolder.clickMedia(i: Int) {
|
|||
}
|
||||
|
||||
// 内蔵メディアビューアを使う
|
||||
PrefB.bpUseInternalMediaViewer(App1.pref) ->
|
||||
PrefB.bpUseInternalMediaViewer() ->
|
||||
ActMediaViewer.open(
|
||||
activity,
|
||||
column.showMediaDescription,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package jp.juggler.subwaytooter.itemviewholder
|
||||
|
||||
import android.view.View
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.column.ColumnType
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.table.MediaShown
|
||||
import jp.juggler.subwaytooter.util.DecodeOptions
|
||||
import jp.juggler.subwaytooter.util.HTMLDecoder
|
||||
|
@ -135,7 +135,7 @@ fun ItemViewHolder.showPreviewCard(status: TootStatus) {
|
|||
}
|
||||
|
||||
val imageUrl = accessInfo.supplyBaseUrl(image)
|
||||
ivCardImage.setImageUrl(activity.pref, 0f, imageUrl, imageUrl)
|
||||
ivCardImage.setImageUrl(0f, imageUrl, imageUrl)
|
||||
|
||||
btnCardImageShow.blurhash = card.blurhash
|
||||
|
||||
|
|
|
@ -261,7 +261,6 @@ fun ItemViewHolder.showAccount(whoRef: TootAccountRef) {
|
|||
val who = whoRef.get()
|
||||
llFollow.visibility = View.VISIBLE
|
||||
ivFollow.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(ivFollow.layoutParams),
|
||||
accessInfo.supplyBaseUrl(who.avatar_static),
|
||||
accessInfo.supplyBaseUrl(who.avatar)
|
||||
|
@ -434,7 +433,7 @@ fun ItemViewHolder.showGap() {
|
|||
btnGapTail.vg(column.type.gapDirection(column, false))
|
||||
?.imageTintList = contentColorCsl
|
||||
|
||||
val c = PrefI.ipEventBgColorGap(App1.pref)
|
||||
val c = PrefI.ipEventBgColorGap()
|
||||
if (c != 0) this.viewRoot.backgroundColor = c
|
||||
}
|
||||
|
||||
|
@ -710,7 +709,6 @@ fun ItemViewHolder.showScheduled(item: TootScheduled) {
|
|||
tvName.text = whoRef.decoded_display_name
|
||||
nameInvalidator.register(whoRef.decoded_display_name)
|
||||
ivAvatar.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(ivAvatar.layoutParams),
|
||||
accessInfo.supplyBaseUrl(who.avatar_static),
|
||||
accessInfo.supplyBaseUrl(who.avatar)
|
||||
|
@ -814,7 +812,6 @@ fun ItemViewHolder.showConversationIcons(cs: TootConversationSummary) {
|
|||
|
||||
val who = accountsOther[idx].get()
|
||||
iv.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(iv.layoutParams),
|
||||
accessInfo.supplyBaseUrl(who.avatar_static),
|
||||
accessInfo.supplyBaseUrl(who.avatar)
|
||||
|
@ -841,7 +838,7 @@ fun ItemViewHolder.setAcct(tv: TextView, accessInfo: SavedAccount, who: TootAcco
|
|||
val ac = AcctColor.load(accessInfo, who)
|
||||
tv.text = when {
|
||||
AcctColor.hasNickname(ac) -> ac.nickname
|
||||
PrefB.bpShortAcctLocalUser(App1.pref) -> "@${who.acct.pretty}"
|
||||
PrefB.bpShortAcctLocalUser() -> "@${who.acct.pretty}"
|
||||
else -> "@${ac.nickname}"
|
||||
}
|
||||
tv.textColor = ac.color_fg.notZero() ?: this.acctColor
|
||||
|
|
|
@ -4,7 +4,8 @@ import android.text.Spannable
|
|||
import android.text.SpannableStringBuilder
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.actmain.checkAutoCW
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.column.Column
|
||||
|
@ -62,7 +63,7 @@ fun ItemViewHolder.showStatus(status: TootStatus, colorBg: Int = 0) {
|
|||
?: (activity.attrColor(R.attr.colorImageButtonAccent) and 0xffffff) or 0x20000000
|
||||
} else {
|
||||
colorBg.notZero() ?: when (status.bookmarked) {
|
||||
true -> PrefI.ipEventBgColorBookmark(App1.pref)
|
||||
true -> PrefI.ipEventBgColorBookmark()
|
||||
false -> 0
|
||||
}.notZero() ?: when (status.getBackgroundColorType(accessInfo)) {
|
||||
TootVisibility.UnlistedHome -> ItemViewHolder.toot_color_unlisted
|
||||
|
@ -86,7 +87,6 @@ fun ItemViewHolder.showStatus(status: TootStatus, colorBg: Int = 0) {
|
|||
tvName.text = whoRef.decoded_display_name
|
||||
nameInvalidator.register(whoRef.decoded_display_name)
|
||||
ivAvatar.setImageUrl(
|
||||
activity.pref,
|
||||
Styler.calcIconRound(ivAvatar.layoutParams),
|
||||
accessInfo.supplyBaseUrl(who.avatar_static),
|
||||
accessInfo.supplyBaseUrl(who.avatar)
|
||||
|
@ -230,11 +230,11 @@ private fun ItemViewHolder.showOpenSticker(who: TootAccount) {
|
|||
val host = who.apDomain
|
||||
|
||||
// LTLでホスト名が同じならTickerを表示しない
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (column.type) {
|
||||
ColumnType.LOCAL, ColumnType.LOCAL_AROUND -> {
|
||||
if (host == accessInfo.apDomain) return
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
val item = OpenSticker.lastList[host.ascii] ?: return
|
||||
|
@ -249,7 +249,7 @@ private fun ItemViewHolder.showOpenSticker(who: TootAccount) {
|
|||
lp.width = (density * item.imageWidth + 0.5f).toInt()
|
||||
|
||||
ivOpenSticker.layoutParams = lp
|
||||
ivOpenSticker.setImageUrl(activity.pref, 0f, item.favicon)
|
||||
ivOpenSticker.setImageUrl(0f, item.favicon)
|
||||
val colorBg = item.bgColor
|
||||
when (colorBg.size) {
|
||||
1 -> {
|
||||
|
@ -330,7 +330,7 @@ fun ItemViewHolder.setMedia(
|
|||
|
||||
iv.setFocusPoint(ta.focusX, ta.focusY)
|
||||
|
||||
if (PrefB.bpDontCropMediaThumb(App1.pref)) {
|
||||
if (PrefB.bpDontCropMediaThumb()) {
|
||||
iv.scaleType = ImageView.ScaleType.FIT_CENTER
|
||||
} else {
|
||||
iv.setScaleTypeForMedia()
|
||||
|
@ -342,14 +342,14 @@ fun ItemViewHolder.setMedia(
|
|||
TootAttachmentType.Audio -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(Styler.defaultColorIcon(activity, R.drawable.wide_music))
|
||||
iv.setImageUrl(activity.pref, 0f, ta.urlForThumbnail(activity.pref))
|
||||
iv.setImageUrl(0f, ta.urlForThumbnail(activity.pref))
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
TootAttachmentType.Unknown -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(Styler.defaultColorIcon(activity, R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
iv.setImageUrl(0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ fun ItemViewHolder.setMedia(
|
|||
null, "" -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(Styler.defaultColorIcon(activity, R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
iv.setImageUrl(0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,6 @@ fun ItemViewHolder.setMedia(
|
|||
)
|
||||
iv.setDefaultImage(null)
|
||||
iv.setImageUrl(
|
||||
activity.pref,
|
||||
0f,
|
||||
accessInfo.supplyBaseUrl(urlThumbnail),
|
||||
accessInfo.supplyBaseUrl(urlThumbnail)
|
||||
|
|
|
@ -218,9 +218,7 @@ class SpanOutputEnv(
|
|||
// リンク表記はユーザの記述やアプリ設定の影響を受ける
|
||||
val caption = "@${
|
||||
when {
|
||||
PrefB.bpMentionFullAcct(
|
||||
App1.pref
|
||||
) -> fullAcct
|
||||
PrefB.bpMentionFullAcct() -> fullAcct
|
||||
else -> rawAcct
|
||||
}.pretty
|
||||
}"
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.google.firebase.messaging.FirebaseMessaging
|
|||
import jp.juggler.subwaytooter.*
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.pref.PrefDevice
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.pref.pref
|
||||
|
@ -404,7 +405,7 @@ class PollingWorker private constructor(contextArg: Context) {
|
|||
// クラッシュレポートによると App1.onCreate より前にここを通る場合がある
|
||||
// データベースへアクセスできるようにする
|
||||
this.appState = App1.prepare(context, "PollingWorker.init")
|
||||
this.pref = App1.pref
|
||||
this.pref = appPref
|
||||
|
||||
this.connectivityManager = systemService(context)
|
||||
?: error("missing ConnectivityManager system service")
|
||||
|
@ -670,7 +671,6 @@ class PollingWorker private constructor(contextArg: Context) {
|
|||
|
||||
// return false if app data import started.
|
||||
fun onStartTask(taskId: TaskId): Boolean {
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (taskId) {
|
||||
TaskId.AppDataImportBefore -> {
|
||||
|
||||
|
@ -689,6 +689,8 @@ class PollingWorker private constructor(contextArg: Context) {
|
|||
NotificationTracking.resetPostAll()
|
||||
// fall
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
// アプリデータのインポート処理がビジーな間、他のジョブは実行されない
|
||||
|
|
|
@ -185,7 +185,6 @@ class TaskRunner(
|
|||
|
||||
private fun beforePolling(): Boolean {
|
||||
// タスクによってはポーリング前にすることがある
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN", "MissingWhenCase")
|
||||
when (taskId) {
|
||||
|
||||
TaskId.BootCompleted ->
|
||||
|
@ -272,6 +271,8 @@ class TaskRunner(
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -371,7 +372,7 @@ class TaskRunner(
|
|||
val who = it.account
|
||||
when {
|
||||
it.type == TootNotification.TYPE_FOLLOW ||
|
||||
it.type == TootNotification.TYPE_FOLLOW_REQUEST -> true
|
||||
it.type == TootNotification.TYPE_FOLLOW_REQUEST -> true
|
||||
|
||||
who == null -> true
|
||||
account.isMe(who) -> true
|
||||
|
@ -630,12 +631,18 @@ class TaskRunner(
|
|||
|
||||
Build.VERSION.SDK_INT >= 23 && PrefB.bpDivideNotification(pref) -> {
|
||||
updateNotificationDivided(notificationTag, nt)
|
||||
nt.updatePost(first.notification.id, first.notification.time_created_at)
|
||||
nt.updatePost(
|
||||
first.notification.id,
|
||||
first.notification.time_created_at
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
updateNotificationMerged(notificationTag, first)
|
||||
nt.updatePost(first.notification.id, first.notification.time_created_at)
|
||||
nt.updatePost(
|
||||
first.notification.id,
|
||||
first.notification.time_created_at
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -656,12 +663,16 @@ class TaskRunner(
|
|||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private fun updateNotificationDivided(notificationTag: String, nt: NotificationTracking) {
|
||||
private fun updateNotificationDivided(
|
||||
notificationTag: String,
|
||||
nt: NotificationTracking
|
||||
) {
|
||||
log.d("updateNotificationDivided[${account.acct.pretty}] creating notification(1)")
|
||||
|
||||
val activeNotificationMap = notificationManager.activeNotifications?.filterNotNull()?.filter {
|
||||
it.id == PollingWorker.NOTIFICATION_ID && it.tag.startsWith("$notificationTag/")
|
||||
}?.map { Pair(it.tag, it) }?.toMutableMap() ?: mutableMapOf()
|
||||
val activeNotificationMap =
|
||||
notificationManager.activeNotifications?.filterNotNull()?.filter {
|
||||
it.id == PollingWorker.NOTIFICATION_ID && it.tag.startsWith("$notificationTag/")
|
||||
}?.map { Pair(it.tag, it) }?.toMutableMap() ?: mutableMapOf()
|
||||
|
||||
val lastPostTime = nt.post_time
|
||||
val lastPostId = nt.post_id
|
||||
|
@ -684,7 +695,10 @@ class TaskRunner(
|
|||
continue
|
||||
}
|
||||
|
||||
createNotification(itemTag, notificationId = item.notification.id.toString()) { builder ->
|
||||
createNotification(
|
||||
itemTag,
|
||||
notificationId = item.notification.id.toString()
|
||||
) { builder ->
|
||||
builder.setWhen(item.notification.time_created_at)
|
||||
val summary = item.getNotificationLine()
|
||||
builder.setContentTitle(summary)
|
||||
|
@ -736,7 +750,10 @@ class TaskRunner(
|
|||
|
||||
// Android 8 未満ではチャネルではなく通知に個別にスタイルを設定する
|
||||
@TargetApi(25)
|
||||
private fun setNotificationSound25(builder: NotificationCompat.Builder, item: NotificationData) {
|
||||
private fun setNotificationSound25(
|
||||
builder: NotificationCompat.Builder,
|
||||
item: NotificationData
|
||||
) {
|
||||
var iv = 0
|
||||
if (PrefB.bpNotificationSound(pref)) {
|
||||
var soundUri: Uri? = null
|
||||
|
@ -810,7 +827,7 @@ class TaskRunner(
|
|||
}.joinToString("&")
|
||||
|
||||
val flag = PendingIntent.FLAG_UPDATE_CURRENT or
|
||||
(if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)
|
||||
(if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)
|
||||
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
|
@ -851,7 +868,11 @@ class TaskRunner(
|
|||
setContent(builder)
|
||||
|
||||
log.d("showNotification[${account.acct.pretty}] set notification...")
|
||||
notificationManager.notify(notificationTag, PollingWorker.NOTIFICATION_ID, builder.build())
|
||||
notificationManager.notify(
|
||||
notificationTag,
|
||||
PollingWorker.NOTIFICATION_ID,
|
||||
builder.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package jp.juggler.subwaytooter.pref.impl
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.pref.pref
|
||||
|
||||
@Suppress("EqualsOrHashCode")
|
||||
|
@ -34,7 +34,7 @@ abstract class BasePref<T>(val key: String, val defVal: T) {
|
|||
open operator fun invoke(context: Context): T =
|
||||
invoke(context.pref())
|
||||
|
||||
operator fun invoke(): T = invoke(App1.pref)
|
||||
operator fun invoke(): T = invoke(appPref)
|
||||
|
||||
fun remove(e: SharedPreferences.Editor): SharedPreferences.Editor =
|
||||
e.remove(key)
|
||||
|
|
|
@ -89,7 +89,7 @@ class NetworkEmojiSpan internal constructor(
|
|||
} ?: return
|
||||
|
||||
val t = when {
|
||||
PrefB.bpDisableEmojiAnimation(App1.pref) -> 0L
|
||||
PrefB.bpDisableEmojiAnimation() -> 0L
|
||||
else -> invalidateCallback.timeFromStart
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class NetworkEmojiSpan internal constructor(
|
|||
|
||||
// 少し後に描画しなおす
|
||||
val delay = mFrameFindResult.delay
|
||||
if (delay != Long.MAX_VALUE && !PrefB.bpDisableEmojiAnimation(App1.pref)) {
|
||||
if (delay != Long.MAX_VALUE && !PrefB.bpDisableEmojiAnimation()) {
|
||||
invalidateCallback.delayInvalidate(delay)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import android.text.style.BackgroundColorSpan
|
|||
import android.text.style.ForegroundColorSpan
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.collection.LruCache
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.entity.Acct
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccount
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
class AcctColor {
|
||||
|
@ -63,7 +63,7 @@ class AcctColor {
|
|||
COL_NOTIFICATION_SOUND,
|
||||
if (notification_sound == null) "" else notification_sound
|
||||
)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
mMemoryCache.remove(key)
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
|
@ -104,7 +104,8 @@ class AcctColor {
|
|||
private val COL_NICKNAME = ColumnMeta(columnList, 0, "nick", "text")
|
||||
|
||||
// 未設定ならnullか空文字列
|
||||
private val COL_NOTIFICATION_SOUND = ColumnMeta(columnList, 17, "notification_sound", "text default ''")
|
||||
private val COL_NOTIFICATION_SOUND =
|
||||
ColumnMeta(columnList, 17, "notification_sound", "text default ''")
|
||||
|
||||
private const val CHAR_REPLACE: Char = 0x328A.toChar()
|
||||
|
||||
|
@ -136,7 +137,7 @@ class AcctColor {
|
|||
try {
|
||||
val where_arg = load_where_arg.get() ?: arrayOfNulls<String?>(1)
|
||||
where_arg[0] = key
|
||||
App1.database.query(table, null, load_where, where_arg, null, null, null)
|
||||
appDatabase.query(table, null, load_where, where_arg, null, null, null)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
|
||||
|
|
|
@ -3,14 +3,12 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.ColumnMeta
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import jp.juggler.util.put
|
||||
import java.util.*
|
||||
|
||||
object AcctSet : TableCompanion {
|
||||
|
||||
|
@ -51,7 +49,7 @@ object AcctSet : TableCompanion {
|
|||
try {
|
||||
// 古いデータを掃除する
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteOld failed.")
|
||||
}
|
||||
|
@ -64,7 +62,7 @@ object AcctSet : TableCompanion {
|
|||
cv.put(COL_TIME_SAVE, now)
|
||||
|
||||
var bOK = false
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
db.execSQL("BEGIN TRANSACTION")
|
||||
try {
|
||||
for (i in 0 until length) {
|
||||
|
@ -110,7 +108,7 @@ object AcctSet : TableCompanion {
|
|||
try {
|
||||
val where_arg = prefix_search_where_arg.get() ?: arrayOfNulls<String?>(1)
|
||||
where_arg[0] = makePattern(prefix)
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
prefix_search_where,
|
||||
|
|
|
@ -3,7 +3,7 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
object ClientInfo : TableCompanion {
|
||||
|
@ -30,7 +30,15 @@ object ClientInfo : TableCompanion {
|
|||
|
||||
fun load(instance: String, clientName: String): JsonObject? {
|
||||
try {
|
||||
App1.database.query(table, null, "h=? and cn=?", arrayOf(instance, clientName), null, null, null)
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"h=? and cn=?",
|
||||
arrayOf(instance, clientName),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
return cursor.getString(COL_RESULT).decodeJsonObject()
|
||||
|
@ -49,7 +57,7 @@ object ClientInfo : TableCompanion {
|
|||
cv.put(COL_HOST, instance)
|
||||
cv.put(COL_CLIENT_NAME, clientName)
|
||||
cv.put(COL_RESULT, json)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
}
|
||||
|
@ -58,7 +66,11 @@ object ClientInfo : TableCompanion {
|
|||
// 単体テスト用。インスタンス名を指定して削除する
|
||||
fun delete(instance: String, clientName: String) {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_HOST=? and $COL_CLIENT_NAME=?", arrayOf(instance, clientName))
|
||||
appDatabase.delete(
|
||||
table,
|
||||
"$COL_HOST=? and $COL_CLIENT_NAME=?",
|
||||
arrayOf(instance, clientName)
|
||||
)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
|
|
|
@ -3,9 +3,8 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
object ContentWarning : TableCompanion {
|
||||
|
@ -44,7 +43,7 @@ object ContentWarning : TableCompanion {
|
|||
try {
|
||||
// 古いデータを掃除する
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteOld failed.")
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ object ContentWarning : TableCompanion {
|
|||
put(COL_STATUS_URI, uri)
|
||||
put(COL_SHOWN, isShown)
|
||||
put(COL_TIME_SAVE, System.currentTimeMillis())
|
||||
}.let { App1.database.replace(table, null, it) }
|
||||
}.let { appDatabase.replace(table, null, it) }
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ object ContentWarning : TableCompanion {
|
|||
|
||||
private fun isShownImpl(uri: String, defaultValue: Boolean): Boolean {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
projection_shown,
|
||||
"$COL_STATUS_URI=?",
|
||||
|
|
|
@ -3,9 +3,8 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.entity.Acct
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
|
||||
|
@ -39,7 +38,7 @@ object FavMute : TableCompanion {
|
|||
try {
|
||||
val cv = ContentValues()
|
||||
cv.put(COL_ACCT, acct.ascii)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
}
|
||||
|
@ -47,20 +46,20 @@ object FavMute : TableCompanion {
|
|||
|
||||
fun delete(acct: Acct) {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ACCT=?", arrayOf(acct.ascii))
|
||||
appDatabase.delete(table, "$COL_ACCT=?", arrayOf(acct.ascii))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
}
|
||||
|
||||
fun createCursor(): Cursor {
|
||||
return App1.database.query(table, null, null, null, null, null, "$COL_ACCT asc")
|
||||
return appDatabase.query(table, null, null, null, null, null, "$COL_ACCT asc")
|
||||
}
|
||||
|
||||
val acctSet: HashSet<Acct>
|
||||
get() = HashSet<Acct>().also { dst ->
|
||||
try {
|
||||
App1.database.query(table, null, null, null, null, null, null)
|
||||
appDatabase.query(table, null, null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
val idx_name = cursor.getColumnIndex(COL_ACCT)
|
||||
while (cursor.moveToNext()) {
|
||||
|
@ -76,7 +75,7 @@ object FavMute : TableCompanion {
|
|||
fun contains(acct: Acct): Boolean {
|
||||
var found = false
|
||||
try {
|
||||
App1.database.query(table, null, "$COL_ACCT=?", arrayOf(acct.ascii), null, null, null)
|
||||
appDatabase.query(table, null, "$COL_ACCT=?", arrayOf(acct.ascii), null, null, null)
|
||||
.use { cursor ->
|
||||
while (cursor.moveToNext()) {
|
||||
found = true
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.database.Cursor
|
|||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
|
@ -69,7 +70,7 @@ class HighlightWord {
|
|||
|
||||
fun load(name: String): HighlightWord? {
|
||||
try {
|
||||
App1.database.query(table, null, selection_name, arrayOf(name), null, null, null)
|
||||
appDatabase.query(table, null, selection_name, arrayOf(name), null, null, null)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
return HighlightWord(cursor)
|
||||
|
@ -84,7 +85,15 @@ class HighlightWord {
|
|||
|
||||
fun load(id: Long): HighlightWord? {
|
||||
try {
|
||||
App1.database.query(table, null, selection_id, arrayOf(id.toString()), null, null, null)
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
selection_id,
|
||||
arrayOf(id.toString()),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
return HighlightWord(cursor)
|
||||
|
@ -98,14 +107,14 @@ class HighlightWord {
|
|||
}
|
||||
|
||||
fun createCursor(): Cursor {
|
||||
return App1.database.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
return appDatabase.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
}
|
||||
|
||||
val nameSet: WordTrieTree?
|
||||
get() {
|
||||
val dst = WordTrieTree()
|
||||
try {
|
||||
App1.database.query(table, columns_name, null, null, null, null, null)
|
||||
appDatabase.query(table, columns_name, null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
val idx_name = cursor.getColumnIndex(COL_NAME)
|
||||
while (cursor.moveToNext()) {
|
||||
|
@ -128,7 +137,7 @@ class HighlightWord {
|
|||
if (cached == null) {
|
||||
cached = false
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
columns_name,
|
||||
selection_speech,
|
||||
|
@ -218,9 +227,9 @@ class HighlightWord {
|
|||
cv.put(COL_SPEECH, speech)
|
||||
|
||||
if (id == -1L) {
|
||||
id = App1.database.replace(table, null, cv)
|
||||
id = appDatabase.replace(table, null, cv)
|
||||
} else {
|
||||
App1.database.update(table, cv, selection_id, arrayOf(id.toString()))
|
||||
appDatabase.update(table, cv, selection_id, arrayOf(id.toString()))
|
||||
}
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
|
@ -234,7 +243,7 @@ class HighlightWord {
|
|||
|
||||
fun delete(context: Context) {
|
||||
try {
|
||||
App1.database.delete(table, selection_id, arrayOf(id.toString()))
|
||||
appDatabase.delete(table, selection_id, arrayOf(id.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
object MediaShown : TableCompanion {
|
||||
|
@ -44,7 +44,7 @@ object MediaShown : TableCompanion {
|
|||
fun deleteOld(now: Long) {
|
||||
try {
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteOld failed.")
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ object MediaShown : TableCompanion {
|
|||
val table = "media_shown"
|
||||
val COL_TIME_SAVE = "time_save"
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ object MediaShown : TableCompanion {
|
|||
put(COL_STATUS_ID, id)
|
||||
put(COL_SHOWN, isShown)
|
||||
put(COL_TIME_SAVE, System.currentTimeMillis())
|
||||
}.let { App1.database.replace(table, null, it) }
|
||||
}.let { appDatabase.replace(table, null, it) }
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "saveImpl failed.")
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ object MediaShown : TableCompanion {
|
|||
|
||||
private fun isShownImpl(host: String, id: String, defaultValue: Boolean): Boolean {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
projection_shown,
|
||||
"h=? and si=?",
|
||||
|
|
|
@ -3,12 +3,10 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import java.util.*
|
||||
|
||||
object MutedApp : TableCompanion {
|
||||
|
||||
|
@ -47,19 +45,19 @@ object MutedApp : TableCompanion {
|
|||
val cv = ContentValues()
|
||||
cv.put(COL_NAME, appName)
|
||||
cv.put(COL_TIME_SAVE, now)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
}
|
||||
}
|
||||
|
||||
fun createCursor(): Cursor {
|
||||
return App1.database.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
return appDatabase.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
}
|
||||
|
||||
fun delete(name: String) {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_NAME=?", arrayOf(name))
|
||||
appDatabase.delete(table, "$COL_NAME=?", arrayOf(name))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
|
@ -95,7 +93,7 @@ object MutedApp : TableCompanion {
|
|||
get() {
|
||||
val dst = HashSet<String>()
|
||||
try {
|
||||
App1.database.query(table, null, null, null, null, null, null)
|
||||
appDatabase.query(table, null, null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
val idx_name = cursor.getColumnIndex(COL_NAME)
|
||||
while (cursor.moveToNext()) {
|
||||
|
|
|
@ -3,8 +3,7 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import jp.juggler.util.WordTrieTree
|
||||
|
@ -44,19 +43,19 @@ object MutedWord : TableCompanion {
|
|||
val cv = ContentValues()
|
||||
cv.put(COL_NAME, word)
|
||||
cv.put(COL_TIME_SAVE, now)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
}
|
||||
}
|
||||
|
||||
fun createCursor(): Cursor {
|
||||
return App1.database.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
return appDatabase.query(table, null, null, null, null, null, "$COL_NAME asc")
|
||||
}
|
||||
|
||||
fun delete(name: String) {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_NAME=?", arrayOf(name))
|
||||
appDatabase.delete(table, "$COL_NAME=?", arrayOf(name))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
|
@ -92,7 +91,7 @@ object MutedWord : TableCompanion {
|
|||
get() {
|
||||
val dst = WordTrieTree()
|
||||
try {
|
||||
App1.database.query(table, null, null, null, null, null, null)
|
||||
appDatabase.query(table, null, null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
val idx_name = cursor.getColumnIndex(COL_NAME)
|
||||
while (cursor.moveToNext()) {
|
||||
|
|
|
@ -3,13 +3,13 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.ApiPath
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.TootApiResult
|
||||
import jp.juggler.subwaytooter.api.entity.EntityId
|
||||
import jp.juggler.subwaytooter.api.entity.TootNotification
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
@ -77,7 +77,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
try {
|
||||
val cv = ContentValues()
|
||||
cv.put(COL_LAST_LOAD, 0L)
|
||||
App1.database.update(table, cv, WHERE_AID, arrayOf(dbId.toString()))
|
||||
appDatabase.update(table, cv, WHERE_AID, arrayOf(dbId.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "resetLastLoad(db_id) failed.")
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
try {
|
||||
val cv = ContentValues()
|
||||
cv.put(COL_LAST_LOAD, 0L)
|
||||
App1.database.update(table, cv, null, null)
|
||||
appDatabase.update(table, cv, null, null)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "resetLastLoad() failed.")
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
cv.put(COL_ACCOUNT_DB_ID, dbId)
|
||||
cv.put(COL_LAST_LOAD, 0L)
|
||||
cv.putNull(COL_DATA)
|
||||
App1.database.replaceOrThrow(table, null, cv)
|
||||
appDatabase.replaceOrThrow(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteCache failed.")
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
// load into this object
|
||||
fun load() {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
WHERE_AID,
|
||||
|
@ -192,7 +192,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
cv.put(COL_LAST_LOAD, last_load)
|
||||
cv.put(COL_DATA, data.toJsonArray().toString())
|
||||
|
||||
val rv = App1.database.replaceOrThrow(table, null, cv)
|
||||
val rv = appDatabase.replaceOrThrow(table, null, cv)
|
||||
if (rv != -1L && id == -1L) id = rv
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
|
@ -358,7 +358,7 @@ class NotificationCache(private val account_db_id: Long) {
|
|||
// val cv = ContentValues()
|
||||
// post_id.putTo(cv, COL_POST_ID)
|
||||
// cv.put(COL_POST_TIME, post_time)
|
||||
// val rows = App1.database.update(table, cv, WHERE_AID, arrayOf(account_db_id.toString()))
|
||||
// val rows = appDatabase.update(table, cv, WHERE_AID, arrayOf(account_db_id.toString()))
|
||||
// log.d(
|
||||
// "updatePost account_db_id=%s,post=%s,%s last_data=%s,update_rows=%s"
|
||||
// , account_db_id
|
||||
|
|
|
@ -3,9 +3,9 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.entity.EntityId
|
||||
import jp.juggler.subwaytooter.api.entity.putMayNull
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import jp.juggler.util.getLong
|
||||
|
@ -63,7 +63,7 @@ class NotificationTracking {
|
|||
post_id.putMayNull(cv, COL_POST_ID)
|
||||
cv.put(COL_POST_TIME, post_time)
|
||||
|
||||
val rv = App1.database.replaceOrThrow(table, null, cv)
|
||||
val rv = appDatabase.replaceOrThrow(table, null, cv)
|
||||
if (rv != -1L && id == -1L) id = rv
|
||||
|
||||
log.d("$acct/$notificationType save. post=($post_id,$post_time)")
|
||||
|
@ -83,7 +83,7 @@ class NotificationTracking {
|
|||
val cv = ContentValues()
|
||||
postId.putTo(cv, COL_POST_ID)
|
||||
cv.put(COL_POST_TIME, postTime)
|
||||
val rows = App1.database.update(
|
||||
val rows = appDatabase.update(
|
||||
table,
|
||||
cv,
|
||||
WHERE_AID,
|
||||
|
@ -230,7 +230,7 @@ class NotificationTracking {
|
|||
dst.accountDbId = accountDbId
|
||||
dst.notificationType = notificationType
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
WHERE_AID,
|
||||
|
@ -263,7 +263,7 @@ class NotificationTracking {
|
|||
show.putTo(cv, COL_NID_READ) //変数名とキー名が異なるのに注意
|
||||
val where_args =
|
||||
arrayOf(accountDbId.toString(), notificationType)
|
||||
App1.database.update(table, cv, WHERE_AID, where_args)
|
||||
appDatabase.update(table, cv, WHERE_AID, where_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ class NotificationTracking {
|
|||
fun updateRead(accountDbId: Long, notificationType: String) {
|
||||
try {
|
||||
val where_args = arrayOf(accountDbId.toString(), notificationType)
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
arrayOf(COL_NID_SHOW, COL_NID_READ),
|
||||
WHERE_AID,
|
||||
|
@ -312,7 +312,7 @@ class NotificationTracking {
|
|||
log.i("updateRead[$accountDbId,$notificationType]: update nid_read as $nid_show...")
|
||||
val cv = ContentValues()
|
||||
nid_show.putTo(cv, COL_NID_READ) //変数名とキー名が異なるのに注意
|
||||
App1.database.update(table, cv, WHERE_AID, where_args)
|
||||
appDatabase.update(table, cv, WHERE_AID, where_args)
|
||||
clearCache(accountDbId, notificationType)
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ class NotificationTracking {
|
|||
val cv = ContentValues()
|
||||
cv.putNull(COL_POST_ID)
|
||||
cv.put(COL_POST_TIME, 0)
|
||||
App1.database.update(table, cv, null, null)
|
||||
appDatabase.update(table, cv, null, null)
|
||||
cache.clear()
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "resetPostAll failed.")
|
||||
|
@ -340,7 +340,7 @@ class NotificationTracking {
|
|||
fun resetTrackingState(accountDbId: Long?) {
|
||||
accountDbId ?: return
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ACCOUNT_DB_ID=?", arrayOf(accountDbId.toString()))
|
||||
appDatabase.delete(table, "$COL_ACCOUNT_DB_ID=?", arrayOf(accountDbId.toString()))
|
||||
cache.remove(accountDbId)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "resetTrackingState failed.")
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.content.ContentValues
|
|||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
class PostDraft {
|
||||
|
@ -17,7 +17,7 @@ class PostDraft {
|
|||
|
||||
fun delete() {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ID=?", arrayOf(id.toString()))
|
||||
appDatabase.delete(table, "$COL_ID=?", arrayOf(id.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "delete failed.")
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class PostDraft {
|
|||
try {
|
||||
// 古いデータを掃除する
|
||||
val expire = now - 86400000L * 30
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteOld failed.")
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class PostDraft {
|
|||
}.toString().digestSHA256Hex()
|
||||
|
||||
// save to db
|
||||
App1.database.replace(table, null, ContentValues().apply {
|
||||
appDatabase.replace(table, null, ContentValues().apply {
|
||||
put(COL_TIME_SAVE, now)
|
||||
put(COL_JSON, json.toString())
|
||||
put(COL_HASH, hash)
|
||||
|
@ -97,7 +97,7 @@ class PostDraft {
|
|||
|
||||
fun hasDraft(): Boolean {
|
||||
try {
|
||||
App1.database.query(table, arrayOf("count(*)"), null, null, null, null, null)
|
||||
appDatabase.query(table, arrayOf("count(*)"), null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
val count = cursor.getInt(0)
|
||||
|
@ -114,7 +114,7 @@ class PostDraft {
|
|||
@SuppressLint("Recycle")
|
||||
fun createCursor(): Cursor? =
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
null,
|
||||
|
|
|
@ -5,12 +5,12 @@ import android.content.Context
|
|||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.TootApiResult
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.subwaytooter.notification.PollingWorker
|
||||
import jp.juggler.subwaytooter.util.LinkHelper
|
||||
import jp.juggler.util.*
|
||||
|
@ -181,7 +181,7 @@ class SavedAccount(
|
|||
|
||||
fun delete() {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
appDatabase.delete(table, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
errorEx(ex, "SavedAccount.delete failed.")
|
||||
|
@ -197,7 +197,7 @@ class SavedAccount(
|
|||
|
||||
ContentValues().apply {
|
||||
put(COL_TOKEN, token_info.toString())
|
||||
}.let { App1.database.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
}.let { appDatabase.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
}
|
||||
|
||||
fun saveSetting() {
|
||||
|
@ -243,7 +243,7 @@ class SavedAccount(
|
|||
// 以下のデータはUIからは更新しない
|
||||
// notification_tag
|
||||
// register_key
|
||||
}.let { App1.database.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
}.let { appDatabase.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
}
|
||||
|
||||
// fun saveNotificationTag() {
|
||||
|
@ -253,7 +253,7 @@ class SavedAccount(
|
|||
// val cv = ContentValues()
|
||||
// cv.put(COL_NOTIFICATION_TAG, notification_tag)
|
||||
//
|
||||
// App1.database.update(table, cv, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
// appDatabase.update(table, cv, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
// }
|
||||
//
|
||||
// fun saveRegisterKey() {
|
||||
|
@ -264,7 +264,7 @@ class SavedAccount(
|
|||
// cv.put(COL_REGISTER_KEY, register_key)
|
||||
// cv.put(COL_REGISTER_TIME, register_time)
|
||||
//
|
||||
// App1.database.update(table, cv, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
// appDatabase.update(table, cv, "$COL_ID=?", arrayOf(db_id.toString()))
|
||||
// }
|
||||
|
||||
// onResumeの時に設定を読み直す
|
||||
|
@ -533,7 +533,7 @@ class SavedAccount(
|
|||
put(COL_ACCOUNT, account.toString())
|
||||
put(COL_TOKEN, token.toString())
|
||||
put(COL_MISSKEY_VERSION, misskeyVersion)
|
||||
}.let { App1.database.insert(table, null, it) }
|
||||
}.let { appDatabase.insert(table, null, it) }
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
errorEx(ex, "SavedAccount.insert failed.")
|
||||
|
@ -546,12 +546,12 @@ class SavedAccount(
|
|||
ContentValues().apply {
|
||||
put(COL_REGISTER_KEY, REGISTER_KEY_UNREGISTERED)
|
||||
put(COL_REGISTER_TIME, 0L)
|
||||
}.let { App1.database.update(table, it, null, null) }
|
||||
}.let { appDatabase.update(table, it, null, null) }
|
||||
}
|
||||
|
||||
fun loadAccount(context: Context, dbId: Long): SavedAccount? {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"$COL_ID=?",
|
||||
|
@ -577,7 +577,7 @@ class SavedAccount(
|
|||
fun loadAccountList(context: Context) =
|
||||
ArrayList<SavedAccount>().also { result ->
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
null,
|
||||
|
@ -603,7 +603,7 @@ class SavedAccount(
|
|||
fun loadByTag(context: Context, tag: String): ArrayList<SavedAccount> {
|
||||
val result = ArrayList<SavedAccount>()
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"$COL_NOTIFICATION_TAG=?",
|
||||
|
@ -629,7 +629,7 @@ class SavedAccount(
|
|||
|
||||
fun loadAccountByAcct(context: Context, fullAcct: String): SavedAccount? {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"$COL_USER=?",
|
||||
|
@ -653,7 +653,7 @@ class SavedAccount(
|
|||
|
||||
fun hasRealAccount(): Boolean {
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"$COL_USER NOT LIKE '?@%'",
|
||||
|
@ -679,7 +679,7 @@ class SavedAccount(
|
|||
val count: Int
|
||||
get() {
|
||||
try {
|
||||
App1.database.query(table, arrayOf("count(*)"), null, null, null, null, null)
|
||||
appDatabase.query(table, arrayOf("count(*)"), null, null, null, null, null)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
return cursor.getInt(0)
|
||||
|
@ -762,7 +762,7 @@ class SavedAccount(
|
|||
|
||||
val list = ArrayList<Long>()
|
||||
try {
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
"$COL_ACCOUNT like ?",
|
||||
|
@ -782,7 +782,7 @@ class SavedAccount(
|
|||
|
||||
list.forEach {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ID=?", arrayOf(it.toString()))
|
||||
appDatabase.delete(table, "$COL_ID=?", arrayOf(it.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
log.e(ex, "sweepBuggieData failed.")
|
||||
|
@ -861,7 +861,7 @@ class SavedAccount(
|
|||
ContentValues().apply {
|
||||
put(COL_ACCOUNT, result.jsonObject.toString())
|
||||
}.let {
|
||||
App1.database.update(
|
||||
appDatabase.update(
|
||||
table,
|
||||
it,
|
||||
"$COL_ID=?",
|
||||
|
@ -883,7 +883,7 @@ class SavedAccount(
|
|||
if (db_id != INVALID_DB_ID) {
|
||||
ContentValues()
|
||||
.apply { put(col, value) }
|
||||
.let { App1.database.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
.let { appDatabase.update(table, it, "$COL_ID=?", arrayOf(db_id.toString())) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ package jp.juggler.subwaytooter.table
|
|||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import jp.juggler.util.getString
|
||||
|
@ -48,7 +47,7 @@ object SubscriptionServerKey : TableCompanion {
|
|||
try {
|
||||
val whereArgs = findWhereArgs.get() ?: arrayOfNulls<String?>(1)
|
||||
whereArgs[0] = clientIdentifier
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
findColumns,
|
||||
"$COL_CLIENT_IDENTIFIER=?",
|
||||
|
@ -73,7 +72,7 @@ object SubscriptionServerKey : TableCompanion {
|
|||
val cv = ContentValues()
|
||||
cv.put(COL_CLIENT_IDENTIFIER, clientIdentifier)
|
||||
cv.put(COL_SERVER_KEY, serverKey)
|
||||
App1.database.replace(table, null, cv)
|
||||
appDatabase.replace(table, null, cv)
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
log.trace(ex)
|
||||
|
|
|
@ -2,7 +2,7 @@ package jp.juggler.subwaytooter.table
|
|||
|
||||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.TableCompanion
|
||||
import java.util.*
|
||||
|
@ -47,7 +47,7 @@ object TagSet : TableCompanion {
|
|||
// try {
|
||||
// // 古いデータを掃除する
|
||||
// val expire = now - 86400000L * 365
|
||||
// App1.database.delete(table, COL_TIME_SAVE + "<?", arrayOf(expire.toString()))
|
||||
// appDatabase.delete(table, COL_TIME_SAVE + "<?", arrayOf(expire.toString()))
|
||||
//
|
||||
// } catch(ex : Throwable) {
|
||||
// warning.e(ex, "deleteOld failed.")
|
||||
|
@ -73,7 +73,7 @@ object TagSet : TableCompanion {
|
|||
cv.put(COL_TIME_SAVE, now)
|
||||
|
||||
var bOK = false
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
db.execSQL("BEGIN TRANSACTION")
|
||||
try {
|
||||
for (i in 0 until length) {
|
||||
|
@ -121,7 +121,7 @@ object TagSet : TableCompanion {
|
|||
try {
|
||||
val where_arg = prefix_search_where_arg.get() ?: arrayOfNulls<String?>(1)
|
||||
where_arg[0] = makePattern(prefix)
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
null,
|
||||
prefix_search_where,
|
||||
|
|
|
@ -4,12 +4,12 @@ import android.content.ContentValues
|
|||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.provider.BaseColumns
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.subwaytooter.api.entity.Acct
|
||||
import jp.juggler.subwaytooter.api.entity.EntityId
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccount
|
||||
import jp.juggler.subwaytooter.api.entity.TootRelationShip
|
||||
import jp.juggler.subwaytooter.global.appDatabase
|
||||
import jp.juggler.util.*
|
||||
|
||||
class UserRelation {
|
||||
|
@ -94,7 +94,7 @@ class UserRelation {
|
|||
fun deleteOld(now: Long) {
|
||||
try {
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "deleteOld failed.")
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class UserRelation {
|
|||
val table = "user_relation"
|
||||
val COL_TIME_SAVE = "time_save"
|
||||
val expire = now - 86400000L * 365
|
||||
App1.database.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
appDatabase.delete(table, "$COL_TIME_SAVE<?", arrayOf(expire.toString()))
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class UserRelation {
|
|||
put(COL_DB_ID, dbId)
|
||||
put(COL_WHO_ID, id)
|
||||
fromTootRelationShip(src)
|
||||
}.let { App1.database.replaceOrThrow(table, null, it) }
|
||||
}.let { appDatabase.replaceOrThrow(table, null, it) }
|
||||
mMemoryCache.remove(key(dbId, id))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
|
@ -159,7 +159,7 @@ class UserRelation {
|
|||
|
||||
// マストドン用
|
||||
fun saveListMastodon(now: Long, dbId: Long, srcList: Iterable<TootRelationShip>) {
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
db.execSQL("BEGIN TRANSACTION")
|
||||
|
||||
val bOK = try {
|
||||
|
@ -198,7 +198,7 @@ class UserRelation {
|
|||
put(COL_DB_ID, dbId)
|
||||
put(COL_WHO_ID, whoId)
|
||||
fromUserRelation(src)
|
||||
}.let { App1.database.replaceOrThrow(table, null, it) }
|
||||
}.let { appDatabase.replaceOrThrow(table, null, it) }
|
||||
mMemoryCache.remove(key(dbId, whoId))
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "save failed.")
|
||||
|
@ -212,7 +212,7 @@ class UserRelation {
|
|||
start: Int,
|
||||
end: Int,
|
||||
) {
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
db.execSQL("BEGIN TRANSACTION")
|
||||
val bOK = try {
|
||||
val cv = ContentValues()
|
||||
|
@ -248,7 +248,7 @@ class UserRelation {
|
|||
|
||||
// Misskeyのリレーション取得APIから
|
||||
fun saveListMisskeyRelationApi(now: Long, dbId: Long, list: ArrayList<TootRelationShip>) {
|
||||
val db = App1.database
|
||||
val db = appDatabase
|
||||
db.execSQL("BEGIN TRANSACTION")
|
||||
val bOK = try {
|
||||
val cv = ContentValues()
|
||||
|
@ -301,7 +301,7 @@ class UserRelation {
|
|||
val where_arg = loadWhereArg.get() ?: arrayOfNulls<String?>(2)
|
||||
where_arg[0] = dbId.toString()
|
||||
where_arg[1] = whoId
|
||||
App1.database.query(table, null, loadWhere, where_arg, null, null, null)
|
||||
appDatabase.query(table, null, loadWhere, where_arg, null, null, null)
|
||||
.use { cursor ->
|
||||
if (cursor.moveToNext()) {
|
||||
val dst = UserRelation()
|
||||
|
@ -355,7 +355,7 @@ class UserRelation {
|
|||
fun loadPseudo(acct: Acct) = load(DB_ID_PSEUDO, acct.ascii)
|
||||
|
||||
fun createCursorPseudo(): Cursor =
|
||||
App1.database.query(
|
||||
appDatabase.query(
|
||||
table,
|
||||
arrayOf(COL_ID.name, COL_WHO_ID.name),
|
||||
"$COL_DB_ID=$DB_ID_PSEUDO and ( $COL_MUTING=1 or $COL_BLOCKING=1 )",
|
||||
|
@ -367,7 +367,7 @@ class UserRelation {
|
|||
|
||||
fun deletePseudo(rowId: Long) {
|
||||
try {
|
||||
App1.database.delete(table, "$COL_ID=$rowId", null)
|
||||
appDatabase.delete(table, "$COL_ID=$rowId", null)
|
||||
} catch (ex: Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
|
|
|
@ -4,10 +4,9 @@ import android.content.*
|
|||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.core.content.ContextCompat
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.pref.PrefS
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.attrColor
|
||||
|
@ -31,29 +30,28 @@ object CustomShare {
|
|||
"com.google.android.apps.translate/com.google.android.apps.translate.TranslateActivity"
|
||||
|
||||
fun getCustomShareComponentName(
|
||||
pref: SharedPreferences,
|
||||
target: CustomShareTarget,
|
||||
): ComponentName? {
|
||||
val src: String
|
||||
val defaultComponentName: String?
|
||||
when (target) {
|
||||
CustomShareTarget.Translate -> {
|
||||
src = PrefS.spTranslateAppComponent(pref)
|
||||
src = PrefS.spTranslateAppComponent()
|
||||
defaultComponentName = translate_app_component_default
|
||||
}
|
||||
|
||||
CustomShareTarget.CustomShare1 -> {
|
||||
src = PrefS.spCustomShare1(pref)
|
||||
src = PrefS.spCustomShare1()
|
||||
defaultComponentName = null
|
||||
}
|
||||
|
||||
CustomShareTarget.CustomShare2 -> {
|
||||
src = PrefS.spCustomShare2(pref)
|
||||
src = PrefS.spCustomShare2()
|
||||
defaultComponentName = null
|
||||
}
|
||||
|
||||
CustomShareTarget.CustomShare3 -> {
|
||||
src = PrefS.spCustomShare3(pref)
|
||||
src = PrefS.spCustomShare3()
|
||||
defaultComponentName = null
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +101,7 @@ object CustomShare {
|
|||
text: String,
|
||||
) {
|
||||
// convert "pkgName/className" string to ComponentName object.
|
||||
val cn = getCustomShareComponentName(App1.pref, target)
|
||||
val cn = getCustomShareComponentName(target)
|
||||
if (cn == null) {
|
||||
context.showToast(true, R.string.custom_share_app_not_found)
|
||||
return
|
||||
|
@ -155,7 +153,7 @@ object CustomShare {
|
|||
status ?: return
|
||||
try {
|
||||
// convert "pkgName/className" string to ComponentName object.
|
||||
val cn = getCustomShareComponentName(App1.pref, target)
|
||||
val cn = getCustomShareComponentName(target)
|
||||
if (cn == null) {
|
||||
context.showToast(true, R.string.custom_share_app_not_found)
|
||||
return
|
||||
|
@ -172,9 +170,9 @@ object CustomShare {
|
|||
|
||||
fun getCache(target: CustomShareTarget) = cache[target]
|
||||
|
||||
fun reloadCache(context: Context, pref: SharedPreferences) {
|
||||
fun reloadCache(context: Context) {
|
||||
CustomShareTarget.values().forEach { target ->
|
||||
val cn = getCustomShareComponentName(pref, target)
|
||||
val cn = getCustomShareComponentName(target)
|
||||
val pair = getInfo(context, cn)
|
||||
cache[target] = pair
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.text.SpannableStringBuilder
|
|||
import android.text.Spanned
|
||||
import android.util.SparseBooleanArray
|
||||
import androidx.annotation.DrawableRes
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.emoji.CustomEmoji
|
||||
import jp.juggler.subwaytooter.emoji.EmojiMap
|
||||
|
@ -384,7 +383,7 @@ object EmojiDecoder {
|
|||
val emojiCustom = emojiMapCustom?.get(name)
|
||||
if (emojiCustom != null) {
|
||||
val url = when {
|
||||
PrefB.bpDisableEmojiAnimation(App1.pref) && emojiCustom.staticUrl?.isNotEmpty() == true -> emojiCustom.staticUrl
|
||||
PrefB.bpDisableEmojiAnimation() && emojiCustom.staticUrl?.isNotEmpty() == true -> emojiCustom.staticUrl
|
||||
else -> emojiCustom.url
|
||||
}
|
||||
builder.addNetworkEmojiSpan(part, url)
|
||||
|
@ -430,7 +429,7 @@ object EmojiDecoder {
|
|||
s: String,
|
||||
emojiMapCustom: HashMap<String, CustomEmoji>? = null
|
||||
): String {
|
||||
val decodeEmojioneShortcode = PrefB.bpEmojioneShortcode(App1.pref)
|
||||
val decodeEmojioneShortcode = PrefB.bpEmojioneShortcode()
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
|
|
|
@ -874,7 +874,7 @@ object HTMLDecoder {
|
|||
val linkInfo = if (fullAcct != null) {
|
||||
LinkInfo(
|
||||
url = item.url,
|
||||
caption = "@${(if (PrefB.bpMentionFullAcct(App1.pref)) fullAcct else item.acct).pretty}",
|
||||
caption = "@${(if (PrefB.bpMentionFullAcct()) fullAcct else item.acct).pretty}",
|
||||
ac = AcctColor.load(fullAcct),
|
||||
mention = item,
|
||||
tag = link_tag
|
||||
|
@ -964,7 +964,7 @@ object HTMLDecoder {
|
|||
|
||||
fun afterFullAcctResolved(fullAcct: Acct) {
|
||||
linkInfo.ac = AcctColor.load(fullAcct)
|
||||
if (options.mentionFullAcct || PrefB.bpMentionFullAcct(App1.pref)) {
|
||||
if (options.mentionFullAcct || PrefB.bpMentionFullAcct()) {
|
||||
linkInfo.caption = "@${fullAcct.pretty}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.core.content.ContextCompat
|
|||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.entity.Acct
|
||||
import jp.juggler.subwaytooter.global.appPref
|
||||
import jp.juggler.subwaytooter.view.MyEditText
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.asciiPattern
|
||||
|
@ -46,7 +47,7 @@ internal class PopupAutoCompleteAcct(
|
|||
private val popupWidth: Int
|
||||
val handler: Handler
|
||||
|
||||
private val pref: SharedPreferences = App1.pref
|
||||
private val pref: SharedPreferences = appPref
|
||||
|
||||
private var popupRows: Int = 0
|
||||
|
||||
|
|
|
@ -3,14 +3,13 @@ package jp.juggler.subwaytooter.util
|
|||
import android.os.SystemClock
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.Styler
|
||||
import jp.juggler.subwaytooter.api.*
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.dialog.DlgConfirm
|
||||
import jp.juggler.subwaytooter.emoji.CustomEmoji
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.span.MyClickableSpan
|
||||
import jp.juggler.subwaytooter.table.AcctColor
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
|
@ -150,7 +149,7 @@ class PostImpl(
|
|||
return false
|
||||
}
|
||||
|
||||
if (!bConfirmTagCharacter && PrefB.bpWarnHashtagAsciiAndNonAscii(App1.pref)) {
|
||||
if (!bConfirmTagCharacter && PrefB.bpWarnHashtagAsciiAndNonAscii()) {
|
||||
val tags = TootTag.findHashtags(content, account.isMisskey)
|
||||
val badTags = tags
|
||||
?.filter {
|
||||
|
@ -269,7 +268,12 @@ class PostImpl(
|
|||
) {
|
||||
if (actual != extra || checkFun(instance)) return
|
||||
val strVisibility = Styler.getVisibilityString(activity, account.isMisskey, extra)
|
||||
errorApiResult(activity.getString(R.string.server_has_no_support_of_visibility, strVisibility))
|
||||
errorApiResult(
|
||||
activity.getString(
|
||||
R.string.server_has_no_support_of_visibility,
|
||||
strVisibility
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun checkVisibility(
|
||||
|
@ -281,8 +285,18 @@ class PostImpl(
|
|||
TootVisibility.WebSetting -> getWebVisibility(client, parser, instance)
|
||||
else -> visibilityArg
|
||||
}
|
||||
checkServerHasVisibility(v, TootVisibility.Mutual, instance, InstanceCapability::visibilityMutual)
|
||||
checkServerHasVisibility(v, TootVisibility.Limited, instance, InstanceCapability::visibilityLimited)
|
||||
checkServerHasVisibility(
|
||||
v,
|
||||
TootVisibility.Mutual,
|
||||
instance,
|
||||
InstanceCapability::visibilityMutual
|
||||
)
|
||||
checkServerHasVisibility(
|
||||
v,
|
||||
TootVisibility.Limited,
|
||||
instance,
|
||||
InstanceCapability::visibilityLimited
|
||||
)
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -407,9 +421,11 @@ class PostImpl(
|
|||
|
||||
json["status"] = EmojiDecoder.decodeShortCode(content, emojiMapCustom = emojiMapCustom)
|
||||
json["sensitive"] = bNSFW
|
||||
json["spoiler_text"] = EmojiDecoder.decodeShortCode(spoilerText ?: "", emojiMapCustom = emojiMapCustom)
|
||||
json["spoiler_text"] =
|
||||
EmojiDecoder.decodeShortCode(spoilerText ?: "", emojiMapCustom = emojiMapCustom)
|
||||
|
||||
inReplyToId?.toString()?.let { json[if (useQuoteToot) "quote_id" else "in_reply_to_id"] = it }
|
||||
inReplyToId?.toString()
|
||||
?.let { json[if (useQuoteToot) "quote_id" else "in_reply_to_id"] = it }
|
||||
|
||||
if (attachmentList != null) {
|
||||
json["media_ids"] = jsonArray {
|
||||
|
@ -556,7 +572,7 @@ class PostImpl(
|
|||
|
||||
val requestBuilder = bodyString.toRequestBody(MEDIA_TYPE_JSON).toPost()
|
||||
|
||||
if (!PrefB.bpDontDuplicationCheck(App1.pref)) {
|
||||
if (!PrefB.bpDontDuplicationCheck()) {
|
||||
val digest = (bodyString + account.acct.ascii).digestSHA256Hex()
|
||||
requestBuilder.header("Idempotency-Key", digest)
|
||||
}
|
||||
|
@ -575,7 +591,8 @@ class PostImpl(
|
|||
} else {
|
||||
val status = parser.status(
|
||||
when {
|
||||
account.isMisskey -> jsonObject?.jsonObject("createdNote") ?: jsonObject
|
||||
account.isMisskey -> jsonObject?.jsonObject("createdNote")
|
||||
?: jsonObject
|
||||
else -> jsonObject
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package jp.juggler.subwaytooter.view
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Matrix
|
||||
|
@ -58,7 +57,11 @@ class MyNetworkImageView : AppCompatImageView {
|
|||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
fun setDefaultImage(defaultImage: Drawable?) {
|
||||
mDefaultImage = defaultImage
|
||||
|
@ -71,7 +74,6 @@ class MyNetworkImageView : AppCompatImageView {
|
|||
}
|
||||
|
||||
fun setImageUrl(
|
||||
pref: SharedPreferences,
|
||||
r: Float,
|
||||
url: String?,
|
||||
gifUrlArg: String? = null,
|
||||
|
@ -79,7 +81,7 @@ class MyNetworkImageView : AppCompatImageView {
|
|||
|
||||
mCornerRadius = r
|
||||
|
||||
val gifUrl = if (PrefB.bpEnableGifAnimation(pref)) gifUrlArg else null
|
||||
val gifUrl = if (PrefB.bpEnableGifAnimation()) gifUrlArg else null
|
||||
|
||||
if (gifUrl?.isNotEmpty() == true) {
|
||||
mUrl = gifUrl
|
||||
|
|
|
@ -16,9 +16,8 @@ import android.widget.CompoundButton
|
|||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import kotlin.math.pow
|
||||
|
||||
|
@ -200,7 +199,7 @@ fun AppCompatActivity.setStatusBarColor(forceDark: Boolean = false) {
|
|||
@Suppress("DEPRECATION")
|
||||
clearFlags(
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -208,13 +207,13 @@ fun AppCompatActivity.setStatusBarColor(forceDark: Boolean = false) {
|
|||
|
||||
var c = when {
|
||||
forceDark -> Color.BLACK
|
||||
else -> PrefI.ipStatusBarColor(App1.pref).notZero() ?: attrColor(R.attr.colorPrimaryDark)
|
||||
else -> PrefI.ipStatusBarColor().notZero() ?: attrColor(R.attr.colorPrimaryDark)
|
||||
}
|
||||
setStatusBarColorCompat(c)
|
||||
|
||||
c = when {
|
||||
forceDark -> Color.BLACK
|
||||
else -> PrefI.ipNavigationBarColor(App1.pref)
|
||||
else -> PrefI.ipNavigationBarColor()
|
||||
}
|
||||
setNavigationBarColorCompat(c)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ buildscript {
|
|||
|
||||
ext.detekt_version = '1.18.1'
|
||||
|
||||
ext.compose_version = '1.0.4'
|
||||
ext.compose_version = '1.0.5'
|
||||
|
||||
ext.koin_version = '3.1.3'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
|
Loading…
Reference in New Issue