summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java26
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java41
2 files changed, 33 insertions, 34 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
index ad2a1ffe..9ac88ef6 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
@@ -31,9 +31,6 @@ import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
import android.widget.Toast;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Iterables;
import com.nononsenseapps.filepicker.FilePickerActivity;
import com.zeapo.pwdstore.autofill.AutofillPreferenceActivity;
import com.zeapo.pwdstore.crypto.PgpHandler;
@@ -48,11 +45,11 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
-import java.util.Set;
public class UserPreference extends AppCompatActivity {
private final static int IMPORT_SSH_KEY = 1;
@@ -131,7 +128,7 @@ public class UserPreference extends AppCompatActivity {
}
});
- findPreference("git_delete_repo").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ findPreference("git_delete_repo").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(callingActivity).
@@ -242,19 +239,18 @@ public class UserPreference extends AppCompatActivity {
findPreference("ssh_see_key").setEnabled(sharedPreferences.getBoolean("use_generated_key", false));
findPreference("git_delete_repo").setEnabled(!sharedPreferences.getBoolean("git_external", false));
Preference keyPref = findPreference("openpgp_key_id_pref");
- Set<String> selectedKeys = sharedPreferences.getStringSet("openpgp_key_ids_set", new HashSet<String>());
+ ArrayList<String> selectedKeys = new ArrayList<>(sharedPreferences.getStringSet("openpgp_key_ids_set", new HashSet<String>()));
if (selectedKeys.isEmpty()) {
keyPref.setSummary("No key selected");
} else {
- keyPref.setSummary(
- Joiner.on(',')
- .join(Iterables.transform(selectedKeys, new Function<String, Object>() {
- @Override
- public Object apply(String input) {
- return OpenPgpUtils.convertKeyIdToHex(Long.valueOf(input));
- }
- }))
- );
+ StringBuilder summaryBuilder = new StringBuilder();
+ for (int i = 0; i < selectedKeys.size(); ++i) {
+ String s = selectedKeys.get(i);
+ summaryBuilder.append(OpenPgpUtils.convertKeyIdToHex(Long.valueOf(s)));
+ if (i < selectedKeys.size() - 1)
+ summaryBuilder.append("; ");
+ }
+ keyPref.setSummary(summaryBuilder.toString());
}
// see if the autofill service is enabled and check the preference accordingly
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
index 12f2bcad..13e8704b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
@@ -32,7 +32,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-import com.google.common.primitives.Longs;
import com.zeapo.pwdstore.BuildConfig;
import com.zeapo.pwdstore.PasswordEntry;
import com.zeapo.pwdstore.R;
@@ -53,7 +52,6 @@ import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@@ -139,7 +137,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
- switch (getIntent().getStringExtra("Operation")){
+ switch (getIntent().getStringExtra("Operation")) {
case "ENCRYPT":
getMenuInflater().inflate(R.menu.pgp_handler_new_password, menu);
break;
@@ -187,11 +185,11 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
}
private void selectFolder() {
- if (selectFolderData == null || passwordList == null){
- Log.wtf(Constants.TAG,"Folder selected while the app didn't ask for one to be selected?");
+ if (selectFolderData == null || passwordList == null) {
+ Log.wtf(Constants.TAG, "Folder selected while the app didn't ask for one to be selected?");
}
- selectFolderData.putExtra("SELECTED_FOLDER_PATH",passwordList.getCurrentDir().getAbsolutePath());
- setResult(RESULT_OK,selectFolderData);
+ selectFolderData.putExtra("SELECTED_FOLDER_PATH", passwordList.getCurrentDir().getAbsolutePath());
+ setResult(RESULT_OK, selectFolderData);
finish();
}
@@ -277,7 +275,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
DialogFragment df = new pwgenDialogFragment();
df.show(getFragmentManager(), "generator");
default:
- Log.wtf(Constants.TAG,"This should not happen.... PgpHandler.java#handleClick(View) default reached.");
+ Log.wtf(Constants.TAG, "This should not happen.... PgpHandler.java#handleClick(View) default reached.");
// should not happen
}
}
@@ -365,7 +363,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
public void run() {
clipboard.setPrimaryClip(ClipData.newPlainText(count, count));
}
- }, i*500);
+ }, i * 500);
}
}
}
@@ -430,15 +428,15 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
private void selectFolder(Intent data) {
- if (data.getStringExtra("Operation") == null || !data.getStringExtra("Operation").equals("SELECTFOLDER")){
- Log.e(Constants.TAG,"PgpHandler#selectFolder(Intent) triggered with incorrect intent.");
- if (BuildConfig.DEBUG){
+ if (data.getStringExtra("Operation") == null || !data.getStringExtra("Operation").equals("SELECTFOLDER")) {
+ Log.e(Constants.TAG, "PgpHandler#selectFolder(Intent) triggered with incorrect intent.");
+ if (BuildConfig.DEBUG) {
throw new UnsupportedOperationException("Triggered with incorrect intent.");
}
return;
}
- Log.d(Constants.TAG,"PgpHandler#selectFolder(Intent).");
+ Log.d(Constants.TAG, "PgpHandler#selectFolder(Intent).");
FragmentManager fragmentManager = getSupportFragmentManager();
@@ -492,8 +490,8 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
textViewPassword.setText(entry.getPassword());
Button toggleVisibilityButton = (Button) findViewById(R.id.crypto_password_toggle_show);
- toggleVisibilityButton.setVisibility(showPassword?View.GONE:View.VISIBLE);
- textViewPassword.setTransformationMethod(showPassword?null:new HoldToShowPasswordTransformation(toggleVisibilityButton, new Runnable() {
+ toggleVisibilityButton.setVisibility(showPassword ? View.GONE : View.VISIBLE);
+ textViewPassword.setTransformationMethod(showPassword ? null : new HoldToShowPasswordTransformation(toggleVisibilityButton, new Runnable() {
@Override
public void run() {
textViewPassword.setText(entry.getPassword());
@@ -662,9 +660,14 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
public void encrypt(Intent data) {
data.setAction(OpenPgpApi.ACTION_ENCRYPT);
- ArrayList<Long> longKeys = new ArrayList<>();
- for (String keyId : keyIDs) longKeys.add(Long.valueOf(keyId));
- data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, Longs.toArray(longKeys));
+ // EXTRA_KEY_IDS requires long[]
+ long[] longKeys = new long[keyIDs.size()];
+ int i = 0;
+ for (String keyId : keyIDs) {
+ longKeys[i] = Long.valueOf(keyId);
+ ++i;
+ }
+ data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, longKeys);
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
@@ -721,7 +724,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
Bundle extra = getIntent().getExtras();
final String operation = extra.getString("Operation");
- if (operation == null){
+ if (operation == null) {
return;
}
switch (operation) {