From b94b52a42ddc2325b539d0956fd0adcf35308b52 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 17 Apr 2020 18:36:07 +0530 Subject: Refactor Git related activities (#685) * Refactor git logic into separate parts * Extract hardcoded strings * Add KDoc to updateHostname, remove unused field * Cleanups * Fix dialog message * Wire in repository clone flow * spotless * Remove unused method * Cleanup GitActivity - Rename to GitOperationActivity. - Ensure identityBuilder is always closed regardless of what fragment uses it. - Remove hardcoded "Operation" strings and replace with REQUEST_ARG_OP. - Apply a transparent theme to GitOperationActivity make the UI less jarring. * Tweak some stupidly worded dialog messages As pointed out in #629, these strings are shoddily worded and do not express any clear intent to the user, leaving them confused and angry. * GitOperationActivity: wrap Context to ensure right theme is used * spotless * undo build.gradle change * Use correct parent theme, remove now useless wrapping * GitServerConfigActivity: fix repository clone flow * temp: disable leakcanary framework leaks on Samsung are pissing me off * Make system bars transparent in git activity * Tweak HTTPS password layout * Unhardcode wrong passphrase string * Store SSH passphrase in EncryptedSharedPreferences Also revamp the dialog to look a bit better * Implement support for remembering HTTPS password Fixes #521 * Try to patch HTTPS remote creation logic * Update security-crypto * Clear saved passphrase/password on auth failure * Revert "Update security-crypto" Broken on R DP2.1 This reverts commit 4b20371dd42c512a3dd3b759859abb6c1ffd2961. * Revert "temp: disable leakcanary" This reverts commit 2db7d41bd67b79c6dc8c5b359a7b27100379f45f. * Update CHANGELOG * Remove spacer * Remove useless override * Wrap git server activity in a ScrollView * GitOperation: always finish calling activity when dialogs are dismissed * Wipe saved password/passphrase when hostname changes * Don't commit prefs updates * Don't call listFiles excessively * Finish activity after saving configuration * Make ConnectionMode and Protocol enum classes * Change SSH key passphrase key, don't wipe on host change * Reimplement BaseGitActivity.updateUrl (was updateHostname) * Use SharedPreferences.edit KTX extension * Disable inapplicable connection modes depending on scheme * BaseGitActivity: annotate onDestroy with CallSuper We'll leak the identityBuilder connection otherwise * Move input hack for AlertDialog into an extension function We re-use this in many places * Fix protocol/mode toggle issue and consistenly name options * Fix a crash when opening GitServerConfigActivity without a repo * Fix OpenKeychain callbacks by moving onActivityResult to BaseGitActivity * Run spotlessApply Signed-off-by: Harsh Shandilya Co-authored-by: Fabian Henneke --- app/src/main/res/color/toggle_button_selector.xml | 6 + app/src/main/res/drawable/bottom_line.xml | 14 - app/src/main/res/drawable/red_rectangle.xml | 24 -- app/src/main/res/layout/activity_git_clone.xml | 362 ++++++++++++--------- app/src/main/res/layout/activity_git_config.xml | 5 +- app/src/main/res/layout/autofill_instructions.xml | 1 - app/src/main/res/layout/git_passphrase_layout.xml | 36 +- app/src/main/res/layout/password_recycler_view.xml | 1 - app/src/main/res/menu/git_clone.xml | 2 +- app/src/main/res/values-ar/strings.xml | 1 - app/src/main/res/values-cs/strings.xml | 4 - app/src/main/res/values-de/strings.xml | 4 - app/src/main/res/values-es/strings.xml | 4 - app/src/main/res/values-fr/strings.xml | 4 - app/src/main/res/values-ja/strings.xml | 4 - app/src/main/res/values-night/colors.xml | 2 + app/src/main/res/values-ru/strings.xml | 4 - app/src/main/res/values-zh-rCN/strings.xml | 4 - app/src/main/res/values-zh-rTW/strings.xml | 4 - app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/strings.xml | 20 +- app/src/main/res/values/styles.xml | 15 + 22 files changed, 260 insertions(+), 263 deletions(-) create mode 100644 app/src/main/res/color/toggle_button_selector.xml delete mode 100644 app/src/main/res/drawable/bottom_line.xml delete mode 100644 app/src/main/res/drawable/red_rectangle.xml (limited to 'app/src/main/res') diff --git a/app/src/main/res/color/toggle_button_selector.xml b/app/src/main/res/color/toggle_button_selector.xml new file mode 100644 index 00000000..cb4de6a7 --- /dev/null +++ b/app/src/main/res/color/toggle_button_selector.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bottom_line.xml b/app/src/main/res/drawable/bottom_line.xml deleted file mode 100644 index e67c96fa..00000000 --- a/app/src/main/res/drawable/bottom_line.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/red_rectangle.xml b/app/src/main/res/drawable/red_rectangle.xml deleted file mode 100644 index bec893f2..00000000 --- a/app/src/main/res/drawable/red_rectangle.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_git_clone.xml b/app/src/main/res/layout/activity_git_clone.xml index 05d9a557..de9a240e 100644 --- a/app/src/main/res/layout/activity_git_clone.xml +++ b/app/src/main/res/layout/activity_git_clone.xml @@ -1,178 +1,216 @@ - - - - - - - - - + + - - - - - + + + + + + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + android:textColor="?android:attr/windowBackground" + android:layout_marginTop="8dp" + app:backgroundTint="?attr/colorSecondary" + app:layout_constraintTop_toBottomOf="@id/connection_mode_group" + app:layout_constraintStart_toStartOf="parent" /> + + diff --git a/app/src/main/res/layout/activity_git_config.xml b/app/src/main/res/layout/activity_git_config.xml index a576ec46..94c09e27 100644 --- a/app/src/main/res/layout/activity_git_config.xml +++ b/app/src/main/res/layout/activity_git_config.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:padding="@dimen/activity_horizontal_margin" android:background="?android:attr/windowBackground" - tools:context="com.zeapo.pwdstore.git.GitActivity" + tools:context="com.zeapo.pwdstore.git.GitConfigActivity" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="81dp"> @@ -51,7 +51,6 @@ android:layout_height="wrap_content" android:layout_margin="8dp" android:text="@string/crypto_save" - android:onClick="applyGitConfigs" android:textColor="?android:attr/windowBackground" app:backgroundTint="?attr/colorSecondary" app:layout_constraintTop_toBottomOf="@id/email_input_layout" @@ -95,7 +94,6 @@ android:layout_height="wrap_content" android:layout_margin="8dp" android:text="@string/abort_rebase" - android:onClick="abortRebase" android:textColor="?android:attr/windowBackground" app:backgroundTint="?attr/colorSecondary" app:layout_constraintTop_toBottomOf="@id/commit_hash_label" /> @@ -107,7 +105,6 @@ android:layout_height="wrap_content" android:layout_margin="8dp" android:text="@string/reset_to_remote" - android:onClick="resetToRemote" android:textColor="?android:attr/windowBackground" app:backgroundTint="?attr/colorSecondary" app:layout_constraintTop_toBottomOf="@id/git_abort_rebase" /> diff --git a/app/src/main/res/layout/autofill_instructions.xml b/app/src/main/res/layout/autofill_instructions.xml index 8ce0a793..e7cf3dd1 100644 --- a/app/src/main/res/layout/autofill_instructions.xml +++ b/app/src/main/res/layout/autofill_instructions.xml @@ -19,7 +19,6 @@ android:textSize="16sp" /> + android:layout_height="match_parent" + android:padding="16dp"> - + app:layout_constraintTop_toTopOf="parent"> + + - + app:layout_constraintTop_toBottomOf="@+id/git_auth_passphrase_layout" /> diff --git a/app/src/main/res/layout/password_recycler_view.xml b/app/src/main/res/layout/password_recycler_view.xml index dd6b00c1..5368d593 100644 --- a/app/src/main/res/layout/password_recycler_view.xml +++ b/app/src/main/res/layout/password_recycler_view.xml @@ -25,7 +25,6 @@ + tools:context="com.zeapo.pwdstore.git.GitServerConfigActivity" > حسناً نعم لا - لا … لاحقاً إلغاء زامن المستودع إظهار كلمة السر diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 86985f8f..5917ff6b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -9,7 +9,6 @@ Informace repozitáře Naklonujte nebo vytvořte nový repozitář před pokusem přidat heslo nebo spustit synchronizaci. - Před inicializací repozitáře je třeba vybrat "ID PGP klíče" Opravdu chcete smazat heslo %1$s? Přesunout Editovat @@ -43,7 +42,6 @@ Zapomněli jste uvést přihlašovací jméno? - Je třeba zadat informaci o serveru před vlastní synchronizací Importujte nebo si prosím vygenerujte svůj SSH klíč v nastavení aplikace Žádný SSH klíč Import @@ -163,8 +161,6 @@ OK Ano Ne - Je na cestě… - Ne… později Ajaj… Zrušit Synchronizovat repozitář diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4960387f..aec047f9 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -9,7 +9,6 @@ Repository Informationen Bitte klone oder erstelle ein neues Repository, bevor du versuchst ein Passwort hinzuzufügen oder jegliche Synchronisation-Operation durchführst. - Du musst deine PGP-Key ID auwählen, bevor das Repository intialisiert wird. Bist du dir sicher, dass du das Passwort löschen möchtest %1$s? Verschieben Bearbeiten @@ -28,7 +27,6 @@ Hast du vergessen einen Nutzernamen zu vergeben? - You have to set the information about the server before synchronizing with the server Please import or generate your SSH key file in the preferences Kein SSH-Key angegeben Import @@ -141,8 +139,6 @@ OK Ja Nein - Auf dem Weg… - Nah… später Oops… Abbruch Synchronisiere Repository diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 47ec808d..aeb0a133 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -9,7 +9,6 @@ Información de repositorio Por favor clona o crea un nuevo repositorio antes de añadir una contraseña o ejecutar una operación de sincronización. - Tienes que seleccionar una llave PGP antes de inicializar el repositorio Confirma que deseas eliminar la contraseña %1$s Mover Editar @@ -39,7 +38,6 @@ Olvidaste especificar un nombre de usuario? - Necesitas configurar la información del servidor antes de sincronizar Por favor importa o genera tu llave SSH en los ajustes No hay llave SSH Importar @@ -177,8 +175,6 @@ OK Sí No - Ok, Vamos… - Nah… después Ups… Cancelar Sincronizar con servidor diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 0f4c2025..8461d96d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -9,7 +9,6 @@ Information sur le dépôt Git Clonez ou créez un dépôt suivant avant d\'essayer d\'ajouter un mot de pass ou d\'effectuer une opération de synchornisation. - Vous devez sélectionner votre "PGP-Key ID" avant d\'initialiser le dépôt Êtes-vous sûr de vouloir supprimer le mot de passe %1$s? Déplacer Éditer @@ -45,7 +44,6 @@ Avez-vous oublié to renseigner votre nom d\'utilisateur ? - Vous devez renseignez les informations à propos du serveur avant d\'effectuer une synchronisation avec celui-ci Vous devez importer ou générer votre fichier de clef SSH dans les préférences Absence de cled SSH Importer @@ -178,8 +176,6 @@ OK Oui Non - En chemin… - Non… plus tard Oups… Annuler Synchronisation du dépôt diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c798f6c2..a70c5670 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -9,7 +9,6 @@ リポジトリ情報 パスワードや同期操作を追加する前に、以下の新しいリポジトリをクローンまたは作成してください。 - リポジトリを初期化する前に "PGP 鍵 ID"を選択する必要があります パスワードを削除してもよろしいですか %1$s 削除 @@ -28,7 +27,6 @@ ユーザー名の指定を忘れましたか? - サーバーと同期する前に、サーバーに関する情報を設定する必要があります プリファレンスで SSH 鍵ファイルをインポートまたは生成してください SSH 鍵がありませんkey インポート @@ -120,8 +118,6 @@ OK はい いいえ - 途中… - いや…あとで おっと… キャンセル リポジトリを同期 diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 9dfc9d73..0b858c75 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -16,4 +16,6 @@ @color/primary_color #66EEEEEE @color/window_background + #aaff7539 + #44ff7539 diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bc73c5c2..04d7b837 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -9,7 +9,6 @@ Информация о репозитории Пожалуйста, клонируйте или создайте новый репозиторий перед тем, как добавлять пароль или выполнять синхронизацию. - Вы должны выбрать PGP ключ перед инициализацией хранилища Вы уверены что хотите удалить пароль %1$s Переместить Редактировать @@ -47,7 +46,6 @@ Вы забыли указать имя пользователя? - Вы должны указать информацию о сервере до выполнения синхронизации Пожалуйста, импортируйте или сгенерируйте новый SSH ключ в настройках Нет SSH ключа Импортировать @@ -211,8 +209,6 @@ OK Да Нет - On my way… - Не … позже Упс… Отмена Синхронизировать репозиторий diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 019f703c..76926ce9 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -9,7 +9,6 @@ Repo 信息 在尝试添加密码或任何同步操作前请在下方克隆或添加一个新的 Repo - 在初始化 Repo 之前你必须选择你的\"PGP-Key ID\" 你确定要删除密码 %1$s 删除 @@ -28,7 +27,6 @@ 你忘了提供用户名了吗? - 你必须在与服务器同步前设置服务器信息 请在设置中导入或生成你的SSH密钥文件 无SSH密钥 导入 @@ -117,8 +115,6 @@ 确定 确定 否 - 现在就去 - 呃… 算了吧 糟糕… 取消 同步 Repo diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index bdc6f1fb..7a4b4f1f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -9,7 +9,6 @@ Repo 訊息 在嘗試新增密碼或任何同步操作之前請在下方 clone 或新增一個新的 Repo - 在初始化 Repo 之前你必須選擇你的\"PGP-Key ID\" 你確定要刪除密碼 %1$s 刪除 @@ -25,7 +24,6 @@ 你忘記輸入使用者名稱了嗎? - 你必須在與伺服器同步前設定伺服器資訊 請在設定中匯入或產生你的 SSH 金鑰 無 SSH 金鑰 匯入 @@ -114,8 +112,6 @@ 確定 確定 否 - 確定 - 呃… 算了吧 糟糕… 取消 同步 Repo diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 13bc049d..54a3af70 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -19,6 +19,8 @@ #668eacbb #000000 @color/primary_dark_color + #aaff7043 + #44ff7043 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bd2aa75e..dafad85a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,7 +19,7 @@ Please clone or create a new repository below before trying to add a password or running any synchronization operation. - You have to select your PGP key ID before initializing the repository + A valid PGP key must be selected in Settings before initializing the repository Are you sure you want to delete the password %1$s? Move Edit @@ -57,7 +57,7 @@ Did you forget to specify a username? - You have to set the information about the server before synchronizing with the server + Please fix the remote server configuration in settings before proceeding Please import or generate your SSH key file in the preferences No SSH key Import @@ -228,8 +228,8 @@ OK Yes No - On my way… - Nah… later + Go to Settings + Go back Oops… Cancel Synchronize repository @@ -309,7 +309,7 @@ Error occurred during the push operation: Clear ssh-key saved passphrase Clear saved preference for HOTP incrementing - Remember the passphrase in the app configuration (insecure) + Remember key passphrase Hackish tools Abort rebase and push new branch Hard reset to remote branch @@ -349,4 +349,14 @@ Dark Set by Battery Saver System default + SSH + HTTPS + SSH key + Password + OpenKeychain + Successfully saved configuration + Configuration error: please verify your settings and try again + Unable to open the ssh-key + Please check that it was imported. + Wrong passphrase diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 090b56b9..b5a03bb4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -33,6 +33,21 @@ @color/primary_color + + -- cgit v1.2.3