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/jni" 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" />
|
||||
</content>
|
||||
<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.
|
||||
*
|
||||
* Class delegated to encrypt data
|
||||
*/
|
||||
public class Crypto {
|
||||
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();
|
||||
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHM);
|
||||
keyGenerator.init(OUTPUT_KEY_LENGTH, secureRandom);
|
||||
SecretKey secretKey = keyGenerator.generateKey();
|
||||
|
||||
return secretKey;
|
||||
secretKey = keyGenerator.generateKey();
|
||||
}
|
||||
|
||||
private void getSecretKey() throws NoSuchAlgorithmException, IOException, ClassNotFoundException {
|
||||
String key;
|
||||
|
||||
// First try to open file
|
||||
File keyFile = new File(context.getFilesDir(), KEY_FILE);
|
||||
if(!keyFile.exists()) { // new key
|
||||
secretKey = generateKey();
|
||||
generateKey();
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(keyFile);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||
objectOutputStream.writeObject(secretKey);
|
||||
|
@ -95,7 +93,6 @@ public class Crypto {
|
|||
|
||||
public String decryptBase64(String encodedString) throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
|
||||
byte [] encryptedString = Base64.decode(encodedString, Base64.DEFAULT);
|
||||
String decrypted = decrypt(encryptedString);
|
||||
return decrypted;
|
||||
return decrypt(encryptedString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,4 @@ public class ElementArrayAdapter extends ArrayAdapter<String> {
|
|||
public List<String> getFieldArray(){
|
||||
return fields;
|
||||
}
|
||||
|
||||
public List<String> getValueArray(){
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,14 @@ import android.preference.CheckBoxPreference;
|
|||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Base64;
|
||||
|
||||
/**
|
||||
* Created by nerull7 on 18.07.14.
|
||||
*
|
||||
* Fragment for Preferences/Settings
|
||||
*/
|
||||
public class SettingsFragment extends PreferenceFragment implements NumberPickerDialog.OnNumberSetListener, Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||
public static final String ENTRIES_PAGE_LIMIT = "entries_limit";
|
||||
|
@ -35,7 +38,8 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
preferences = getPreferenceManager().getDefaultSharedPreferences(getActivity());
|
||||
getPreferenceManager();
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
crypto = new Crypto(getActivity());
|
||||
|
||||
loadPrefs();
|
||||
|
@ -70,7 +74,6 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
|||
}
|
||||
editor.putBoolean(SAVE_SERVER_CREDENTIALS, isEnabled);
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
|
||||
if(!isEnabled)
|
||||
reloadLoginPrefsView();
|
||||
|
@ -80,7 +83,7 @@ public class SettingsFragment extends PreferenceFragment implements NumberPicker
|
|||
saveCredentials.setChecked(preferences.getBoolean(SAVE_SERVER_CREDENTIALS, false));
|
||||
connectorUrlCredentials.setText(preferences.getString(URL_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(){
|
||||
|
|
Loading…
Reference in a new issue