Some fixes
This commit is contained in:
parent
1623340a77
commit
68dc0893ca
4 changed files with 31 additions and 17 deletions
20
app/app.iml
20
app/app.iml
|
@ -56,7 +56,25 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
||||||
|
|
|
@ -23,6 +23,8 @@ import javax.crypto.SecretKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nerull7 on 28.07.14.
|
* Created by nerull7 on 28.07.14.
|
||||||
|
*
|
||||||
|
* Class delegated to encrypt data
|
||||||
*/
|
*/
|
||||||
public class Crypto {
|
public class Crypto {
|
||||||
private static final String KEY_FILE = "null_file"; // to trick h4x0r5
|
private static final String KEY_FILE = "null_file"; // to trick h4x0r5
|
||||||
|
@ -44,23 +46,19 @@ public class Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecretKey generateKey() throws NoSuchAlgorithmException {
|
private void generateKey() throws NoSuchAlgorithmException {
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
|
||||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHM);
|
KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHM);
|
||||||
keyGenerator.init(OUTPUT_KEY_LENGTH, secureRandom);
|
keyGenerator.init(OUTPUT_KEY_LENGTH, secureRandom);
|
||||||
SecretKey secretKey = keyGenerator.generateKey();
|
secretKey = keyGenerator.generateKey();
|
||||||
|
|
||||||
return secretKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSecretKey() throws NoSuchAlgorithmException, IOException, ClassNotFoundException {
|
private void getSecretKey() throws NoSuchAlgorithmException, IOException, ClassNotFoundException {
|
||||||
String key;
|
|
||||||
|
|
||||||
// First try to open file
|
// First try to open file
|
||||||
File keyFile = new File(context.getFilesDir(), KEY_FILE);
|
File keyFile = new File(context.getFilesDir(), KEY_FILE);
|
||||||
if(!keyFile.exists()) { // new key
|
if(!keyFile.exists()) { // new key
|
||||||
secretKey = generateKey();
|
generateKey();
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(keyFile);
|
FileOutputStream fileOutputStream = new FileOutputStream(keyFile);
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||||
objectOutputStream.writeObject(secretKey);
|
objectOutputStream.writeObject(secretKey);
|
||||||
|
@ -95,7 +93,6 @@ public class Crypto {
|
||||||
|
|
||||||
public String decryptBase64(String encodedString) throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
|
public String decryptBase64(String encodedString) throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
|
||||||
byte [] encryptedString = Base64.decode(encodedString, Base64.DEFAULT);
|
byte [] encryptedString = Base64.decode(encodedString, Base64.DEFAULT);
|
||||||
String decrypted = decrypt(encryptedString);
|
return decrypt(encryptedString);
|
||||||
return decrypted;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,4 @@ public class ElementArrayAdapter extends ArrayAdapter<String> {
|
||||||
public List<String> getFieldArray(){
|
public List<String> getFieldArray(){
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getValueArray(){
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,14 @@ import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nerull7 on 18.07.14.
|
* Created by nerull7 on 18.07.14.
|
||||||
|
*
|
||||||
|
* Fragment for Preferences/Settings
|
||||||
*/
|
*/
|
||||||
public class SettingsFragment extends PreferenceFragment implements NumberPickerDialog.OnNumberSetListener, Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
public class SettingsFragment extends PreferenceFragment implements NumberPickerDialog.OnNumberSetListener, Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||||
public static final String ENTRIES_PAGE_LIMIT = "entries_limit";
|
public static final String ENTRIES_PAGE_LIMIT = "entries_limit";
|
||||||
|
@ -35,7 +38,8 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
preferences = getPreferenceManager().getDefaultSharedPreferences(getActivity());
|
getPreferenceManager();
|
||||||
|
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
crypto = new Crypto(getActivity());
|
crypto = new Crypto(getActivity());
|
||||||
|
|
||||||
loadPrefs();
|
loadPrefs();
|
||||||
|
@ -70,7 +74,6 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
||||||
}
|
}
|
||||||
editor.putBoolean(SAVE_SERVER_CREDENTIALS, isEnabled);
|
editor.putBoolean(SAVE_SERVER_CREDENTIALS, isEnabled);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
if(!isEnabled)
|
if(!isEnabled)
|
||||||
reloadLoginPrefsView();
|
reloadLoginPrefsView();
|
||||||
|
@ -80,7 +83,7 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
||||||
saveCredentials.setChecked(preferences.getBoolean(SAVE_SERVER_CREDENTIALS, false));
|
saveCredentials.setChecked(preferences.getBoolean(SAVE_SERVER_CREDENTIALS, false));
|
||||||
connectorUrlCredentials.setText(preferences.getString(URL_CREDENTIALS, null));
|
connectorUrlCredentials.setText(preferences.getString(URL_CREDENTIALS, null));
|
||||||
loginCredentials.setText(preferences.getString(LOGIN_CREDENTIALS, null));
|
loginCredentials.setText(preferences.getString(LOGIN_CREDENTIALS, null));
|
||||||
passwordCredentials.setText(preferences.getString(PASSWORD_CREDENTIALS, null));;
|
passwordCredentials.setText(preferences.getString(PASSWORD_CREDENTIALS, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEntriesPageLimit(){
|
private int getEntriesPageLimit(){
|
||||||
|
|
Loading…
Reference in a new issue