aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/utils
diff options
context:
space:
mode:
authorFelix Bechstein <f@ub0r.de>2017-07-25 15:23:50 +0200
committerMohamed Zenadi <zeapo@users.noreply.github.com>2017-07-25 14:23:50 +0100
commit5da9e67545644925902b04a11306289add29c033 (patch)
treede8ec31c4fe216157b7680a4defdee86429a4122 /app/src/main/java/com/zeapo/pwdstore/utils
parent5cba6c62d7b4628dfaf482dd883e333f93d323d4 (diff)
downloadHardenedPass-5da9e67545644925902b04a11306289add29c033.tar.gz
HardenedPass-5da9e67545644925902b04a11306289add29c033.zip
Fix lint warnings (#319)
* Fix lint errors/warnings Fix a lot of lint errors and warnings. Most things are automatically applied fixes done with android studio: * externalize strings * remove unused code / classes / layouts / imports * migrate some fields to local variables * Remove dead code from comments Removed code that is commented out long ago. * remove unused resources * colors * strings * drawables * layouts * menus
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/utils')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/EntryRecyclerAdapter.java25
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java14
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java25
3 files changed, 30 insertions, 34 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/EntryRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/utils/EntryRecyclerAdapter.java
index 5247c6a3..a36b1124 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/EntryRecyclerAdapter.java
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/EntryRecyclerAdapter.java
@@ -19,10 +19,10 @@ import java.util.TreeSet;
public abstract class EntryRecyclerAdapter extends RecyclerView.Adapter<EntryRecyclerAdapter.ViewHolder> {
private final Activity activity;
- protected final ArrayList<PasswordItem> values;
- protected final Set<Integer> selectedItems = new TreeSet<>();
+ private final ArrayList<PasswordItem> values;
+ final Set<Integer> selectedItems = new TreeSet<>();
- public EntryRecyclerAdapter(Activity activity, ArrayList<PasswordItem> values) {
+ EntryRecyclerAdapter(Activity activity, ArrayList<PasswordItem> values) {
this.activity = activity;
this.values = values;
}
@@ -52,7 +52,7 @@ public abstract class EntryRecyclerAdapter extends RecyclerView.Adapter<EntryRec
this.notifyItemInserted(getItemCount());
}
- public void toggleSelection(int position) {
+ void toggleSelection(int position) {
if (!selectedItems.remove(position)) {
selectedItems.add(position);
}
@@ -106,11 +106,6 @@ public abstract class EntryRecyclerAdapter extends RecyclerView.Adapter<EntryRec
}
holder.type.setText(pass.getFullPathToParent());
- if (pass.getType() == PasswordItem.TYPE_CATEGORY) {
-// holder.card.setCardBackgroundColor(activity.getResources().getColor(R.color.blue_grey_200));
- } else {
-// holder.card.setCardBackgroundColor(activity.getResources().getColor(R.color.blue_grey_50));
- }
holder.view.setOnClickListener(getOnClickListener(holder, pass));
@@ -134,14 +129,14 @@ public abstract class EntryRecyclerAdapter extends RecyclerView.Adapter<EntryRec
// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
- public static class ViewHolder extends RecyclerView.ViewHolder {
+ static class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case
- public View view;
- public TextView name;
- public TextView type;
- public ImageView typeImage;
+ public final View view;
+ public final TextView name;
+ final TextView type;
+ final ImageView typeImage;
- public ViewHolder(View v) {
+ ViewHolder(View v) {
super(v);
view = v;
name = (TextView) view.findViewById(R.id.label);
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 404091b2..cfdb829d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordItem.java
@@ -1,5 +1,7 @@
package com.zeapo.pwdstore.utils;
+import android.support.annotation.NonNull;
+
import java.io.File;
public class PasswordItem implements Comparable{
@@ -12,7 +14,6 @@ public class PasswordItem implements Comparable{
private PasswordItem parent;
private File file;
private String fullPathToParent;
- public boolean selected = false;
/** Create a password item
*
@@ -93,14 +94,15 @@ public class PasswordItem implements Comparable{
}
@Override
- public boolean equals(Object o){
- PasswordItem other = (PasswordItem) o;
+ public boolean equals(Object o) {
// Makes it possible to have a category and a password with the same name
- return (other.getFile().equals(this.getFile()));
-}
+ return o != null
+ && o.getClass() == PasswordItem.class
+ && ((PasswordItem) o).getFile().equals(this.getFile());
+ }
@Override
- public int compareTo(Object o) {
+ public int compareTo(@NonNull Object o) {
PasswordItem other = (PasswordItem) o;
// Appending the type will make the sort type dependent
return (this.getType() + this.getName())
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java
index ab86d2e1..d97e3294 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java
@@ -27,7 +27,6 @@ import static java.util.Collections.sort;
public class PasswordRepository {
private static Repository repository;
- private static boolean initialized = false;
protected PasswordRepository(){ }
@@ -165,13 +164,13 @@ public class PasswordRepository {
* @return the list of gpg files in that directory
*/
public static ArrayList<File> getFilesList(File path){
- if (!path.exists()) return new ArrayList<File>();
+ if (!path.exists()) return new ArrayList<>();
Log.d("REPO", "current path: " + path.getPath());
- ArrayList<File> files = new ArrayList<File>(Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())));
- files.addAll( new ArrayList<File>((List<File>)FileUtils.listFiles(path, new String[] {"gpg"}, false)));
+ ArrayList<File> files = new ArrayList<>(Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())));
+ files.addAll(new ArrayList<>((List<File>) FileUtils.listFiles(path, new String[]{"gpg"}, false)));
- return new ArrayList<File>(files);
+ return new ArrayList<>(files);
}
/**
@@ -183,9 +182,9 @@ public class PasswordRepository {
//We need to recover the passwords then parse the files
ArrayList<File> passList = getFilesList(path);
- if (passList.size() == 0) return new ArrayList<PasswordItem>();
+ if (passList.size() == 0) return new ArrayList<>();
- ArrayList<PasswordItem> passwordList = new ArrayList<PasswordItem>();
+ ArrayList<PasswordItem> passwordList = new ArrayList<>();
for (File file : passList) {
if (file.isFile()) {
@@ -203,7 +202,7 @@ public class PasswordRepository {
/**
* Sets the git user name
- * @param String username username
+ * @param username username
*/
public static void setUserName(String username) {
setStringConfig("user", null, "name", username);
@@ -211,7 +210,7 @@ public class PasswordRepository {
/**
* Sets the git user email
- * @param String email email
+ * @param email email
*/
public static void setUserEmail(String email) {
setStringConfig("user", null, "email", email);
@@ -219,10 +218,10 @@ public class PasswordRepository {
/**
* Sets a git config value
- * @param String section config section name
- * @param String subsection config subsection name
- * @param String name config name
- * @param String value the value to be set
+ * @param section config section name
+ * @param subsection config subsection name
+ * @param name config name
+ * @param value the value to be set
*/
private static void setStringConfig(String section, String subsection, String name, String value) {
if (isInitialized()) {