Upgraded few dependencies. * Upgraded kotlin to to make it compatible with gradle . * Upgraded dagger to to make it compatible with gradle . * Removed from project since it is not maintained from 2020 and new gradle is not compatible with this library, so we have changed the it with binding.

This commit is contained in:
MohitMaliFtechiz 2023-11-23 18:43:33 +05:30 committed by Kelson
parent 2a9bbe71b3
commit 8c522daa07
6 changed files with 134 additions and 133 deletions

View File

@ -12,7 +12,7 @@ repositories {
dependencies { dependencies {
implementation("com.android.tools.build:gradle:8.1.3") implementation("com.android.tools.build:gradle:8.1.3")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
implementation("org.jacoco:org.jacoco.core:0.8.8") implementation("org.jacoco:org.jacoco.core:0.8.8")
implementation("org.jlleitschuh.gradle:ktlint-gradle:10.3.0") implementation("org.jlleitschuh.gradle:ktlint-gradle:10.3.0")
implementation("com.google.apis:google-api-services-androidpublisher:v3-rev20230406-2.0.0") { implementation("com.google.apis:google-api-services-androidpublisher:v3-rev20230406-2.0.0") {

View File

@ -144,23 +144,6 @@ object Libs {
const val dagger_compiler: String = "com.google.dagger:dagger-compiler:" + const val dagger_compiler: String = "com.google.dagger:dagger-compiler:" +
Versions.com_google_dagger Versions.com_google_dagger
/**
* https://github.com/JakeWharton/butterknife/
*/
const val butterknife: String = "com.jakewharton:butterknife:" + Versions.com_jakewharton
/**
* https://github.com/JakeWharton/butterknife/
*/
const val butterknife_compiler: String = "com.jakewharton:butterknife-compiler:" +
Versions.com_jakewharton
/**
* https://github.com/JakeWharton/butterknife/
*/
const val butterknife_gradle_plugin: String = "com.jakewharton:butterknife-gradle-plugin:" +
Versions.com_jakewharton
/** /**
* https://developer.android.com/testing * https://developer.android.com/testing
*/ */

View File

@ -22,13 +22,13 @@ object Versions {
const val com_squareup_okhttp3: String = "4.10.0" const val com_squareup_okhttp3: String = "4.10.0"
const val org_jetbrains_kotlin: String = "1.7.0" const val org_jetbrains_kotlin: String = "1.9.20"
const val androidx_navigation: String = "2.5.3" const val androidx_navigation: String = "2.5.3"
const val navigation_ui_ktx: String = "2.4.1" const val navigation_ui_ktx: String = "2.4.1"
const val com_google_dagger: String = "2.42" const val com_google_dagger: String = "2.48.1"
const val com_jakewharton: String = "10.2.3" const val com_jakewharton: String = "10.2.3"

View File

@ -217,8 +217,6 @@ class AllProjectConfigurer {
implementation(Libs.core_ktx) implementation(Libs.core_ktx)
implementation(Libs.fragment_ktx) implementation(Libs.fragment_ktx)
implementation(Libs.collection_ktx) implementation(Libs.collection_ktx)
implementation(Libs.butterknife)
kapt(Libs.butterknife_compiler)
implementation(Libs.rxandroid) implementation(Libs.rxandroid)
implementation(Libs.rxjava) implementation(Libs.rxjava)
implementation(Libs.preference_ktx) implementation(Libs.preference_ktx)

View File

@ -18,10 +18,7 @@
package org.kiwix.kiwixmobile.core.base package org.kiwix.kiwixmobile.core.base
import android.os.Bundle import android.os.Bundle
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import butterknife.ButterKnife
import butterknife.Unbinder
import org.kiwix.kiwixmobile.core.utils.LanguageUtils import org.kiwix.kiwixmobile.core.utils.LanguageUtils
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import javax.inject.Inject import javax.inject.Inject
@ -31,20 +28,8 @@ open class BaseActivity : AppCompatActivity() {
@Inject @Inject
lateinit var sharedPreferenceUtil: SharedPreferenceUtil lateinit var sharedPreferenceUtil: SharedPreferenceUtil
private var unbinder: Unbinder? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil) LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil)
} }
override fun setContentView(@LayoutRes layoutResID: Int) {
super.setContentView(layoutResID)
unbinder = ButterKnife.bind(this)
}
override fun onDestroy() {
super.onDestroy()
unbinder?.unbind()
}
} }

View File

@ -81,11 +81,6 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
import butterknife.BindView
import butterknife.ButterKnife
import butterknife.OnClick
import butterknife.OnLongClick
import butterknife.Unbinder
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.bottomappbar.BottomAppBar
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
@ -100,11 +95,11 @@ import org.json.JSONException
import org.kiwix.kiwixmobile.core.BuildConfig import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.DarkModeConfig import org.kiwix.kiwixmobile.core.DarkModeConfig
import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.R2
import org.kiwix.kiwixmobile.core.StorageObserver import org.kiwix.kiwixmobile.core.StorageObserver
import org.kiwix.kiwixmobile.core.base.BaseFragment import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks
import org.kiwix.kiwixmobile.core.databinding.FragmentReaderBinding
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.consumeObservable import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.consumeObservable
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.hasNotificationPermission import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.hasNotificationPermission
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.observeNavigationResult import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.observeNavigationResult
@ -183,55 +178,50 @@ abstract class CoreReaderFragment :
NavigationHistoryClickListener { NavigationHistoryClickListener {
protected val webViewList: MutableList<KiwixWebView> = ArrayList() protected val webViewList: MutableList<KiwixWebView> = ArrayList()
private val webUrlsProcessor = BehaviorProcessor.create<String>() private val webUrlsProcessor = BehaviorProcessor.create<String>()
private var fragmentReaderBinding: FragmentReaderBinding? = null
@JvmField val toolbar: Toolbar? by lazy {
@BindView(R2.id.toolbar) fragmentReaderBinding?.root?.findViewById(R.id.toolbar)
var toolbar: Toolbar? = null }
val toolbarContainer: AppBarLayout? by lazy {
fragmentReaderBinding?.root?.findViewById(R.id.fragment_main_app_bar)
}
val progressBar: ContentLoadingProgressBar? by lazy {
fragmentReaderBinding?.root?.findViewById(R.id.main_fragment_progress_view)
}
@JvmField val drawerLayout: DrawerLayout? by lazy {
@BindView(R2.id.toolbarWithSearchPlaceholder) fragmentReaderBinding?.navigationFragmentMainDrawerLayout
var toolbarWithSearchPlaceholder: ConstraintLayout? = null }
@JvmField
@BindView(R2.id.fragment_main_app_bar)
var toolbarContainer: AppBarLayout? = null
@JvmField
@BindView(R2.id.main_fragment_progress_view)
var progressBar: ContentLoadingProgressBar? = null
@JvmField
@BindView(R2.id.navigation_fragment_main_drawer_layout)
var drawerLayout: DrawerLayout? = null
protected var tableDrawerRightContainer: NavigationView? = null protected var tableDrawerRightContainer: NavigationView? = null
@JvmField val contentFrame: FrameLayout? by lazy {
@BindView(R2.id.activity_main_content_frame) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_content_frame)
var contentFrame: FrameLayout? = null }
@JvmField val bottomToolbar: BottomAppBar? by lazy {
@BindView(R2.id.bottom_toolbar) fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar)
var bottomToolbar: BottomAppBar? = null }
@JvmField val tabSwitcherRoot: View? by lazy {
@BindView(R2.id.activity_main_tab_switcher) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_tab_switcher)
var tabSwitcherRoot: View? = null }
@JvmField val closeAllTabsButton: FloatingActionButton? by lazy {
@BindView(R2.id.tab_switcher_close_all_tabs) fragmentReaderBinding?.root?.findViewById(R.id.tab_switcher_close_all_tabs)
var closeAllTabsButton: FloatingActionButton? = null }
@JvmField val videoView: ViewGroup? by lazy {
@BindView(R2.id.fullscreen_video_container) fragmentReaderBinding?.fullscreenVideoContainer
var videoView: ViewGroup? = null }
@JvmField val noOpenBookButton: Button? by lazy {
@BindView(R2.id.go_to_library_button_no_open_book) fragmentReaderBinding?.goToLibraryButtonNoOpenBook
var noOpenBookButton: Button? = null }
@JvmField val activityMainRoot: View? by lazy {
@BindView(R2.id.activity_main_root) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_root)
var activityMainRoot: View? = null }
@JvmField @JvmField
@Inject @Inject
@ -265,49 +255,61 @@ abstract class CoreReaderFragment :
protected var actionBar: ActionBar? = null protected var actionBar: ActionBar? = null
protected var mainMenu: MainMenu? = null protected var mainMenu: MainMenu? = null
@JvmField val toolbarWithSearchPlaceholder: ConstraintLayout? by lazy {
@BindView(R2.id.activity_main_back_to_top_fab) fragmentReaderBinding?.root?.findViewById(R.id.toolbarWithSearchPlaceholder)
var backToTopButton: FloatingActionButton? = null }
@JvmField val backToTopButton: FloatingActionButton? by lazy {
@BindView(R2.id.activity_main_button_stop_tts) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_back_to_top_fab)
var stopTTSButton: Button? = null }
@JvmField private val stopTTSButton: Button? by lazy {
@BindView(R2.id.activity_main_button_pause_tts) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_button_stop_tts)
var pauseTTSButton: Button? = null }
@JvmField val pauseTTSButton: Button? by lazy {
@BindView(R2.id.activity_main_tts_controls) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_button_pause_tts)
var ttsControls: Group? = null }
@JvmField val ttsControls: Group? by lazy {
@BindView(R2.id.activity_main_fullscreen_button) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_tts_controls)
var exitFullscreenButton: ImageButton? = null }
@JvmField private val exitFullscreenButton: ImageButton? by lazy {
@BindView(R2.id.bottom_toolbar_bookmark) fragmentReaderBinding?.root?.findViewById(R.id.activity_main_fullscreen_button)
var bottomToolbarBookmark: ImageView? = null }
@JvmField private val bottomToolbarBookmark: ImageView? by lazy {
@BindView(R2.id.bottom_toolbar_arrow_back) fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar_bookmark)
var bottomToolbarArrowBack: ImageView? = null }
@JvmField private val bottomToolbarArrowBack: ImageView? by lazy {
@BindView(R2.id.bottom_toolbar_arrow_forward) fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar_arrow_back)
var bottomToolbarArrowForward: ImageView? = null }
@JvmField private val bottomToolbarArrowForward: ImageView? by lazy {
@BindView(R2.id.tab_switcher_recycler_view) fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar_arrow_forward)
var tabRecyclerView: RecyclerView? = null }
@JvmField private val bottomToolbarHome: ImageView? by lazy {
@BindView(R2.id.snackbar_root) fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar_home)
var snackBarRoot: CoordinatorLayout? = null }
@JvmField private val tabRecyclerView: RecyclerView? by lazy {
@BindView(R2.id.no_open_book_text) fragmentReaderBinding?.root?.findViewById(R.id.tab_switcher_recycler_view)
var noOpenBookText: TextView? = null }
private val snackBarRoot: CoordinatorLayout? by lazy {
fragmentReaderBinding?.root?.findViewById(R.id.snackbar_root)
}
private val noOpenBookText: TextView? by lazy {
fragmentReaderBinding?.noOpenBookText
}
private val bottomToolbarToc: ImageView? by lazy {
fragmentReaderBinding?.root?.findViewById(R.id.bottom_toolbar_toc)
}
private var isFirstTimeMainPageLoaded = true private var isFirstTimeMainPageLoaded = true
@ -346,7 +348,6 @@ abstract class CoreReaderFragment :
private var tabCallback: ItemTouchHelper.Callback? = null private var tabCallback: ItemTouchHelper.Callback? = null
private var bookmarkingDisposable: Disposable? = null private var bookmarkingDisposable: Disposable? = null
private var isBookmarked = false private var isBookmarked = false
private var unbinder: Unbinder? = null
private lateinit var serviceConnection: ServiceConnection private lateinit var serviceConnection: ServiceConnection
private var readAloudService: ReadAloudService? = null private var readAloudService: ReadAloudService? = null
private var navigationHistoryList: MutableList<NavigationHistoryListItem> = ArrayList() private var navigationHistoryList: MutableList<NavigationHistoryListItem> = ArrayList()
@ -531,6 +532,53 @@ abstract class CoreReaderFragment :
toolbarWithSearchPlaceholder?.setOnClickListener { toolbarWithSearchPlaceholder?.setOnClickListener {
openSearch(searchString = "", isOpenedFromTabView = false, false) openSearch(searchString = "", isOpenedFromTabView = false, false)
} }
backToTopButton?.setOnClickListener {
backToTop()
}
stopTTSButton?.setOnClickListener {
stopTts()
}
pauseTTSButton?.setOnClickListener {
pauseTts()
}
exitFullscreenButton?.setOnClickListener {
closeFullScreen()
}
bottomToolbarBookmark?.apply {
setOnClickListener {
toggleBookmark()
}
setOnLongClickListener {
goToBookmarks()
}
}
bottomToolbarArrowBack?.apply {
setOnClickListener {
goBack()
}
setOnLongClickListener {
showBackwardHistory()
true
}
}
bottomToolbarArrowForward?.apply {
setOnClickListener {
goForward()
}
setOnLongClickListener {
showForwardHistory()
true
}
}
bottomToolbarToc?.setOnClickListener {
openToc()
}
closeAllTabsButton?.setOnClickListener {
closeAllTabs()
}
bottomToolbarHome?.setOnClickListener {
openMainPage()
}
} }
private fun initTabCallback() { private fun initTabCallback() {
@ -590,9 +638,8 @@ abstract class CoreReaderFragment :
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
val root = inflater.inflate(R.layout.fragment_reader, container, false) fragmentReaderBinding = FragmentReaderBinding.inflate(inflater, container, false)
unbinder = ButterKnife.bind(this, root) return fragmentReaderBinding?.root
return root
} }
private fun handleIntentExtras(intent: Intent) { private fun handleIntentExtras(intent: Intent) {
@ -840,19 +887,18 @@ abstract class CoreReaderFragment :
drawerLayout?.setDrawerLockMode(lockMode) drawerLayout?.setDrawerLockMode(lockMode)
} }
@OnClick(R2.id.bottom_toolbar_arrow_back) fun goBack() { fun goBack() {
if (getCurrentWebView()?.canGoBack() == true) { if (getCurrentWebView()?.canGoBack() == true) {
getCurrentWebView()?.goBack() getCurrentWebView()?.goBack()
} }
} }
@OnClick(R2.id.bottom_toolbar_arrow_forward) fun goForward() { fun goForward() {
if (getCurrentWebView()?.canGoForward() == true) { if (getCurrentWebView()?.canGoForward() == true) {
getCurrentWebView()?.goForward() getCurrentWebView()?.goForward()
} }
} }
@OnLongClick(R2.id.bottom_toolbar_arrow_back)
fun showBackwardHistory() { fun showBackwardHistory() {
if (getCurrentWebView()?.canGoBack() == true) { if (getCurrentWebView()?.canGoBack() == true) {
getCurrentWebView()?.copyBackForwardList()?.let { historyList -> getCurrentWebView()?.copyBackForwardList()?.let { historyList ->
@ -868,7 +914,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnLongClick(R2.id.bottom_toolbar_arrow_forward)
fun showForwardHistory() { fun showForwardHistory() {
if (getCurrentWebView()?.canGoForward() == true) { if (getCurrentWebView()?.canGoForward() == true) {
getCurrentWebView()?.copyBackForwardList()?.let { historyList -> getCurrentWebView()?.copyBackForwardList()?.let { historyList ->
@ -945,7 +990,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnClick(R2.id.bottom_toolbar_toc)
fun openToc() { fun openToc() {
drawerLayout?.openDrawer(GravityCompat.END) drawerLayout?.openDrawer(GravityCompat.END)
} }
@ -1112,7 +1156,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnClick(R2.id.activity_main_button_pause_tts)
fun pauseTts() { fun pauseTts() {
if (tts?.currentTTSTask == null) { if (tts?.currentTTSTask == null) {
tts?.stop() tts?.stop()
@ -1132,7 +1175,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnClick(R2.id.activity_main_button_stop_tts)
fun stopTts() { fun stopTts() {
tts?.stop() tts?.stop()
setActionAndStartTTSService(ACTION_STOP_TTS) setActionAndStartTTSService(ACTION_STOP_TTS)
@ -1163,7 +1205,6 @@ abstract class CoreReaderFragment :
tabRecyclerView?.adapter = null tabRecyclerView?.adapter = null
tableDrawerRight?.adapter = null tableDrawerRight?.adapter = null
tableDrawerAdapter = null tableDrawerAdapter = null
unbinder?.unbind()
webViewList.clear() webViewList.clear()
tempWebViewListForUndo.clear() tempWebViewListForUndo.clear()
// create a base Activity class that class this. // create a base Activity class that class this.
@ -1514,7 +1555,6 @@ abstract class CoreReaderFragment :
return isPermissionGranted return isPermissionGranted
} }
@OnLongClick(R2.id.bottom_toolbar_bookmark)
fun goToBookmarks(): Boolean { fun goToBookmarks(): Boolean {
val parentActivity = requireActivity() as CoreMainActivity val parentActivity = requireActivity() as CoreMainActivity
parentActivity.navigate(parentActivity.bookmarksFragmentResId) parentActivity.navigate(parentActivity.bookmarksFragmentResId)
@ -1541,7 +1581,6 @@ abstract class CoreReaderFragment :
} }
@Suppress("MagicNumber") @Suppress("MagicNumber")
@OnClick(R2.id.activity_main_fullscreen_button)
open fun closeFullScreen() { open fun closeFullScreen() {
sharedPreferenceUtil?.putPrefFullScreen(false) sharedPreferenceUtil?.putPrefFullScreen(false)
toolbarContainer?.visibility = View.VISIBLE toolbarContainer?.visibility = View.VISIBLE
@ -1699,7 +1738,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnClick(R2.id.tab_switcher_close_all_tabs)
fun closeAllTabs() { fun closeAllTabs() {
onReadAloudStop() onReadAloudStop()
closeAllTabsButton?.apply { closeAllTabsButton?.apply {
@ -1769,7 +1807,6 @@ abstract class CoreReaderFragment :
} }
@Suppress("NestedBlockDepth") @Suppress("NestedBlockDepth")
@OnClick(R2.id.bottom_toolbar_bookmark)
fun toggleBookmark() { fun toggleBookmark() {
try { try {
getCurrentWebView()?.url?.let { articleUrl -> getCurrentWebView()?.url?.let { articleUrl ->
@ -1971,7 +2008,6 @@ abstract class CoreReaderFragment :
openArticle(articleUrl) openArticle(articleUrl)
} }
@OnClick(R2.id.bottom_toolbar_home)
fun openMainPage() { fun openMainPage() {
val articleUrl = zimReaderContainer?.mainPage val articleUrl = zimReaderContainer?.mainPage
openArticle(articleUrl) openArticle(articleUrl)
@ -1983,7 +2019,6 @@ abstract class CoreReaderFragment :
} }
} }
@OnClick(R2.id.activity_main_back_to_top_fab)
fun backToTop() { fun backToTop() {
getCurrentWebView()?.pageUp(true) getCurrentWebView()?.pageUp(true)
} }