Merge pull request #8577 from osmandapp/RefreshTextFieldBoxLib

Refresh TextFieldBoxes library
This commit is contained in:
max-klaus 2020-02-28 19:39:30 +03:00 committed by GitHub
commit 5f0a5c9400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 98 deletions

View file

@ -495,7 +495,7 @@ dependencies {
exclude group: 'com.android.support'
}
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
implementation ("com.github.HITGIF:TextFieldBoxes:1.4.4"){
exclude group: 'com.android.support'
}

View file

@ -14,7 +14,7 @@
android:layout_marginTop="@dimen/list_header_top_margin"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:layout_marginBottom="8dp">
android:layout_marginBottom="@dimen/content_padding_half">
<ImageView
android:id="@+id/type_down_arrow"
@ -30,7 +30,7 @@
android:id="@+id/master_profile_otfb"
android:layout_width="match_parent"
android:layout_height="60dp"
app:labelText="@string/master_profile"
app:labelText="@string/profile_type_base_string"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary">

View file

@ -105,9 +105,6 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text);
nameEditText.setText(displayedName);
nameEditText.setTextColor(ContextCompat.getColor(getContext(), textPrimaryColor));
if (textBox instanceof OsmandTextFieldBoxes) {
((OsmandTextFieldBoxes) textBox).activate(true);
}
mainView.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -86,7 +86,6 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text);
nameEditText.setText(savedGpxName);
nameEditText.setTextColor(ContextCompat.getColor(ctx, textPrimaryColor));
textBox.activate(true);
nameEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

View file

@ -7,8 +7,8 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.RelativeLayout;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
@ -50,9 +50,9 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
editText = view.findViewById(R.id.edit_text);
editText.setText(text);
RelativeLayout editTextLayout = view.findViewById(R.id.text_field_boxes_editTextLayout);
if (editTextLayout != null && editTextLayout.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) editTextLayout.getLayoutParams();
ViewGroup editTextLayout = view.findViewById(R.id.text_field_boxes_editTextLayout);
if (editTextLayout != null && editTextLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) editTextLayout.getLayoutParams();
params.setMargins(params.leftMargin, AndroidUtils.dpToPx(ctx, 9), params.rightMargin, params.bottomMargin);
}

View file

@ -1,20 +1,12 @@
package net.osmand.plus.widgets;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import net.osmand.plus.R;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
public class OsmandTextFieldBoxes extends TextFieldBoxes {
private boolean useOsmandKeyboard;
public OsmandTextFieldBoxes(Context context) {
super(context);
}
@ -27,83 +19,4 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
super(context, attrs, defStyleAttr);
}
public void setUseOsmandKeyboard(boolean useOsmandKeyboard) {
this.useOsmandKeyboard = useOsmandKeyboard;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
if (editText != null) {
this.panel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
select();
}
});
this.iconImageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
select();
}
});
}
}
public void select() {
if(!OsmandTextFieldBoxes.this.isActivated()) {
OsmandTextFieldBoxes.this.activate(true);
}
OsmandTextFieldBoxes.this.setHasFocus(true);
if (!useOsmandKeyboard) {
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
}
performClick();
}
@Override
public void activate(boolean animated) {
super.activate(animated);
}
@Override
public void deactivate() {
if(this.editText.getText().toString().isEmpty()) {
ViewCompat.animate(this.floatingLabel).alpha(1.0F).scaleX(1.0F).scaleY(1.0F).translationY(0.0F).setDuration((long)this.ANIMATION_DURATION);
this.editTextLayout.setVisibility(View.INVISIBLE);
if(this.editText.hasFocus()) {
if (!useOsmandKeyboard) {
this.inputMethodManager.hideSoftInputFromWindow(this.editText.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
this.editText.clearFocus();
}
}
this.activated = false;
}
public ExtendedEditText getEditText() {
return editText;
}
@Override
protected void makeCursorBlink() {
CharSequence hintCache = this.editText.getHint();
this.editText.setHint(" ");
this.editText.setHint(hintCache);
}
@Override
public void setError(String errorText, boolean giveFocus) {
super.setError(errorText, giveFocus);
this.findViewById(R.id.text_field_boxes_bottom).setVisibility(View.VISIBLE);
}
@Override
public void removeError() {
super.removeError();
this.findViewById(R.id.text_field_boxes_bottom).setVisibility(View.GONE);
}
}