diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-07-30 06:24:06 +0530 |
---|---|---|
committer | Harsh Shandilya <msfjarvis@gmail.com> | 2019-07-30 06:24:06 +0530 |
commit | 36b0a4157819b27f7efcf69372088d5a39d9814e (patch) | |
tree | 7f4edc43e5d74c21494ceea723620e0f33e5fe76 /app/src/main/java | |
parent | c635704032727c04737f41de64652926aa3af12f (diff) |
Ensure we always have valid timestamps
Non-git repositories deserve love too!
Fixes #530
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 8 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 7d79afb6..b32f2358 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -423,13 +423,13 @@ public class PasswordStore extends AppCompatActivity { return fullPath.replace(repositoryPath, "").replaceAll("/+", "/"); } - public int getLastChangedTimestamp(String fullPath) { + public long getLastChangedTimestamp(String fullPath) { File repoPath = PasswordRepository.getRepositoryDirectory(this); Repository repository = PasswordRepository.getRepository(repoPath); if (repository == null) { - Log.e(TAG, "getLastChangedTimestamp: No git repository"); - return -1; + Log.d(TAG, "getLastChangedTimestamp: No git repository"); + return new File(fullPath).lastModified(); } Git git = new Git(repository); @@ -453,7 +453,7 @@ public class PasswordStore extends AppCompatActivity { return -1; } - return iterator.next().getCommitTime(); + return iterator.next().getCommitTime() * 1000; } public void decryptPassword(PasswordItem item) { 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 ca6c14e8..ecf301a1 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -79,9 +79,9 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { private val name: String by lazy { getName(fullPath) } private val lastChangedString: CharSequence by lazy { getLastChangedString( - intent.getIntExtra( + intent.getLongExtra( "LAST_CHANGED_TIMESTAMP", - -1 + -1L ) ) } @@ -701,12 +701,12 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { * Gets a relative string describing when this shape was last changed * (e.g. "one hour ago") */ - private fun getLastChangedString(timeStamp: Int): CharSequence { + private fun getLastChangedString(timeStamp: Long): CharSequence { if (timeStamp < 0) { throw RuntimeException() } - return DateUtils.getRelativeTimeSpanString(this, timeStamp.toLong() * 1000, true) + return DateUtils.getRelativeTimeSpanString(this, timeStamp, true) } @Suppress("StaticFieldLeak") |