diff options
author | حسين <zidhussein@gmail.com> | 2018-12-25 14:39:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-25 14:39:32 +0000 |
commit | 81aff5d870af5da4b16cc5ed455106dd58aefd54 (patch) | |
tree | 69923380f3522b603d5041e72f65335e5ff0a0dd /app | |
parent | 62954ee78f007545d7630d74c9e11ede90627309 (diff) |
Commit messages (#455)
* use full password path in add/edit git commit message
* commit strings are format strings
* use format strings in other languages
* use move/rename commit message
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 43 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt | 29 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java | 24 | ||||
-rw-r--r-- | app/src/main/res/values-ar/strings.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/values-cs/strings.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values-de/strings.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values-fr/strings.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values-ja/strings.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values-ru/strings.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values-zh-rCN/strings.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values-zh-rTW/strings.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 9 |
12 files changed, 86 insertions, 50 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 04a7f9de..d79e7c19 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -40,6 +40,7 @@ import com.zeapo.pwdstore.utils.PasswordItem; import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter; import com.zeapo.pwdstore.utils.PasswordRepository; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Repository; @@ -557,7 +558,8 @@ public class PasswordStore extends AppCompatActivity { it.remove(); adapter.updateSelectedItems(position, selectedItems); - commitChange("[ANDROID PwdStore] Remove " + item + " from store."); + commitChange(getResources().getString(R.string.git_commit_remove_text, + item.getLongName())); deletePasswords(adapter, selectedItems); } }) @@ -641,19 +643,23 @@ public class PasswordStore extends AppCompatActivity { // if went from decrypt->edit and user saved changes or HOTP counter was incremented, we need to commitChange if (data != null && data.getBooleanExtra("needCommit", false)) { if (data.getStringExtra("OPERATION").equals("EDIT")) { - commitChange(this.getResources().getString(R.string.edit_commit_text) + data.getExtras().getString("NAME")); + commitChange(this.getResources().getString(R.string.git_commit_edit_text, + data.getExtras().getString("LONG_NAME"))); } else { - commitChange(this.getResources().getString(R.string.increment_commit_text) + data.getExtras().getString("NAME")); + commitChange(this.getResources().getString(R.string.git_commit_increment_text, + data.getExtras().getString("LONG_NAME"))); } } refreshListAdapter(); break; case REQUEST_CODE_ENCRYPT: - commitChange(this.getResources().getString(R.string.add_commit_text) + data.getExtras().getString("NAME") + this.getResources().getString(R.string.from_store)); + commitChange(this.getResources().getString(R.string.git_commit_add_text, + data.getExtras().getString("LONG_NAME"))); refreshListAdapter(); break; case REQUEST_CODE_EDIT: - commitChange(this.getResources().getString(R.string.edit_commit_text) + data.getExtras().getString("NAME")); + commitChange(this.getResources().getString(R.string.git_commit_edit_text, + data.getExtras().getString("LONG_NAME"))); refreshListAdapter(); break; case GitActivity.REQUEST_INIT: @@ -698,22 +704,35 @@ public class PasswordStore extends AppCompatActivity { break; } + String repositoryPath = PasswordRepository + .getRepositoryDirectory(getApplicationContext()) + .getAbsolutePath(); + // TODO move this to an async task - for (String string : data.getStringArrayListExtra("Files")) { - File source = new File(string); + for (String fileString : data.getStringArrayListExtra("Files")) { + File source = new File(fileString); if (!source.exists()) { Log.e("Moving", "Tried moving something that appears non-existent."); continue; } + + if (!source.renameTo(new File(target.getAbsolutePath() + "/" + source.getName()))) { // TODO this should show a warning to the user Log.e("Moving", "Something went wrong while moving."); } else { - commitChange("[ANDROID PwdStore] Moved " - + string.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "") - + " to " - + target.getAbsolutePath().replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "") - + target.getAbsolutePath() + "/" + source.getName() + "."); + String basename = FilenameUtils.getBaseName(source.getAbsolutePath()); + + String sourceLongName = PgpActivity.getLongName(source.getParent(), + repositoryPath, basename); + + String destinationLongName = PgpActivity.getLongName(target.getAbsolutePath(), + repositoryPath, basename); + + commitChange(this.getResources() + .getString(R.string.git_commit_move_text, + sourceLongName, + destinationLongName)); } } updateListAdapter(); diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt index 74295e6a..53582973 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -41,6 +41,7 @@ import com.zeapo.pwdstore.utils.Otp import kotlinx.android.synthetic.main.decrypt_layout.* import kotlinx.android.synthetic.main.encrypt_layout.* import org.apache.commons.io.FileUtils +import org.apache.commons.io.FilenameUtils import org.openintents.openpgp.IOpenPgpService2 import org.openintents.openpgp.OpenPgpError import org.openintents.openpgp.util.OpenPgpApi @@ -73,7 +74,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { private val repoPath: String by lazy { intent.getStringExtra("REPO_PATH") } private val fullPath: String by lazy { intent.getStringExtra("FILE_PATH") } - private val name: String by lazy { getName(fullPath, repoPath) } + private val name: String by lazy { getName(fullPath) } private val lastChangedString: CharSequence by lazy { getLastChangedString(intent.getIntExtra("LAST_CHANGED_TIMESTAMP", -1)) } private val relativeParentPath: String by lazy { getParentPath(fullPath, repoPath) } @@ -412,6 +413,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { val returnIntent = Intent() returnIntent.putExtra("CREATED_FILE", path) returnIntent.putExtra("NAME", editName) + returnIntent.putExtra("LONG_NAME", getLongName(fullPath, repoPath, this.editName!!)) // if coming from decrypt screen->edit button if (intent.getBooleanExtra("fromDecrypt", false)) { @@ -785,10 +787,27 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { /** * Gets the name of the password (excluding .gpg) */ - fun getName(fullPath: String, repositoryPath: String): String { - val relativePath = getRelativePath(fullPath, repositoryPath) - val index = relativePath.lastIndexOf("/") - return relativePath.substring(index + 1).replace("\\.gpg$".toRegex(), "") + fun getName(fullPath: String): String { + return FilenameUtils.getBaseName(fullPath); + } + + /** + * /path/to/store/social/facebook.gpg -> social/facebook + */ + @JvmStatic + fun getLongName(fullPath: String, repositoryPath: String, basename: String): String { + var relativePath = getRelativePath(fullPath, repositoryPath) + if (relativePath.isNotEmpty() && relativePath != "/") { + // remove preceding '/' + relativePath = relativePath.substring(1); + if (relativePath.endsWith('/')) { + return relativePath + basename + } else { + return "$relativePath/$basename" + } + } else { + return basename + } } } } diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java index d02adeda..5c2231a5 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java @@ -1,19 +1,22 @@ package com.zeapo.pwdstore.utils; +import com.zeapo.pwdstore.crypto.PgpActivity; + import androidx.annotation.NonNull; import java.io.File; -public class PasswordItem implements Comparable{ +public class PasswordItem implements Comparable { public final static char TYPE_CATEGORY = 'c'; public final static char TYPE_PASSWORD = 'p'; - private char type; - private String name; - private PasswordItem parent; - private File file; - private String fullPathToParent; + private final char type; + private final String name; + private final PasswordItem parent; + private final File file; + private final String fullPathToParent; + private final String longName; /** Create a password item * @@ -24,7 +27,10 @@ public class PasswordItem implements Comparable{ this.parent = parent; this.type = type; this.file = file; - this.fullPathToParent = file.getAbsolutePath().replace(rootDir.getAbsolutePath(), "").replace(file.getName(), ""); + fullPathToParent = file.getAbsolutePath() + .replace(rootDir.getAbsolutePath(), "") + .replace(file.getName(), ""); + longName = PgpActivity.getLongName(fullPathToParent, rootDir.getAbsolutePath(), toString()); } /** Create a new Category item @@ -71,6 +77,10 @@ public class PasswordItem implements Comparable{ return this.fullPathToParent; } + public String getLongName() { + return longName; + } + @Override public String toString(){ return this.getName().replace(".gpg", ""); diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 5b863e6d..95c95f7f 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -15,7 +15,7 @@ <string name="edit">تعديل</string> <string name="delete">حذف</string> - <string name="from_store">  مِن المخزن.</string> + <!-- git commits --> <!-- PGPHandler --> <string name="provider_toast_text">لم يتم إختيار مزود الأوبن بي جي بي بعد !</string> diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index a8bb0a50..407b6367 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -18,9 +18,6 @@ <string name="delete_dialog_text">Opravdu chcete smazat heslo /"</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] Add  </string> - <string name="edit_commit_text">[ANDROID PwdStore] Edit  </string> - <string name="from_store">  from store.</string> <!-- PGPHandler --> <string name="provider_toast_text">Nebyl vybrán poskytovatel OpenPGP!</string> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8c63a37b..bfa35daf 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -21,8 +21,6 @@ <string name="delete">Löschen</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] Add  </string> - <string name="from_store">  from store.</string> <!-- PGPHandler --> <string name="provider_toast_text">Kein OpenPGP-Provider ausgewählt!</string> @@ -170,7 +168,6 @@ <string name="show_extra_content_pref_summary">Soll weiterer Inhalt sichtbar sein?</string> <string name="pwd_generate_button">Generieren</string> <string name="no_repo_selected">Kein externes Repository ausgewählt</string> - <string name="edit_commit_text">[ANDROID PwdStore] Edit  </string> <string name="send_plaintext_password_to">Passwort senden als Nur-Text mit behilfe von…</string> <string name="show_password">Password wiedergeben</string> <string name="repository_uri">Repository URI</string> diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 0f4b427d..a3905ced 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -18,9 +18,8 @@ <string name="delete_dialog_text">Êtes-vous sûr de vouloir supprimer le mot de passe /"</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] Ajouter  </string> - <string name="edit_commit_text">[ANDROID PwdStore] Editer  </string> - <string name="from_store">  depuis le dépôt.</string> + <string name="git_commit_add_text">Ajouter %1$s depuis le dépôt.</string> + <string name="git_commit_edit_text">Editer %1$s depuis le dépôt.</string> <!-- PGPHandler --> <string name="provider_toast_text">Aucun prestataire OpenPGP sélectionné !</string> diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 051d7edf..ca1c08da 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -18,9 +18,8 @@ <string name="delete_dialog_text">パスワードを削除してもよろしいですか /"</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] 追加  </string> - <string name="edit_commit_text">[ANDROID PwdStore] 編集  </string> - <string name="from_store">  ストアから。</string> + <string name="git_commit_add_text">追加 %1$s ストアから。</string> + <string name="git_commit_edit_text">編集 %1$s ストアから。</string> <!-- PGPHandler --> <string name="provider_toast_text">OpenPGP プロバイダが選択されていません!</string> diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d8177901..6863d800 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -21,9 +21,8 @@ <string name="delete">Удалить</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] Добавлен пароль  </string> - <string name="edit_commit_text">[ANDROID PwdStore] Отредактирован пароль  </string> - <string name="from_store">  из хранилища.</string> + <string name="git_commit_add_text">Добавлен пароль %1$s из хранилища.</string> + <string name="git_commit_edit_text">Отредактирован %1$s из хранилища.</string> <!-- PGPHandler --> <string name="provider_toast_text">Не выбран провайдер OpenPGP!</string> diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 6854271d..e0b2a54d 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -3,7 +3,6 @@ <string name="app_name">Password Store</string> <string name="action_search">搜索</string> <string name="action_settings">设置</string> - <string name="add_commit_text">[ANDROID PwdStore] 添加  </string> <string name="autofill_apps_default">使用默认设置</string> <string name="autofill_apps_delete">删除</string> <string name="autofill_apps_first">自动匹配</string> @@ -30,11 +29,11 @@ <string name="dialog_ok">确定</string> <string name="dialog_oops">糟糕…</string> <string name="dialog_yes">确定</string> - <string name="edit_commit_text">[ANDROID PwdStore] 修改  </string> <string name="empty_toast_text">无法使用空白密码或者空白的额外内容</string> <string name="file_toast_text">请提供一个文件名</string> <string name="forget_username_dialog_text">你忘了提供用户名了吗?</string> - <string name="from_store">  从商店</string> + <string name="git_commit_edit_text">修改 %1$s 从商店</string> + <string name="git_commit_add_text">添加 %1$s 从商店</string> <string name="git_pull">Git Pull</string> <string name="git_push">Git Push</string> <string name="git_sync">同步 Repo</string> diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d0970f00..3a9fca05 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -3,7 +3,6 @@ <string name="app_name">Password Store</string> <string name="action_search">搜尋</string> <string name="action_settings">設定</string> - <string name="add_commit_text">[ANDROID PwdStore] Add  </string> <string name="autofill_apps_default">使用預設值</string> <string name="autofill_apps_delete">刪除</string> <string name="autofill_apps_first">自動選取</string> @@ -30,11 +29,9 @@ <string name="dialog_ok">確定</string> <string name="dialog_oops">糟糕…</string> <string name="dialog_yes">確定</string> - <string name="edit_commit_text">[ANDROID PwdStore] Modify  </string> <string name="empty_toast_text">不能使用空白密碼或者空白的備註</string> <string name="file_toast_text">請填寫文件名稱</string> <string name="forget_username_dialog_text">你忘記輸入使用者名稱了嗎?</string> - <string name="from_store">  從商店</string> <string name="git_pull">Git Pull</string> <string name="git_push">Git Push</string> <string name="git_sync">同步 Repo</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 247275a1..a5506aa7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,10 +22,11 @@ <string name="delete">Delete</string> <!-- git commits --> - <string name="add_commit_text">[ANDROID PwdStore] Add  </string> - <string name="edit_commit_text">"[ANDROID PwdStore] Edit "</string> - <string name="increment_commit_text">"[ANDROID PwdStore] Increment HOTP counter for "</string> - <string name="from_store">  from store.</string> + <string name="git_commit_add_text">Add password for %1$s using android password store.</string> + <string name="git_commit_edit_text">"Edit %1$s using android password store."</string> + <string name="git_commit_remove_text">"Remove %1$s from store."</string> + <string name="git_commit_move_text">"Rename %1$s to %2$s."</string> + <string name="git_commit_increment_text">"Increment HOTP counter for %1$s."</string> <!-- PGPHandler --> <string name="provider_toast_text">No OpenPGP Provider selected!</string> |