@@ -137,24 +137,6 @@ public String toString() {
137137 }
138138 }
139139
140- enum GalleryType {
141- IMAGE ("Image" , 0 ),
142- AUDIO ("Audio" , 1 );
143-
144- private String stringValue ;
145- private int intValue ;
146-
147- GalleryType (String toString , int value ) {
148- stringValue = toString ;
149- intValue = value ;
150- }
151-
152- @ Override
153- public String toString () {
154- return stringValue ;
155- }
156- }
157-
158140 public ReportFragment () {
159141 // Required empty public constructor
160142 }
@@ -342,7 +324,7 @@ public void onCompletion(MediaPlayer mp) {
342324
343325 public void updateAudio (final Uri uri ) {
344326 if (uri != null ) {
345- Attachment _attachment = new Attachment ();
327+ Attachment _attachment = new Attachment (Attachment . AttachmentType . AUDIO );
346328 _attachment .setUri (uri );
347329 attachmentAdapter .add (_attachment );
348330 Log .d (LOG_TAG , "updateAudio " + uri );
@@ -388,7 +370,7 @@ private String niceName(Uri uri) {
388370
389371 public void updatePhoto (Uri uri , Boolean broadcast ) {
390372 if (uri != null ) {
391- Attachment _attachment = new Attachment ();
373+ Attachment _attachment = new Attachment (Attachment . AttachmentType . IMAGE );
392374 _attachment .setUri (uri );
393375 attachmentAdapter .add (_attachment );
394376 Log .d (LOG_TAG , "updatePhoto " + uri );
@@ -455,7 +437,7 @@ public void onCreate(Bundle savedInstanceState) {
455437
456438 // Retain this fragment across configuration changes
457439 setRetainInstance (true );
458-
440+ attachmentAdapter = new AttachmentAdapter ( getContext ());
459441 attributes = new LinkedList <Attribute >();
460442 attrInfoList = new LinkedList <AttributeInfo >();
461443 installationId = ((MainActivity ) getActivity ()).getInstallationId ();
@@ -702,7 +684,7 @@ public void onClick(DialogInterface dialog, int item) {
702684 requestPermissions (new String []{Manifest .permission .READ_EXTERNAL_STORAGE },
703685 READ_STORAGE_REQUEST );
704686 } else {
705- handleGallery (GalleryType .AUDIO );
687+ handleGallery (Attachment . AttachmentType .AUDIO );
706688 }
707689 }
708690 }
@@ -743,7 +725,7 @@ public void onClick(DialogInterface dialog, int item) {
743725 requestPermissions (new String []{Manifest .permission .READ_EXTERNAL_STORAGE },
744726 READ_STORAGE_REQUEST );
745727 } else {
746- handleGallery (GalleryType .IMAGE );
728+ handleGallery (Attachment . AttachmentType .IMAGE );
747729 }
748730 }
749731 }
@@ -780,7 +762,7 @@ private void handleLocation() {
780762 * Because we check permissions for Android 6+, this function is also used to propagate
781763 * actions from the checker
782764 */
783- private void handleGallery (GalleryType type ) {
765+ private void handleGallery (Attachment . AttachmentType type ) {
784766 Log .d (LOG_TAG , "HandleGallery" );
785767 View v = getActivity ().findViewById (R .id .report_submit );
786768 if (!isExternalStorageWritable ()) {
@@ -791,7 +773,7 @@ private void handleGallery(GalleryType type) {
791773 }
792774 // Pass the GalleryType to the intent
793775 Intent intent = new Intent (Intent .ACTION_GET_CONTENT , null );
794- intent .putExtra ("GalleryType" , type .intValue );
776+ intent .putExtra ("GalleryType" , type .toInt () );
795777 intent .putExtra ("return_data" , true );
796778 // Initiate the correct type of Gallery
797779 switch (type ) {
@@ -819,7 +801,7 @@ private void handleRecorder() {
819801 }
820802 Intent audioIntent = new Intent (getActivity (), SoundRecorderActivity .class );
821803 try {
822- File audio = createFile (GalleryType .AUDIO );
804+ File audio = createFile (Attachment . AttachmentType .AUDIO );
823805 audioIntent .setAction (ACTION_EDIT );
824806 audioIntent .setData (Uri .fromFile (audio ));
825807 startActivityForResult (audioIntent , RECORDER_REQUEST );
@@ -851,7 +833,7 @@ private void handleCamera() {
851833 // Create the File where the photo should go
852834 File photo ;
853835 try {
854- photo = createFile (GalleryType .IMAGE );
836+ photo = createFile (Attachment . AttachmentType .IMAGE );
855837 cameraIntent .putExtra (MediaStore .EXTRA_OUTPUT , Uri .fromFile (photo ));
856838 startActivityForResult (cameraIntent , CAMERA_REQUEST );
857839
@@ -901,23 +883,23 @@ private void onSubmitButtonClicked() {
901883 Normalizer .normalize (
902884 mDescriptionView .getText ().toString (), Normalizer .Form .NFD )
903885 .replaceAll (pattern , "" ));
904-
905- if (imageUri != null ) {
906- Glide .with (getActivity ().getApplicationContext ())
907- .load (imageUri )
908- .asBitmap ()
909- .diskCacheStrategy (DiskCacheStrategy .SOURCE )
910- .into (new SimpleTarget <Bitmap >() {
911- @ Override
912- public void onResourceReady (Bitmap bitmap , GlideAnimation anim ) {
913- PostServiceRequestTask bgTask = new PostServiceRequestTask (data , bitmap );
914- bgTask .execute ();
915- }
916- });
917- } else {
886+ // todo, if single attachment and the type is image
887+ // if (imageUri != null) {
888+ // Glide.with(getActivity().getApplicationContext())
889+ // .load(imageUri)
890+ // .asBitmap()
891+ // .diskCacheStrategy(DiskCacheStrategy.SOURCE)
892+ // .into(new SimpleTarget<Bitmap>() {
893+ // @Override
894+ // public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
895+ // PostServiceRequestTask bgTask = new PostServiceRequestTask(data, bitmap);
896+ // bgTask.execute();
897+ // }
898+ // });
899+ // } else {
918900 PostServiceRequestTask bgTask = new PostServiceRequestTask (data , null );
919901 bgTask .execute ();
920- }
902+ // }
921903 } else {
922904
923905 AlertDialog .Builder builder = new AlertDialog .Builder (getContext (), R .style .AppTheme_Dialog );
@@ -941,22 +923,22 @@ public void onClick(DialogInterface dialog, int which) {
941923 mDescriptionView .getText ().toString (), Normalizer .Form .NFD )
942924 .replaceAll (pattern , "" ));
943925
944- if (imageUri != null ) {
945- Glide .with (getActivity ().getApplicationContext ())
946- .load (imageUri )
947- .asBitmap ()
948- .diskCacheStrategy (DiskCacheStrategy .SOURCE )
949- .into (new SimpleTarget <Bitmap >() {
950- @ Override
951- public void onResourceReady (Bitmap bitmap , GlideAnimation anim ) {
952- PostServiceRequestTask bgTask = new PostServiceRequestTask (data , bitmap );
953- bgTask .execute ();
954- }
955- });
956- } else {
926+ // if (imageUri != null) {
927+ // Glide.with(getActivity().getApplicationContext())
928+ // .load(imageUri)
929+ // .asBitmap()
930+ // .diskCacheStrategy(DiskCacheStrategy.SOURCE)
931+ // .into(new SimpleTarget<Bitmap>() {
932+ // @Override
933+ // public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
934+ // PostServiceRequestTask bgTask = new PostServiceRequestTask(data, bitmap);
935+ // bgTask.execute();
936+ // }
937+ // });
938+ // } else {
957939 PostServiceRequestTask bgTask = new PostServiceRequestTask (data , null );
958940 bgTask .execute ();
959- }
941+ // }
960942 }
961943 })
962944 .show ();
@@ -1036,10 +1018,10 @@ protected String doInBackground(Void... ignore) {
10361018 try {
10371019 APIWrapperFactory wrapperFactory = new APIWrapperFactory (((MainActivity ) getActivity ()).getCurrentCity (), EndpointType .PRODUCTION );
10381020 // todo this has to go as the app should check the attachments
1039- if (imageUri != null ) {
1040- HTTPNetworkManager networkManager = new HTTPNetworkManager (bitmap );
1041- wrapperFactory .setNetworkManager (networkManager );
1042- }
1021+ // if (imageUri != null) {
1022+ // HTTPNetworkManager networkManager = new HTTPNetworkManager(bitmap);
1023+ // wrapperFactory.setNetworkManager(networkManager);
1024+ // }
10431025 wrapperFactory .setApiKey (((MainActivity ) getActivity ()).getCurrentCity ().getApiKey ());
10441026
10451027 APIWrapper wrapper = wrapperFactory .build ();
@@ -1175,11 +1157,11 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
11751157 }
11761158 if (requestCode == GALLERY_AUDIO_REQUEST
11771159 && grantResults [0 ] == PackageManager .PERMISSION_GRANTED ) {
1178- handleGallery (GalleryType .AUDIO );
1160+ handleGallery (Attachment . AttachmentType .AUDIO );
11791161 }
11801162 if (requestCode == GALLERY_IMAGE_REQUEST
11811163 && grantResults [0 ] == PackageManager .PERMISSION_GRANTED ) {
1182- handleGallery (GalleryType .IMAGE );
1164+ handleGallery (Attachment . AttachmentType .IMAGE );
11831165 }
11841166 if (requestCode == LOCATION_REQUEST
11851167 && grantResults [0 ] == PackageManager .PERMISSION_GRANTED ) {
@@ -1206,7 +1188,7 @@ public static boolean hasPermissions(Context context, String... permissions) {
12061188 return true ;
12071189 }
12081190
1209- private File createFile (GalleryType type ) throws IOException {
1191+ private File createFile (Attachment . AttachmentType type ) throws IOException {
12101192 String prefix ;
12111193 String extension ;
12121194 File storageDir ;
@@ -1233,7 +1215,6 @@ private File createFile(GalleryType type) throws IOException {
12331215 extension , /* suffix */
12341216 storageDir /* directory */
12351217 );
1236-
12371218 return file ;
12381219 }
12391220
0 commit comments