summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-05-26 21:43:41 +0530
committerGitHub <noreply@github.com>2020-05-26 21:43:41 +0530
commiteb936e1f36d308fe210fdfa4a34a5df66fc1a70b (patch)
tree99ce5103eb6a3c789e4a9632d0185f41e855130a /app/src
parent96ed53206e62421e7e7e375ce921c24a85053a13 (diff)
Introduce better R8 optimizations (#796)
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt36
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt11
-rw-r--r--app/src/main/res/layout/fragment_to_clone_or_not.xml9
3 files changed, 25 insertions, 31 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
index 52419852..2b3c1c59 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
@@ -22,7 +22,6 @@ import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.MenuItem.OnActionExpandListener
-import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatTextView
@@ -65,6 +64,9 @@ import com.zeapo.pwdstore.utils.PasswordRepository.Companion.getRepositoryDirect
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.initialize
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.isInitialized
import com.zeapo.pwdstore.utils.PasswordRepository.PasswordSortOrder.Companion.getSortOrder
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.clone_from_server_button
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.local_directory_button
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.settings_button
import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import org.eclipse.jgit.api.Git
@@ -126,6 +128,10 @@ class PasswordStore : AppCompatActivity() {
super.onCreate(savedInstance)
setContentView(R.layout.activity_pwdstore)
+ settings_button.setOnClickListener { startActivity(Intent(this, UserPreference::class.java)) }
+ local_directory_button.setOnClickListener { initRepository(NEW_REPO_BUTTON) }
+ clone_from_server_button.setOnClickListener { initRepository(CLONE_REPO_BUTTON) }
+
// If user is eligible for Oreo autofill, prompt them to switch.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
!settings.getBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, false)) {
@@ -329,24 +335,6 @@ class PasswordStore : AppCompatActivity() {
searchItem.collapseActionView()
}
- fun openSettings(@Suppress("UNUSED_PARAMETER") view: View?) {
- val intent: Intent
- try {
- intent = Intent(this, UserPreference::class.java)
- startActivity(intent)
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
-
- fun cloneExistingRepository(@Suppress("UNUSED_PARAMETER") view: View?) {
- initRepository(CLONE_REPO_BUTTON)
- }
-
- fun createNewRepository(@Suppress("UNUSED_PARAMETER") view: View?) {
- initRepository(NEW_REPO_BUTTON)
- }
-
private fun createRepository() {
if (!isInitialized) {
initialize(this)
@@ -780,7 +768,7 @@ class PasswordStore : AppCompatActivity() {
}
}
- private fun initRepository(operation: Int) {
+ fun initRepository(operation: Int) {
closeRepository()
MaterialAlertDialogBuilder(this)
.setTitle(resources.getString(R.string.location_dialog_title))
@@ -843,18 +831,14 @@ class PasswordStore : AppCompatActivity() {
get() = getSortOrder(settings)
companion object {
- const val REQUEST_CODE_SIGN = 9910
const val REQUEST_CODE_ENCRYPT = 9911
- const val REQUEST_CODE_SIGN_AND_ENCRYPT = 9912
const val REQUEST_CODE_DECRYPT_AND_VERIFY = 9913
- const val REQUEST_CODE_GET_KEY = 9914
- const val REQUEST_CODE_GET_KEY_IDS = 9915
const val REQUEST_CODE_EDIT = 9916
const val REQUEST_CODE_SELECT_FOLDER = 9917
const val REQUEST_ARG_PATH = "PATH"
private val TAG = PasswordStore::class.java.name
- private const val CLONE_REPO_BUTTON = 401
- private const val NEW_REPO_BUTTON = 402
+ const val CLONE_REPO_BUTTON = 401
+ const val NEW_REPO_BUTTON = 402
private const val HOME = 403
private const val REQUEST_EXTERNAL_STORAGE = 50
private fun isPrintable(c: Char): Boolean {
diff --git a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
index 5964b461..511e978e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
@@ -4,11 +4,15 @@
*/
package com.zeapo.pwdstore
+import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.clone_from_server_button
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.local_directory_button
+import kotlinx.android.synthetic.main.fragment_to_clone_or_not.settings_button
class ToCloneOrNot : Fragment() {
@@ -20,4 +24,11 @@ class ToCloneOrNot : Fragment() {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_to_clone_or_not, container, false)
}
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ settings_button.setOnClickListener { startActivity(Intent(requireContext(), UserPreference::class.java)) }
+ local_directory_button.setOnClickListener { (requireActivity() as PasswordStore).initRepository(PasswordStore.NEW_REPO_BUTTON) }
+ clone_from_server_button.setOnClickListener { (requireActivity() as PasswordStore).initRepository(PasswordStore.CLONE_REPO_BUTTON) }
+ }
}
diff --git a/app/src/main/res/layout/fragment_to_clone_or_not.xml b/app/src/main/res/layout/fragment_to_clone_or_not.xml
index 716b0c8f..2ee73679 100644
--- a/app/src/main/res/layout/fragment_to_clone_or_not.xml
+++ b/app/src/main/res/layout/fragment_to_clone_or_not.xml
@@ -37,24 +37,23 @@
app:layout_constraintTop_toBottomOf="@+id/app_icon" />
<com.google.android.material.button.MaterialButton
+ android:id="@+id/settings_button"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
- android:onClick="openSettings"
android:text="@string/action_settings"
android:textColor="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
- android:id="@+id/use_local_directory"
+ android:id="@+id/local_directory_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
- android:onClick="createNewRepository"
android:text="@string/initialize"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
@@ -62,13 +61,13 @@
app:layout_constraintTop_toBottomOf="@id/app_name" />
<com.google.android.material.button.MaterialButton
+ android:id="@+id/clone_from_server_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:onClick="cloneExistingRepository"
android:text="@string/clone"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/use_local_directory" />
+ app:layout_constraintTop_toBottomOf="@id/local_directory_button" />
</androidx.constraintlayout.widget.ConstraintLayout>