Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,24 @@ android {
jniLibs {
useLegacyPackaging = false
}
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt']
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

// Foundation modules
implementation project(':core')
implementation project(':common')
implementation project(':util')
implementation project(':stubs')

// Settings module
implementation project(':settings')

// AndroidX
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
Expand Down Expand Up @@ -182,6 +194,11 @@ dependencies {
implementation libs.play.services.gcm
implementation libs.play.services.drive
implementation libs.play.services.auth
implementation libs.google.api.client.android
implementation(libs.google.api.services.drive) {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.guava'
}

// Utilities
implementation libs.eventbus
Expand Down
11 changes: 11 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@
-keep class com.google.firebase.crashlytics.** { *; }
-dontwarn com.google.firebase.crashlytics.**


# Google API Client
-keep class com.google.api.** { *; }
-keep class com.google.api.services.drive.** { *; }
-dontwarn com.google.api.client.**
-dontwarn com.google.common.**

# Google Drive REST API
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
20 changes: 10 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute"
android:dataExtractionRules="@xml/data_extraction_rules">
<!-- <activity -->
<!-- android:name=".activity.settings.GoogleBackupActivity" -->
<!-- android:label="@string/title_activity_google_backup" -->
<!-- android:screenOrientation="fullUser" -->
<!-- android:theme="@style/DarkTheme_DarkSide"> -->
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
<!-- </activity> -->
<activity
android:name=".activity.settings.GoogleBackupActivity"
android:label="@string/title_activity_google_backup"
android:screenOrientation="fullUser"
android:theme="@style/DarkTheme_DarkSide" />
<activity
android:name=".activity.settings.AppSettingsActivity"
android:exported="false"
android:screenOrientation="fullUser"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
<!-- [START fcm_default_icon] -->
<!--
Set custom default icon. This is used when no icon is set for incoming notification messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.NotificationManagerCompat
import androidx.lifecycle.LifecycleObserver
import coil.ImageLoader
import coil.ImageLoaderFactory
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
import com.google.android.gms.security.ProviderInstaller
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
Expand All @@ -19,6 +21,7 @@ import io.github.gmathi.novellibrary.database.deleteWebPages
import io.github.gmathi.novellibrary.model.other.SelectorQuery
import io.github.gmathi.novellibrary.network.HostNames
import io.github.gmathi.novellibrary.network.MultiTrustManager
import io.github.gmathi.novellibrary.network.NetworkHelper
import io.github.gmathi.novellibrary.util.Constants
import io.github.gmathi.novellibrary.model.preference.DataCenter
import io.github.gmathi.novellibrary.util.Logs
Expand All @@ -37,7 +40,11 @@ import javax.net.ssl.HttpsURLConnection
import javax.net.ssl.SSLContext


open class NovelLibraryApplication : Application(), LifecycleObserver {
open class NovelLibraryApplication : Application(), LifecycleObserver, ImageLoaderFactory {

private val networkHelper: NetworkHelper by injectLazy()

override fun newImageLoader(): ImageLoader = networkHelper.coilImageLoader
companion object {
private const val TAG = "NovelLibraryApplication"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
package io.github.gmathi.novellibrary.activity

import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.appbar.AppBarLayout
import com.google.firebase.analytics.FirebaseAnalytics
import io.github.gmathi.novellibrary.database.DBHelper
import io.github.gmathi.novellibrary.model.preference.DataCenter
import io.github.gmathi.novellibrary.model.source.SourceManager
import io.github.gmathi.novellibrary.network.NetworkHelper
import io.github.gmathi.novellibrary.util.lang.LocaleManager
import io.github.gmathi.novellibrary.util.system.DataAccessor
import io.github.gmathi.novellibrary.util.view.applyTopSystemWindowInsetsPadding
import io.github.gmathi.novellibrary.util.view.extensions.applyTopSystemWindowInsetsPadding
import uy.kohesive.injekt.injectLazy


abstract class BaseActivity : AppCompatActivity(), DataAccessor {
abstract class BaseActivity : io.github.gmathi.novellibrary.core.activity.BaseActivity() {

override val firebaseAnalytics: FirebaseAnalytics by injectLazy()
override val dataCenter: DataCenter by injectLazy()
override val dbHelper: DBHelper by injectLazy()
override val sourceManager: SourceManager by injectLazy()
override val networkHelper: NetworkHelper by injectLazy()
override fun getContext(): Context? = this

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
override fun setupEdgeToEdge() {
// Enable edge-to-edge display
androidx.core.view.WindowCompat.setDecorFitsSystemWindows(window, false)
}

override fun onContentChanged() {
super.onContentChanged()
override fun applyWindowInsets() {
// Automatically apply window insets to AppBarLayout
applyWindowInsetsToAppBar()
}

override fun getLocaleContext(context: Context): Context {
return LocaleManager.updateContextLocale(context)
}

private fun applyWindowInsetsToAppBar() {
// Find AppBarLayout in the view hierarchy and apply top insets
val rootView = findViewById<ViewGroup>(android.R.id.content)
Expand All @@ -55,8 +53,4 @@ abstract class BaseActivity : AppCompatActivity(), DataAccessor {
}
}

override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleManager.updateContextLocale(newBase))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import io.github.gmathi.novellibrary.model.database.Novel
import io.github.gmathi.novellibrary.model.database.WebPage
import io.github.gmathi.novellibrary.model.other.ChapterActionModeEvent
import io.github.gmathi.novellibrary.model.other.DownloadWebPageEvent
import io.github.gmathi.novellibrary.util.R as UtilR
import io.github.gmathi.novellibrary.model.other.EventType
import io.github.gmathi.novellibrary.service.download.DownloadListener
import io.github.gmathi.novellibrary.service.download.DownloadNovelService
Expand Down Expand Up @@ -521,7 +522,7 @@ class ChaptersPagerActivity : BaseActivity(), ActionMode.Callback, DownloadListe

private fun showAlertDialog(title: String? = null, message: String? = null) {
MaterialDialog(this).show {
icon(R.drawable.ic_warning_white_vector)
icon(UtilR.drawable.ic_warning_white_vector)
if (title.isNullOrBlank())
title(R.string.alert)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package io.github.gmathi.novellibrary.activity

import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.ExtensionsPageListener
import io.github.gmathi.novellibrary.adapter.GenericFragmentStatePagerAdapter
import io.github.gmathi.novellibrary.databinding.ActivityExtensionsPagerBinding

class ExtensionsPagerActivity : AppCompatActivity() {
class ExtensionsPagerActivity : BaseActivity() {

private lateinit var binding: ActivityExtensionsPagerBinding

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
import com.tingyik90.snackprogressbar.SnackProgressBar
import com.tingyik90.snackprogressbar.SnackProgressBarManager
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.database.getNovelByUrl
import io.github.gmathi.novellibrary.database.insertNovel
import io.github.gmathi.novellibrary.databinding.ActivityImportLibraryBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.text.Html
import android.view.MenuItem
import android.view.View
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.databinding.ActivityMetaDataBinding
import io.github.gmathi.novellibrary.databinding.ListitemMetadataBinding
import io.github.gmathi.novellibrary.model.database.Novel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.afollestad.materialdialogs.lifecycle.lifecycleOwner
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.database.*
import io.github.gmathi.novellibrary.databinding.ActivityNovelDownloadsBinding
import io.github.gmathi.novellibrary.databinding.ListitemDownloadQueueOldBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.afollestad.materialdialogs.input.input
import com.afollestad.materialdialogs.lifecycle.lifecycleOwner
import com.google.firebase.analytics.ktx.logEvent
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.database.*
import io.github.gmathi.novellibrary.databinding.ActivityNovelSectionsBinding
import io.github.gmathi.novellibrary.databinding.ListitemNovelSectionBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.database.getNovel
import io.github.gmathi.novellibrary.database.getWebPage
import io.github.gmathi.novellibrary.databinding.ActivityTextToSpeechControlsBinding
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.github.gmathi.novellibrary.activity.settings

import androidx.work.WorkInfo.State
import androidx.work.WorkManager
import androidx.work.WorkRequest
import io.github.gmathi.novellibrary.settings.api.SettingsActivity
import io.github.gmathi.novellibrary.worker.oneTimeGoogleDriveBackupWorkRequest
import io.github.gmathi.novellibrary.worker.oneTimeGoogleDriveRestoreWorkRequest

/**
* App-module subclass of SettingsActivity.
*
* Only overrides backup/restore execution to enqueue WorkManager workers,
* which depend on app-module classes (DBHelper, DataCenter, notifications, etc.).
* All other Google Drive logic (sign-in, sign-out, backup info) is handled
* by the base SettingsActivity in the settings module.
*/
class AppSettingsActivity : SettingsActivity() {

override fun onExecuteGoogleDriveBackup(
simpleText: Boolean, database: Boolean, preferences: Boolean, files: Boolean
) {
val workRequest = oneTimeGoogleDriveBackupWorkRequest(
shouldBackupSimpleText = simpleText,
shouldBackupDatabase = database,
shouldBackupPreferences = preferences,
shouldBackupFiles = files
)
observeWork(workRequest)
}

override fun onExecuteGoogleDriveRestore(
simpleText: Boolean, database: Boolean, preferences: Boolean, files: Boolean
) {
val workRequest = oneTimeGoogleDriveRestoreWorkRequest(
shouldRestoreSimpleText = simpleText,
shouldRestoreDatabase = database,
shouldRestorePreferences = preferences,
shouldRestoreFiles = files
)
observeWork(workRequest)
}

private fun observeWork(workRequest: WorkRequest) {
val workManager = WorkManager.getInstance(applicationContext)
workManager.enqueue(workRequest)
val observable = workManager.getWorkInfoByIdLiveData(workRequest.id)
observable.observe(this) { info ->
if (info != null && info.state in arrayOf(State.SUCCEEDED, State.FAILED, State.CANCELLED)) {
observable.removeObservers(this)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import com.google.android.material.snackbar.Snackbar
import com.tingyik90.snackprogressbar.SnackProgressBar
import com.tingyik90.snackprogressbar.SnackProgressBarManager
import io.github.gmathi.novellibrary.R
import io.github.gmathi.novellibrary.common.R as CommonR
import io.github.gmathi.novellibrary.activity.BaseActivity
import io.github.gmathi.novellibrary.adapter.GenericAdapter
import io.github.gmathi.novellibrary.common.adapter.GenericAdapter
import io.github.gmathi.novellibrary.databinding.ActivitySettingsBinding
import io.github.gmathi.novellibrary.databinding.ListitemTitleSubtitleWidgetBinding
import io.github.gmathi.novellibrary.util.R as UtilR
import io.github.gmathi.novellibrary.common.databinding.ListitemTitleSubtitleWidgetBinding
import io.github.gmathi.novellibrary.util.Constants.WORK_KEY_RESULT
import io.github.gmathi.novellibrary.util.Utils
import io.github.gmathi.novellibrary.util.lang.launchIO
Expand Down Expand Up @@ -101,7 +103,7 @@ class BackupSettingsActivity : BaseActivity(), GenericAdapter.Listener<String> {
settingsItems = ArrayList(resources.getStringArray(R.array.backup_and_restore_titles_list).asList())
settingsItemsDescription = ArrayList(resources.getStringArray(R.array.backup_and_restore_subtitles_list).asList())
setBackupFrequencyDescription()
adapter = GenericAdapter(items = settingsItems, layoutResId = R.layout.listitem_title_subtitle_widget, listener = this)
adapter = GenericAdapter(items = settingsItems, layoutResId = CommonR.layout.listitem_title_subtitle_widget, listener = this)
binding.contentRecyclerView.recyclerView.setDefaults(adapter)
binding.contentRecyclerView.recyclerView.addItemDecoration(CustomDividerItemDecoration(this, DividerItemDecoration.VERTICAL))
binding.contentRecyclerView.swipeRefreshLayout.isEnabled = false
Expand Down Expand Up @@ -188,6 +190,10 @@ class BackupSettingsActivity : BaseActivity(), GenericAdapter.Listener<String> {
}.positiveButton(R.string.okay)
}
}

getString(R.string.google_drive_backup) -> {
startActivity(Intent(this, GoogleBackupActivity::class.java))
}
}
}

Expand All @@ -201,7 +207,7 @@ class BackupSettingsActivity : BaseActivity(), GenericAdapter.Listener<String> {
super.onDestroy()
}

private fun showDialog(title: String? = null, content: String? = null, @DrawableRes iconRes: Int = R.drawable.ic_warning_white_vector) {
private fun showDialog(title: String? = null, content: String? = null, @DrawableRes iconRes: Int = UtilR.drawable.ic_warning_white_vector) {
if (confirmDialog != null && confirmDialog!!.isShowing) confirmDialog!!.dismiss()

MaterialDialog(this).show {
Expand Down
Loading