Commit d278102c by Kunj Gupta

UOFLMA-116: Fixed - Mandatory fields issue.

parents 7062c7e8 b73ee666
...@@ -30,6 +30,7 @@ import android.support.v7.widget.Toolbar; ...@@ -30,6 +30,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.StringBuilderPrinter;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
...@@ -308,20 +309,18 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -308,20 +309,18 @@ public class CatalogueVariableScreen extends AppCompatActivity {
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin); childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
mContainerLayout.addView(label, childLabelViewLayoutParams); mContainerLayout.addView(label, childLabelViewLayoutParams);
} else { } else {
/*Create label with mandatory value*/ /*Create labelWithMandatory with mandatory value*/
LinearLayout labelLayout = new LinearLayout(CatalogueVariableScreen.this); StringBuilder stringBuilder = new StringBuilder();
labelLayout.setOrientation(LinearLayout.HORIZONTAL); stringBuilder.append(catalogueVariable.getQuestionText());
TextView label = new TextView(CatalogueVariableScreen.this); stringBuilder.append(getString(R.string.variable_form_view_mandatory_sign_string));
label.setText(catalogueVariable.getQuestionText());
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin); TextView labelWithMandatory = new TextView(CatalogueVariableScreen.this);
labelLayout.addView(label, childLabelViewLayoutParams); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
labelWithMandatory.setText(Html.fromHtml(stringBuilder.toString(), Html.FROM_HTML_MODE_LEGACY));
TextView mandatory = new TextView(CatalogueVariableScreen.this); } else {
mandatory.setText("*"); labelWithMandatory.setText(Html.fromHtml(stringBuilder.toString()));
mandatory.setTextColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.error_color)); }
labelLayout.addView(mandatory); mContainerLayout.addView(labelWithMandatory, childLabelViewLayoutParams);
mContainerLayout.addView(labelLayout);
} }
} }
...@@ -415,27 +414,29 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -415,27 +414,29 @@ public class CatalogueVariableScreen extends AppCompatActivity {
jsonColumnValue = Util.getDateTime(Util.getDateTimeFromString(value)); jsonColumnValue = Util.getDateTime(Util.getDateTimeFromString(value));
} }
if(viewType != ViewType.SELECT_BOX && viewType != ViewType.UI_PAGE) { if(catalogueVariable.isMandatory()) {
if (TextUtils.isEmpty(jsonColumnValue)) { if (viewType != ViewType.SELECT_BOX && viewType != ViewType.UI_PAGE) {
hasErrors = true; if (TextUtils.isEmpty(jsonColumnValue)) {
// show error view hasErrors = true;
if (errorView != null) // show error view
errorView.setVisibility(View.VISIBLE); if (errorView != null)
} else { errorView.setVisibility(View.VISIBLE);
// hide error view } else {
if (errorView != null) // hide error view
errorView.setVisibility(View.GONE); if (errorView != null)
} errorView.setVisibility(View.GONE);
} else { }
if (jsonColumnValue.equals(getString(R.string.none_string))) {
hasErrors = true;
// show error view
if (errorView != null)
errorView.setVisibility(View.VISIBLE);
} else { } else {
// hide error view if (jsonColumnValue.equals(getString(R.string.none_string))) {
if (errorView != null) hasErrors = true;
errorView.setVisibility(View.GONE); // show error view
if (errorView != null)
errorView.setVisibility(View.VISIBLE);
} else {
// hide error view
if (errorView != null)
errorView.setVisibility(View.GONE);
}
} }
} }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<!--Variable Screen--> <!--Variable Screen-->
<string name="variable_form_misc_info_string">%1$s [add %2$s]</string> <string name="variable_form_misc_info_string">%1$s [add %2$s]</string>
<string name="variable_form_header_string">Submit Order</string> <string name="variable_form_header_string">Submit Order</string>
<string name="variable_form_view_mandatory_sign_string">&lt;font color="#FF0000"&gt;*&lt;/font&gt;</string>
<string name="variable_form_reference_dialog_title_string">Search \'%s\'</string> <string name="variable_form_reference_dialog_title_string">Search \'%s\'</string>
<string name="variable_form_radio_text_string">%d</string> <string name="variable_form_radio_text_string">%d</string>
<string name="variable_form_ui_page_button_label_string">Add Attachment</string> <string name="variable_form_ui_page_button_label_string">Add Attachment</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment