@@ -69,7 +69,9 @@ public class NewIssueFragment extends HSFragmentParent {
69
69
70
70
public static final String EXTRAS_USER = NewIssueActivity .EXTRAS_USER ;
71
71
public static final String RESULT_TICKET = NewIssueActivity .RESULT_TICKET ;
72
- private static final String EXTRAS_ATTACHMENT = NewIssueActivity .EXTRAS_ATTACHMENT ;
72
+ public static final String EXTRAS_SUBJECT = NewIssueActivity .EXTRAS_SUBJECT ;
73
+ public static final String EXTRAS_MESSAGE = NewIssueActivity .EXTRAS_MESSAGE ;
74
+ public static final String EXTRAS_ATTACHMENT = NewIssueActivity .EXTRAS_ATTACHMENT ;
73
75
74
76
EditText subjectField , messageField ;
75
77
ImageView imageView1 ;
@@ -119,6 +121,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
119
121
120
122
gearSource = new HSSource (getActivity ());
121
123
124
+ this .subjectField .setText (gearSource .getDraftSubject ());
125
+ this .messageField .setText (gearSource .getDraftMessage ());
126
+
122
127
if (!HSHelpStack .getInstance (getActivity ()).getShowCredits ()) {
123
128
rootView .findViewById (R .id .footerTextLabel ).setVisibility (View .GONE );
124
129
rootView .findViewById (R .id .footerDivider ).setVisibility (View .GONE );
@@ -136,6 +141,20 @@ public void onSaveInstanceState(Bundle outState) {
136
141
outState .putSerializable ("attachment" , selectedAttachment );
137
142
}
138
143
144
+ @ Override
145
+ public void onPause () {
146
+ super .onPause ();
147
+
148
+ HSAttachment [] attachmentArray = null ;
149
+
150
+ if (selectedAttachment != null ) {
151
+ attachmentArray = new HSAttachment [1 ];
152
+ attachmentArray [0 ] = selectedAttachment ;
153
+ }
154
+
155
+ gearSource .saveTicketDetailsInDraft (subjectField .getText ().toString (), messageField .getText ().toString (), attachmentArray );
156
+ }
157
+
139
158
@ Override
140
159
public void onActivityCreated (Bundle savedInstanceState ) {
141
160
super .onActivityCreated (savedInstanceState );
@@ -176,8 +195,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
176
195
return false ;
177
196
}
178
197
179
-
180
-
181
198
HSAttachment [] attachmentArray = null ;
182
199
183
200
if (selectedAttachment != null ) {
@@ -198,6 +215,7 @@ public void onSuccess(HSUser udpatedUserDetail, HSTicket ticket) {
198
215
199
216
getHelpStackActivity ().setSupportProgressBarIndeterminateVisibility (false );
200
217
sendSuccessSignal (ticket );
218
+ clearFormData ();
201
219
Toast .makeText (getActivity (), getResources ().getString (R .string .hs_issue_created_raised ), Toast .LENGTH_LONG ).show ();
202
220
}
203
221
@@ -211,7 +229,6 @@ public void onErrorResponse(VolleyError error) {
211
229
});
212
230
}
213
231
else {
214
- Bundle bundle = new Bundle ();
215
232
HSActivityManager .startNewUserActivity (this , REQUEST_CODE_NEW_TICKET , getSubject (), formattedBody , attachmentArray );
216
233
}
217
234
@@ -246,7 +263,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
246
263
selectedAttachment = HSAttachment .createAttachment (selectedImage .toString (), display_name , mime_type );
247
264
248
265
resetAttachmentImage ();
249
-
250
266
}
251
267
case REQUEST_CODE_NEW_TICKET :
252
268
if (resultCode == HSActivityManager .resultCode_sucess ) {
@@ -283,7 +299,6 @@ public void onClick(DialogInterface dialog, int which) {
283
299
Intent intent = new Intent (getActivity (), EditAttachmentActivity .class );
284
300
startActivityForResult (intent , REQUEST_CODE_PHOTO_PICKER );
285
301
}
286
-
287
302
else if (which == 1 ) {
288
303
selectedAttachment = null ;
289
304
resetAttachmentImage ();
@@ -296,14 +311,11 @@ else if (which == 1) {
296
311
}
297
312
};
298
313
299
-
300
-
301
314
private void resetAttachmentImage () {
302
315
if (selectedAttachment == null ) {
303
316
this .imageView1 .setImageResource (R .drawable .hs_add_attachment_img );
304
317
}
305
318
else {
306
-
307
319
try {
308
320
Uri uri = Uri .parse (selectedAttachment .getUrl ());
309
321
Bitmap selectedBitmap ;
@@ -313,10 +325,14 @@ private void resetAttachmentImage() {
313
325
// TODO Auto-generated catch block
314
326
e .printStackTrace ();
315
327
}
316
-
317
-
318
328
}
329
+ }
330
+
319
331
332
+ private void clearFormData () {
333
+ this .subjectField .setText ("" );
334
+ this .messageField .setText ("" );
335
+ gearSource .clearTicketDraft ();
320
336
}
321
337
322
338
public String getSubject () {
0 commit comments