mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2026-01-01 09:20:31 -06:00
Merge branch 'feature/ktlint' of https://github.com/yogeshpaliyal/KeyPass
Conflicts: app/build.gradle app/src/main/java/com/yogeshpaliyal/keypass/AppDatabase.kt app/src/main/java/com/yogeshpaliyal/keypass/data/AccountModel.kt app/src/main/java/com/yogeshpaliyal/keypass/db/DbDao.kt app/src/main/java/com/yogeshpaliyal/keypass/db_helper/DbBackupRestore.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/auth/AuthenticationActivity.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/detail/DetailActivity.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/generate/GeneratePasswordActivity.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/home/HomeFragment.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/home/HomeViewModel.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/BottomNavDrawerFragment.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardActivity.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/settings/MySettingsFragment.kt app/src/main/java/com/yogeshpaliyal/keypass/ui/settings_activity/SettingsActivity.kt app/src/main/java/com/yogeshpaliyal/keypass/utils/BackupUtils.kt app/src/main/java/com/yogeshpaliyal/keypass/utils/IntentHelper.kt app/src/main/java/com/yogeshpaliyal/keypass/utils/SharedPreferenceUtils.kt
This commit is contained in:
@@ -3,6 +3,7 @@ plugins {
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
id 'androidx.navigation.safeargs.kotlin'
|
||||
// id("com.diffplug.spotless") version "5.10.2"
|
||||
id("dagger.hilt.android.plugin")
|
||||
|
||||
}
|
||||
|
||||
BIN
app/production/release/app-production-release.apk
Normal file
BIN
app/production/release/app-production-release.apk
Normal file
Binary file not shown.
18
app/production/release/output-metadata.json
Normal file
18
app/production/release/output-metadata.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 2,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.yogeshpaliyal.keypass",
|
||||
"variantName": "processProductionReleaseResources",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 3,
|
||||
"versionName": "1.3",
|
||||
"outputFile": "app-production-release.apk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.yogeshpaliyal.keypass
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
@@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.yogeshpaliyal.keypass", appContext.packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.yogeshpaliyal.keypass
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.db.DbDao
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.yogeshpaliyal.keypass
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
* https://techpaliyal.com
|
||||
* created on 23-01-2021 10:33
|
||||
*/
|
||||
data class InfoModel(var user_id: String,
|
||||
var username : String,
|
||||
var password : String,
|
||||
var notes: String,
|
||||
var insertedDate : Long,
|
||||
var lastUpdatedDate : Long)
|
||||
data class InfoModel(
|
||||
var user_id: String,
|
||||
var username: String,
|
||||
var password: String,
|
||||
var notes: String,
|
||||
var insertedDate: Long,
|
||||
var lastUpdatedDate: Long
|
||||
)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.yogeshpaliyal.keypass
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* yogeshpaliyal.foss@gmail.com
|
||||
@@ -13,14 +12,12 @@ import dagger.hilt.android.HiltAndroidApp
|
||||
@HiltAndroidApp
|
||||
class MyApplication : Application() {
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
lateinit var instance: MyApplication
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
instance = this
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,4 @@ class MaskedCardView @JvmOverloads constructor(
|
||||
pathProvider.calculatePath(shapeAppearance, 1f, rectF, path)
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import androidx.room.PrimaryKey
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.yogeshpaliyal.keypass.data
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -13,8 +12,8 @@ import com.google.gson.annotations.SerializedName
|
||||
data class BackupData(
|
||||
@SerializedName("version")
|
||||
@Expose
|
||||
val version : Int,
|
||||
val version: Int,
|
||||
@SerializedName("data")
|
||||
@Expose
|
||||
val data : List<AccountModel> ) {
|
||||
}
|
||||
val data: List<AccountModel>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.yogeshpaliyal.keypass.db_helper
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.yogeshpaliyal.keypass.db_helper
|
||||
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
@@ -15,7 +14,6 @@ import javax.crypto.*
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -25,21 +23,20 @@ import javax.crypto.spec.SecretKeySpec
|
||||
*/
|
||||
object EncryptionHelper {
|
||||
private const val ALGORITHM = "AES"
|
||||
private const val TRANSFORMATION = "AES/CBC/PKCS5Padding"
|
||||
//private const val TRANSFORMATION = "AES"
|
||||
private const val TRANSFORMATION = "AES/CBC/PKCS5Padding"
|
||||
// private const val TRANSFORMATION = "AES"
|
||||
// private const val TRANSFORMATION = "DES/CBC/PKCS5Padding"
|
||||
|
||||
private val iV = byteArrayOf(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
|
||||
|
||||
private val iV = byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
|
||||
@Throws(CryptoException::class)
|
||||
fun doCryptoEncrypt(
|
||||
key: String, data: String,
|
||||
key: String,
|
||||
data: String,
|
||||
outputFile: OutputStream?
|
||||
) {
|
||||
try {
|
||||
|
||||
|
||||
val secretKey: Key =
|
||||
SecretKeySpec(key.toByteArray(), ALGORITHM)
|
||||
val cipher = Cipher.getInstance(TRANSFORMATION)
|
||||
@@ -47,7 +44,7 @@ object EncryptionHelper {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, IvParameterSpec(iV))
|
||||
|
||||
data.byteInputStream().use {
|
||||
val inputStream = it
|
||||
val inputStream = it
|
||||
outputFile?.use {
|
||||
val outputStream = it
|
||||
CipherOutputStream(outputStream, cipher).use {
|
||||
@@ -62,7 +59,7 @@ object EncryptionHelper {
|
||||
// Log.d("TestingEnc","NoSuchAlgorithmException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: InvalidKeyException) {
|
||||
//Log.d("TestingEnc","InvalidKeyException")
|
||||
// Log.d("TestingEnc","InvalidKeyException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: BadPaddingException) {
|
||||
// Log.d("TestingEnc","BadPaddingException")
|
||||
@@ -76,11 +73,11 @@ object EncryptionHelper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Throws(CryptoException::class)
|
||||
fun doCryptoDecrypt(
|
||||
key: String, inputFile: InputStream?
|
||||
) : String {
|
||||
key: String,
|
||||
inputFile: InputStream?
|
||||
): String {
|
||||
var data = ""
|
||||
try {
|
||||
val secretKey: Key =
|
||||
@@ -91,25 +88,24 @@ object EncryptionHelper {
|
||||
|
||||
inputFile.use {
|
||||
val inputStream = it
|
||||
CipherInputStream(inputStream, cipher).use {
|
||||
data = String(it.readBytes())
|
||||
}
|
||||
CipherInputStream(inputStream, cipher).use {
|
||||
data = String(it.readBytes())
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ex: NoSuchPaddingException) {
|
||||
//Log.d("TestingEnc","NoSuchPaddingException")
|
||||
// Log.d("TestingEnc","NoSuchPaddingException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: NoSuchAlgorithmException) {
|
||||
//Log.d("TestingEnc","NoSuchAlgorithmException")
|
||||
// Log.d("TestingEnc","NoSuchAlgorithmException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: InvalidKeyException) {
|
||||
//Log.d("TestingEnc","InvalidKeyException")
|
||||
// Log.d("TestingEnc","InvalidKeyException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: BadPaddingException) {
|
||||
//Log.d("TestingEnc","BadPaddingException")
|
||||
// Log.d("TestingEnc","BadPaddingException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: IllegalBlockSizeException) {
|
||||
//Log.d("TestingEnc","IllegalBlockSizeException")
|
||||
// Log.d("TestingEnc","IllegalBlockSizeException")
|
||||
throw CryptoException("Error encrypting/decrypting file", ex)
|
||||
} catch (ex: IOException) {
|
||||
// Log.d("TestingEnc","IOException")
|
||||
@@ -119,9 +115,7 @@ object EncryptionHelper {
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun encryptPassword(message: String, password: String): String{
|
||||
fun encryptPassword(message: String, password: String): String {
|
||||
/* Encrypt the message. */
|
||||
var cipher: Cipher? = null
|
||||
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding")
|
||||
@@ -147,11 +141,8 @@ object EncryptionHelper {
|
||||
return String(cipher.doFinal(encryptedMessage.toByteArray()))
|
||||
}
|
||||
|
||||
|
||||
@Throws(NoSuchAlgorithmException::class, InvalidKeySpecException::class)
|
||||
fun generateKey(passLockKey: String): SecretKey {
|
||||
return SecretKeySpec(passLockKey.encodeToByteArray(), "AES")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.yogeshpaliyal.keypass.listener
|
||||
|
||||
import android.view.View
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -11,4 +10,4 @@ import android.view.View
|
||||
*/
|
||||
interface UniversalClickListener<T> {
|
||||
fun onItemClick(view: View, model: T)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ class BasicService : AutofillService() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Create the base response
|
||||
val response = FillResponse.Builder()
|
||||
|
||||
@@ -129,8 +128,9 @@ class BasicService : AutofillService() {
|
||||
fields[hint] = id
|
||||
} else {
|
||||
Log.v(
|
||||
TAG, "Ignoring hint '" + hint + "' on " + id
|
||||
+ " because it was already set"
|
||||
TAG,
|
||||
"Ignoring hint '" + hint + "' on " + id +
|
||||
" because it was already set"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,9 @@ class BasicService : AutofillService() {
|
||||
text: CharSequence
|
||||
): RemoteViews {
|
||||
val presentation = RemoteViews(packageName, R.layout.multidataset_service_list_item)
|
||||
presentation.setTextViewText(R.id.text, "paliyal"+text)
|
||||
presentation.setTextViewText(R.id.text, "paliyal" + text)
|
||||
presentation.setImageViewResource(R.id.icon, R.mipmap.ic_launcher)
|
||||
return presentation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package com.yogeshpaliyal.keypass.service
|
||||
|
||||
import android.app.assist.AssistStructure
|
||||
import android.app.assist.AssistStructure.ViewNode
|
||||
import android.os.Build
|
||||
import android.os.CancellationSignal
|
||||
import android.service.autofill.*
|
||||
import android.view.autofill.AutofillId
|
||||
import android.view.autofill.AutofillValue
|
||||
import android.widget.RemoteViews
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -24,21 +17,13 @@ class MyAutoFillService : AutofillService() {
|
||||
private val TAG = "MyAutoFillService"
|
||||
private val NUMBER_DATASETS = 4
|
||||
|
||||
|
||||
override fun onFillRequest(
|
||||
request: FillRequest,
|
||||
cancellationSignal: CancellationSignal,
|
||||
callback: FillCallback
|
||||
) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onSaveRequest(request: SaveRequest, callback: SaveCallback) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -30,8 +29,5 @@ class DetailViewModel @Inject constructor(application: Application, val appDb: A
|
||||
appDb.getDao().getAccount(accountId) ?: AccountModel()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -23,13 +22,13 @@ class BottomNavViewModel @Inject constructor (application: Application,val appDb
|
||||
private val _navigationList: MutableLiveData<List<NavigationModelItem>> = MutableLiveData()
|
||||
private val tagsDb = appDb.getDao().getTags()
|
||||
|
||||
private var tagsList : List<String> ?= null
|
||||
private var tagsList: List<String> ? = null
|
||||
|
||||
val navigationList: LiveData<List<NavigationModelItem>>
|
||||
get() = _navigationList
|
||||
|
||||
init {
|
||||
postListUpdate()
|
||||
postListUpdate()
|
||||
|
||||
viewModelScope.launch {
|
||||
tagsDb.collect {
|
||||
@@ -39,8 +38,6 @@ class BottomNavViewModel @Inject constructor (application: Application,val appDb
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the currently selected menu item.
|
||||
*
|
||||
@@ -59,18 +56,13 @@ class BottomNavViewModel @Inject constructor (application: Application,val appDb
|
||||
return updated
|
||||
}
|
||||
|
||||
|
||||
private fun postListUpdate() {
|
||||
val newList = if(tagsList.isNullOrEmpty().not()){
|
||||
val newList = if (tagsList.isNullOrEmpty().not()) {
|
||||
NavigationModel.navigationMenuItems + NavigationModelItem.NavDivider("Tags") + (tagsList?.filter { it != null }?.map { NavigationModelItem.NavEmailFolder(it) } ?: listOf())
|
||||
}else{
|
||||
} else {
|
||||
NavigationModel.navigationMenuItems
|
||||
}
|
||||
|
||||
|
||||
_navigationList.value = newList
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +97,4 @@ class BottomNavigationDrawerCallback : BottomSheetBehavior.BottomSheetCallback()
|
||||
fun removeOnStateChangedAction(action: OnStateChangedAction): Boolean {
|
||||
return onStateChangedActions.remove(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,4 +86,4 @@ class NavigationAdapter(
|
||||
) {
|
||||
holder.bind(getItem(position))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.yogeshpaliyal.keypass.ui.nav
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
|
||||
/**
|
||||
@@ -12,7 +10,6 @@ object NavigationModel {
|
||||
const val HOME = 0
|
||||
const val GENERATE_PASSWORD = 1
|
||||
|
||||
|
||||
var navigationMenuItems = mutableListOf(
|
||||
NavigationModelItem.NavMenuItem(
|
||||
id = HOME,
|
||||
@@ -27,11 +24,4 @@ object NavigationModel {
|
||||
checked = false,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ sealed class NavigationModelItem {
|
||||
newItem: NavigationModelItem
|
||||
): Boolean {
|
||||
return when {
|
||||
oldItem is NavMenuItem && newItem is NavMenuItem ->
|
||||
oldItem.icon == newItem.icon &&
|
||||
oldItem.titleRes == newItem.titleRes &&
|
||||
oldItem.checked == newItem.checked
|
||||
oldItem is NavMenuItem && newItem is NavMenuItem ->
|
||||
oldItem.icon == newItem.icon &&
|
||||
oldItem.titleRes == newItem.titleRes &&
|
||||
oldItem.checked == newItem.checked
|
||||
oldItem is NavEmailFolder && newItem is NavEmailFolder ->
|
||||
StringDiffUtil.areContentsTheSame(oldItem.category, newItem.category)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.yogeshpaliyal.keypass.ui.nav
|
||||
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.yogeshpaliyal.keypass.databinding.NavDividerItemLayoutBinding
|
||||
@@ -11,7 +10,7 @@ sealed class NavigationViewHolder<T : NavigationModelItem>(
|
||||
view: View
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
abstract fun bind(navItem : T)
|
||||
abstract fun bind(navItem: T)
|
||||
|
||||
class NavMenuItemViewHolder(
|
||||
private val binding: NavMenuItemLayoutBinding,
|
||||
@@ -49,4 +48,4 @@ sealed class NavigationViewHolder<T : NavigationModelItem>(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,4 +132,4 @@ fun Float.normalize(
|
||||
|
||||
return outputMin * (1 - (this - inputMin) / (inputMax - inputMin)) +
|
||||
outputMax * ((this - inputMin) / (inputMax - inputMin))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.Context
|
||||
import android.view.autofill.AutofillManager
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -12,9 +11,8 @@ import androidx.core.content.ContextCompat.getSystemService
|
||||
* created on 31-01-2021 15:27
|
||||
*/
|
||||
|
||||
|
||||
fun Context?.getAutoFillService() = if (this != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
getSystemService(this, AutofillManager::class.java)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
fun Context?.getAutoFillService() = if (this != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
getSystemService(this, AutofillManager::class.java)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
@@ -15,31 +15,29 @@
|
||||
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import android.widget.ImageView
|
||||
import android.widget.Spinner
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.BindingAdapter
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
|
||||
@BindingAdapter(
|
||||
"popupElevationOverlay"
|
||||
)
|
||||
fun Spinner.bindPopupElevationOverlay(popupElevationOverlay: Float) {
|
||||
setPopupBackgroundDrawable(ColorDrawable(
|
||||
ElevationOverlayProvider(context)
|
||||
.compositeOverlayWithThemeSurfaceColorIfNeeded(popupElevationOverlay)
|
||||
))
|
||||
setPopupBackgroundDrawable(
|
||||
ColorDrawable(
|
||||
ElevationOverlayProvider(context)
|
||||
.compositeOverlayWithThemeSurfaceColorIfNeeded(popupElevationOverlay)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@BindingAdapter(
|
||||
@@ -67,8 +65,6 @@ fun TextView.bindDrawables(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@BindingAdapter("goneIf")
|
||||
fun View.bindGoneIf(gone: Boolean) {
|
||||
visibility = if (gone) {
|
||||
@@ -219,4 +215,4 @@ fun View.requestApplyInsetsWhenAttached() {
|
||||
override fun onViewDetachedFromWindow(v: View) = Unit
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -46,4 +45,4 @@ class ContentViewBindingDelegate<in R : AppCompatActivity, out T : ViewDataBindi
|
||||
|
||||
fun <R : AppCompatActivity, T : ViewDataBinding> contentView(
|
||||
@LayoutRes layoutRes: Int
|
||||
): ContentViewBindingDelegate<R, T> = ContentViewBindingDelegate(layoutRes)
|
||||
): ContentViewBindingDelegate<R, T> = ContentViewBindingDelegate(layoutRes)
|
||||
|
||||
@@ -67,4 +67,4 @@ fun Context.themeInterpolator(@AttrRes attr: Int): Interpolator {
|
||||
|
||||
fun Context.getDrawableOrNull(@DrawableRes id: Int?): Drawable? {
|
||||
return if (id == null || id == 0) null else AppCompatResources.getDrawable(this, id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.yogeshpaliyal.keypass.utils
|
||||
import android.util.Log
|
||||
import com.yogeshpaliyal.keypass.BuildConfig
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -47,4 +46,4 @@ fun Any?.logV(tag: String?) {
|
||||
|
||||
fun Any?.logW(tag: String?) {
|
||||
if (BuildConfig.DEBUG) Log.w(tag, this.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
|
||||
class PasswordGenerator(private var length: Int, private var includeUpperCaseLetters : Boolean,
|
||||
private var includeLowerCaseLetters : Boolean,
|
||||
private var includeSymbols : Boolean, private var includeNumbers: Boolean) {
|
||||
class PasswordGenerator(
|
||||
private var length: Int,
|
||||
private var includeUpperCaseLetters: Boolean,
|
||||
private var includeLowerCaseLetters: Boolean,
|
||||
private var includeSymbols: Boolean,
|
||||
private var includeNumbers: Boolean
|
||||
) {
|
||||
|
||||
constructor() : this(10,true, true, true, true)
|
||||
|
||||
@@ -11,27 +15,27 @@ class PasswordGenerator(private var length: Int, private var includeUpperCaseLet
|
||||
private val NUMBERS = 2
|
||||
private val SYMBOLS = 3
|
||||
|
||||
public fun generatePassword() : String {
|
||||
public fun generatePassword(): String {
|
||||
var password = ""
|
||||
val list = ArrayList<Int>()
|
||||
if(includeUpperCaseLetters)
|
||||
val list = ArrayList<Int>()
|
||||
if (includeUpperCaseLetters)
|
||||
list.add(UPPER_CASE)
|
||||
if(includeLowerCaseLetters)
|
||||
if (includeLowerCaseLetters)
|
||||
list.add(LOWER_CASE)
|
||||
if(includeNumbers)
|
||||
if (includeNumbers)
|
||||
list.add(NUMBERS)
|
||||
if(includeSymbols)
|
||||
if (includeSymbols)
|
||||
list.add(SYMBOLS)
|
||||
|
||||
for(i in 1..length){
|
||||
for (i in 1..length) {
|
||||
val choice = list.random()
|
||||
when(choice){
|
||||
when (choice) {
|
||||
UPPER_CASE -> password += ('A'..'Z').random().toString()
|
||||
LOWER_CASE -> password += ('a'..'z').random().toString()
|
||||
NUMBERS -> password += ('0'..'9').random().toString()
|
||||
SYMBOLS -> password += listOf('!','@','#','$','%','&','*','+','=','-','~','?','/','_').random().toString()
|
||||
SYMBOLS -> password += listOf('!', '@', '#', '$', '%', '&', '*', '+', '=', '-', '~', '?', '/', '_').random().toString()
|
||||
}
|
||||
}
|
||||
return password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.yogeshpaliyal.keypass.utils
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
@@ -10,4 +9,4 @@ import java.util.*
|
||||
* created on 22-01-2021 23:14
|
||||
*/
|
||||
|
||||
fun getRandomString()= UUID.randomUUID().toString()
|
||||
fun getRandomString() = UUID.randomUUID().toString()
|
||||
|
||||
@@ -17,19 +17,8 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Bitmap.Config.ARGB_8888
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.annotation.Px
|
||||
import androidx.core.graphics.applyCanvas
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.forEach
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun TextView.setTextAppearanceCompat(context: Context, resId: Int) {
|
||||
|
||||
@@ -32,4 +32,3 @@ fun <T : ViewModel> ViewModelStoreOwner.initViewModel(viewModel: Class<T>): T =
|
||||
this,
|
||||
ViewModelFactory()
|
||||
).get(viewModel)
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.yogeshpaliyal.keypass
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
@@ -14,4 +13,4 @@ class ExampleUnitTest {
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
29
build.gradle
29
build.gradle
@@ -27,6 +27,9 @@ buildscript {
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id 'com.diffplug.spotless' version '5.10.2'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
@@ -37,6 +40,30 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
/*task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
subprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
apply plugin: 'com.diffplug.spotless'
|
||||
spotless {
|
||||
kotlin {
|
||||
target '**/*.kt'
|
||||
targetExclude("$buildDir/**/*.kt")
|
||||
targetExclude('bin/**/*.kt')
|
||||
|
||||
java.util.HashMap<String, String> map = new HashMap<>();
|
||||
map.put("disabled_rules","no-wildcard-imports")
|
||||
ktlint("0.40.0").userData(map)
|
||||
// licenseHeaderFile rootProject.file('spotless/copyright.kt')
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user