mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add fix for encryption rounds
This commit is contained in:
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Brian Pellin.
|
|
||||||
*
|
|
||||||
* This file is part of KeePassDroid.
|
|
||||||
*
|
|
||||||
* KeePassDroid is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* KeePassDroid is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.keepassdroid.settings;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.v7.preference.EditTextPreference;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
|
||||||
|
|
||||||
public class LongEditTextPreference extends EditTextPreference {
|
|
||||||
|
|
||||||
public LongEditTextPreference(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LongEditTextPreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LongEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getPersistedString(String defaultReturnValue) {
|
|
||||||
return String.valueOf(getPersistedLong(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean persistString(String value) {
|
|
||||||
try {
|
|
||||||
return persistLong(Long.valueOf(value));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Toast.makeText(getContext(), R.string.error_rounds_not_number, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,14 @@ package com.keepassdroid.settings;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.preference.EditTextPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.app.App;
|
import com.keepassdroid.app.App;
|
||||||
|
import com.kunzisoft.keepass.R;
|
||||||
|
|
||||||
public class MainPreferenceFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceClickListener {
|
public class MainPreferenceFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceClickListener {
|
||||||
|
|
||||||
@@ -40,6 +42,21 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat implements
|
|||||||
} else {
|
} else {
|
||||||
preference.setOnPreferenceClickListener(this);
|
preference.setOnPreferenceClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditTextPreference fixDatabaseRoundPref = (EditTextPreference)
|
||||||
|
getPreferenceScreen().findPreference(getString(R.string.roundsFix_key));
|
||||||
|
fixDatabaseRoundPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
try {
|
||||||
|
Long.valueOf(newValue.toString());
|
||||||
|
return true;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Toast.makeText(getContext(), R.string.error_rounds_not_number, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="?attr/iconPreferenceColor"
|
||||||
|
android:pathData="M11,4.07L11,2.05c-2.01,0.2 -3.84,1 -5.32,2.21L7.1,5.69c1.11,-0.86 2.44,-1.44 3.9,-1.62zM18.32,4.26C16.84,3.05 15.01,2.25 13,2.05v2.02c1.46,0.18 2.79,0.76 3.9,1.62l1.42,-1.43zM19.93,11h2.02c-0.2,-2.01 -1,-3.84 -2.21,-5.32L18.31,7.1c0.86,1.11 1.44,2.44 1.62,3.9zM5.69,7.1L4.26,5.68C3.05,7.16 2.25,8.99 2.05,11h2.02c0.18,-1.46 0.76,-2.79 1.62,-3.9zM4.07,13L2.05,13c0.2,2.01 1,3.84 2.21,5.32l1.43,-1.43c-0.86,-1.1 -1.44,-2.43 -1.62,-3.89zM15,12c0,-1.66 -1.34,-3 -3,-3s-3,1.34 -3,3 1.34,3 3,3 3,-1.34 3,-3zM18.31,16.9l1.43,1.43c1.21,-1.48 2.01,-3.32 2.21,-5.32h-2.02c-0.18,1.45 -0.76,2.78 -1.62,3.89zM13,19.93v2.02c2.01,-0.2 3.84,-1 5.32,-2.21l-1.43,-1.43c-1.1,0.86 -2.43,1.44 -3.89,1.62zM5.68,19.74C7.16,20.95 9,21.75 11,21.95v-2.02c-1.46,-0.18 -2.79,-0.76 -3.9,-1.62l-1.42,1.43z"/>
|
||||||
|
</vector>
|
||||||
@@ -171,6 +171,7 @@
|
|||||||
<string name="root">Root</string>
|
<string name="root">Root</string>
|
||||||
<string name="rounds">Encryption Rounds</string>
|
<string name="rounds">Encryption Rounds</string>
|
||||||
<string name="rounds_explaination">Higher encryption rounds provide additional protection against brute force attacks, but can really slow down loading and saving.</string>
|
<string name="rounds_explaination">Higher encryption rounds provide additional protection against brute force attacks, but can really slow down loading and saving.</string>
|
||||||
|
<string name="rounds_fix_title">Fix of database encryption rounds</string>
|
||||||
<string name="rounds_fix">Key encryption rounds before corruption</string>
|
<string name="rounds_fix">Key encryption rounds before corruption</string>
|
||||||
<string name="rounds_fix_explaination">If your database was corrupted by KeePassDroid version 2.2.0.0 to 2.2.0.6, enter the number of rounds used previously and this will allow you to open your database.</string>
|
<string name="rounds_fix_explaination">If your database was corrupted by KeePassDroid version 2.2.0.0 to 2.2.0.6, enter the number of rounds used previously and this will allow you to open your database.</string>
|
||||||
<string name="rounds_hint">rounds</string>
|
<string name="rounds_hint">rounds</string>
|
||||||
|
|||||||
@@ -54,13 +54,6 @@
|
|||||||
android:defaultValue="@bool/saf_default"
|
android:defaultValue="@bool/saf_default"
|
||||||
android:title="@string/use_saf_title"
|
android:title="@string/use_saf_title"
|
||||||
android:key="@string/saf_key"/>
|
android:key="@string/saf_key"/>
|
||||||
<!-- TODO Remove
|
|
||||||
<com.keepassdroid.settings.LongEditTextPreference
|
|
||||||
android:key="@string/roundsFix_key"
|
|
||||||
android:summary="@string/rounds_fix_explaination"
|
|
||||||
android:numeric="integer"
|
|
||||||
android:title="@string/rounds_fix"/>
|
|
||||||
-->
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,16 @@
|
|||||||
android:title="@string/menu_db_settings"
|
android:title="@string/menu_db_settings"
|
||||||
android:icon="@drawable/ic_data_usage_white_24dp"
|
android:icon="@drawable/ic_data_usage_white_24dp"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
<!-- TODO change dialog android:summary="@string/rounds_fix_explaination" -->
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="@string/roundsFix_key"
|
||||||
|
android:title="@string/rounds_fix_title"
|
||||||
|
android:summary="@string/rounds_fix"
|
||||||
|
android:defaultValue="@integer/roundsFix_default"
|
||||||
|
android:icon="@drawable/ic_filter_tilt_shift_pref_24dp"
|
||||||
|
android:numeric="integer"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:digits="0123456789"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
Reference in New Issue
Block a user