mirror of
https://github.com/TrianguloY/UrlChecker.git
synced 2024-09-19 20:02:16 +02:00
Non Editable Input Text Fix (#361)
**Goal**: Declutter Screen for Improved Usability ### Actions: - Added a TextView as a default state for displaying the URL. - Changed the visibility of the EditText to be initially hidden. - Updated the TextInputModule to reflect the appropriate changes. - Implemented an onClickListener: When the user clicks on the URL, it changes into an EditText to allow for editing. ### Testing: - Tested the default state of the URL display. - Verified the visibility change of the EditText. - Confirmed the functionality of the onClickListener to ensure the URL changes to an EditText correctly. <img src="https://github.com/TrianguloY/UrlChecker/assets/115141097/bda62db3-34b5-4e89-b4ce-f689cbedc21c" alt="DefaultState" width="200"> <img src="https://github.com/TrianguloY/UrlChecker/assets/115141097/60133586-18ab-46c9-9923-97b09a3e2375" alt="StateWhenClickedOn" width="200"> ### Ideas for further improvement: - To add a switch in the input text module for the User to assign the default state (EditText or TextView). resolves #100
This commit is contained in:
parent
988073b4d1
commit
59b203da0f
@ -3,6 +3,7 @@ package com.trianguloy.urlchecker.modules.list;
|
||||
import android.text.Editable;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.trianguloy.urlchecker.R;
|
||||
import com.trianguloy.urlchecker.activities.ModulesActivity;
|
||||
@ -46,6 +47,7 @@ class TextInputDialog extends AModuleDialog {
|
||||
private final DoubleEvent doubleEdit = new DoubleEvent(1000); // if two updates happens in less than this milliseconds, they are considered as the same
|
||||
private boolean skipUpdate = false;
|
||||
|
||||
private TextView txt_url;
|
||||
private EditText edtxt_url;
|
||||
|
||||
public TextInputDialog(MainDialog dialog) {
|
||||
@ -59,7 +61,8 @@ class TextInputDialog extends AModuleDialog {
|
||||
|
||||
@Override
|
||||
public void onInitialize(View views) {
|
||||
edtxt_url = views.findViewById(R.id.url);
|
||||
txt_url = views.findViewById(R.id.url);
|
||||
edtxt_url = views.findViewById(R.id.urlEdit);
|
||||
edtxt_url.addTextChangedListener(new DefaultTextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
@ -76,13 +79,22 @@ class TextInputDialog extends AModuleDialog {
|
||||
// set
|
||||
setUrl(newUrlData);
|
||||
}
|
||||
|
||||
});
|
||||
txt_url.setOnClickListener(v -> {
|
||||
txt_url.setVisibility(View.GONE);
|
||||
edtxt_url.setVisibility(View.VISIBLE);
|
||||
edtxt_url.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisplayUrl(UrlData urlData) {
|
||||
// setText fires the afterTextChanged listener, so we need to skip it
|
||||
skipUpdate = true;
|
||||
txt_url.setText(urlData.url);
|
||||
edtxt_url.setText(urlData.url);
|
||||
skipUpdate = false;
|
||||
doubleEdit.reset(); // next user update, even if immediately after, will be considered new
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true">
|
||||
@ -8,11 +9,18 @@
|
||||
android:layout_width="0px"
|
||||
android:layout_height="0px" />
|
||||
|
||||
<EditText
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
style="@android:style/Widget.TextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/urlEdit"
|
||||
style="@android:style/Widget.EditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"/>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user