Fixed: Lint Issue - Unconditional Logging.

* Re-enabled the `LogConditional` lint check.
* Introduced a `Log` class that exclusively handles logging operations in the debug variant.
* Removed unnecessary `if (BuildConfig.DEBUG)` conditions from the project.
This commit is contained in:
MohitMaliFtechiz 2024-02-27 16:50:41 +05:30
parent fd20568841
commit 8828a8b917
45 changed files with 160 additions and 101 deletions

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile package org.kiwix.kiwixmobile
import android.Manifest import android.Manifest
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso
import androidx.test.espresso.IdlingPolicies import androidx.test.espresso.IdlingPolicies

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.download package org.kiwix.kiwixmobile.download
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.doesNotExist

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.initial.download package org.kiwix.kiwixmobile.initial.download
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.doesNotExist

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.nav.destination.library package org.kiwix.kiwixmobile.nav.destination.library
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.click

View File

@ -24,7 +24,7 @@ import android.content.pm.PackageManager
import android.graphics.Bitmap import android.graphics.Bitmap
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.test.core.app.canTakeScreenshot import androidx.test.core.app.canTakeScreenshot

View File

@ -17,7 +17,7 @@
*/ */
package org.kiwix.kiwixmobile.utils package org.kiwix.kiwixmobile.utils
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso
import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.webserver package org.kiwix.kiwixmobile.webserver
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches

View File

