Skip to content

Commit

Permalink
fix #987:Enhancing the dialog fragment (Identifier+document upload)
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshGautam committed Jun 13, 2018
1 parent 2fa433d commit 9b69d98
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ public class DocumentDialogFragment extends DialogFragment implements DocumentDi
private final String LOG_TAG = getClass().getSimpleName();

@BindView(R.id.tv_document_action)
TextView tv_document_action;
TextView tvDocumentAction;

@BindView(R.id.et_document_name)
EditText et_document_name;
EditText etDocumentName;

@BindView(R.id.et_document_description)
EditText et_document_description;
EditText etDocumentDescription;

@BindView(R.id.tv_choose_file)
TextView tv_choose_file;
TextView tvChooseFile;

@BindView(R.id.bt_upload)
Button bt_upload;
Button btUpload;

@Inject
DocumentDialogPresenter mDocumentDialogPresenter;
Expand Down Expand Up @@ -124,16 +124,14 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
rootView = inflater.inflate(R.layout.dialog_fragment_document, container, false);

ButterKnife.bind(this, rootView);
mDocumentDialogPresenter.attachView(this);

if (getResources().getString(R.string.update_document).equals(documentAction)) {
tv_document_action.setText(R.string.update_document);
et_document_name.setText(document.getName());
et_document_description.setText(document.getDescription());
tvDocumentAction.setText(R.string.update_document);
etDocumentName.setText(document.getName());
etDocumentDescription.setText(document.getDescription());
} else if (getResources().getString(R.string.upload_document).equals(documentAction)) {
tv_document_action.setText(R.string.upload_document);
tvDocumentAction.setText(R.string.upload_document);
}

return rootView;
Expand All @@ -149,7 +147,7 @@ public void beginUpload() {
}
}

@OnClick(R.id.tv_choose_file)
@OnClick(R.id.btn_browse_document)
public void openFilePicker() {
checkPermissionAndRequest();
}
Expand All @@ -162,13 +160,13 @@ public void openFilePicker() {
*/
public void validateInput() throws RequiredFieldException {

documentName = et_document_name.getEditableText().toString();
documentName = etDocumentName.getEditableText().toString();

if (documentName.length() == 0 || documentName.equals(""))
throw new RequiredFieldException(getResources().getString(R.string.name),
getString(R.string.message_field_required));

documentDescription = et_document_description.getEditableText().toString();
documentDescription = etDocumentDescription.getEditableText().toString();

if (documentDescription.length() == 0 || documentDescription.equals(""))
throw new RequiredFieldException(getResources().getString(R.string.description),
Expand Down Expand Up @@ -285,11 +283,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}

if (fileChoosen != null) {
tv_choose_file.setText(fileChoosen.getName());
tvChooseFile.setText(fileChoosen.getName());
} else {
break;
}
bt_upload.setEnabled(true);
btUpload.setEnabled(true);

}
break;
Expand Down Expand Up @@ -338,4 +336,5 @@ public void onDestroyView() {
public interface OnDialogFragmentInteractionListener {
void initiateFileUpload(String name, String description);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/white"
android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
</vector>
173 changes: 100 additions & 73 deletions mifosng-android/src/main/res/layout/dialog_fragment_document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,122 @@
~ See https://github.com/openMF/android-client/blob/master/LICENSE.md
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<TableLayout
android:layout_width="match_parent"
<LinearLayout android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingBottom="24dp"
android:layout_centerHorizontal="true"
android:minWidth="300dp"
android:minHeight="300dp"
android:scrollbars="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:padding="8dp"
android:id="@+id/tableLayout">
android:layout_width="match_parent"
android:orientation="vertical">

<TextView
style="@style/Base.TextAppearance.AppCompat.Large"
android:id="@+id/tv_document_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingBottom="@dimen/layout_padding_30dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingStart="24dp"
android:paddingTop="24dp"
android:gravity="center"
android:padding="10dp"
android:text="@string/upload_document"
/>
android:textColor="@color/primary"
android:textStyle="bold"/>

<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tableRow1">

<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/name"
android:id="@+id/textView2" />
<android.support.design.widget.TextInputLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingLeft="24dp"
android:paddingRight="24dp">

<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="@string/name"
android:id="@+id/et_document_name"
android:maxLines="3"
android:inputType="text"
android:scrollbars="vertical"/>
</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tableRow2"
android:layout_marginTop="16dp">

<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/description"
android:id="@+id/textView3" />
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/til_description"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="16dp">

<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="@string/description"
android:id="@+id/et_document_description"
android:maxLines="3"
android:inputType="text"
android:inputType="textMultiLine"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scrollHorizontally="false"
android:scrollbars="vertical"/>
</TableRow>

</TableLayout>
</android.support.design.widget.TextInputLayout>


<android.support.design.widget.TextInputLayout
android:id="@+id/til_selected_file"
android:gravity="center"
android:layout_height="match_parent"
android:layout_weight=".7"
android:layout_width="match_parent"
android:paddingEnd="8dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="16dp">
<EditText
android:hint="@string/selected_file"
android:id="@+id/tv_choose_file"
android:inputType="text"
android:lines="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scrollHorizontally="false"
android:enabled="false"
android:scrollbars="vertical"/>
</android.support.design.widget.TextInputLayout>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<Button
android:drawableLeft="@drawable/ic_folder_black_24dp"
android:drawableStart="@drawable/ic_folder_black_24dp"
android:id="@+id/btn_browse_document"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:layout_weight="0.5"
android:text="@string/browse"
android:backgroundTint="@color/primary"
android:textAllCaps="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/choose_file"
android:id="@+id/tv_choose_file"
android:layout_marginTop="16dp"
android:layout_below="@+id/tableLayout"
android:layout_centerHorizontal="true" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/upload"
android:id="@+id/bt_upload"
android:enabled="false"
android:layout_below="@+id/tv_choose_file"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp" />
<Button
android:id="@+id/bt_upload"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:text="@string/upload"
android:layout_weight="0.5"
android:textAllCaps="true"
android:backgroundTint="@color/primary" />

</LinearLayout>

</RelativeLayout>
</LinearLayout>
Loading

0 comments on commit 9b69d98

Please sign in to comment.