Commit 378b7783 by Kunj Gupta

UOFLMA-113 - In Incident form, UI improvement is done.

parent c83c220c
......@@ -10,7 +10,10 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
......@@ -46,6 +49,8 @@ public class ReportIncidentScreen extends AppCompatActivity {
@BindView(R.id.incident_short_description_edit_text) EditText mShortDesEditText;
@BindView(R.id.incident_impact_error_tv) TextView mImpactErrorTextView;
@BindView(R.id.incident_short_des_error_tv) TextView mShortDesErrorTextView;
@BindView(R.id.incident_impact_header_text_view) TextView mImpactHeaderTextView;
@BindView(R.id.incident_short_description_header_tv) TextView mShortDescriptionHeaderTextView;
private CatalogueApplication mApplication;
private Impact mImpact;
......@@ -59,7 +64,43 @@ public class ReportIncidentScreen extends AppCompatActivity {
setContentView(R.layout.incidents_form_screen);
ButterKnife.bind(this);
final int shortDescriptionTextLimit = getResources().getInteger(R.integer.incident_from_short_description_text_limit);
mApplication = (CatalogueApplication) getApplication();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
mImpactHeaderTextView.setText(Html.fromHtml(getString(R.string.incident_form_impact_text_string), Html.FROM_HTML_MODE_LEGACY));
mShortDescriptionHeaderTextView.setText(
Html.fromHtml(String.format(getString(R.string.incident_form_describe_your_issue_text_string), shortDescriptionTextLimit),
Html.FROM_HTML_MODE_LEGACY));
} else {
mImpactHeaderTextView.setText(Html.fromHtml(getString(R.string.incident_form_impact_text_string)));
mShortDescriptionHeaderTextView.setText(Html.fromHtml(
String.format(getString(R.string.incident_form_describe_your_issue_text_string),
shortDescriptionTextLimit)));
}
mShortDesEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if(charSequence.length() > shortDescriptionTextLimit) {
mShortDesErrorTextView.setVisibility(View.VISIBLE);
mShortDesErrorTextView.setText(String.format(getString(R.string.incident_form_short_description_limit_error_text_string),
(charSequence.length() - shortDescriptionTextLimit)));
} else {
if(mShortDesErrorTextView.getVisibility() == View.VISIBLE)
mShortDesErrorTextView.setVisibility(View.GONE);
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
......@@ -168,10 +209,15 @@ public class ReportIncidentScreen extends AppCompatActivity {
}
if (!TextUtils.isEmpty(mShortDescription)) {
if(mShortDesErrorTextView.getVisibility() == View.VISIBLE) {
hasError = true;
} else {
mShortDesErrorTextView.setVisibility(View.GONE);
}
} else {
hasError = true;
mShortDesErrorTextView.setVisibility(View.VISIBLE);
mShortDesErrorTextView.setText(R.string.error_string);
}
return hasError;
}
......
......@@ -31,11 +31,11 @@
android:textSize="@dimen/normal_text_size" />
<TextView
android:id="@+id/incident_impact_header_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/normal_margin"
android:layout_marginTop="@dimen/normal_margin"
android:text="@string/incident_form_impact_text_string"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold" />
......@@ -43,7 +43,9 @@
android:id="@+id/incident_impact_spinner"
android:layout_width="match_parent"
android:layout_height="@dimen/impact_spinner_drop_down_height"
android:layout_margin="@dimen/normal_margin"
android:layout_marginTop="@dimen/normal_margin"
android:layout_marginLeft="@dimen/normal_margin"
android:layout_marginRight="@dimen/normal_margin"
android:background="@drawable/spinner_bg"
style="@style/OverflowMenu"/>
......@@ -57,10 +59,10 @@
android:textColor="@color/error_color"/>
<TextView
android:id="@+id/incident_short_description_header_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/normal_margin"
android:text="@string/incident_form_describe_your_issue_text_string"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold" />
......@@ -68,7 +70,6 @@
android:id="@+id/incident_short_description_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/normal_margin"
android:layout_marginRight="@dimen/normal_margin"
android:background="@drawable/list_view_item_bg_with_border"
......@@ -92,6 +93,7 @@
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginRight="@dimen/normal_margin"
android:layout_marginTop="@dimen/normal_margin"
android:background="@drawable/submit_button_bg_with_border"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/large_margin"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="incident_from_short_description_text_limit">10</integer>
</resources>
\ No newline at end of file
......@@ -77,10 +77,11 @@
<!--Incident screen-->
<string name="incident_form_report_incident_text_string">Report Incident</string>
<string name="incident_form_top_text_string">Create an Incident record to report and request assistance with an issue you are having\n\nRequest assistance with an issue you are having. An incident record will be created and managed through to successful resolution. You will also be notified of progress.</string>
<string name="incident_form_impact_text_string">Impact</string>
<string name="incident_form_impact_text_string">Impact &lt;font color="#FF0000"&gt;*&lt;/font&gt;</string>
<string name="incident_form_incident_successful_submission_string">Your Incident has been reported successfully</string>
<string name="incident_form_describe_your_issue_text_string">Please Describe Your Issue below</string>
<string name="incident_form_describe_your_issue_text_string">Please Describe Your Issue below &lt;font color="#FF0000"&gt;*&lt;/font&gt;(Max %d)</string>
<string name="incident_item_text_string"><![CDATA[<b>Number: </b>%1$s<br><br><b>Opened: </b>%2$s<br><br><b>Short Description: </b>%3$s]]></string>
<string name="incident_form_short_description_limit_error_text_string">Max limit exceeded by %d</string>
<!--My Incidents-->
<string name="my_incidents_text_string">My Incidents</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