Skip to content

Commit

Permalink
Input Dialogue Creation #4
Browse files Browse the repository at this point in the history
*Create ScrollView to fit multiple input fields if input fields extend beyond container.
  • Loading branch information
rayliverified committed Jul 23, 2017
1 parent fdce23f commit 6ded29e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 52 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/stream/customalertapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void OnClick(View view, Dialog dialog) {
}
})
.setLineInputHint(lineHint)
.setBoxInputHint(boxHint)
// .setBoxInputHint(boxHint)
.build();
alert.show();
}
Expand Down
2 changes: 1 addition & 1 deletion customalert/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ android {
}

dependencies {
compile 'com.android.support:design:+'
compile 'com.android.support:design:25.3.1'
}

9 changes: 6 additions & 3 deletions customalert/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<manifest package="stream.customalert">
<application/>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="stream.customalert">
<application
android:allowBackup="true"
android:supportsRtl="true">
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcel;
Expand Down Expand Up @@ -36,7 +35,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class CustomAlertDialogue extends DialogFragment {
public static final String TAG = CustomAlertDialogue.class.getSimpleName();
Expand All @@ -59,7 +57,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

if (savedInstanceState != null) {
if (builder != null) {
builder = (Builder) savedInstanceState.getParcelable(Builder.class.getSimpleName());
builder = savedInstanceState.getParcelable(Builder.class.getSimpleName());
}
}
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.CustomDialog);
Expand Down Expand Up @@ -415,7 +413,7 @@ public void onClick(View v) {
}

//Initialize input boxes.
ViewStub viewStub = (ViewStub) view.findViewById(R.id.viewStubVertical);
ViewStub viewStub = (ViewStub) view.findViewById(R.id.viewStubVerticalInput);
viewStub.inflate();

LinearLayout alertInput = (LinearLayout) view.findViewById(R.id.alertInput);
Expand Down Expand Up @@ -453,7 +451,7 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
{
View boxInput = LayoutInflater.from(view.getContext()).inflate(R.layout.alert_input_box, null);
TextInputLayout inputLayout = (TextInputLayout) boxInput.findViewById(R.id.alert_input_layout);
inputLayout.setHint(builder.getLineInputHint().get(i));
inputLayout.setHint(builder.getBoxInputHint().get(i));
EditText editInput = (EditText) boxInput.findViewById(R.id.alert_input_text);
editInput.setTag("Box" + i);
tagList.add("Box" + i);
Expand Down
77 changes: 42 additions & 35 deletions customalert/src/main/res/layout/alert_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,62 @@
android:background="@color/transparent"
android:orientation="vertical">

<LinearLayout
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dialogue_margin_side"
android:layout_marginRight="@dimen/dialogue_margin_side"
android:layout_marginTop="80dp"
android:layout_marginBottom="80dp"
android:layout_gravity="center"
android:background="@drawable/bg_alertview"
android:orientation="vertical">
android:background="@drawable/bg_alertview">

<TextView
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/text_margin_border"
android:layout_marginBottom="@dimen/text_title_message_space"
android:layout_marginLeft="@dimen/text_margin_border"
android:layout_marginRight="@dimen/text_margin_border"
android:gravity="left"
android:text="Dialogue Title"
android:textSize="@dimen/text_title_size"
android:textColor="@color/text_default"/>
android:layout_marginBottom="@dimen/button_height"
android:layout_gravity="top"
android:orientation="vertical">

<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/text_input_margin_bottom"
android:layout_marginLeft="@dimen/text_margin_border"
android:layout_marginRight="@dimen/text_margin_border"
android:gravity="left"
android:text="Sample Dialogue Message"
android:textSize="@dimen/text_message_size"
android:textColor="@color/text_default"
android:maxLines="4"
android:minLines="1"
android:scrollbars="vertical"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/text_margin_border"
android:layout_marginBottom="@dimen/text_message_margin_bottom"
android:layout_marginLeft="@dimen/text_margin_border"
android:layout_marginRight="@dimen/text_margin_border"
android:gravity="left"
android:text="Dialogue Title"
android:textSize="@dimen/text_title_size"
android:textColor="@color/text_default"/>

<ViewStub
android:id="@+id/viewStubVertical"
android:layout="@layout/alertview_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/text_input_margin_bottom"
android:layout_marginLeft="@dimen/text_margin_border"
android:layout_marginRight="@dimen/text_margin_border"
android:gravity="left"
android:text="Sample Dialogue Message"
android:textSize="@dimen/text_message_size"
android:textColor="@color/text_default"
android:maxLines="4"
android:minLines="1"
android:scrollbars="vertical"/>

<ViewStub
android:id="@+id/viewStubVerticalInput"
android:layout="@layout/alertview_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<ViewStub
android:id="@+id/viewStubHorizontal"
android:layout="@layout/alertview_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</FrameLayout>
</LinearLayout>
19 changes: 12 additions & 7 deletions customalert/src/main/res/layout/alertview_input.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/alertInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"/>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">

<LinearLayout android:id="@+id/alertInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"/>
</ScrollView>

0 comments on commit 6ded29e

Please sign in to comment.