Remove Telegram bot token from public source
This commit is contained in:
@@ -21,8 +21,8 @@ android {
|
||||
applicationId 'org.koitharu.kotatsu'
|
||||
minSdk = 21
|
||||
targetSdk = 36
|
||||
versionCode = 1023
|
||||
versionName = '9.0.1'
|
||||
versionCode = 1024
|
||||
versionName = '9.1'
|
||||
generatedDensities = []
|
||||
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
|
||||
ksp {
|
||||
@@ -32,6 +32,12 @@ android {
|
||||
// https://issuetracker.google.com/issues/408030127
|
||||
generateLocaleConfig false
|
||||
}
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localProperties.load(new FileInputStream(localPropertiesFile))
|
||||
}
|
||||
resValue 'string', 'tg_backup_bot_token', localProperties.getProperty('tg_backup_bot_token', '')
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
|
||||
@@ -49,7 +49,7 @@ class PeriodicalBackupService : CoroutineIntentService() {
|
||||
}
|
||||
externalBackupStorage.put(output)
|
||||
externalBackupStorage.trim(settings.periodicalBackupMaxCount)
|
||||
if (settings.isBackupTelegramUploadEnabled) {
|
||||
if (settings.isBackupTelegramUploadEnabled && telegramBackupUploader.isAvailable) {
|
||||
telegramBackupUploader.uploadBackup(output)
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.activity.result.ActivityResultCallback
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.koitharu.kotatsu.R
|
||||
@@ -37,6 +38,7 @@ class PeriodicalBackupSettingsFragment : BasePreferenceFragment(R.string.periodi
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_backup_periodic)
|
||||
findPreference<PreferenceCategory>(AppSettings.KEY_BACKUP_TG)?.isVisible = viewModel.isTelegramAvailable
|
||||
findPreference<EditTextPreference>(AppSettings.KEY_BACKUP_TG_CHAT)?.summaryProvider =
|
||||
EditTextFallbackSummaryProvider(R.string.telegram_chat_id_summary)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ class PeriodicalBackupSettingsViewModel @Inject constructor(
|
||||
@ApplicationContext private val appContext: Context,
|
||||
) : BaseViewModel() {
|
||||
|
||||
val isTelegramAvailable
|
||||
get() = telegramUploader.isAvailable
|
||||
|
||||
val lastBackupDate = MutableStateFlow<Date?>(null)
|
||||
val backupsDirectory = MutableStateFlow<String?>("")
|
||||
val isTelegramCheckLoading = MutableStateFlow(false)
|
||||
|
||||
@@ -30,6 +30,9 @@ class TelegramBackupUploader @Inject constructor(
|
||||
|
||||
private val botToken = context.getString(R.string.tg_backup_bot_token)
|
||||
|
||||
val isAvailable: Boolean
|
||||
get() = botToken.isNotEmpty()
|
||||
|
||||
suspend fun uploadBackup(file: File) {
|
||||
val requestBody = file.asRequestBody("application/zip".toMediaTypeOrNull())
|
||||
val multipartBody = MultipartBody.Builder()
|
||||
|
||||
@@ -812,6 +812,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
||||
const val KEY_PROXY_TEST = "proxy_test"
|
||||
const val KEY_OPEN_BROWSER = "open_browser"
|
||||
const val KEY_HANDLE_LINKS = "handle_links"
|
||||
const val KEY_BACKUP_TG = "backup_periodic_tg"
|
||||
const val KEY_BACKUP_TG_OPEN = "backup_periodic_tg_open"
|
||||
const val KEY_BACKUP_TG_TEST = "backup_periodic_tg_test"
|
||||
const val KEY_CLEAR_MANGA_DATA = "manga_data_clear"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<string name="acra_password" translatable="false">kgpuhoNJpSsQDCwu</string>
|
||||
<string name="sync_authority_history" translatable="false">org.koitharu.kotatsu.history</string>
|
||||
<string name="sync_authority_favourites" translatable="false">org.koitharu.kotatsu.favourites</string>
|
||||
<string name="tg_backup_bot_token" translatable="false">7455491254:AAHq5AJmizJJpVqFgx16pEAO4g0AX8V6NTY</string>
|
||||
<string name="tg_backup_bot_name" translatable="false">kotatsu_backup_bot</string>
|
||||
<string name="discord_app_id" translatable="false">1395464028611940393</string>
|
||||
<string name="app_icon_url" translatable="false">https://raw.githubusercontent.com/KotatsuApp/Kotatsu/refs/heads/devel/metadata/en-US/icon.png</string>
|
||||
|
||||
@@ -878,4 +878,5 @@
|
||||
<string name="manga_restricted_description">This manga is not available to read in this source. Try searching for it in other sources or opening it in a browser for more information</string>
|
||||
<string name="no_chapters_in_manga">This manga does not contain any chapters</string>
|
||||
<string name="chapters_load_failed">Failed to load chapter list</string>
|
||||
<string name="telegram_integration">Telegram integration</string>
|
||||
</resources>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<androidx.preference.PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:title="@string/periodic_backups">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
@@ -48,31 +49,39 @@
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
app:isPreferenceVisible="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:dependency="backup_periodic"
|
||||
android:key="backup_periodic_tg_enabled"
|
||||
android:title="@string/send_backups_telegram"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
<EditTextPreference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:inputType="text"
|
||||
android:key="backup_periodic_tg_chat_id"
|
||||
android:title="@string/telegram_chat_id" />
|
||||
|
||||
<Preference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:key="backup_periodic_tg_open"
|
||||
android:persistent="false"
|
||||
android:summary="@string/open_telegram_bot_summary"
|
||||
android:title="@string/open_telegram_bot" />
|
||||
|
||||
<Preference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:key="backup_periodic_tg_test"
|
||||
android:persistent="false"
|
||||
android:title="@string/test_connection" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/telegram_integration"
|
||||
app:isPreferenceVisible="false"
|
||||
android:key="backup_periodic_tg"
|
||||
tools:isPreferenceVisible="true">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:dependency="backup_periodic"
|
||||
android:key="backup_periodic_tg_enabled"
|
||||
android:title="@string/send_backups_telegram"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
<EditTextPreference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:inputType="text"
|
||||
android:key="backup_periodic_tg_chat_id"
|
||||
android:title="@string/telegram_chat_id" />
|
||||
|
||||
<Preference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:key="backup_periodic_tg_open"
|
||||
android:persistent="false"
|
||||
android:summary="@string/open_telegram_bot_summary"
|
||||
android:title="@string/open_telegram_bot" />
|
||||
|
||||
<Preference
|
||||
android:dependency="backup_periodic_tg_enabled"
|
||||
android:key="backup_periodic_tg_test"
|
||||
android:persistent="false"
|
||||
android:title="@string/test_connection" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
||||
@@ -34,7 +34,7 @@ material = "1.14.0-alpha03"
|
||||
moshi = "1.15.2"
|
||||
okhttp = "4.12.0"
|
||||
okio = "3.12.0"
|
||||
parsers = "a83baf4c12"
|
||||
parsers = "74d0951d3d"
|
||||
preference = "1.2.1"
|
||||
recyclerview = "1.4.0"
|
||||
room = "2.7.2"
|
||||
|
||||
Reference in New Issue
Block a user