Introduce better R8 optimizations (#796)
This commit is contained in:
parent
96ed53206e
commit
eb936e1f36
6 changed files with 63 additions and 32 deletions
|
@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Reduce Autofill false positives on username fields by removing "name" from list of heuristic terms
|
- Reduce Autofill false positives on username fields by removing "name" from list of heuristic terms
|
||||||
|
- Reduced app size
|
||||||
|
|
||||||
## [1.8.1] - 2020-05-24
|
## [1.8.1] - 2020-05-24
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ android {
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled = true
|
minifyEnabled = true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles 'proguard-android-optimize.txt', 'proguard-rules.pro'
|
||||||
buildConfigField 'boolean', 'ENABLE_DEBUG_FEATURES', isSnapshot() ? 'true' : 'false'
|
buildConfigField 'boolean', 'ENABLE_DEBUG_FEATURES', isSnapshot() ? 'true' : 'false'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
|
|
36
app/proguard-android-optimize.txt
Normal file
36
app/proguard-android-optimize.txt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
-allowaccessmodification
|
||||||
|
-dontpreverify
|
||||||
|
-dontusemixedcaseclassnames
|
||||||
|
-dontskipnonpubliclibraryclasses
|
||||||
|
-verbose
|
||||||
|
|
||||||
|
-keepattributes *Annotation*
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers enum * {
|
||||||
|
public static **[] values();
|
||||||
|
public static ** valueOf(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
public static final ** CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class androidx.annotation.Keep
|
||||||
|
|
||||||
|
-keep @androidx.annotation.Keep class * {*;}
|
||||||
|
|
||||||
|
-keepclasseswithmembers class * {
|
||||||
|
@androidx.annotation.Keep <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembers class * {
|
||||||
|
@androidx.annotation.Keep <fields>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembers class * {
|
||||||
|
@androidx.annotation.Keep <init>(...);
|
||||||
|
}
|
|
@ -22,7 +22,6 @@ import android.view.KeyEvent
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.MenuItem.OnActionExpandListener
|
import android.view.MenuItem.OnActionExpandListener
|
||||||
import android.view.View
|
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
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.initialize
|
||||||
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.isInitialized
|
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.isInitialized
|
||||||
import com.zeapo.pwdstore.utils.PasswordRepository.PasswordSortOrder.Companion.getSortOrder
|
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.FileUtils
|
||||||
import org.apache.commons.io.FilenameUtils
|
import org.apache.commons.io.FilenameUtils
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
|
@ -126,6 +128,10 @@ class PasswordStore : AppCompatActivity() {
|
||||||
super.onCreate(savedInstance)
|
super.onCreate(savedInstance)
|
||||||
setContentView(R.layout.activity_pwdstore)
|
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 user is eligible for Oreo autofill, prompt them to switch.
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||||
!settings.getBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, false)) {
|
!settings.getBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, false)) {
|
||||||
|
@ -329,24 +335,6 @@ class PasswordStore : AppCompatActivity() {
|
||||||
searchItem.collapseActionView()
|
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() {
|
private fun createRepository() {
|
||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
initialize(this)
|
initialize(this)
|
||||||
|
@ -780,7 +768,7 @@ class PasswordStore : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initRepository(operation: Int) {
|
fun initRepository(operation: Int) {
|
||||||
closeRepository()
|
closeRepository()
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(resources.getString(R.string.location_dialog_title))
|
.setTitle(resources.getString(R.string.location_dialog_title))
|
||||||
|
@ -843,18 +831,14 @@ class PasswordStore : AppCompatActivity() {
|
||||||
get() = getSortOrder(settings)
|
get() = getSortOrder(settings)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val REQUEST_CODE_SIGN = 9910
|
|
||||||
const val REQUEST_CODE_ENCRYPT = 9911
|
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_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_EDIT = 9916
|
||||||
const val REQUEST_CODE_SELECT_FOLDER = 9917
|
const val REQUEST_CODE_SELECT_FOLDER = 9917
|
||||||
const val REQUEST_ARG_PATH = "PATH"
|
const val REQUEST_ARG_PATH = "PATH"
|
||||||
private val TAG = PasswordStore::class.java.name
|
private val TAG = PasswordStore::class.java.name
|
||||||
private const val CLONE_REPO_BUTTON = 401
|
const val CLONE_REPO_BUTTON = 401
|
||||||
private const val NEW_REPO_BUTTON = 402
|
const val NEW_REPO_BUTTON = 402
|
||||||
private const val HOME = 403
|
private const val HOME = 403
|
||||||
private const val REQUEST_EXTERNAL_STORAGE = 50
|
private const val REQUEST_EXTERNAL_STORAGE = 50
|
||||||
private fun isPrintable(c: Char): Boolean {
|
private fun isPrintable(c: Char): Boolean {
|
||||||
|
|
|
@ -4,11 +4,15 @@
|
||||||
*/
|
*/
|
||||||
package com.zeapo.pwdstore
|
package com.zeapo.pwdstore
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
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() {
|
class ToCloneOrNot : Fragment() {
|
||||||
|
|
||||||
|
@ -20,4 +24,11 @@ class ToCloneOrNot : Fragment() {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_to_clone_or_not, container, false)
|
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) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,24 +37,23 @@
|
||||||
app:layout_constraintTop_toBottomOf="@+id/app_icon" />
|
app:layout_constraintTop_toBottomOf="@+id/app_icon" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/settings_button"
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
android:onClick="openSettings"
|
|
||||||
android:text="@string/action_settings"
|
android:text="@string/action_settings"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="48dp"
|
android:layout_marginTop="48dp"
|
||||||
android:onClick="createNewRepository"
|
|
||||||
android:text="@string/initialize"
|
android:text="@string/initialize"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -62,13 +61,13 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/app_name" />
|
app:layout_constraintTop_toBottomOf="@id/app_name" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/clone_from_server_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="cloneExistingRepository"
|
|
||||||
android:text="@string/clone"
|
android:text="@string/clone"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
Loading…
Reference in a new issue