Commits

Dariusz Kordonski  committed a0b6f59

progress bar and disabling buttons while sending replies

  • Participants
  • Parent commits 65a6c3d

Comments (0)

Files changed (2)

File jiraconnect-android-main/res/values/jconnect_droid_strings.xml

     <string name="jconnect.droid.create_feedback_desc">Send Feedback to the Application Developer</string>
     <string name="jconnect.droid.feedback_inbox">Feedback Inbox</string>
 
-    <string name="jconnect.droid.title_placeholder">[Title]</string>
-    <string name="jconnect.droid.description_placeholder">[Description]</string>
-    <string name="jconnect.droid.comment_placeholder">[Comment]</string>
-    <string name="jconnect.droid.feedback_placeholder">Type Feedback</string>
-    <string name="jconnect.droid.reply_placeholder">Type Reply</string>
+    <string name="jconnect.droid.feedback_placeholder">[Type Feedback]</string>
+    <string name="jconnect.droid.reply_placeholder">[Type Reply]</string>
 
     <string name="jconnect.droid.no_config_property">\'%s\' configuration property value is empty. Cannot create feedback. Please check jconnect_droid_baseconfig.xml in your application resources.</string>
     <string name="jconnect.droid.sending_feedback">Sending feedback for \'%s\'</string>

File jiraconnect-android-main/src/com/atlassian/jconnect/droid/activity/ViewFeedbackActivity.java

 import android.text.style.StyleSpan;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.Window;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.EditText;
     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
+        getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
         setContentView(R.layout.jconnect_droid_view_feedback);
         initIssue(savedInstanceState);
         setListAdapter(new CommentsViewAdapter());
     }
 
     private void initSendButton() {
-        Button sendFeedback = findView(this, R.id.jconnect_droid_viewfeedback_reply_button, Button.class);
+        Button sendFeedback = findReplyButton();
         sendFeedback.setOnClickListener(new Button.OnClickListener() {
             @Override
             public void onClick(View v) {
-                String reply = findView(ViewFeedbackActivity.this, R.id.jconnect_droid_viewfeedback_reply_text, EditText.class)
-                        .getText().toString();
+                final String reply = findReplyTextView().getText().toString();
                 if (!Strings.isNullOrEmpty(reply)) {
                     sendReply(reply);
                 }
     }
 
     private void sendReply(String reply) {
+        setSending(true);
         serviceBinder.getService().reply(issue, reply, new ReplyCallback(this));
     }
 
+    private void setSending(boolean isSending) {
+        findReplyTextView().setEnabled(!isSending);
+        findReplyButton().setEnabled(!isSending);
+        setProgressBarIndeterminateVisibility(isSending);
+    }
+
+    private Button findReplyButton() {
+        return findView(this, R.id.jconnect_droid_viewfeedback_reply_button, Button.class);
+    }
+
+    private EditText findReplyTextView() {
+        return findView(this, R.id.jconnect_droid_viewfeedback_reply_text, EditText.class);
+    }
+
     @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         protected void onSuccess(ViewFeedbackActivity owner, Comment result) {
             owner.getAdapter().add(result);
             owner.getAdapter().notifyDataSetChanged();
+            owner.findReplyTextView().getText().clear();
+            owner.setSending(false);
+        }
+
+        @Override
+        protected void onFailure(ViewFeedbackActivity owner, Comment result) {
+            owner.setSending(false);
         }
     }