mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-01 14:55:19 +00:00
treewide: Reformat
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
@@ -3,17 +3,19 @@ package com.zeapo.pwdstore;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
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.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.zeapo.pwdstore.utils.PasswordItem;
|
import com.zeapo.pwdstore.utils.PasswordItem;
|
||||||
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
|
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
|
||||||
@@ -40,6 +42,7 @@ public class PasswordFragment extends Fragment {
|
|||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private OnFragmentInteractionListener mListener;
|
private OnFragmentInteractionListener mListener;
|
||||||
private SharedPreferences settings;
|
private SharedPreferences settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||||
* fragment (e.g. upon screen orientation changes).
|
* fragment (e.g. upon screen orientation changes).
|
||||||
|
@@ -12,7 +12,6 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -20,15 +19,17 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.MenuItemCompat;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.zeapo.pwdstore.crypto.PgpActivity;
|
import com.zeapo.pwdstore.crypto.PgpActivity;
|
||||||
import com.zeapo.pwdstore.git.GitActivity;
|
import com.zeapo.pwdstore.git.GitActivity;
|
||||||
@@ -37,6 +38,7 @@ import com.zeapo.pwdstore.git.GitOperation;
|
|||||||
import com.zeapo.pwdstore.utils.PasswordItem;
|
import com.zeapo.pwdstore.utils.PasswordItem;
|
||||||
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
|
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
|
||||||
import com.zeapo.pwdstore.utils.PasswordRepository;
|
import com.zeapo.pwdstore.utils.PasswordRepository;
|
||||||
|
|
||||||
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;
|
||||||
|
@@ -2,16 +2,18 @@ package com.zeapo.pwdstore;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
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.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.zeapo.pwdstore.utils.FolderRecyclerAdapter;
|
import com.zeapo.pwdstore.utils.FolderRecyclerAdapter;
|
||||||
import com.zeapo.pwdstore.utils.PasswordItem;
|
import com.zeapo.pwdstore.utils.PasswordItem;
|
||||||
@@ -34,6 +36,7 @@ public class SelectFolderFragment extends Fragment {
|
|||||||
private FolderRecyclerAdapter recyclerAdapter;
|
private FolderRecyclerAdapter recyclerAdapter;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private OnFragmentInteractionListener mListener;
|
private OnFragmentInteractionListener mListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||||
* fragment (e.g. upon screen orientation changes).
|
* fragment (e.g. upon screen orientation changes).
|
||||||
|
@@ -12,7 +12,6 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -25,10 +24,14 @@ import android.widget.EditText;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.jcraft.jsch.JSch;
|
import com.jcraft.jsch.JSch;
|
||||||
import com.jcraft.jsch.KeyPair;
|
import com.jcraft.jsch.KeyPair;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@@ -9,8 +9,8 @@ import androidx.fragment.app.Fragment
|
|||||||
class ToCloneOrNot : Fragment() {
|
class ToCloneOrNot : Fragment() {
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// 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)
|
||||||
|
@@ -31,7 +31,9 @@ import java.io.File
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
import java.util.HashSet
|
||||||
|
import java.util.TimeZone
|
||||||
|
|
||||||
class UserPreference : AppCompatActivity() {
|
class UserPreference : AppCompatActivity() {
|
||||||
|
|
||||||
@@ -310,7 +312,7 @@ class UserPreference : AppCompatActivity() {
|
|||||||
val am = this
|
val am = this
|
||||||
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
|
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
|
||||||
val runningServices = am
|
val runningServices = am
|
||||||
.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC)
|
.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC)
|
||||||
return runningServices
|
return runningServices
|
||||||
.map { it.id.substringBefore("/") }
|
.map { it.id.substringBefore("/") }
|
||||||
.any { it == BuildConfig.APPLICATION_ID }
|
.any { it == BuildConfig.APPLICATION_ID }
|
||||||
|
@@ -71,7 +71,7 @@ class AutofillFragment : DialogFragment() {
|
|||||||
}
|
}
|
||||||
(view.findViewById<View>(R.id.matched) as ListView).adapter = adapter
|
(view.findViewById<View>(R.id.matched) as ListView).adapter = adapter
|
||||||
// delete items by clicking them
|
// delete items by clicking them
|
||||||
(view.findViewById<View>(R.id.matched) as ListView).setOnItemClickListener { _, _, position, _ -> adapter!!.remove(adapter!!.getItem(position)) }
|
(view.findViewById<View>(R.id.matched) as ListView).onItemClickListener = { _, _, position, _ -> adapter!!.remove(adapter!!.getItem(position)) }
|
||||||
|
|
||||||
// set the existing preference, if any
|
// set the existing preference, if any
|
||||||
val prefs: SharedPreferences = if (!isWeb) {
|
val prefs: SharedPreferences = if (!isWeb) {
|
||||||
|
@@ -37,7 +37,11 @@ import com.zeapo.pwdstore.R
|
|||||||
import com.zeapo.pwdstore.UserPreference
|
import com.zeapo.pwdstore.UserPreference
|
||||||
import com.zeapo.pwdstore.utils.Otp
|
import com.zeapo.pwdstore.utils.Otp
|
||||||
import kotlinx.android.synthetic.main.decrypt_layout.*
|
import kotlinx.android.synthetic.main.decrypt_layout.*
|
||||||
import kotlinx.android.synthetic.main.encrypt_layout.*
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_extra_edit
|
||||||
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_category
|
||||||
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_edit
|
||||||
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_file_edit
|
||||||
|
import kotlinx.android.synthetic.main.encrypt_layout.generate_password
|
||||||
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.openintents.openpgp.IOpenPgpService2
|
import org.openintents.openpgp.IOpenPgpService2
|
||||||
@@ -75,16 +79,18 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
private val name: String by lazy { getName(fullPath) }
|
private val name: String by lazy { getName(fullPath) }
|
||||||
private val lastChangedString: CharSequence by lazy {
|
private val lastChangedString: CharSequence by lazy {
|
||||||
getLastChangedString(
|
getLastChangedString(
|
||||||
intent.getIntExtra(
|
intent.getIntExtra(
|
||||||
"LAST_CHANGED_TIMESTAMP",
|
"LAST_CHANGED_TIMESTAMP",
|
||||||
-1
|
-1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private val relativeParentPath: String by lazy { getParentPath(fullPath, repoPath) }
|
private val relativeParentPath: String by lazy { getParentPath(fullPath, repoPath) }
|
||||||
|
|
||||||
val settings: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
|
val settings: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
|
||||||
private val keyIDs: MutableSet<String> by lazy { settings.getStringSet("openpgp_key_ids_set", mutableSetOf()) ?: emptySet() }
|
private val keyIDs: MutableSet<String> by lazy {
|
||||||
|
settings.getStringSet("openpgp_key_ids_set", mutableSetOf()) ?: emptySet()
|
||||||
|
}
|
||||||
private var mServiceConnection: OpenPgpServiceConnection? = null
|
private var mServiceConnection: OpenPgpServiceConnection? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -192,8 +198,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
val pi: PendingIntent = result.getParcelableExtra(RESULT_INTENT)
|
val pi: PendingIntent = result.getParcelableExtra(RESULT_INTENT)
|
||||||
try {
|
try {
|
||||||
this@PgpActivity.startIntentSenderFromChild(
|
this@PgpActivity.startIntentSenderFromChild(
|
||||||
this@PgpActivity, pi.intentSender, requestCode,
|
this@PgpActivity, pi.intentSender, requestCode,
|
||||||
null, 0, 0, 0
|
null, 0, 0, 0
|
||||||
)
|
)
|
||||||
} catch (e: IntentSender.SendIntentException) {
|
} catch (e: IntentSender.SendIntentException) {
|
||||||
Log.e(TAG, "SendIntentException", e)
|
Log.e(TAG, "SendIntentException", e)
|
||||||
@@ -265,8 +271,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
HoldToShowPasswordTransformation(
|
HoldToShowPasswordTransformation(
|
||||||
crypto_password_toggle_show,
|
crypto_password_toggle_show,
|
||||||
Runnable { crypto_password_show.text = entry.password }
|
Runnable { crypto_password_show.text = entry.password }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,19 +325,19 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
if (entry.hasTotp()) {
|
if (entry.hasTotp()) {
|
||||||
crypto_copy_otp.setOnClickListener {
|
crypto_copy_otp.setOnClickListener {
|
||||||
copyOtpToClipBoard(
|
copyOtpToClipBoard(
|
||||||
Otp.calculateCode(
|
Otp.calculateCode(
|
||||||
entry.totpSecret,
|
entry.totpSecret,
|
||||||
Date().time / (1000 * entry.totpPeriod),
|
Date().time / (1000 * entry.totpPeriod),
|
||||||
entry.totpAlgorithm,
|
entry.totpAlgorithm,
|
||||||
entry.digits)
|
entry.digits)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
crypto_otp_show.text =
|
crypto_otp_show.text =
|
||||||
Otp.calculateCode(
|
Otp.calculateCode(
|
||||||
entry.totpSecret,
|
entry.totpSecret,
|
||||||
Date().time / (1000 * entry.totpPeriod),
|
Date().time / (1000 * entry.totpPeriod),
|
||||||
entry.totpAlgorithm,
|
entry.totpAlgorithm,
|
||||||
entry.digits)
|
entry.digits)
|
||||||
} else {
|
} else {
|
||||||
// we only want to calculate and show HOTP if the user requests it
|
// we only want to calculate and show HOTP if the user requests it
|
||||||
crypto_copy_otp.setOnClickListener {
|
crypto_copy_otp.setOnClickListener {
|
||||||
@@ -346,31 +352,31 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
val checkInflater = LayoutInflater.from(this)
|
val checkInflater = LayoutInflater.from(this)
|
||||||
val checkLayout = checkInflater.inflate(R.layout.otp_confirm_layout, null)
|
val checkLayout = checkInflater.inflate(R.layout.otp_confirm_layout, null)
|
||||||
val rememberCheck: CheckBox =
|
val rememberCheck: CheckBox =
|
||||||
checkLayout.findViewById(R.id.hotp_remember_checkbox)
|
checkLayout.findViewById(R.id.hotp_remember_checkbox)
|
||||||
val dialogBuilder = AlertDialog.Builder(this)
|
val dialogBuilder = AlertDialog.Builder(this)
|
||||||
dialogBuilder.setView(checkLayout)
|
dialogBuilder.setView(checkLayout)
|
||||||
dialogBuilder.setMessage(R.string.dialog_update_body)
|
dialogBuilder.setMessage(R.string.dialog_update_body)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.dialog_update_positive) { _, _ ->
|
.setPositiveButton(R.string.dialog_update_positive) { _, _ ->
|
||||||
run {
|
run {
|
||||||
calculateAndCommitHotp(entry)
|
calculateAndCommitHotp(entry)
|
||||||
if (rememberCheck.isChecked) {
|
if (rememberCheck.isChecked) {
|
||||||
|
val editor = settings.edit()
|
||||||
|
editor.putBoolean("hotp_remember_check", true)
|
||||||
|
editor.putBoolean("hotp_remember_choice", true)
|
||||||
|
editor.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.dialog_update_negative) { _, _ ->
|
||||||
|
run {
|
||||||
|
calculateHotp(entry)
|
||||||
val editor = settings.edit()
|
val editor = settings.edit()
|
||||||
editor.putBoolean("hotp_remember_check", true)
|
editor.putBoolean("hotp_remember_check", true)
|
||||||
editor.putBoolean("hotp_remember_choice", true)
|
editor.putBoolean("hotp_remember_choice", false)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.setNegativeButton(R.string.dialog_update_negative) { _, _ ->
|
|
||||||
run {
|
|
||||||
calculateHotp(entry)
|
|
||||||
val editor = settings.edit()
|
|
||||||
editor.putBoolean("hotp_remember_check", true)
|
|
||||||
editor.putBoolean("hotp_remember_choice", false)
|
|
||||||
editor.apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val updateDialog = dialogBuilder.create()
|
val updateDialog = dialogBuilder.create()
|
||||||
updateDialog.setTitle(R.string.dialog_update_title)
|
updateDialog.setTitle(R.string.dialog_update_title)
|
||||||
updateDialog.show()
|
updateDialog.show()
|
||||||
@@ -602,7 +608,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inner class HoldToShowPasswordTransformation constructor(button: Button, private val onToggle: Runnable) :
|
private inner class HoldToShowPasswordTransformation constructor(button: Button, private val onToggle: Runnable) :
|
||||||
PasswordTransformationMethod(), View.OnTouchListener {
|
PasswordTransformationMethod(), View.OnTouchListener {
|
||||||
private var shown = false
|
private var shown = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -673,10 +679,10 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, passwordEntry?.password)
|
sendIntent.putExtra(Intent.EXTRA_TEXT, passwordEntry?.password)
|
||||||
sendIntent.type = "text/plain"
|
sendIntent.type = "text/plain"
|
||||||
startActivity(
|
startActivity(
|
||||||
Intent.createChooser(
|
Intent.createChooser(
|
||||||
sendIntent,
|
sendIntent,
|
||||||
resources.getText(R.string.send_plaintext_password_to)
|
resources.getText(R.string.send_plaintext_password_to)
|
||||||
)
|
)
|
||||||
)//Always show a picker to give the user a chance to cancel
|
)//Always show a picker to give the user a chance to cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,8 +783,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
for (i in 0..19) {
|
for (i in 0..19) {
|
||||||
val count = i.toString()
|
val count = i.toString()
|
||||||
handler.postDelayed(
|
handler.postDelayed(
|
||||||
{ clipboard.setPrimaryClip(ClipData.newPlainText(count, count)) },
|
{ clipboard.setPrimaryClip(ClipData.newPlainText(count, count)) },
|
||||||
(i * 500).toLong()
|
(i * 500).toLong()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -815,7 +821,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||||||
* Gets the relative path to the repository
|
* Gets the relative path to the repository
|
||||||
*/
|
*/
|
||||||
fun getRelativePath(fullPath: String, repositoryPath: String): String =
|
fun getRelativePath(fullPath: String, repositoryPath: String): String =
|
||||||
fullPath.replace(repositoryPath, "").replace("/+".toRegex(), "/")
|
fullPath.replace(repositoryPath, "").replace("/+".toRegex(), "/")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Parent path, relative to the repository
|
* Gets the Parent path, relative to the repository
|
||||||
|
@@ -4,8 +4,10 @@ import android.app.Activity;
|
|||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.PasswordStore;
|
import com.zeapo.pwdstore.PasswordStore;
|
||||||
import com.zeapo.pwdstore.R;
|
import com.zeapo.pwdstore.R;
|
||||||
|
|
||||||
import org.eclipse.jgit.api.CommitCommand;
|
import org.eclipse.jgit.api.CommitCommand;
|
||||||
import org.eclipse.jgit.api.GitCommand;
|
import org.eclipse.jgit.api.GitCommand;
|
||||||
import org.eclipse.jgit.api.PullCommand;
|
import org.eclipse.jgit.api.PullCommand;
|
||||||
@@ -26,10 +28,6 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
|
|||||||
private ProgressDialog dialog;
|
private ProgressDialog dialog;
|
||||||
private GitOperation operation;
|
private GitOperation operation;
|
||||||
|
|
||||||
private Activity getActivity() {
|
|
||||||
return activityWeakReference.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GitAsyncTask(Activity activity, boolean finishOnEnd, boolean refreshListOnEnd, GitOperation operation) {
|
public GitAsyncTask(Activity activity, boolean finishOnEnd, boolean refreshListOnEnd, GitOperation operation) {
|
||||||
this.activityWeakReference = new WeakReference<>(activity);
|
this.activityWeakReference = new WeakReference<>(activity);
|
||||||
this.finishOnEnd = finishOnEnd;
|
this.finishOnEnd = finishOnEnd;
|
||||||
@@ -39,6 +37,10 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
|
|||||||
dialog = new ProgressDialog(getActivity());
|
dialog = new ProgressDialog(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Activity getActivity() {
|
||||||
|
return activityWeakReference.get();
|
||||||
|
}
|
||||||
|
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
this.dialog.setMessage(getActivity().getResources().getString(R.string.running_dialog_text));
|
this.dialog.setMessage(getActivity().getResources().getString(R.string.running_dialog_text));
|
||||||
this.dialog.setCancelable(false);
|
this.dialog.setCancelable(false);
|
||||||
|
@@ -43,6 +43,7 @@ public class SshApiSessionFactory extends GitConfigSessionFactory {
|
|||||||
public static final int POST_SIGNATURE = 301;
|
public static final int POST_SIGNATURE = 301;
|
||||||
private String username;
|
private String username;
|
||||||
private Identity identity;
|
private Identity identity;
|
||||||
|
|
||||||
public SshApiSessionFactory(String username, Identity identity) {
|
public SshApiSessionFactory(String username, Identity identity) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.identity = identity;
|
this.identity = identity;
|
||||||
|
@@ -6,7 +6,6 @@ import com.zeapo.pwdstore.R
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object PasswordGenerator {
|
object PasswordGenerator {
|
||||||
internal const val DIGITS = 0x0001
|
internal const val DIGITS = 0x0001
|
||||||
internal const val UPPERS = 0x0002
|
internal const val UPPERS = 0x0002
|
||||||
@@ -82,7 +81,8 @@ object PasswordGenerator {
|
|||||||
* preferences file 'PasswordGenerator'
|
* preferences file 'PasswordGenerator'
|
||||||
* @return list of generated passwords
|
* @return list of generated passwords
|
||||||
*/
|
*/
|
||||||
@JvmStatic @Throws(PasswordGenerator.PasswordGeneratorExeption::class)
|
@JvmStatic
|
||||||
|
@Throws(PasswordGenerator.PasswordGeneratorExeption::class)
|
||||||
fun generate(ctx: Context): ArrayList<String> {
|
fun generate(ctx: Context): ArrayList<String> {
|
||||||
val prefs = ctx.getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE)
|
val prefs = ctx.getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
@@ -7,46 +7,46 @@ internal object Phonemes {
|
|||||||
private const val NOT_FIRST = 0x0008
|
private const val NOT_FIRST = 0x0008
|
||||||
|
|
||||||
private val elements = arrayOf(
|
private val elements = arrayOf(
|
||||||
Element("a", VOWEL),
|
Element("a", VOWEL),
|
||||||
Element("ae", VOWEL or DIPTHONG),
|
Element("ae", VOWEL or DIPTHONG),
|
||||||
Element("ah", VOWEL or DIPTHONG),
|
Element("ah", VOWEL or DIPTHONG),
|
||||||
Element("ai", VOWEL or DIPTHONG),
|
Element("ai", VOWEL or DIPTHONG),
|
||||||
Element("b", CONSONANT),
|
Element("b", CONSONANT),
|
||||||
Element("c", CONSONANT),
|
Element("c", CONSONANT),
|
||||||
Element("ch", CONSONANT or DIPTHONG),
|
Element("ch", CONSONANT or DIPTHONG),
|
||||||
Element("d", CONSONANT),
|
Element("d", CONSONANT),
|
||||||
Element("e", VOWEL),
|
Element("e", VOWEL),
|
||||||
Element("ee", VOWEL or DIPTHONG),
|
Element("ee", VOWEL or DIPTHONG),
|
||||||
Element("ei", VOWEL or DIPTHONG),
|
Element("ei", VOWEL or DIPTHONG),
|
||||||
Element("f", CONSONANT),
|
Element("f", CONSONANT),
|
||||||
Element("g", CONSONANT),
|
Element("g", CONSONANT),
|
||||||
Element("gh", CONSONANT or DIPTHONG or NOT_FIRST),
|
Element("gh", CONSONANT or DIPTHONG or NOT_FIRST),
|
||||||
Element("h", CONSONANT),
|
Element("h", CONSONANT),
|
||||||
Element("i", VOWEL),
|
Element("i", VOWEL),
|
||||||
Element("ie", VOWEL or DIPTHONG),
|
Element("ie", VOWEL or DIPTHONG),
|
||||||
Element("j", CONSONANT),
|
Element("j", CONSONANT),
|
||||||
Element("k", CONSONANT),
|
Element("k", CONSONANT),
|
||||||
Element("l", CONSONANT),
|
Element("l", CONSONANT),
|
||||||
Element("m", CONSONANT),
|
Element("m", CONSONANT),
|
||||||
Element("n", CONSONANT),
|
Element("n", CONSONANT),
|
||||||
Element("ng", CONSONANT or DIPTHONG or NOT_FIRST),
|
Element("ng", CONSONANT or DIPTHONG or NOT_FIRST),
|
||||||
Element("o", VOWEL),
|
Element("o", VOWEL),
|
||||||
Element("oh", VOWEL or DIPTHONG),
|
Element("oh", VOWEL or DIPTHONG),
|
||||||
Element("oo", VOWEL or DIPTHONG),
|
Element("oo", VOWEL or DIPTHONG),
|
||||||
Element("p", CONSONANT),
|
Element("p", CONSONANT),
|
||||||
Element("ph", CONSONANT or DIPTHONG),
|
Element("ph", CONSONANT or DIPTHONG),
|
||||||
Element("qu", CONSONANT or DIPTHONG),
|
Element("qu", CONSONANT or DIPTHONG),
|
||||||
Element("r", CONSONANT),
|
Element("r", CONSONANT),
|
||||||
Element("s", CONSONANT),
|
Element("s", CONSONANT),
|
||||||
Element("sh", CONSONANT or DIPTHONG),
|
Element("sh", CONSONANT or DIPTHONG),
|
||||||
Element("t", CONSONANT),
|
Element("t", CONSONANT),
|
||||||
Element("th", CONSONANT or DIPTHONG),
|
Element("th", CONSONANT or DIPTHONG),
|
||||||
Element("u", VOWEL),
|
Element("u", VOWEL),
|
||||||
Element("v", CONSONANT),
|
Element("v", CONSONANT),
|
||||||
Element("w", CONSONANT),
|
Element("w", CONSONANT),
|
||||||
Element("x", CONSONANT),
|
Element("x", CONSONANT),
|
||||||
Element("y", CONSONANT),
|
Element("y", CONSONANT),
|
||||||
Element("z", CONSONANT)
|
Element("z", CONSONANT)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val NUM_ELEMENTS = elements.size
|
private val NUM_ELEMENTS = elements.size
|
||||||
@@ -106,7 +106,7 @@ internal object Phonemes {
|
|||||||
}
|
}
|
||||||
// Don't allow VOWEL followed a Vowel/Dipthong pair
|
// Don't allow VOWEL followed a Vowel/Dipthong pair
|
||||||
if (prev and VOWEL > 0 && flags and VOWEL > 0
|
if (prev and VOWEL > 0 && flags and VOWEL > 0
|
||||||
&& flags and DIPTHONG > 0
|
&& flags and DIPTHONG > 0
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -165,8 +165,8 @@ internal object Phonemes {
|
|||||||
cha = Character.forDigit(RandomNumberGenerator.number(10), 10)
|
cha = Character.forDigit(RandomNumberGenerator.number(10), 10)
|
||||||
`val` = cha.toString()
|
`val` = cha.toString()
|
||||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||||
`val`
|
`val`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
password += `val`
|
password += `val`
|
||||||
curSize++
|
curSize++
|
||||||
@@ -190,8 +190,8 @@ internal object Phonemes {
|
|||||||
cha = PasswordGenerator.SYMBOLS_STR.toCharArray()[num]
|
cha = PasswordGenerator.SYMBOLS_STR.toCharArray()[num]
|
||||||
`val` = cha.toString()
|
`val` = cha.toString()
|
||||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||||
`val`
|
`val`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
password += `val`
|
password += `val`
|
||||||
curSize++
|
curSize++
|
||||||
@@ -205,7 +205,7 @@ internal object Phonemes {
|
|||||||
VOWEL
|
VOWEL
|
||||||
} else {
|
} else {
|
||||||
if (prev and VOWEL > 0 || flags and DIPTHONG > 0
|
if (prev and VOWEL > 0 || flags and DIPTHONG > 0
|
||||||
|| RandomNumberGenerator.number(10) > 3
|
|| RandomNumberGenerator.number(10) > 3
|
||||||
) {
|
) {
|
||||||
CONSONANT
|
CONSONANT
|
||||||
} else {
|
} else {
|
||||||
|
@@ -49,8 +49,8 @@ internal object RandomPasswordGenerator {
|
|||||||
cha = bank.toCharArray()[num]
|
cha = bank.toCharArray()[num]
|
||||||
`val` = cha.toString()
|
`val` = cha.toString()
|
||||||
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||||
`val`
|
`val`
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,11 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.R;
|
import com.zeapo.pwdstore.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
package com.zeapo.pwdstore.utils;
|
package com.zeapo.pwdstore.utils;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.SelectFolderActivity;
|
import com.zeapo.pwdstore.SelectFolderActivity;
|
||||||
import com.zeapo.pwdstore.SelectFolderFragment;
|
import com.zeapo.pwdstore.SelectFolderFragment;
|
||||||
|
|
||||||
|
@@ -1,16 +1,18 @@
|
|||||||
package com.zeapo.pwdstore.utils;
|
package com.zeapo.pwdstore.utils;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base32;
|
import org.apache.commons.codec.binary.Base32;
|
||||||
|
|
||||||
import javax.crypto.Mac;
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
public class Otp {
|
public class Otp {
|
||||||
|
|
||||||
private static final Base32 BASE_32 = new Base32();
|
private static final Base32 BASE_32 = new Base32();
|
||||||
@@ -50,7 +52,6 @@ public class Otp {
|
|||||||
bigInt /= 26;
|
bigInt /= 26;
|
||||||
}
|
}
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
} else return strCode.substring(strCode.length() - Integer.parseInt(digits));
|
||||||
else return strCode.substring(strCode.length() - Integer.parseInt(digits));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.zeapo.pwdstore.utils;
|
package com.zeapo.pwdstore.utils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.crypto.PgpActivity;
|
import com.zeapo.pwdstore.crypto.PgpActivity;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@@ -3,8 +3,10 @@ package com.zeapo.pwdstore.utils;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.view.ActionMode;
|
import androidx.appcompat.view.ActionMode;
|
||||||
|
|
||||||
import com.zeapo.pwdstore.PasswordFragment;
|
import com.zeapo.pwdstore.PasswordFragment;
|
||||||
import com.zeapo.pwdstore.PasswordStore;
|
import com.zeapo.pwdstore.PasswordStore;
|
||||||
import com.zeapo.pwdstore.R;
|
import com.zeapo.pwdstore.R;
|
||||||
|
@@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.apache.commons.io.filefilter.FileFilterUtils;
|
import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
Reference in New Issue
Block a user