fix unchecked
Also use File.listFiles rather than FileUtils
This commit is contained in:
parent
96aa605b75
commit
3daa34de90
1 changed files with 24 additions and 11 deletions
|
@ -19,6 +19,7 @@ import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static java.util.Collections.sort;
|
import static java.util.Collections.sort;
|
||||||
|
@ -27,10 +28,12 @@ public class PasswordRepository {
|
||||||
|
|
||||||
private static Repository repository;
|
private static Repository repository;
|
||||||
|
|
||||||
protected PasswordRepository(){ }
|
protected PasswordRepository() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the git repository
|
* Returns the git repository
|
||||||
|
*
|
||||||
* @param localDir needed only on the creation
|
* @param localDir needed only on the creation
|
||||||
* @return the git repository
|
* @return the git repository
|
||||||
*/
|
*/
|
||||||
|
@ -151,6 +154,7 @@ public class PasswordRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the password items in the root directory
|
* Gets the password items in the root directory
|
||||||
|
*
|
||||||
* @return a list of passwords in the root direcotyr
|
* @return a list of passwords in the root direcotyr
|
||||||
*/
|
*/
|
||||||
public static ArrayList<PasswordItem> getPasswords(File rootDir) {
|
public static ArrayList<PasswordItem> getPasswords(File rootDir) {
|
||||||
|
@ -159,6 +163,7 @@ public class PasswordRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the .gpg files in a directory
|
* Gets the .gpg files in a directory
|
||||||
|
*
|
||||||
* @param path the directory path
|
* @param path the directory path
|
||||||
* @return the list of gpg files in that directory
|
* @return the list of gpg files in that directory
|
||||||
*/
|
*/
|
||||||
|
@ -166,14 +171,19 @@ public class PasswordRepository {
|
||||||
if (!path.exists()) return new ArrayList<>();
|
if (!path.exists()) return new ArrayList<>();
|
||||||
|
|
||||||
Log.d("REPO", "current path: " + path.getPath());
|
Log.d("REPO", "current path: " + path.getPath());
|
||||||
ArrayList<File> files = new ArrayList<>(Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())));
|
List<File> directories = Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()));
|
||||||
files.addAll(new ArrayList<>(FileUtils.listFiles(path, new String[]{"gpg"}, false)));
|
List<File> files = Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.suffixFileFilter(".gpg")));
|
||||||
|
|
||||||
return new ArrayList<>(files);
|
ArrayList<File> items = new ArrayList<>();
|
||||||
|
items.addAll(directories);
|
||||||
|
items.addAll(files);
|
||||||
|
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the passwords (PasswordItem) in a directory
|
* Gets the passwords (PasswordItem) in a directory
|
||||||
|
*
|
||||||
* @param path the directory path
|
* @param path the directory path
|
||||||
* @return a list of password items
|
* @return a list of password items
|
||||||
*/
|
*/
|
||||||
|
@ -201,6 +211,7 @@ public class PasswordRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the git user name
|
* Sets the git user name
|
||||||
|
*
|
||||||
* @param username username
|
* @param username username
|
||||||
*/
|
*/
|
||||||
public static void setUserName(String username) {
|
public static void setUserName(String username) {
|
||||||
|
@ -209,6 +220,7 @@ public class PasswordRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the git user email
|
* Sets the git user email
|
||||||
|
*
|
||||||
* @param email email
|
* @param email email
|
||||||
*/
|
*/
|
||||||
public static void setUserEmail(String email) {
|
public static void setUserEmail(String email) {
|
||||||
|
@ -217,6 +229,7 @@ public class PasswordRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a git config value
|
* Sets a git config value
|
||||||
|
*
|
||||||
* @param section config section name
|
* @param section config section name
|
||||||
* @param subsection config subsection name
|
* @param subsection config subsection name
|
||||||
* @param name config name
|
* @param name config name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue