aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/Application.kt5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt6
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt44
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.kt8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt12
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt20
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/ClipboardUtils.kt4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/auth/Authenticator.kt9
11 files changed, 70 insertions, 56 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/Application.kt b/app/src/main/java/com/zeapo/pwdstore/Application.kt
index b476dd45..166d2b3a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/Application.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/Application.kt
@@ -11,8 +11,9 @@ import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.Timber.DebugTree
+import com.github.ajalt.timberkt.Timber.plant
import com.haroldadmin.whatthestack.WhatTheStack
-import timber.log.Timber
@Suppress("Unused")
class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener {
@@ -20,7 +21,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
override fun onCreate() {
super.onCreate()
- Timber.plant(Timber.DebugTree())
+ plant(DebugTree())
if (BuildConfig.ENABLE_DEBUG_FEATURES) {
WhatTheStack(this).init()
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt b/app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt
index c7c5ee84..f24f3c07 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt
@@ -17,6 +17,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.content.getSystemService
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.d
import com.zeapo.pwdstore.utils.ClipboardUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -26,7 +27,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import timber.log.Timber
class ClipboardService : Service() {
@@ -92,7 +92,7 @@ class ClipboardService : Service() {
ClipboardUtils.clearClipboard(clipboardManager, deepClear)
}
} else {
- Timber.tag("ClipboardService").d("Cannot get clipboard manager service")
+ d { "Cannot get clipboard manager service" }
}
}
@@ -144,7 +144,7 @@ class ClipboardService : Service() {
if (manager != null) {
manager.createNotificationChannel(serviceChannel)
} else {
- Timber.tag("ClipboardService").d("Failed to create notification channel")
+ d { "Failed to create notification channel" }
}
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
index 9b4a4023..ad8d4a70 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
@@ -35,6 +35,11 @@ import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.observe
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.Timber.tag
+import com.github.ajalt.timberkt.d
+import com.github.ajalt.timberkt.e
+import com.github.ajalt.timberkt.i
+import com.github.ajalt.timberkt.w
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.autofill.oreo.AutofillMatcher
@@ -64,7 +69,6 @@ import org.apache.commons.io.FilenameUtils
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.errors.GitAPIException
import org.eclipse.jgit.revwalk.RevCommit
-import timber.log.Timber
class PasswordStore : AppCompatActivity() {
@@ -334,7 +338,7 @@ class PasswordStore : AppCompatActivity() {
} catch (e: Exception) {
e.printStackTrace()
if (!localDir.delete()) {
- Timber.tag(TAG).d("Failed to delete local repository")
+ tag(TAG).d { "Failed to delete local repository" }
}
return
}
@@ -381,7 +385,7 @@ class PasswordStore : AppCompatActivity() {
val fragmentManager = supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
if (localDir != null && settings.getBoolean("repository_initialized", false)) {
- Timber.tag(TAG).d("Check, dir: ${localDir.absolutePath}")
+ tag(TAG).d { "Check, dir: ${localDir.absolutePath}" }
// do not push the fragment if we already have it
if (fragmentManager.findFragmentByTag("PasswordsList") == null ||
settings.getBoolean("repo_changed", false)) {
@@ -424,7 +428,7 @@ class PasswordStore : AppCompatActivity() {
val repoPath = getRepositoryDirectory(this)
val repository = getRepository(repoPath)
if (repository == null) {
- Timber.tag(TAG).d("getLastChangedTimestamp: No git repository")
+ tag(TAG).d { "getLastChangedTimestamp: No git repository" }
return File(fullPath).lastModified()
}
val git = Git(repository)
@@ -433,11 +437,11 @@ class PasswordStore : AppCompatActivity() {
iterator = try {
git.log().addPath(relativePath).call().iterator()
} catch (e: GitAPIException) {
- Timber.tag(TAG).e(e, "getLastChangedTimestamp: GITAPIException")
+ tag(TAG).e(e) { "getLastChangedTimestamp: GITAPIException" }
return -1
}
if (!iterator.hasNext()) {
- Timber.tag(TAG).w("getLastChangedTimestamp: No commits for file: $relativePath")
+ tag(TAG).w { "getLastChangedTimestamp: No commits for file: $relativePath" }
return -1
}
return iterator.next().commitTime.toLong() * 1000
@@ -509,7 +513,7 @@ class PasswordStore : AppCompatActivity() {
fun createPassword() {
if (!validateState()) return
val currentDir = currentDir
- Timber.tag(TAG).i("Adding file to : ${currentDir.absolutePath}")
+ tag(TAG).i { "Adding file to : ${currentDir.absolutePath}" }
val intent = Intent(this, PgpActivity::class.java)
intent.putExtra("FILE_PATH", currentDir.absolutePath)
intent.putExtra("REPO_PATH", getRepositoryDirectory(applicationContext).absolutePath)
@@ -649,24 +653,26 @@ class PasswordStore : AppCompatActivity() {
startActivityForResult(intent, BaseGitActivity.REQUEST_CLONE)
}
REQUEST_CODE_SELECT_FOLDER -> {
- Timber.tag(TAG)
- .d("Moving passwords to ${data!!.getStringExtra("SELECTED_FOLDER_PATH")}")
- Timber.tag(TAG).d(
- TextUtils.join(", ", requireNotNull(data.getStringArrayListExtra("Files")))
- )
+ val intentData = data ?: return
+ tag(TAG).d {
+ "Moving passwords to ${intentData.getStringExtra("SELECTED_FOLDER_PATH")}"
+ }
+ tag(TAG).d {
+ TextUtils.join(", ", requireNotNull(intentData.getStringArrayListExtra("Files")))
+ }
- val target = File(requireNotNull(data.getStringExtra("SELECTED_FOLDER_PATH")))
+ val target = File(requireNotNull(intentData.getStringExtra("SELECTED_FOLDER_PATH")))
val repositoryPath = getRepositoryDirectory(applicationContext).absolutePath
if (!target.isDirectory) {
- Timber.tag(TAG).e("Tried moving passwords to a non-existing folder.")
+ tag(TAG).e { "Tried moving passwords to a non-existing folder." }
return
}
// TODO move this to an async task
- for (fileString in requireNotNull(data.getStringArrayListExtra("Files"))) {
+ for (fileString in requireNotNull(intentData.getStringArrayListExtra("Files"))) {
val source = File(fileString)
if (!source.exists()) {
- Timber.tag(TAG).e("Tried moving something that appears non-existent.")
+ tag(TAG).e { "Tried moving something that appears non-existent." }
continue
}
val destinationFile = File(target.absolutePath + "/" + source.name)
@@ -674,7 +680,7 @@ class PasswordStore : AppCompatActivity() {
val sourceLongName = getLongName(requireNotNull(source.parent), repositoryPath, basename)
val destinationLongName = getLongName(target.absolutePath, repositoryPath, basename)
if (destinationFile.exists()) {
- Timber.tag(TAG).e("Trying to move a file that already exists.")
+ tag(TAG).e { "Trying to move a file that already exists." }
// TODO: Add option to cancel overwrite. Will be easier once this is an async task.
MaterialAlertDialogBuilder(this)
.setTitle(resources.getString(R.string.password_exists_title))
@@ -697,7 +703,7 @@ class PasswordStore : AppCompatActivity() {
}
if (!source.renameTo(destinationFile)) {
// TODO this should show a warning to the user
- Timber.tag(TAG).e("Something went wrong while moving.")
+ tag(TAG).e { "Something went wrong while moving." }
} else {
AutofillMatcher.updateMatches(this, sourceDestinationMap)
commitChange(this.resources
@@ -803,7 +809,7 @@ class PasswordStore : AppCompatActivity() {
fun commitChange(activity: Activity, message: String, finishWithResultOnEnd: Intent? = null) {
object : GitOperation(getRepositoryDirectory(activity), activity) {
override fun execute() {
- Timber.tag(TAG).d("Committing with message $message")
+ tag(TAG).d { "Committing with message $message" }
val git = Git(repository)
val tasks = GitAsyncTask(activity, true, this, finishWithResultOnEnd)
tasks.execute(
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
index 370c7983..9d56845c 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
@@ -33,6 +33,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import androidx.preference.SwitchPreferenceCompat
+import com.github.ajalt.timberkt.Timber.tag
import com.github.ajalt.timberkt.d
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
@@ -59,7 +60,6 @@ import java.util.HashSet
import java.util.TimeZone
import me.msfjarvis.openpgpktx.util.OpenPgpUtils
import org.apache.commons.io.FileUtils
-import timber.log.Timber
typealias ClickListener = Preference.OnPreferenceClickListener
typealias ChangeListener = Preference.OnPreferenceChangeListener
@@ -643,7 +643,7 @@ class UserPreference : AppCompatActivity() {
SELECT_GIT_DIRECTORY -> {
val uri = data.data
- Timber.tag(TAG).d { "Selected repository URI is $uri" }
+ tag(TAG).d { "Selected repository URI is $uri" }
// TODO: This is fragile. Workaround until PasswordItem is backed by DocumentFile
val docId = DocumentsContract.getTreeDocumentId(uri)
val split = docId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
@@ -651,7 +651,7 @@ class UserPreference : AppCompatActivity() {
val repoPath = "${Environment.getExternalStorageDirectory()}/$path"
val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
- Timber.tag(TAG).d {"Selected repository path is $repoPath" }
+ tag(TAG).d { "Selected repository path is $repoPath" }
if (Environment.getExternalStorageDirectory().path == repoPath) {
MaterialAlertDialogBuilder(this)
@@ -714,7 +714,7 @@ class UserPreference : AppCompatActivity() {
val repositoryDirectory = requireNotNull(PasswordRepository.getRepositoryDirectory(applicationContext))
val sourcePassDir = DocumentFile.fromFile(repositoryDirectory)
- Timber.tag(TAG).d { "Copying ${repositoryDirectory.path} to $targetDirectory" }
+ tag(TAG).d { "Copying ${repositoryDirectory.path} to $targetDirectory" }
val dateString = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
LocalDateTime
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
index bd22f4a4..87881968 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
@@ -12,10 +12,11 @@ import android.content.SharedPreferences
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
+import com.github.ajalt.timberkt.Timber.tag
+import com.github.ajalt.timberkt.e
import com.zeapo.pwdstore.PasswordStore
import com.zeapo.pwdstore.utils.splitLines
import org.eclipse.jgit.util.StringUtils
-import timber.log.Timber
// blank activity started by service for calling startIntentSenderForResult
class AutofillActivity : AppCompatActivity() {
@@ -29,7 +30,7 @@ class AutofillActivity : AppCompatActivity() {
val pi = extras.getParcelable<PendingIntent>("pending_intent") ?: return
startIntentSenderForResult(pi.intentSender, REQUEST_CODE_DECRYPT_AND_VERIFY, null, 0, 0, 0)
} catch (e: IntentSender.SendIntentException) {
- Timber.tag(AutofillService.Constants.TAG).e(e, "SendIntentException")
+ tag(AutofillService.Constants.TAG).e(e) { "SendIntentException" }
}
} else if (extras != null && extras.containsKey("pick")) {
val intent = Intent(applicationContext, PasswordStore::class.java)
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
index 2d9eb813..7a2cc521 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
@@ -24,6 +24,9 @@ import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.Timber.tag
+import com.github.ajalt.timberkt.e
+import com.github.ajalt.timberkt.i
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.zeapo.pwdstore.PasswordEntry
import com.zeapo.pwdstore.R
@@ -48,7 +51,6 @@ import me.msfjarvis.openpgpktx.util.OpenPgpServiceConnection
import org.apache.commons.io.FileUtils
import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.OpenPgpError
-import timber.log.Timber
class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope(Dispatchers.Default) {
private var serviceConnection: OpenPgpServiceConnection? = null
@@ -522,11 +524,11 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope
lastPasswordMaxDate = System.currentTimeMillis() + ttl * 1000L
}
} catch (e: UnsupportedEncodingException) {
- Timber.tag(Constants.TAG).e(e)
+ tag(Constants.TAG).e(e)
}
}
OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> {
- Timber.tag("PgpHandler").i("RESULT_CODE_USER_INTERACTION_REQUIRED")
+ tag("PgpHandler").i { "RESULT_CODE_USER_INTERACTION_REQUIRED" }
val pi = result.getParcelableExtra<PendingIntent>(OpenPgpApi.RESULT_INTENT)
// need to start a blank activity to call startIntentSenderForResult
val intent = Intent(applicationContext, AutofillActivity::class.java)
@@ -538,8 +540,8 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope
val error = result.getParcelableExtra<OpenPgpError>(OpenPgpApi.RESULT_ERROR)
if (error != null) {
withContext(Dispatchers.Main) { Toast.makeText(applicationContext, "Error from OpenKeyChain : ${error.message}", Toast.LENGTH_LONG).show() }
- Timber.tag(Constants.TAG).e("onError getErrorId: ${error.errorId}")
- Timber.tag(Constants.TAG).e("onError getMessage: ${error.message}")
+ tag(Constants.TAG).e { "onError getErrorId: ${error.errorId}" }
+ tag(Constants.TAG).e { "onError getMessage: ${error.message}" }
}
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
index 3d8ef1a7..f6d2b169 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
@@ -38,6 +38,9 @@ import androidx.core.widget.doOnTextChanged
import androidx.lifecycle.lifecycleScope
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.Timber.e
+import com.github.ajalt.timberkt.Timber.i
+import com.github.ajalt.timberkt.Timber.tag
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.ClipboardService
@@ -71,7 +74,6 @@ import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.OpenPgpError
-import timber.log.Timber
class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
private val clipboard by lazy { getSystemService<ClipboardManager>() }
@@ -116,7 +118,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
- Timber.tag(TAG)
+ tag(TAG)
// some persistence
_keyIDs = settings.getStringSet("openpgp_key_ids_set", null) ?: emptySet()
@@ -318,7 +320,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
* @param requestCode The code we'd like to use to identify the behaviour
*/
private fun handleUserInteractionRequest(result: Intent, requestCode: Int) {
- Timber.i("RESULT_CODE_USER_INTERACTION_REQUIRED")
+ i { "RESULT_CODE_USER_INTERACTION_REQUIRED" }
val pi: PendingIntent? = result.getParcelableExtra(RESULT_INTENT)
try {
@@ -327,7 +329,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
null, 0, 0, 0
)
} catch (e: IntentSender.SendIntentException) {
- Timber.e(e, "SendIntentException")
+ e(e) { "SendIntentException" }
}
}
@@ -346,8 +348,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
val error: OpenPgpError? = result.getParcelableExtra(RESULT_ERROR)
if (error != null) {
showSnackbar("Error from OpenKeyChain : " + error.message)
- Timber.e("onError getErrorId: ${error.errorId}")
- Timber.e("onError getMessage: ${error.message}")
+ e { "onError getErrorId: ${error.errorId}" }
+ e { "onError getMessage: ${error.message}" }
}
}
@@ -524,7 +526,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
copyPasswordToClipBoard()
}
} catch (e: Exception) {
- Timber.e(e, "An Exception occurred")
+ e(e) { "An Exception occurred" }
}
}
RESULT_CODE_USER_INTERACTION_REQUIRED -> handleUserInteractionRequest(result, REQUEST_DECRYPT)
@@ -624,7 +626,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
setResult(RESULT_OK, returnIntent)
finish()
} catch (e: Exception) {
- Timber.e(e, "An Exception occurred")
+ e(e) { "An Exception occurred" }
}
}
RESULT_CODE_ERROR -> handleError(result)
@@ -730,7 +732,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
setResult(RESULT_OK)
finish()
} catch (e: Exception) {
- Timber.e(e, "An Exception occurred")
+ e(e) { "An Exception occurred" }
}
}
RESULT_CODE_USER_INTERACTION_REQUIRED -> handleUserInteractionRequest(result, REQUEST_KEY_ID)
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt
index e5d600d8..2af6c131 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt
@@ -14,6 +14,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.core.text.isDigitsOnly
import androidx.preference.PreferenceManager
+import com.github.ajalt.timberkt.Timber.tag
+import com.github.ajalt.timberkt.e
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.zeapo.pwdstore.git.config.ConnectionMode
import com.zeapo.pwdstore.git.config.Protocol
@@ -23,7 +25,6 @@ import com.zeapo.pwdstore.utils.getEncryptedPrefs
import java.io.File
import java.net.MalformedURLException
import java.net.URI
-import timber.log.Timber
/**
* Abstract AppCompatActivity that holds some information that is commonly shared across git-related
@@ -172,7 +173,7 @@ abstract class BaseGitActivity : AppCompatActivity() {
REQUEST_RESET -> ResetToRemoteOperation(localDir, this).setCommands()
SshApiSessionFactory.POST_SIGNATURE -> return
else -> {
- Timber.tag(TAG).e("Operation not recognized : $operation")
+ tag(TAG).e { "Operation not recognized : $operation" }
setResult(RESULT_CANCELED)
finish()
return
diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt b/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
index dbf8e7a9..58d291d0 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
@@ -18,12 +18,12 @@ import androidx.appcompat.widget.AppCompatEditText
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.edit
import androidx.fragment.app.DialogFragment
+import com.github.ajalt.timberkt.Timber.tag
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.pwgen.PasswordGenerator
import com.zeapo.pwdstore.pwgenxkpwd.CapsType
import com.zeapo.pwdstore.pwgenxkpwd.PasswordBuilder
-import timber.log.Timber
/** A placeholder fragment containing a simple view. */
class XkPasswordGeneratorDialogFragment : DialogFragment() {
@@ -66,7 +66,7 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
val previousStoredCapStyle: String = try {
prefs.getString(PREF_KEY_CAPITALS_STYLE, DEFAULT_CAPS_STYLE)!!
} catch (e: Exception) {
- Timber.tag("xkpw").e(e)
+ tag("xkpw").e(e)
DEFAULT_CAPS_STYLE
}
spinnerCapsType = view.findViewById(R.id.xkCapType)
@@ -76,7 +76,7 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
lastCapitalsStyleIndex = try {
CapsType.valueOf(previousStoredCapStyle).ordinal
} catch (e: Exception) {
- Timber.tag("xkpw").e(e)
+ tag("xkpw").e(e)
DEFAULT_CAPS_INDEX
}
spinnerCapsType.setSelection(lastCapitalsStyleIndex)
@@ -126,7 +126,7 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
.setCapitalization(CapsType.valueOf(spinnerCapsType.selectedItem.toString())).create()
} catch (e: PasswordGenerator.PasswordGeneratorExeption) {
Toast.makeText(requireActivity(), e.message, Toast.LENGTH_SHORT).show()
- Timber.tag("xkpw").e(e, "failure generating xkpasswd")
+ tag("xkpw").e(e, "failure generating xkpasswd")
passwordText.text = FALLBACK_ERROR_PASS
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/ClipboardUtils.kt b/app/src/main/java/com/zeapo/pwdstore/utils/ClipboardUtils.kt
index 174a1743..2e408bfd 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/ClipboardUtils.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/ClipboardUtils.kt
@@ -6,14 +6,14 @@ package com.zeapo.pwdstore.utils
import android.content.ClipData
import android.content.ClipboardManager
+import com.github.ajalt.timberkt.d
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-import timber.log.Timber
object ClipboardUtils {
suspend fun clearClipboard(clipboard: ClipboardManager, deepClear: Boolean = false) {
- Timber.d("Clearing the clipboard")
+ d { "Clearing the clipboard" }
val clip = ClipData.newPlainText("pgp_handler_result_pm", "")
clipboard.setPrimaryClip(clip)
if (deepClear) {
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/auth/Authenticator.kt b/app/src/main/java/com/zeapo/pwdstore/utils/auth/Authenticator.kt
index 7fc69f95..34fc9455 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/auth/Authenticator.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/auth/Authenticator.kt
@@ -8,8 +8,9 @@ import android.os.Handler
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.FragmentActivity
+import com.github.ajalt.timberkt.Timber.tag
+import com.github.ajalt.timberkt.d
import com.zeapo.pwdstore.R
-import timber.log.Timber
internal class Authenticator(
private val fragmentActivity: FragmentActivity,
@@ -22,19 +23,19 @@ internal class Authenticator(
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
- Timber.tag(TAG).d("Error: $errorCode: $errString")
+ tag(TAG).d { "Error: $errorCode: $errString" }
callback(AuthenticationResult.UnrecoverableError(errorCode, errString))
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
- Timber.tag(TAG).d("Failed")
+ tag(TAG).d { "Failed" }
callback(AuthenticationResult.Failure)
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
- Timber.tag(TAG).d("Success")
+ tag(TAG).d { "Success" }
callback(AuthenticationResult.Success(result.cryptoObject))
}
}