mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add Monospace setting for field #5
This commit is contained in:
@@ -142,6 +142,7 @@ public class EntryActivity extends LockCloseHideActivity {
|
||||
titleIconView = (ImageView) findViewById(R.id.entry_icon);
|
||||
titleView = (TextView) findViewById(R.id.entry_title);
|
||||
entryContentsView = (EntryContentsView) findViewById(R.id.entry_contents);
|
||||
entryContentsView.applyFontVisibilityToFields(PrefsUtil.fieldFontIsInVisibility(this));
|
||||
|
||||
fillData();
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
@@ -54,6 +53,7 @@ import com.keepassdroid.database.security.ProtectedString;
|
||||
import com.keepassdroid.fragments.GeneratePasswordDialogFragment;
|
||||
import com.keepassdroid.fragments.IconPickerDialogFragment;
|
||||
import com.keepassdroid.icons.Icons;
|
||||
import com.keepassdroid.settings.PrefsUtil;
|
||||
import com.keepassdroid.tasks.ProgressTask;
|
||||
import com.keepassdroid.utils.MenuUtil;
|
||||
import com.keepassdroid.utils.Types;
|
||||
@@ -87,8 +87,15 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
protected boolean mIsNew;
|
||||
protected int mSelectedIconID = -1;
|
||||
|
||||
// Views
|
||||
private ScrollView scrollView;
|
||||
private ViewGroup extraFieldsContainer;
|
||||
private TextView entryTitleView;
|
||||
private TextView entryUserNameView;
|
||||
private TextView entryUrlView;
|
||||
private TextView entryPasswordView;
|
||||
private TextView entryConfirmationPasswordView;
|
||||
private TextView entryCommentView;
|
||||
private ViewGroup entryExtraFieldsContainer;
|
||||
|
||||
/**
|
||||
* launch EntryEditActivity to update an existing entry
|
||||
@@ -124,6 +131,17 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
scrollView = (ScrollView) findViewById(R.id.entry_scroll);
|
||||
scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||
|
||||
entryTitleView = (TextView) findViewById(R.id.entry_title);
|
||||
entryUserNameView = (TextView) findViewById(R.id.entry_user_name);
|
||||
entryUrlView = (TextView) findViewById(R.id.entry_url);
|
||||
entryPasswordView = (TextView) findViewById(R.id.entry_password);
|
||||
entryConfirmationPasswordView = (TextView) findViewById(R.id.entry_confpassword);
|
||||
entryCommentView = (TextView) findViewById(R.id.entry_comment);
|
||||
entryExtraFieldsContainer = (ViewGroup) findViewById(R.id.advanced_container);
|
||||
|
||||
// Likely the app has been killed exit the activity
|
||||
Database db = App.getDB();
|
||||
@@ -146,10 +164,7 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
mEntry = pm.entries.get(uuid);
|
||||
mIsNew = false;
|
||||
fillData();
|
||||
}
|
||||
|
||||
scrollView = (ScrollView) findViewById(R.id.entry_scroll);
|
||||
scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||
}
|
||||
|
||||
View iconButton = findViewById(R.id.icon_button);
|
||||
iconButton.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -193,7 +208,7 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
|
||||
});
|
||||
|
||||
extraFieldsContainer = (ViewGroup) findViewById(R.id.advanced_container);
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
View add = findViewById(R.id.add_new_field);
|
||||
add.setVisibility(View.VISIBLE);
|
||||
@@ -203,7 +218,7 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
public void onClick(View v) {
|
||||
EntryEditNewField ees = new EntryEditNewField(EntryEditActivity.this);
|
||||
ees.setData("", new ProtectedString(false, ""));
|
||||
extraFieldsContainer.addView(ees);
|
||||
entryExtraFieldsContainer.addView(ees);
|
||||
|
||||
// Scroll bottom
|
||||
scrollView.post(new Runnable() {
|
||||
@@ -219,15 +234,15 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
|
||||
protected boolean validateBeforeSaving() {
|
||||
// Require title
|
||||
String title = Util.getEditText(this, R.id.entry_title);
|
||||
String title = entryTitleView.getText().toString();
|
||||
if ( title.length() == 0 ) {
|
||||
Toast.makeText(this, R.string.error_title_required, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate password
|
||||
String pass = Util.getEditText(this, R.id.entry_password);
|
||||
String conf = Util.getEditText(this, R.id.entry_confpassword);
|
||||
String pass = entryPasswordView.getText().toString();
|
||||
String conf = entryConfirmationPasswordView.getText().toString();
|
||||
if ( ! pass.equals(conf) ) {
|
||||
Toast.makeText(this, R.string.error_pass_match, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@@ -235,9 +250,9 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
|
||||
// Validate extra fields
|
||||
if (mEntry.allowExtraFields()) {
|
||||
for (int i = 0; i < extraFieldsContainer.getChildCount(); i++) {
|
||||
EntryEditNewField ees = (EntryEditNewField) extraFieldsContainer.getChildAt(i);
|
||||
String key = ees.getLabel();
|
||||
for (int i = 0; i < entryExtraFieldsContainer.getChildCount(); i++) {
|
||||
EntryEditNewField entryEditNewField = (EntryEditNewField) entryExtraFieldsContainer.getChildAt(i);
|
||||
String key = entryEditNewField.getLabel();
|
||||
if (key == null || key.length() == 0) {
|
||||
Toast.makeText(this, R.string.error_string_key, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@@ -263,7 +278,7 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
newEntry.setLastModificationTime(now);
|
||||
|
||||
PwDatabase db = App.getDB().pm;
|
||||
newEntry.setTitle(Util.getEditText(this, R.id.entry_title), db);
|
||||
newEntry.setTitle(entryTitleView.getText().toString(), db);
|
||||
if(mSelectedIconID != -1)
|
||||
// or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID));
|
||||
newEntry.setIcon(new PwIconStandard(mSelectedIconID));
|
||||
@@ -276,19 +291,17 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
newEntry.setIcon(mEntry.icon);
|
||||
}
|
||||
}
|
||||
newEntry.setUrl(Util.getEditText(this, R.id.entry_url), db);
|
||||
newEntry.setUsername(Util.getEditText(this, R.id.entry_user_name), db);
|
||||
newEntry.setNotes(Util.getEditText(this, R.id.entry_comment), db);
|
||||
newEntry.setPassword(Util.getEditText(this, R.id.entry_password), db);
|
||||
|
||||
newEntry.setUrl(entryUrlView.getText().toString(), db);
|
||||
newEntry.setUsername(entryUserNameView.getText().toString(), db);
|
||||
newEntry.setNotes(entryCommentView.getText().toString(), db);
|
||||
newEntry.setPassword(entryPasswordView.getText().toString(), db);
|
||||
|
||||
if (newEntry.allowExtraFields()) {
|
||||
// Delete all new standard strings
|
||||
newEntry.removeExtraFields();
|
||||
|
||||
// Add extra fields from views
|
||||
for (int i = 0; i < extraFieldsContainer.getChildCount(); i++) {
|
||||
EntryEditNewField view = (EntryEditNewField) extraFieldsContainer.getChildAt(i);
|
||||
for (int i = 0; i < entryExtraFieldsContainer.getChildCount(); i++) {
|
||||
EntryEditNewField view = (EntryEditNewField) entryExtraFieldsContainer.getChildAt(i);
|
||||
String key = view.getLabel();
|
||||
String value = view.getValue();
|
||||
boolean protect = view.isProtected();
|
||||
@@ -326,31 +339,28 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
||||
App.getDB().drawFactory.assignDrawableTo(currIconButton, getResources(), mEntry.getIcon());
|
||||
|
||||
populateText(R.id.entry_title, mEntry.getTitle());
|
||||
populateText(R.id.entry_user_name, mEntry.getUsername());
|
||||
populateText(R.id.entry_url, mEntry.getUrl());
|
||||
|
||||
String password = mEntry.getPassword();
|
||||
populateText(R.id.entry_password, password);
|
||||
populateText(R.id.entry_confpassword, password);
|
||||
boolean visibilityFont = PrefsUtil.fieldFontIsInVisibility(this);
|
||||
|
||||
populateText(R.id.entry_comment, mEntry.getNotes());
|
||||
entryTitleView.setText(mEntry.getTitle());
|
||||
entryUserNameView.setText(mEntry.getUsername());
|
||||
entryUrlView.setText(mEntry.getUrl());
|
||||
String password = mEntry.getPassword();
|
||||
entryPasswordView.setText(password);
|
||||
entryConfirmationPasswordView.setText(password);
|
||||
entryCommentView.setText(mEntry.getNotes());
|
||||
Util.applyFontVisibilityToTextView(visibilityFont, entryCommentView);
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container);
|
||||
for (Map.Entry<String, ProtectedString> pair : mEntry.getExtraProtectedFields().entrySet()) {
|
||||
EntryEditNewField ees = new EntryEditNewField(EntryEditActivity.this);
|
||||
ees.setData(pair.getKey(), pair.getValue());
|
||||
container.addView(ees);
|
||||
EntryEditNewField entryEditNewField = new EntryEditNewField(EntryEditActivity.this);
|
||||
entryEditNewField.setData(pair.getKey(), pair.getValue());
|
||||
entryEditNewField.setFontVisibility(visibilityFont);
|
||||
container.addView(entryEditNewField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populateText(int viewId, String text) {
|
||||
TextView tv = (TextView) findViewById(viewId);
|
||||
tv.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void iconPicked(Bundle bundle) {
|
||||
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
||||
@@ -361,11 +371,8 @@ public class EntryEditActivity extends LockCloseHideActivity
|
||||
@Override
|
||||
public void acceptPassword(Bundle bundle) {
|
||||
String generatedPassword = bundle.getString(GeneratePasswordDialogFragment.KEY_PASSWORD_ID);
|
||||
EditText password = (EditText) findViewById(R.id.entry_password);
|
||||
EditText confPassword = (EditText) findViewById(R.id.entry_confpassword);
|
||||
|
||||
password.setText(generatedPassword);
|
||||
confPassword.setText(generatedPassword);
|
||||
entryPasswordView.setText(generatedPassword);
|
||||
entryConfirmationPasswordView.setText(generatedPassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -119,4 +119,10 @@ public class PrefsUtil {
|
||||
return prefs.getBoolean(ctx.getString(R.string.maskpass_key),
|
||||
ctx.getResources().getBoolean(R.bool.maskpass_default));
|
||||
}
|
||||
|
||||
public static boolean fieldFontIsInVisibility(Context ctx) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
return prefs.getBoolean(ctx.getString(R.string.monospace_font_fields_enable_key),
|
||||
ctx.getResources().getBoolean(R.bool.monospace_font_fields_enable_default));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.text.ClipboardManager;
|
||||
import android.widget.TextView;
|
||||
@@ -40,13 +41,13 @@ public class Util {
|
||||
if (csText == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
return csText.toString();
|
||||
}
|
||||
|
||||
|
||||
public static void copyToClipboard(Context context, String text) throws SamsungClipboardException {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
||||
|
||||
try {
|
||||
clipboard.setText(text);
|
||||
} catch (NullPointerException e) {
|
||||
@@ -67,7 +68,7 @@ public class Util {
|
||||
|
||||
public static String getEditText(Activity act, int resId) {
|
||||
TextView te = (TextView) act.findViewById(resId);
|
||||
|
||||
|
||||
if (te != null) {
|
||||
return te.getText().toString();
|
||||
} else {
|
||||
@@ -83,4 +84,9 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyFontVisibilityToTextView(boolean applyMonospace, TextView textView) {
|
||||
if (applyMonospace)
|
||||
textView.setTypeface(Typeface.MONOSPACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.keepassdroid.utils.Util;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@@ -36,6 +37,8 @@ import java.util.Date;
|
||||
|
||||
public class EntryContentsView extends LinearLayout {
|
||||
|
||||
private boolean fontInVisibility;
|
||||
|
||||
private View userNameContainerView;
|
||||
private TextView userNameView;
|
||||
private ImageView userNameActionView;
|
||||
@@ -67,6 +70,8 @@ public class EntryContentsView extends LinearLayout {
|
||||
public EntryContentsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
fontInVisibility = false;
|
||||
|
||||
dateFormat = android.text.format.DateFormat.getDateFormat(context);
|
||||
timeFormat = android.text.format.DateFormat.getTimeFormat(context);
|
||||
|
||||
@@ -100,6 +105,10 @@ public class EntryContentsView extends LinearLayout {
|
||||
expiresDateView = (TextView) findViewById(R.id.entry_expires);
|
||||
}
|
||||
|
||||
public void applyFontVisibilityToFields(boolean fontInVisibility) {
|
||||
this.fontInVisibility = fontInVisibility;
|
||||
}
|
||||
|
||||
public void assignUserName(String userName) {
|
||||
if (userName != null && !userName.isEmpty()) {
|
||||
userNameContainerView.setVisibility(VISIBLE);
|
||||
@@ -145,13 +154,15 @@ public class EntryContentsView extends LinearLayout {
|
||||
public void assignComment(String comment) {
|
||||
if (comment != null && !comment.isEmpty()) {
|
||||
commentContainerView.setVisibility(VISIBLE);
|
||||
Util.applyFontVisibilityToTextView(fontInVisibility, commentView);
|
||||
commentView.setText(comment);
|
||||
}
|
||||
}
|
||||
|
||||
public void addExtraField(String title, String value, OnClickListener onActionClickListener) {
|
||||
View view = new EntryNewField(getContext(), null, title, value, onActionClickListener);
|
||||
extrasView.addView(view);
|
||||
EntryNewField entryNewField = new EntryNewField(getContext(), null, title, value, onActionClickListener);
|
||||
entryNewField.applyFontVisibilityToValue(fontInVisibility);
|
||||
extrasView.addView(entryNewField);
|
||||
}
|
||||
|
||||
public void clearExtraFields() {
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.keepassdroid.database.security.ProtectedString;
|
||||
import com.keepassdroid.utils.Util;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
public class EntryEditNewField extends RelativeLayout {
|
||||
@@ -87,6 +88,10 @@ public class EntryEditNewField extends RelativeLayout {
|
||||
return protectionCheckView.isChecked();
|
||||
}
|
||||
|
||||
public void setFontVisibility(boolean applyFontVisibility) {
|
||||
Util.applyFontVisibilityToTextView(applyFontVisibility, valueView);
|
||||
}
|
||||
|
||||
public void deleteViewFromParent() {
|
||||
try {
|
||||
ViewGroup parent = (ViewGroup) getParent();
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.keepassdroid.utils.Util;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
public class EntryNewField extends LinearLayout {
|
||||
@@ -61,6 +62,10 @@ public class EntryNewField extends LinearLayout {
|
||||
setValue(value);
|
||||
setAction(onClickActionListener);
|
||||
}
|
||||
|
||||
public void applyFontVisibilityToValue(boolean changeFont) {
|
||||
Util.applyFontVisibilityToTextView(changeFont, valueView);
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
if (label != null) {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class GroupHeaderView extends RelativeLayout {
|
||||
|
||||
private void inflate(Context context) {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
assert inflater != null;
|
||||
inflater.inflate(R.layout.group_header, this);
|
||||
|
||||
if (App.getDB().readOnly) {
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<string name="full_file_path_enable_key" translatable="true">full_file_path_enable_key</string>
|
||||
<string name="fingerprint_delete_all_key" translatable="true">fingerprint_delete_all_key</string>
|
||||
<string name="recycle_bin_key" translatable="true">recycle_bin_key</string>
|
||||
<string name="monospace_font_fields_enable_key" translatable="true">monospace_font_extra_fields_enable_key</string>
|
||||
|
||||
<bool name="maskpass_default" translatable="false">true</bool>
|
||||
<bool name="keyfile_default" translatable="false">true</bool>
|
||||
@@ -75,6 +76,7 @@
|
||||
<bool name="sort_group_before_default" translatable="true">true</bool>
|
||||
<bool name="sort_ascending_default" translatable="true">true</bool>
|
||||
<bool name="sort_recycle_bin_bottom_default" translatable="true">true</bool>
|
||||
<bool name="monospace_font_fields_enable_default" translatable="true">false</bool>
|
||||
|
||||
<string name="clipboard_timeout_default" translatable="false">300000</string>
|
||||
<string-array name="clipboard_timeout_values">
|
||||
|
||||
@@ -258,6 +258,8 @@
|
||||
<string name="permission_external_storage_rationale_read_database">KeePass DX need external storage permission to read an URI not provided by a Content Provider</string>
|
||||
<string name="permission_external_storage_denied">External storage permission denied</string>
|
||||
<string name="permission_external_storage_never_ask">Can\'t perform the action without external storage permission</string>
|
||||
<string name="monospace_font_fields_enable_title">Fields Font</string>
|
||||
<string name="monospace_font_fields_enable_summary">Change the font of the fields for better character visibility</string>
|
||||
|
||||
<string-array name="clipboard_timeout_options">
|
||||
<item>5 seconds</item>
|
||||
|
||||
@@ -143,6 +143,11 @@
|
||||
android:entryValues="@array/list_size_values"
|
||||
android:dialogTitle="@string/list_size_summary"
|
||||
android:defaultValue="@string/list_size_default"/>
|
||||
<android.support.v14.preference.SwitchPreference
|
||||
android:key="@string/monospace_font_fields_enable_key"
|
||||
android:title="@string/monospace_font_fields_enable_title"
|
||||
android:summary="@string/monospace_font_fields_enable_summary"
|
||||
android:defaultValue="@bool/monospace_font_fields_enable_default"/>
|
||||
<android.support.v14.preference.SwitchPreference
|
||||
android:key="@string/full_file_path_enable_key"
|
||||
android:title="@string/full_file_path_enable_title"
|
||||
|
||||
Reference in New Issue
Block a user