@ -19,10 +19,10 @@ package org.kiwix.kiwixmobile.intro
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.animation.Interpolator import android.view.animation.Interpolator
import android.widget.Scroller import android.widget.Scroller
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import org.kiwix.kiwixmobile.core.utils.files.Log
/** /**
* A custom implementation of [ViewPager] to decrease the speed of auto-scroll animation * A custom implementation of [ViewPager] to decrease the speed of auto-scroll animation

View File

@ -36,7 +36,7 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.provider.Settings import android.provider.Settings
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater

View File

@ -18,11 +18,10 @@
package org.kiwix.kiwixmobile.localFileTransfer package org.kiwix.kiwixmobile.localFileTransfer
import android.net.wifi.p2p.WifiP2pInfo import android.net.wifi.p2p.WifiP2pInfo
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.kiwix.kiwixmobile.core.BuildConfig
import java.io.InputStream import java.io.InputStream
import java.io.ObjectInputStream import java.io.ObjectInputStream
import java.io.ObjectOutputStream import java.io.ObjectOutputStream
@ -46,14 +45,14 @@ import java.net.Socket
abstract class PeerGroupHandshake(private var groupInfo: WifiP2pInfo) { abstract class PeerGroupHandshake(private var groupInfo: WifiP2pInfo) {
private val HANDSHAKE_MESSAGE = "Request Kiwix File Sharing" private val HANDSHAKE_MESSAGE = "Request Kiwix File Sharing"
suspend fun handshake(): InetAddress? = withContext(Dispatchers.IO) { suspend fun handshake(): InetAddress? = withContext(Dispatchers.IO) {
if (BuildConfig.DEBUG) { Log.d(TAG, "Handshake in progress")
Log.d(TAG, "Handshake in progress")
}
when { when {
groupInfo.groupFormed && groupInfo.isGroupOwner && isActive -> groupInfo.groupFormed && groupInfo.isGroupOwner && isActive ->
readHandshakeAndExchangeMetaData() readHandshakeAndExchangeMetaData()
groupInfo.groupFormed && isActive -> // && !groupInfo.isGroupOwner groupInfo.groupFormed && isActive -> // && !groupInfo.isGroupOwner
writeHandshakeAndExchangeMetaData() writeHandshakeAndExchangeMetaData()
else -> null else -> null
} }
} }
@ -92,9 +91,7 @@ abstract class PeerGroupHandshake(private var groupInfo: WifiP2pInfo) {
// Verify that the peer trying to communicate is a kiwix app intending to transfer files // Verify that the peer trying to communicate is a kiwix app intending to transfer files
if (isKiwixHandshake(kiwixHandShakeMessage)) { if (isKiwixHandshake(kiwixHandShakeMessage)) {
if (BuildConfig.DEBUG) { Log.d(TAG, "Client IP address: " + server.inetAddress)
Log.d(TAG, "Client IP address: " + server.inetAddress)
}
exchangeFileTransferMetadata(server.getInputStream(), server.getOutputStream()) exchangeFileTransferMetadata(server.getInputStream(), server.getOutputStream())
server.inetAddress server.inetAddress
} else { } else {

View File

@ -17,11 +17,10 @@
*/ */
package org.kiwix.kiwixmobile.localFileTransfer package org.kiwix.kiwixmobile.localFileTransfer
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.localFileTransfer.WifiDirectManager.Companion.copyToOutputStream import org.kiwix.kiwixmobile.localFileTransfer.WifiDirectManager.Companion.copyToOutputStream
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@ -47,15 +46,13 @@ internal class ReceiverDevice(private val wifiDirectManager: WifiDirectManager)
val zimStorageRootPath = wifiDirectManager.zimStorageRootPath val zimStorageRootPath = wifiDirectManager.zimStorageRootPath
val fileItems = wifiDirectManager.getFilesForTransfer() val fileItems = wifiDirectManager.getFilesForTransfer()
var isTransferErrorFree = true var isTransferErrorFree = true
if (BuildConfig.DEBUG) Log.d(TAG, "Expecting " + fileItems.size + " files") Log.d(TAG, "Expecting " + fileItems.size + " files")
fileItems.asSequence() fileItems.asSequence()
.takeWhile { isActive } .takeWhile { isActive }
.forEachIndexed { fileItemIndex, fileItem -> .forEachIndexed { fileItemIndex, fileItem ->
try { try {
serverSocket.accept().use { client -> serverSocket.accept().use { client ->
if (BuildConfig.DEBUG) { Log.d(TAG, "Sender device connected for ${fileItem.fileName}")
Log.d(TAG, "Sender device connected for ${fileItem.fileName}")
}
publishProgress(fileItemIndex, FileItem.FileStatus.SENDING) publishProgress(fileItemIndex, FileItem.FileStatus.SENDING)
val clientNoteFileLocation = File(zimStorageRootPath + fileItem.fileName) val clientNoteFileLocation = File(zimStorageRootPath + fileItem.fileName)
val dirs = File(clientNoteFileLocation.parent) val dirs = File(clientNoteFileLocation.parent)
@ -64,7 +61,7 @@ internal class ReceiverDevice(private val wifiDirectManager: WifiDirectManager)
isTransferErrorFree = false isTransferErrorFree = false
} }
val fileCreated = clientNoteFileLocation.createNewFile() val fileCreated = clientNoteFileLocation.createNewFile()
if (BuildConfig.DEBUG) Log.d(TAG, "File creation: $fileCreated") Log.d(TAG, "File creation: $fileCreated")
copyToOutputStream( copyToOutputStream(
client.getInputStream(), client.getInputStream(),
FileOutputStream(clientNoteFileLocation) FileOutputStream(clientNoteFileLocation)

View File

@ -19,8 +19,7 @@
package org.kiwix.kiwixmobile.localFileTransfer package org.kiwix.kiwixmobile.localFileTransfer
import android.net.wifi.p2p.WifiP2pInfo import android.net.wifi.p2p.WifiP2pInfo
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.BuildConfig
import java.io.InputStream import java.io.InputStream
import java.io.ObjectInputStream import java.io.ObjectInputStream
import java.io.OutputStream import java.io.OutputStream
@ -37,11 +36,11 @@ class ReceiverHandShake(private val wifiDirectManager: WifiDirectManager, groupI
ObjectInputStream(inputStream).use { objectInputStream -> ObjectInputStream(inputStream).use { objectInputStream ->
// Read the number of files // Read the number of files
(objectInputStream.readObject() as? Int)?.let { total -> (objectInputStream.readObject() as? Int)?.let { total ->
if (BuildConfig.DEBUG) Log.d(TAG, "Metadata: $total files") Log.d(TAG, "Metadata: $total files")
// Read names of each of those files, in order // Read names of each of those files, in order
val fileItems = (0 until total).mapNotNull { val fileItems = (0 until total).mapNotNull {
(objectInputStream.readObject() as? String)?.let { fileName -> (objectInputStream.readObject() as? String)?.let { fileName ->
if (BuildConfig.DEBUG) Log.d(TAG, "Expecting $fileName") Log.d(TAG, "Expecting $fileName")
FileItem(fileName = fileName) FileItem(fileName = fileName)
} }
} }

View File

@ -18,12 +18,11 @@
package org.kiwix.kiwixmobile.localFileTransfer package org.kiwix.kiwixmobile.localFileTransfer
import android.content.Context import android.content.Context
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.localFileTransfer.WifiDirectManager.Companion.copyToOutputStream import org.kiwix.kiwixmobile.localFileTransfer.WifiDirectManager.Companion.copyToOutputStream
import java.io.IOException import java.io.IOException
import java.net.InetAddress import java.net.InetAddress
@ -71,7 +70,7 @@ internal class SenderDevice(
val socketOutputStream = socket.getOutputStream() val socketOutputStream = socket.getOutputStream()
@Suppress("UnsafeCallOnNullableType") @Suppress("UnsafeCallOnNullableType")
copyToOutputStream(fileInputStream!!, socketOutputStream) copyToOutputStream(fileInputStream!!, socketOutputStream)
if (BuildConfig.DEBUG) Log.d(TAG, "Sender: Data written") Log.d(TAG, "Sender: Data written")
publishProgress(fileIndex, FileItem.FileStatus.SENT) publishProgress(fileIndex, FileItem.FileStatus.SENT)
} }
} }

View File

@ -19,7 +19,7 @@
package org.kiwix.kiwixmobile.localFileTransfer package org.kiwix.kiwixmobile.localFileTransfer
import android.net.wifi.p2p.WifiP2pInfo import android.net.wifi.p2p.WifiP2pInfo
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import java.io.InputStream import java.io.InputStream
import java.io.ObjectOutputStream import java.io.ObjectOutputStream
import java.io.OutputStream import java.io.OutputStream

View File

@ -35,12 +35,11 @@ import android.net.wifi.p2p.WifiP2pManager.PeerListListener
import android.os.Build.VERSION import android.os.Build.VERSION
import android.os.Build.VERSION_CODES import android.os.Build.VERSION_CODES
import android.os.Looper.getMainLooper import android.os.Looper.getMainLooper
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.widget.Toast import android.widget.Toast
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.kiwix.kiwixmobile.R import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.extensions.toast import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
@ -219,9 +218,7 @@ class WifiDirectManager @Inject constructor(
} }
private fun performHandshakeWith(groupInfo: WifiP2pInfo) { private fun performHandshakeWith(groupInfo: WifiP2pInfo) {
if (BuildConfig.DEBUG) { Log.d(TAG, "Starting handshake")
Log.d(TAG, "Starting handshake")
}
lifecycleCoroutineScope.launch { lifecycleCoroutineScope.launch {
val peerGroupHandshake = if (isFileSender) val peerGroupHandshake = if (isFileSender)
SenderHandShake(this@WifiDirectManager, groupInfo) SenderHandShake(this@WifiDirectManager, groupInfo)
@ -232,9 +229,7 @@ class WifiDirectManager @Inject constructor(
if (inetAddress != null) { if (inetAddress != null) {
startFileTransfer(groupInfo, inetAddress) startFileTransfer(groupInfo, inetAddress)
} else { } else {
if (BuildConfig.DEBUG) { Log.d(TAG, "InetAddress is null")
Log.d(TAG, "InetAddress is null")
}
onFileTransferAsyncTaskComplete(false) onFileTransferAsyncTaskComplete(false)
context.toast(R.string.connection_refused) context.toast(R.string.connection_refused)
} }
@ -262,17 +257,13 @@ class WifiDirectManager @Inject constructor(
val senderDevice = SenderDevice(context, this, fileReceiverDeviceAddress) val senderDevice = SenderDevice(context, this, fileReceiverDeviceAddress)
val isFileSendSuccessfully = senderDevice.send(filesForTransfer) val isFileSendSuccessfully = senderDevice.send(filesForTransfer)
onFileTransferAsyncTaskComplete(isFileSendSuccessfully) onFileTransferAsyncTaskComplete(isFileSendSuccessfully)
if (BuildConfig.DEBUG) { Log.d(TAG, "SenderDevice completed $isFileSendSuccessfully")
Log.d(TAG, "SenderDevice completed $isFileSendSuccessfully")
}
} else { } else {
callbacks?.onFilesForTransferAvailable(filesForTransfer) callbacks?.onFilesForTransferAvailable(filesForTransfer)
val receiverDevice = ReceiverDevice(this) val receiverDevice = ReceiverDevice(this)
val isReceivedFileSuccessFully = receiverDevice.receive() val isReceivedFileSuccessFully = receiverDevice.receive()
onFileTransferAsyncTaskComplete(isReceivedFileSuccessFully) onFileTransferAsyncTaskComplete(isReceivedFileSuccessFully)
if (BuildConfig.DEBUG) { Log.d(TAG, "ReceiverDevice completed $isReceivedFileSuccessFully")
Log.d(TAG, "ReceiverDevice completed $isReceivedFileSuccessFully")
}
} }
} }
} }
@ -360,7 +351,7 @@ class WifiDirectManager @Inject constructor(
} }
@JvmStatic fun getDeviceStatus(status: Int): String { @JvmStatic fun getDeviceStatus(status: Int): String {
if (BuildConfig.DEBUG) Log.d(TAG, "Peer Status: $status") Log.d(TAG, "Peer Status: $status")
return when (status) { return when (status) {
WifiP2pDevice.AVAILABLE -> "Available" WifiP2pDevice.AVAILABLE -> "Available"
WifiP2pDevice.INVITED -> "Invited" WifiP2pDevice.INVITED -> "Invited"

View File

@ -24,7 +24,6 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.View import android.view.View
@ -57,6 +56,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.TAG_CURRENT_FILE import org.kiwix.kiwixmobile.core.utils.TAG_CURRENT_FILE
import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX
import org.kiwix.kiwixmobile.core.utils.files.FileUtils import org.kiwix.kiwixmobile.core.utils.files.FileUtils
import org.kiwix.kiwixmobile.core.utils.files.Log
import java.io.File import java.io.File
private const val HIDE_TAB_SWITCHER_DELAY: Long = 300 private const val HIDE_TAB_SWITCHER_DELAY: Long = 300

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.zimManager package org.kiwix.kiwixmobile.zimManager
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CANNOT_WRITE_4GB import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CANNOT_WRITE_4GB
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CAN_WRITE_4GB import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CAN_WRITE_4GB
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.INCONCLUSIVE import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.INCONCLUSIVE

View File

@ -127,7 +127,6 @@ class AllProjectConfigurer {
add("LockedOrientationActivity") add("LockedOrientationActivity")
// TODO stop ignoring below this // TODO stop ignoring below this
add("LabelFor") add("LabelFor")
add("LogConditional")
add("ConvertToWebp") add("ConvertToWebp")
add("UnknownNullness") add("UnknownNullness")
add("SelectableText") add("SelectableText")

View File

@ -18,9 +18,9 @@
package org.kiwix.kiwixmobile.core package org.kiwix.kiwixmobile.core
import android.content.Context import android.content.Context
import android.util.Log
import org.kiwix.libkiwix.JNIKiwix import org.kiwix.libkiwix.JNIKiwix
import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX
import org.kiwix.kiwixmobile.core.utils.files.Log
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import javax.inject.Inject import javax.inject.Inject

View File

@ -20,7 +20,7 @@ package org.kiwix.kiwixmobile.core.dao
import android.os.Build import android.os.Build
import android.util.Base64 import android.util.Base64
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import io.reactivex.BackpressureStrategy import io.reactivex.BackpressureStrategy
import io.reactivex.BackpressureStrategy.LATEST import io.reactivex.BackpressureStrategy.LATEST
import io.reactivex.Flowable import io.reactivex.Flowable
@ -29,7 +29,6 @@ import io.reactivex.subjects.BehaviorSubject
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.extensions.isFileExist import org.kiwix.kiwixmobile.core.extensions.isFileExist
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem
@ -152,15 +151,13 @@ class LibkiwixBookmarks @Inject constructor(
library.addBook(libKiwixBook).also { library.addBook(libKiwixBook).also {
// now library has changed so update our library list. // now library has changed so update our library list.
libraryBooksList = library.booksIds.toList() libraryBooksList = library.booksIds.toList()
if (BuildConfig.DEBUG) { Log.d(
Log.d( TAG,
TAG, "Added Book to Library:\n" +
"Added Book to Library:\n" + "ZIM File Path: ${book.path}\n" +
"ZIM File Path: ${book.path}\n" + "Book ID: ${book.id}\n" +
"Book ID: ${book.id}\n" + "Book Title: ${book.title}"
"Book Title: ${book.title}" )
)
}
} }
} }
} }
@ -220,14 +217,12 @@ class LibkiwixBookmarks @Inject constructor(
val book = if (isBookAlreadyExistInLibrary(bookmark.bookId)) { val book = if (isBookAlreadyExistInLibrary(bookmark.bookId)) {
library.getBookById(bookmark.bookId) library.getBookById(bookmark.bookId)
} else { } else {
if (BuildConfig.DEBUG) { Log.d(
Log.d( TAG,
TAG, "Library does not contain the book for this bookmark:\n" +
"Library does not contain the book for this bookmark:\n" + "Book Title: ${bookmark.bookTitle}\n" +
"Book Title: ${bookmark.bookTitle}\n" + "Bookmark URL: ${bookmark.url}"
"Bookmark URL: ${bookmark.url}" )
)
}
null null
} }

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.core.data.remote package org.kiwix.kiwixmobile.core.data.remote
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response

View File

@ -18,7 +18,7 @@
package org.kiwix.kiwixmobile.core.data.remote package org.kiwix.kiwixmobile.core.data.remote
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import io.objectbox.Box import io.objectbox.Box
import io.objectbox.BoxStore import io.objectbox.BoxStore
import io.objectbox.kotlin.boxFor import io.objectbox.kotlin.boxFor

View File

@ -25,7 +25,7 @@ import android.content.pm.PackageManager
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View

View File

@ -23,7 +23,7 @@ import android.text.Editable
import android.text.Selection import android.text.Selection
import android.text.Spannable import android.text.Spannable
import android.text.TextWatcher import android.text.TextWatcher
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem

View File

@ -40,7 +40,7 @@ import android.os.IBinder
import android.os.Looper import android.os.Looper
import android.provider.Settings import android.provider.Settings
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.ActionMode import android.view.ActionMode
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu

View File

@ -20,7 +20,7 @@ package org.kiwix.kiwixmobile.core.main
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import android.webkit.WebResourceError import android.webkit.WebResourceError
import android.webkit.WebResourceRequest import android.webkit.WebResourceRequest

View File

@ -31,7 +31,7 @@ import android.speech.tts.TextToSpeech.LANG_NOT_SUPPORTED
import android.speech.tts.TextToSpeech.QUEUE_ADD import android.speech.tts.TextToSpeech.QUEUE_ADD
import android.speech.tts.TextToSpeech.SUCCESS import android.speech.tts.TextToSpeech.SUCCESS
import android.speech.tts.UtteranceProgressListener import android.speech.tts.UtteranceProgressListener
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.webkit.JavascriptInterface import android.webkit.JavascriptInterface
import android.webkit.WebView import android.webkit.WebView
import android.widget.Toast import android.widget.Toast

View File

@ -24,7 +24,7 @@ import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.Message import android.os.Message
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.ContextMenu import android.view.ContextMenu
import android.view.ViewGroup import android.view.ViewGroup
import android.webkit.WebView import android.webkit.WebView

View File

@ -17,7 +17,7 @@
*/ */
package org.kiwix.kiwixmobile.core.main package org.kiwix.kiwixmobile.core.main
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.data.DataSource import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.di.ActivityScope import org.kiwix.kiwixmobile.core.di.ActivityScope

View File

@ -19,7 +19,7 @@ package org.kiwix.kiwixmobile.core.main
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.GestureDetector import android.view.GestureDetector
import android.view.GestureDetector.SimpleOnGestureListener import android.view.GestureDetector.SimpleOnGestureListener
import android.view.MotionEvent import android.view.MotionEvent

View File

@ -18,7 +18,7 @@ package org.kiwix.kiwixmobile.core.page.notes.viewmodel.effects
* *
*/ */
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import io.reactivex.processors.PublishProcessor import io.reactivex.processors.PublishProcessor
import org.kiwix.kiwixmobile.core.base.SideEffect import org.kiwix.kiwixmobile.core.base.SideEffect

View File

@ -22,7 +22,7 @@ import android.content.res.AssetFileDescriptor
import android.net.Uri import android.net.Uri
import android.os.ParcelFileDescriptor import android.os.ParcelFileDescriptor
import android.util.Base64 import android.util.Base64
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.core.net.toUri import androidx.core.net.toUri
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers

View File

@ -17,7 +17,7 @@
*/ */
package org.kiwix.kiwixmobile.core.settings package org.kiwix.kiwixmobile.core.settings
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.base.BasePresenter import org.kiwix.kiwixmobile.core.base.BasePresenter
import org.kiwix.kiwixmobile.core.data.DataSource import org.kiwix.kiwixmobile.core.data.DataSource

View File

@ -19,7 +19,7 @@ package org.kiwix.kiwixmobile.core.utils
import android.content.Context import android.content.Context
import android.net.ConnectivityManager import android.net.ConnectivityManager
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.isNetworkAvailable import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.isNetworkAvailable
import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.isWifi import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.isWifi

View File

@ -17,7 +17,7 @@
*/ */
package org.kiwix.kiwixmobile.core.utils package org.kiwix.kiwixmobile.core.utils
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import java.net.InetAddress import java.net.InetAddress
import java.net.NetworkInterface import java.net.NetworkInterface
import java.net.SocketException import java.net.SocketException

View File

@ -19,7 +19,6 @@
package org.kiwix.kiwixmobile.core.utils.files package org.kiwix.kiwixmobile.core.utils.files
import android.content.Context import android.content.Context
import android.util.Log
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.lang.System.currentTimeMillis import java.lang.System.currentTimeMillis

View File

@ -26,7 +26,6 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.provider.DocumentsContract import android.provider.DocumentsContract
import android.util.Log
import android.webkit.URLUtil import android.webkit.URLUtil
import android.widget.Toast import android.widget.Toast
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat

View File

@ -0,0 +1,89 @@
/*
* Kiwix Android
* Copyright (c) 2024 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.utils.files
import org.kiwix.kiwixmobile.core.BuildConfig
/**
* Helper class for logging that provides conditional logging for the debug variant.
*/
object Log {
/**
* Logs an error message with an optional throwable, but only in debug builds.
*
* @param tag The tag to identify the log.
* @param message The message to be logged.
* @param throwable An optional throwable to be logged.
*/
fun e(tag: String, message: String?, throwable: Throwable? = null) {
if (BuildConfig.DEBUG) {
android.util.Log.e(tag, message, throwable)
}
}
/**
* Logs a warning message with an optional throwable, but only in debug builds.
*
* @param tag The tag to identify the log.
* @param message The message to be logged.
* @param throwable An optional throwable to be logged.
*/
fun w(tag: String, message: String, throwable: Throwable? = null) {
if (BuildConfig.DEBUG) {
android.util.Log.w(tag, message, throwable)
}
}
/**
* Logs a debug message with an optional throwable, but only in debug builds.
*
* @param tag The tag to identify the log.
* @param message The message to be logged.
* @param throwable An optional throwable to be logged.
*/
fun d(tag: String, message: String, throwable: Throwable? = null) {
if (BuildConfig.DEBUG) {
android.util.Log.d(tag, message, throwable)
}
}
/**
* Logs an info message, but only in debug builds.
*
* @param tag The tag to identify the log.
* @param message The message to be logged.
*/
fun i(tag: String, message: String) {
if (BuildConfig.DEBUG) {
android.util.Log.i(tag, message)
}
}
/**
* Logs a verbose message, but only in debug builds.
*
* @param tag The tag to identify the log.
* @param message The message to be logged.
*/
fun v(tag: String?, message: String) {
if (BuildConfig.DEBUG) {
android.util.Log.v(tag, message)
}
}
}

View File

@ -19,7 +19,7 @@
package org.kiwix.kiwixmobile.core.webserver package org.kiwix.kiwixmobile.core.webserver
import android.content.Context import android.content.Context
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
import org.kiwix.kiwixmobile.core.utils.files.FileUtils.getDemoFilePathForCustomApp import org.kiwix.kiwixmobile.core.utils.files.FileUtils.getDemoFilePathForCustomApp
import org.kiwix.libkiwix.Book import org.kiwix.libkiwix.Book

View File

@ -17,7 +17,6 @@
*/ */
package org.kiwix.kiwixmobile.core.webserver package org.kiwix.kiwixmobile.core.webserver
import android.util.Log
import io.reactivex.Flowable import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
@ -27,6 +26,7 @@ import org.kiwix.kiwixmobile.core.utils.ServerUtils
import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIp import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIp
import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIpAddress import org.kiwix.kiwixmobile.core.utils.ServerUtils.getIpAddress
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.IpAddressCallbacks import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.IpAddressCallbacks
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.ServerStatus import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.ServerStatus
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit

View File

@ -30,7 +30,6 @@ import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.provider.Settings import android.provider.Settings
import android.text.method.LinkMovementMethod import android.text.method.LinkMovementMethod
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -39,7 +38,6 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.CoreApp.Companion.coreComponent import org.kiwix.kiwixmobile.core.CoreApp.Companion.coreComponent
import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseActivity import org.kiwix.kiwixmobile.core.base.BaseActivity
@ -58,6 +56,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog.StartServer import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog.StartServer
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_START_SERVER import org.kiwix.kiwixmobile.core.webserver.wifi_hotspot.HotspotService.Companion.ACTION_START_SERVER
@ -110,12 +109,8 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
.map { .map {
it.file.absolutePath it.file.absolutePath
} }
.also { .onEach { path ->
if (BuildConfig.DEBUG) { Log.v(tag, "ZIM PATH : $path")
it.forEach { path ->
Log.v(tag, "ZIM PATH : $path")
}
}
} }
as ArrayList<String> as ArrayList<String>
} }

View File

@ -17,7 +17,7 @@
*/ */
package org.kiwix.kiwixmobile.core.webserver package org.kiwix.kiwixmobile.core.webserver
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import io.reactivex.SingleObserver import io.reactivex.SingleObserver
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.base.BasePresenter import org.kiwix.kiwixmobile.core.base.BasePresenter

View File

@ -19,8 +19,8 @@
package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view
import android.content.Context import android.content.Context
import android.util.Log
import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.utils.files.Log
import java.text.DecimalFormat import java.text.DecimalFormat
import kotlin.math.log10 import kotlin.math.log10
import kotlin.math.pow import kotlin.math.pow

View File

@ -22,7 +22,7 @@ import android.content.Context
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import android.webkit.WebChromeClient import android.webkit.WebChromeClient
import android.webkit.WebView import android.webkit.WebView

View File

@ -21,8 +21,8 @@ package org.kiwix.kiwixmobile.custom.main
import android.content.Context import android.content.Context
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.AssetFileDescriptor import android.content.res.AssetFileDescriptor
import android.util.Log
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.custom.BuildConfig import org.kiwix.kiwixmobile.custom.BuildConfig
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasBothFiles import org.kiwix.kiwixmobile.custom.main.ValidationState.HasBothFiles
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasFile import org.kiwix.kiwixmobile.custom.main.ValidationState.HasFile