Create different module common to store business logic that is common for both xml and jetpack compose
@@ -12,6 +12,7 @@
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/common" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/drawable/ic_undraw_empty_street_sfxm.xml" value="0.21614583333333334" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/drawable/nav_divider_top.xml" value="0.21614583333333334" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_add_totpactivity.xml" value="0.16485507246376813" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_authentication.xml" value="0.1" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_dashboard.xml" value="0.2" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/activity_scanner.xml" value="0.10416666666666667" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/fragment_bottom_nav_drawer.xml" value="0.2" />
|
||||
@@ -15,6 +16,7 @@
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/fragment_home.xml" value="0.16304347826086957" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/item_accounts.xml" value="0.388259526261586" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/item_totp.xml" value="0.2" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/layout_backup_keypharse.xml" value="0.15353260869565216" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/layout_no_accounts.xml" value="0.17074275362318841" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/nav_divider_item_layout.xml" value="0.2" />
|
||||
<entry key="..\:/Users/paliy/StudioProjects/KeyPass/app/src/main/res/layout/nav_email_folder_item_layout.xml" value="0.2" />
|
||||
|
||||
@@ -73,6 +73,8 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation project(":common")
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.31"
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
@@ -148,12 +150,30 @@ dependencies {
|
||||
// For instrumented tests.
|
||||
androidTestImplementation("com.google.dagger:hilt-android-testing:2.38.1")
|
||||
// ...with Kotlin.
|
||||
kaptAndroidTest("com.google.dagger:hilt-android-compiler:2.38.1")
|
||||
kaptAndroidTest("com.google.dagger:hilt-android-compiler:2.40")
|
||||
|
||||
// For Robolectric tests.
|
||||
testImplementation("com.google.dagger:hilt-android-testing:2.38.1")
|
||||
// ...with Kotlin.
|
||||
kaptTest("com.google.dagger:hilt-android-compiler:2.38.1")
|
||||
kaptTest("com.google.dagger:hilt-android-compiler:2.40")
|
||||
|
||||
|
||||
// jetpack compose
|
||||
implementation 'androidx.compose.ui:ui:1.0.5'
|
||||
|
||||
implementation 'androidx.compose.ui:ui-tooling:1.0.5'
|
||||
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
|
||||
implementation 'androidx.compose.foundation:foundation:1.0.5'
|
||||
// Material Design
|
||||
implementation 'androidx.compose.material:material:1.0.5'
|
||||
// Material design icons
|
||||
implementation 'androidx.compose.material:material-icons-core:1.0.5'
|
||||
implementation 'androidx.compose.material:material-icons-extended:1.0.5'
|
||||
// Integration with activities
|
||||
implementation 'androidx.activity:activity-compose:1.4.0'
|
||||
// Integration with ViewModels
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
|
||||
// Integration with observables
|
||||
implementation 'androidx.compose.runtime:runtime-livedata:1.0.5'
|
||||
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@ import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import dagger.hilt.android.testing.HiltAndroidRule
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -28,7 +27,7 @@ class DashboardActivityTest {
|
||||
var activityScenarioRule = ActivityScenarioRule(DashboardActivity::class.java)
|
||||
|
||||
@Inject
|
||||
lateinit var appDatabase: AppDatabase
|
||||
lateinit var appDatabase: com.yogeshpaliyal.common.AppDatabase
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yogeshpaliyal.keypass.data
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.constants.AccountType
|
||||
import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
|
||||
import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
|
||||
|
||||
class MyAccountModel: AccountModel() , BaseDiffUtil, UniversalViewType {
|
||||
override fun getDiffId(): Any? {
|
||||
return id
|
||||
}
|
||||
|
||||
override fun getDiffBody(): Any? {
|
||||
return if (type == AccountType.TOTP) {
|
||||
super.getDiffBody()
|
||||
} else {
|
||||
Gson().toJson(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = if (type == AccountType.TOTP) R.layout.item_totp else R.layout.item_accounts
|
||||
|
||||
fun map(accountModel: AccountModel){
|
||||
this.id = accountModel.id
|
||||
this.title = accountModel.title
|
||||
this.uniqueId = accountModel.uniqueId
|
||||
this.username = accountModel.username
|
||||
this.password = accountModel.password
|
||||
this.site = accountModel.site
|
||||
this.notes = accountModel.notes
|
||||
this.tags = accountModel.tags
|
||||
this.type = accountModel.type
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.yogeshpaliyal.keypass.data
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
|
||||
import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
|
||||
|
||||
@Entity(tableName = "totps")
|
||||
data class TOtpModel(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
@SerializedName("id")
|
||||
var id: Long? = null,
|
||||
|
||||
@ColumnInfo(name = "unique_id")
|
||||
@SerializedName("unique_id")
|
||||
var uniqueId: String? = null,
|
||||
|
||||
@Expose
|
||||
@SerializedName("account_name")
|
||||
val accountName: String? = null
|
||||
|
||||
) : BaseDiffUtil, UniversalViewType {
|
||||
override fun getLayoutId() = R.layout.item_totp
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import androidx.lifecycle.Observer
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.zxing.integration.android.IntentIntegrator
|
||||
import com.yogeshpaliyal.common.utils.TOTPHelper
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.ActivityAddTotpactivityBinding
|
||||
import com.yogeshpaliyal.keypass.utils.TOTPHelper
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -85,7 +85,7 @@ class AddTOTPActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
if (accountId != null)
|
||||
menuInflater.inflate(R.menu.menu_delete, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
||||
@@ -4,18 +4,17 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.constants.AccountType
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.utils.Event
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.common.utils.Event
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class AddTOTPViewModel @Inject constructor(private val appDatabase: AppDatabase) : ViewModel() {
|
||||
class AddTOTPViewModel @Inject constructor(private val appDatabase: com.yogeshpaliyal.common.AppDatabase) : ViewModel() {
|
||||
|
||||
private val _goBack = MutableLiveData<Event<Unit>>()
|
||||
val goBack: LiveData<Event<Unit>> = _goBack
|
||||
|
||||
@@ -12,7 +12,8 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.utils.*
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.BackupActivityBinding
|
||||
import com.yogeshpaliyal.keypass.databinding.LayoutBackupKeypharseBinding
|
||||
@@ -60,7 +61,7 @@ class BackupActivity : AppCompatActivity() {
|
||||
lateinit var sp: SharedPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var appDb: AppDatabase
|
||||
lateinit var appDb: com.yogeshpaliyal.common.AppDatabase
|
||||
|
||||
private val CHOOSE_BACKUPS_LOCATION_REQUEST_CODE = 26212
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.Observer
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.yogeshpaliyal.common.utils.PasswordGenerator
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.FragmentDetailBinding
|
||||
import com.yogeshpaliyal.keypass.utils.PasswordGenerator
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
/*
|
||||
@@ -107,7 +107,7 @@ class DetailActivity : AppCompatActivity() {
|
||||
}.show()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.bottom_app_bar_detail, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.worker.executeAutoBackup
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -22,7 +21,7 @@ import javax.inject.Inject
|
||||
* created on 31-01-2021 11:52
|
||||
*/
|
||||
@HiltViewModel
|
||||
class DetailViewModel @Inject constructor(val app: Application, val appDb: AppDatabase, val sp: SharedPreferences) : AndroidViewModel(app) {
|
||||
class DetailViewModel @Inject constructor(val app: Application, val appDb: com.yogeshpaliyal.common.AppDatabase, val sp: SharedPreferences) : AndroidViewModel(app) {
|
||||
|
||||
private val _accountModel by lazy { MutableLiveData<AccountModel>() }
|
||||
val accountModel: LiveData<AccountModel> = _accountModel
|
||||
|
||||
@@ -5,10 +5,9 @@ import android.content.ClipboardManager
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.getSystemService
|
||||
import com.yogeshpaliyal.common.utils.PasswordGenerator
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.ActivityGeneratePasswordBinding
|
||||
import com.yogeshpaliyal.keypass.utils.PasswordGenerator
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.yogeshpaliyal.keypass.ui.home
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.*
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.data.MyAccountModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -17,7 +18,7 @@ import javax.inject.Inject
|
||||
* created on 30-01-2021 23:02
|
||||
*/
|
||||
@HiltViewModel
|
||||
class DashboardViewModel @Inject constructor(application: Application, val appDb: AppDatabase) :
|
||||
class DashboardViewModel @Inject constructor(application: Application, val appDb: com.yogeshpaliyal.common.AppDatabase) :
|
||||
AndroidViewModel(application) {
|
||||
|
||||
val keyword by lazy {
|
||||
|
||||
@@ -11,9 +11,10 @@ import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.constants.AccountType
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.data.MyAccountModel
|
||||
import com.yogeshpaliyal.keypass.databinding.FragmentHomeBinding
|
||||
import com.yogeshpaliyal.keypass.listener.AccountsClickListener
|
||||
import com.yogeshpaliyal.keypass.ui.addTOTP.AddTOTPActivity
|
||||
@@ -38,7 +39,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private val mAdapter by lazy {
|
||||
UniversalRecyclerAdapter.Builder<AccountModel>(
|
||||
UniversalRecyclerAdapter.Builder<MyAccountModel>(
|
||||
this,
|
||||
content = UniversalAdapterViewType.Content(
|
||||
R.layout.item_accounts,
|
||||
@@ -65,7 +66,8 @@ class HomeFragment : Fragment() {
|
||||
)
|
||||
val clip = ClipData.newPlainText("KeyPass", model.password)
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(context, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +81,10 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private val observer = Observer<List<AccountModel>> {
|
||||
val newList = it.map {
|
||||
it.copy(id = it.id, title = it.title, uniqueId = it.uniqueId, username = it.username, it.password, it.site, it.notes, it.tags, it.type)
|
||||
val newList = it.map {accountModel ->
|
||||
MyAccountModel().also {
|
||||
it.map(accountModel)
|
||||
}
|
||||
}
|
||||
mAdapter.updateData(Resource.success(ArrayList(newList)))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.viewModels
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.observe
|
||||
@@ -19,9 +18,9 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HALF_EX
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.from
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.yogeshpaliyal.common.utils.themeColor
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.FragmentBottomNavDrawerBinding
|
||||
import com.yogeshpaliyal.keypass.utils.themeColor
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.LazyThreadSafetyMode.NONE
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -18,7 +18,7 @@ import javax.inject.Inject
|
||||
* created on 31-01-2021 14:11
|
||||
*/
|
||||
@HiltViewModel
|
||||
class BottomNavViewModel @Inject constructor (application: Application, val appDb: AppDatabase) : AndroidViewModel(application) {
|
||||
class BottomNavViewModel @Inject constructor (application: Application, val appDb: com.yogeshpaliyal.common.AppDatabase) : AndroidViewModel(application) {
|
||||
private val _navigationList: MutableLiveData<List<NavigationModelItem>> = MutableLiveData()
|
||||
private val tagsDb = appDb.getDao().getTags()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.view.View
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import com.google.android.material.R
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.yogeshpaliyal.keypass.utils.normalize
|
||||
import com.yogeshpaliyal.common.utils.normalize
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.yogeshpaliyal.keypass.ui.nav
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import com.yogeshpaliyal.keypass.data.StringDiffUtil
|
||||
import com.yogeshpaliyal.common.data.StringDiffUtil
|
||||
|
||||
/**
|
||||
* A sealed class which encapsulates all objects [NavigationAdapter] is able to display.
|
||||
|
||||
@@ -7,8 +7,8 @@ import androidx.core.view.marginTop
|
||||
import androidx.core.view.updatePadding
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.yogeshpaliyal.common.utils.normalize
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.utils.normalize
|
||||
|
||||
/**
|
||||
* An action to be performed when a bottom sheet's slide offset is changed.
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.yogeshpaliyal.keypass.ui.settings
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
@@ -11,15 +14,14 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.common.db_helper.createBackup
|
||||
import com.yogeshpaliyal.common.db_helper.restoreBackup
|
||||
import com.yogeshpaliyal.common.utils.*
|
||||
import com.yogeshpaliyal.keypass.BuildConfig
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.databinding.LayoutBackupKeypharseBinding
|
||||
import com.yogeshpaliyal.keypass.databinding.LayoutRestoreKeypharseBinding
|
||||
import com.yogeshpaliyal.keypass.db_helper.createBackup
|
||||
import com.yogeshpaliyal.keypass.db_helper.restoreBackup
|
||||
import com.yogeshpaliyal.keypass.ui.backup.BackupActivity
|
||||
import com.yogeshpaliyal.keypass.utils.*
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
@@ -30,7 +32,7 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
private val CHOOSE_RESTORE_FILE_REQUEST_CODE = 26213
|
||||
|
||||
@Inject
|
||||
lateinit var appDb: AppDatabase
|
||||
lateinit var appDb: com.yogeshpaliyal.common.AppDatabase
|
||||
|
||||
@Inject
|
||||
lateinit var sp: SharedPreferences
|
||||
@@ -42,7 +44,10 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||
when (preference?.key) {
|
||||
"feedback" -> {
|
||||
context?.email(getString(R.string.feedback_to_keypass), "yogeshpaliyal.foss@gmail.com")
|
||||
context?.email(
|
||||
getString(R.string.feedback_to_keypass),
|
||||
"yogeshpaliyal.foss@gmail.com"
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -83,8 +88,8 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
intent.addFlags(
|
||||
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
)
|
||||
|
||||
try {
|
||||
@@ -103,7 +108,7 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
intent.addFlags(
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
)
|
||||
|
||||
try {
|
||||
@@ -144,7 +149,11 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
"Restore"
|
||||
) { dialog, which ->
|
||||
lifecycleScope.launch {
|
||||
val result = appDb.restoreBackup(binding.etKeyPhrase.text.toString(), contentResolver, selectedFile)
|
||||
val result = appDb.restoreBackup(
|
||||
binding.etKeyPhrase.text.toString(),
|
||||
contentResolver,
|
||||
selectedFile
|
||||
)
|
||||
if (result) {
|
||||
dialog?.dismiss()
|
||||
Toast.makeText(
|
||||
@@ -187,9 +196,16 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
binding.txtCode.setOnClickListener {
|
||||
val clipboard =
|
||||
getSystemService(requireContext(), ClipboardManager::class.java)
|
||||
val clip = ClipData.newPlainText(getString(R.string.app_name), binding.txtCode.text)
|
||||
val clip = ClipData.newPlainText(
|
||||
getString(R.string.app_name),
|
||||
binding.txtCode.text
|
||||
)
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(context, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.copied_to_clipboard),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
MaterialAlertDialogBuilder(requireContext()).setView(binding.root)
|
||||
.setPositiveButton(
|
||||
@@ -198,7 +214,11 @@ class MySettingsFragment : PreferenceFragmentCompat() {
|
||||
dialog?.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
Toast.makeText(context, getString(R.string.backup_completed), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
context,
|
||||
getString(R.string.backup_completed),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.BindingAdapter
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import com.yogeshpaliyal.common.utils.getDrawableOrNull
|
||||
|
||||
@BindingAdapter(
|
||||
"popupElevationOverlay"
|
||||
|
||||
@@ -6,11 +6,11 @@ import android.net.Uri
|
||||
import androidx.hilt.work.HiltWorker
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.utils.backupAccounts
|
||||
import com.yogeshpaliyal.keypass.utils.canUserAccessBackupDirectory
|
||||
import com.yogeshpaliyal.keypass.utils.getBackupDirectory
|
||||
import com.yogeshpaliyal.keypass.utils.overrideAutoBackup
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.utils.backupAccounts
|
||||
import com.yogeshpaliyal.common.utils.canUserAccessBackupDirectory
|
||||
import com.yogeshpaliyal.common.utils.getBackupDirectory
|
||||
import com.yogeshpaliyal.common.utils.overrideAutoBackup
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.content.SharedPreferences
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.yogeshpaliyal.keypass.utils.isAutoBackupEnabled
|
||||
import com.yogeshpaliyal.common.utils.isAutoBackupEnabled
|
||||
|
||||
fun Context?.executeAutoBackup(sp: SharedPreferences) {
|
||||
this ?: return
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<variable
|
||||
name="accountData"
|
||||
type="com.yogeshpaliyal.keypass.data.AccountModel" />
|
||||
type="com.yogeshpaliyal.common.data.AccountModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<data>
|
||||
<import type="com.yogeshpaliyal.keypass.data.AccountModel" />
|
||||
<import type="com.yogeshpaliyal.keypass.data.MyAccountModel" />
|
||||
|
||||
<variable
|
||||
name="model"
|
||||
type="AccountModel" />
|
||||
type="MyAccountModel" />
|
||||
<variable
|
||||
name="listener"
|
||||
type="com.yogeshpaliyal.keypass.listener.AccountsClickListener<AccountModel>" />
|
||||
type="com.yogeshpaliyal.keypass.listener.AccountsClickListener<MyAccountModel>" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<data>
|
||||
<import type="com.yogeshpaliyal.keypass.data.AccountModel" />
|
||||
<import type="com.yogeshpaliyal.keypass.data.MyAccountModel" />
|
||||
|
||||
<variable
|
||||
name="model"
|
||||
type="AccountModel" />
|
||||
type="MyAccountModel" />
|
||||
<variable
|
||||
name="listener"
|
||||
type="com.yogeshpaliyal.keypass.listener.AccountsClickListener<AccountModel>" />
|
||||
type="com.yogeshpaliyal.keypass.listener.AccountsClickListener<MyAccountModel>" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
lifecycle_version = "2.4.0"
|
||||
room_version = "2.3.0"
|
||||
navigation_version = '2.3.5'
|
||||
ext.hilt_version = '2.38.1'
|
||||
ext.hilt_version = '2.40'
|
||||
|
||||
}
|
||||
repositories {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,69 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
// apache common codec
|
||||
implementation "commons-codec:commons-codec:1.15"
|
||||
|
||||
//Androidx Security
|
||||
implementation "androidx.security:security-crypto:1.1.0-alpha03"
|
||||
|
||||
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
androidTestImplementation 'androidx.test:rules:1.4.0'
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
|
||||
|
||||
// dependency injection
|
||||
implementation("com.google.dagger:hilt-android:$hilt_version")
|
||||
kapt("com.google.dagger:hilt-android-compiler:$hilt_version")
|
||||
implementation("androidx.hilt:hilt-work:1.0.0")
|
||||
// When using Kotlin.
|
||||
kapt("androidx.hilt:hilt-compiler:1.0.0")
|
||||
|
||||
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.8'
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yogeshpaliyal.common
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.yogeshpaliyal.common", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yogeshpaliyal.common">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.KeyPass">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.yogeshpaliyal.keypass
|
||||
package com.yogeshpaliyal.common
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.db.DbDao
|
||||
|
||||
/*
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yogeshpaliyal.common
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
package com.yogeshpaliyal.keypass.data
|
||||
package com.yogeshpaliyal.common.data
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.common.utils.TOTPHelper
|
||||
import com.yogeshpaliyal.common.utils.getRandomString
|
||||
import com.yogeshpaliyal.keypass.constants.AccountType
|
||||
import com.yogeshpaliyal.keypass.utils.TOTPHelper
|
||||
import com.yogeshpaliyal.keypass.utils.getRandomString
|
||||
import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
|
||||
import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
@@ -19,7 +15,7 @@ import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
|
||||
* created on 30-01-2021 20:38
|
||||
*/
|
||||
@Entity(tableName = "account")
|
||||
data class AccountModel(
|
||||
open class AccountModel(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
@SerializedName("id")
|
||||
@@ -57,28 +53,16 @@ data class AccountModel(
|
||||
@ColumnInfo(name = "type")
|
||||
@SerializedName("type")
|
||||
var type: Int? = AccountType.DEFAULT
|
||||
) : BaseDiffUtil, UniversalViewType {
|
||||
) {
|
||||
|
||||
fun getInitials() = (
|
||||
title?.firstOrNull() ?: username?.firstOrNull() ?: site?.firstOrNull()
|
||||
title?.firstOrNull() ?: username?.firstOrNull() ?: site?.firstOrNull()
|
||||
?: notes?.firstOrNull() ?: 'K'
|
||||
).toString()
|
||||
).toString()
|
||||
|
||||
override fun getDiffId(): Any? {
|
||||
return id
|
||||
}
|
||||
|
||||
override fun getDiffBody(): Any? {
|
||||
return if (type == AccountType.TOTP) {
|
||||
super.getDiffBody()
|
||||
} else {
|
||||
Gson().toJson(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun getOtp() = TOTPHelper.generate(password)
|
||||
|
||||
fun getTOtpProgress() = TOTPHelper.getProgress().toInt()
|
||||
|
||||
override fun getLayoutId(): Int = if (type == AccountType.TOTP) R.layout.item_totp else R.layout.item_accounts
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.data
|
||||
package com.yogeshpaliyal.common.data
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.data
|
||||
package com.yogeshpaliyal.common.data
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.yogeshpaliyal.keypass.db
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.*
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/*
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.yogeshpaliyal.keypass.db_helper
|
||||
package com.yogeshpaliyal.common.db_helper
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import androidx.room.withTransaction
|
||||
import com.google.gson.Gson
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.data.BackupData
|
||||
import com.yogeshpaliyal.common.utils.getRandomString
|
||||
import com.yogeshpaliyal.keypass.constants.AccountType
|
||||
import com.yogeshpaliyal.keypass.data.BackupData
|
||||
import com.yogeshpaliyal.keypass.utils.getRandomString
|
||||
import com.yogeshpaliyal.keypass.db_helper.EncryptionHelper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -19,13 +20,17 @@ import kotlinx.coroutines.withContext
|
||||
* created on 20-02-2021 19:31
|
||||
*/
|
||||
|
||||
suspend fun AppDatabase.createBackup(key: String, contentResolver: ContentResolver, fileUri: Uri?) =
|
||||
suspend fun AppDatabase.createBackup(
|
||||
key: String,
|
||||
contentResolver: ContentResolver,
|
||||
fileUri: Uri?
|
||||
) =
|
||||
withContext(Dispatchers.IO) {
|
||||
fileUri ?: return@withContext false
|
||||
val data = getDao().getAllAccountsList()
|
||||
data ?: return@withContext false
|
||||
|
||||
val json = Gson().toJson(BackupData(this@createBackup.openHelper.readableDatabase.version, data))
|
||||
val json =
|
||||
Gson().toJson(BackupData(this@createBackup.openHelper.readableDatabase.version, data))
|
||||
val fileStream = contentResolver.openOutputStream(fileUri)
|
||||
EncryptionHelper.doCryptoEncrypt(key, json, fileStream)
|
||||
|
||||
@@ -49,7 +54,7 @@ suspend fun AppDatabase.restoreBackup(
|
||||
return@withContext Gson().fromJson(restoredFile, BackupData::class.java)?.let { data ->
|
||||
if (data.version == 3) {
|
||||
for (datum in data.data) {
|
||||
datum.uniqueId = getRandomString()
|
||||
getRandomString().also { datum.uniqueId = it }
|
||||
}
|
||||
}
|
||||
if (data.version < 5) {
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.yogeshpaliyal.keypass.di.module
|
||||
package com.yogeshpaliyal.common.di.module
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.room.Room
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.utils.MySharedPreferences
|
||||
import com.yogeshpaliyal.keypass.utils.getRandomString
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.R
|
||||
import com.yogeshpaliyal.common.utils.MySharedPreferences
|
||||
import com.yogeshpaliyal.common.utils.getRandomString
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.FloatRange
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.view.autofill.AutofillManager
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.yogeshpaliyal.keypass.AppDatabase
|
||||
import com.yogeshpaliyal.keypass.db_helper.createBackup
|
||||
import com.yogeshpaliyal.common.AppDatabase
|
||||
import com.yogeshpaliyal.common.db_helper.createBackup
|
||||
import java.security.SecureRandom
|
||||
|
||||
/*
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
/*Used as a wrapper for data that is exposed via a LiveData that represents an
|
||||
event.*/
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.security.keystore.KeyGenParameterSpec
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
class PasswordGenerator(
|
||||
private var length: Int,
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils
|
||||
package com.yogeshpaliyal.common.utils
|
||||
|
||||
import java.util.*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils;
|
||||
package com.yogeshpaliyal.common.utils;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils;
|
||||
package com.yogeshpaliyal.common.utils;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yogeshpaliyal.keypass.utils;
|
||||
package com.yogeshpaliyal.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
@@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.KeyPass" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">common</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.KeyPass" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yogeshpaliyal.common
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
include ':app'
|
||||
rootProject.name = "KeyPass"
|
||||
rootProject.name = "KeyPass"
|
||||
include ':common'
|
||||
|
||||