mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix warnings
This commit is contained in:
@@ -157,7 +157,7 @@ class OpenFileHelper {
|
||||
val browserDialogFragment = BrowserDialogFragment()
|
||||
if (fragment != null && fragment!!.fragmentManager != null)
|
||||
browserDialogFragment.show(fragment!!.fragmentManager!!, "browserDialog")
|
||||
else if ((activity as FragmentActivity).supportFragmentManager != null)
|
||||
else
|
||||
browserDialogFragment.show((activity as FragmentActivity).supportFragmentManager, "browserDialog")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Can't open BrowserDialog", e)
|
||||
|
||||
@@ -119,7 +119,7 @@ class ProtectedBinary : Parcelable {
|
||||
var result = 0
|
||||
result = 31 * result + if (isProtected) 1 else 0
|
||||
result = 31 * result + dataFile!!.hashCode()
|
||||
result = 31 * result + Integer.valueOf(size)!!.hashCode()
|
||||
result = 31 * result + Integer.valueOf(size).hashCode()
|
||||
result = 31 * result + Arrays.hashCode(data)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -26,22 +26,22 @@ class ProtectedString : Parcelable {
|
||||
|
||||
var isProtected: Boolean = false
|
||||
private set
|
||||
private var string: String = ""
|
||||
private var stringValue: String = ""
|
||||
|
||||
constructor(toCopy: ProtectedString) {
|
||||
this.isProtected = toCopy.isProtected
|
||||
this.string = toCopy.string
|
||||
this.stringValue = toCopy.stringValue
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
constructor(enableProtection: Boolean = false, string: String = "") {
|
||||
this.isProtected = enableProtection
|
||||
this.string = string
|
||||
this.stringValue = string
|
||||
}
|
||||
|
||||
constructor(parcel: Parcel) {
|
||||
isProtected = parcel.readByte().toInt() != 0
|
||||
string = parcel.readString()
|
||||
stringValue = parcel.readString() ?: stringValue
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
@@ -50,15 +50,15 @@ class ProtectedString : Parcelable {
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeByte((if (isProtected) 1 else 0).toByte())
|
||||
dest.writeString(string)
|
||||
dest.writeString(stringValue)
|
||||
}
|
||||
|
||||
fun length(): Int {
|
||||
return string.length
|
||||
return stringValue.length
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return string
|
||||
return stringValue
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -821,7 +821,7 @@ class ImporterV4(private val streamDir: File) : Importer<PwDatabaseV4>() {
|
||||
} else {
|
||||
|
||||
try {
|
||||
utcDate = PwDatabaseV4XML.dateFormatter.get().parse(sDate)
|
||||
utcDate = PwDatabaseV4XML.dateFormatter.get()?.parse(sDate)
|
||||
} catch (e: ParseException) {
|
||||
// Catch with null test below
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ class PwDbV3Output(private val mDatabaseV3: PwDatabaseV3, os: OutputStream) : Pw
|
||||
setIVs(header)
|
||||
|
||||
// Content checksum
|
||||
var md: MessageDigest? = null
|
||||
val messageDigest: MessageDigest?
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256")
|
||||
messageDigest = MessageDigest.getInstance("SHA-256")
|
||||
} catch (e: NoSuchAlgorithmException) {
|
||||
throw PwDbOutputException("SHA-256 not implemented here.", e)
|
||||
}
|
||||
@@ -159,7 +159,7 @@ class PwDbV3Output(private val mDatabaseV3: PwDatabaseV3, os: OutputStream) : Pw
|
||||
|
||||
// Output database for the purpose of calculating the content checksum
|
||||
nos = NullOutputStream()
|
||||
val dos = DigestOutputStream(nos, md)
|
||||
val dos = DigestOutputStream(nos, messageDigest)
|
||||
val bos = BufferedOutputStream(dos)
|
||||
try {
|
||||
outputPlanGroupAndEntries(bos)
|
||||
@@ -169,7 +169,7 @@ class PwDbV3Output(private val mDatabaseV3: PwDatabaseV3, os: OutputStream) : Pw
|
||||
throw PwDbOutputException("Failed to generate checksum.", e)
|
||||
}
|
||||
|
||||
header.contentsHash = md!!.digest()
|
||||
header.contentsHash = messageDigest!!.digest()
|
||||
|
||||
// Output header for real output, containing content hash
|
||||
pho = PwDbHeaderOutputV3(header, outputStream)
|
||||
|
||||
@@ -110,7 +110,7 @@ object PreferencesUtil {
|
||||
return try {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
java.lang.Long.parseLong(prefs.getString(context.getString(R.string.app_timeout_key),
|
||||
context.getString(R.string.clipboard_timeout_default)))
|
||||
context.getString(R.string.clipboard_timeout_default)) ?: "60000")
|
||||
} catch (e: NumberFormatException) {
|
||||
TimeoutHelper.DEFAULT_TIMEOUT
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class InputNumberPreference @JvmOverloads constructor(context: Context,
|
||||
if (!restorePersistedValue) {
|
||||
numberValue = 100000
|
||||
if (defaultValue is String) {
|
||||
numberValue = java.lang.Long.parseLong(defaultValue as String?)
|
||||
numberValue = java.lang.Long.parseLong(defaultValue)
|
||||
}
|
||||
if (defaultValue is Int) {
|
||||
numberValue = defaultValue.toLong()
|
||||
|
||||
@@ -60,7 +60,7 @@ class ClipboardHelper(private val context: Context) {
|
||||
val sClipClear = prefs.getString(context.getString(R.string.clipboard_timeout_key),
|
||||
context.getString(R.string.clipboard_timeout_default))
|
||||
|
||||
val clipClearTime = java.lang.Long.parseLong(sClipClear)
|
||||
val clipClearTime = java.lang.Long.parseLong(sClipClear ?: "60000")
|
||||
|
||||
if (clipClearTime > 0) {
|
||||
mTimer.schedule(ClearClipboardTask(context, text), clipClearTime)
|
||||
|
||||
Reference in New Issue
Block a user