From 9a37ab24a9c8909787e5514e06fde01f7412d8a7 Mon Sep 17 00:00:00 2001 From: ai-null Date: Thu, 11 Mar 2021 20:26:15 +0700 Subject: [PATCH] a bit of refactor --- .../ainul/oprek/adapter/ListItemAdapter.kt | 14 +++++++--- .../java/com/ainul/oprek/util/Constants.kt | 2 ++ .../com/ainul/oprek/util/EncryptManager.kt | 2 +- .../main/res/layout/activity_detail_user.xml | 16 ----------- app/src/main/res/layout/activity_profile.xml | 27 +------------------ app/src/main/res/values/strings.xml | 1 + 6 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 app/src/main/res/layout/activity_detail_user.xml diff --git a/app/src/main/java/com/ainul/oprek/adapter/ListItemAdapter.kt b/app/src/main/java/com/ainul/oprek/adapter/ListItemAdapter.kt index f4dfe61..da81313 100644 --- a/app/src/main/java/com/ainul/oprek/adapter/ListItemAdapter.kt +++ b/app/src/main/java/com/ainul/oprek/adapter/ListItemAdapter.kt @@ -24,10 +24,7 @@ class ListItemAdapter(private val clickListener: ListItemListener) : ListAdapter(ProjectDiffUtil()) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListItemViewHolder { - val layoutInflater = LayoutInflater.from(parent.context) - val holder = ListItemBinding.inflate(layoutInflater, parent, false) - - return ListItemViewHolder(holder) + return ListItemViewHolder.from(parent) } override fun onBindViewHolder(holder: ListItemViewHolder, position: Int) { @@ -44,5 +41,14 @@ class ListItemAdapter(private val clickListener: ListItemListener) : binding.project = data binding.executePendingBindings() } + + companion object { + fun from (parent: ViewGroup): ListItemViewHolder { + val layoutInflater = LayoutInflater.from(parent.context) + val holder = ListItemBinding.inflate(layoutInflater, parent, false) + + return ListItemViewHolder(holder) + } + } } } \ No newline at end of file diff --git a/app/src/main/java/com/ainul/oprek/util/Constants.kt b/app/src/main/java/com/ainul/oprek/util/Constants.kt index c3c6e32..d573c84 100644 --- a/app/src/main/java/com/ainul/oprek/util/Constants.kt +++ b/app/src/main/java/com/ainul/oprek/util/Constants.kt @@ -7,6 +7,8 @@ object Constants { CANCEL(-1); } + const val MASTER_KEY = "oprek-master-key" + // Screen navigation request code const val REQUEST_CODE_UPDATE_PROJECT = 1 const val REQUEST_CODE_CHOOSE_IMAGE = 2 diff --git a/app/src/main/java/com/ainul/oprek/util/EncryptManager.kt b/app/src/main/java/com/ainul/oprek/util/EncryptManager.kt index 097fc13..883581c 100644 --- a/app/src/main/java/com/ainul/oprek/util/EncryptManager.kt +++ b/app/src/main/java/com/ainul/oprek/util/EncryptManager.kt @@ -14,7 +14,7 @@ import androidx.security.crypto.MasterKey class EncryptManager(context: Context) { // this will be our private key for the app, also with the schema to encrypt - private val masterKey = MasterKey.Builder(context, "oprek-master-key") + private val masterKey = MasterKey.Builder(context, Constants.MASTER_KEY) .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) .build() diff --git a/app/src/main/res/layout/activity_detail_user.xml b/app/src/main/res/layout/activity_detail_user.xml deleted file mode 100644 index 347b39b..0000000 --- a/app/src/main/res/layout/activity_detail_user.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 6073f81..2af6c96 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -71,6 +71,7 @@ - - - - - - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e15d98e..33f7c92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -155,4 +155,5 @@ %s name can\'t be empty! History + Statistics