Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added text input layout style to phone number edittext #1348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.digitalcampus.oppia.utils.ui.fields;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;

import androidx.annotation.Nullable;

import com.google.android.material.textfield.TextInputLayout;

import org.digitalcampus.mobile.learning.R;

public class ValidableNestedTextInputLayout extends ValidableTextInputLayout {

public ValidableNestedTextInputLayout(Context context) {
super(context);
}

public ValidableNestedTextInputLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}

public ValidableNestedTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}



@Nullable
@Override
public EditText getEditText() {
return getNestedTextInputLayout() != null ? getNestedTextInputLayout().getEditText() : null;
}

@Override
public void setError(@Nullable CharSequence errorText) {
TextInputLayout nestedTextInputLayout = getNestedTextInputLayout();
if (nestedTextInputLayout != null) {
nestedTextInputLayout.setError(errorText);
}
}

@Override
public void setErrorEnabled(boolean enabled) {
TextInputLayout nestedTextInputLayout = getNestedTextInputLayout();
if (nestedTextInputLayout != null) {
nestedTextInputLayout.setErrorEnabled(enabled);
}
}

private TextInputLayout getNestedTextInputLayout() {
return findViewById(R.id.ccp_text_input_layout);
}
}
52 changes: 29 additions & 23 deletions app/src/main/res/layout/activity_edit_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
layout="@layout/toolbar" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/profile_view"
android:visibility="gone"
tools:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar">
android:layout_below="@id/toolbar"
android:visibility="gone"
tools:visibility="visible">

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/btn_save_profile"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteY="56dp">

<LinearLayout
Expand Down Expand Up @@ -103,7 +103,7 @@

</org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout>

<org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout
<org.digitalcampus.oppia.utils.ui.fields.ValidableNestedTextInputLayout
android:id="@+id/field_phoneno"
style="@style/Oppia.CustomField.TextInputLayout"
android:layout_marginTop="@dimen/margin_medium"
Expand All @@ -120,19 +120,25 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
app:ccp_autoDetectCountry="true" />
app:ccp_autoDetectCountry="true"
android:layout_gravity="bottom"/>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ccp_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/register_form_phoneno_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/register_form_phoneno_title"
android:inputType="phone"
android:singleLine="true"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

<EditText
android:id="@+id/register_form_phoneno_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/register_form_phoneno_title"
android:inputType="phone"
android:singleLine="true"
android:textSize="15sp" />

</org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout>
</org.digitalcampus.oppia.utils.ui.fields.ValidableNestedTextInputLayout>


<LinearLayout
Expand All @@ -146,13 +152,13 @@
<Button
android:id="@+id/btn_save_profile"
android:layout_width="wrap_content"
android:layout_marginBottom="@dimen/margin_medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_medium"
android:text="@string/save_profile"
android:theme="@style/PrimaryButton" />
android:theme="@style/PrimaryButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
33 changes: 20 additions & 13 deletions app/src/main/res/layout/fragment_register.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
android:textSize="15sp" />
</org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout>

<org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout
<org.digitalcampus.oppia.utils.ui.fields.ValidableNestedTextInputLayout
android:id="@+id/register_form_phoneno_field"
style="@style/Oppia.CustomField.TextInputLayout"
android:layout_marginTop="@dimen/margin_medium"
Expand All @@ -179,19 +179,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
app:ccp_autoDetectCountry="true" />
</LinearLayout>
app:ccp_autoDetectCountry="true"
android:layout_gravity="bottom" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ccp_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/register_form_phoneno_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/register_form_phoneno_title"
android:inputType="phone"
android:singleLine="true"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>

<EditText
android:id="@+id/register_form_phoneno_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/register_form_phoneno_title"
android:inputType="phone"
android:singleLine="true"
android:textSize="15sp" />

</org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout>
</LinearLayout>
</org.digitalcampus.oppia.utils.ui.fields.ValidableNestedTextInputLayout>


<org.digitalcampus.oppia.utils.ui.fields.ValidableTextInputLayout
Expand Down