mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 14:25:28 +00:00
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
This commit is contained in:
@@ -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();
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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", "");
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user