AndroidManifest.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.mudassar.charityorganizer"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" tools:replace="android:allowBackup" android:roundIcon="@mipmap/ic_launcher_round" android:usesCleartextTraffic="true" android:supportsRtl="true" android:theme="@style/AppTheme" tools:targetApi="m"> <activity android:name=".MainActivity"/> <activity android:name=".signin" /> <activity android:name=".signup" /> <activity android:name=".Profile" /> <activity android:name=".Request" /> <activity android:name=".Description" /> <activity android:name=".MyRequest" /> <activity android:name=".Edit" /> <activity android:name=".ViewProfile" /> <activity android:name=".Events" /> <activity android:name=".MedicalCamps" /> <activity android:name=".MissingPerson" /> <activity android:name=".MyMissingPerson" /> <activity android:name=".AddMissingRecord" /> <activity android:name=".Ambulance"/> <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:theme="@style/Base.Theme.AppCompat" /> <activity android:name="com.thefinestartist.finestwebview.FinestWebViewActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="sensor" android:theme="@style/FinestWebViewTheme.Light" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" /> <activity android:name=".SplashActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Home" android:label="@string/title_activity_home" android:theme="@style/AppTheme" /> </application> </manifest> |
AddMissingRecord.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
package com.mudassar.charityorganizer; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.util.Base64; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import com.android.volley.*; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.google.android.material.snackbar.Snackbar; import com.squareup.picasso.MemoryPolicy; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import com.theartofdev.edmodo.cropper.CropImage; import com.theartofdev.edmodo.cropper.CropImageView; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Hashtable; import java.util.Map; public class AddMissingRecord extends AppCompatActivity { Bitmap image=null; ImageView pf; int user_id=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_missing_record); pf=(ImageView)findViewById(R.id.pf); SharedPreferences sharedPref = getSharedPreferences("LogIn", Context.MODE_PRIVATE); user_id= sharedPref.getInt("id",0); } public void finiss (View v){ finish(); } public void submitit (View v){ String name="",age="",place="",date="",contact=""; String gender=""; name=((EditText)findViewById(R.id.name)).getText().toString(); age=((EditText)findViewById(R.id.age)).getText().toString(); place=((EditText)findViewById(R.id.place)).getText().toString(); date=((EditText)findViewById(R.id.date)).getText().toString(); contact=((EditText)findViewById(R.id.contact)).getText().toString(); gender=((Spinner) findViewById(R.id.gender)).getSelectedItem().toString(); if (image!=null){ if (name!=null&&!(name.equals(""))){ if (age!=null&&!(age.equals(""))){ if (place!=null&&!(place.equals(""))){ if (date!=null&&!(date.equals(""))){ if (contact!=null&&!(contact.equals(""))){ if (gender!=null&&!(gender.equals(""))){ volleyRequest(image,name,age,place,date,contact,gender,user_id); } else { Snackbar.make(findViewById(android.R.id.content), "No Gender Selected", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Contact Number Entered", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Date Entered", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Place Selected", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Age Entered", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Name Entered", Snackbar.LENGTH_LONG).show(); } } else { Snackbar.make(findViewById(android.R.id.content), "No Picture Selected", Snackbar.LENGTH_LONG).show(); } } public void saveImagei (View v){ CropImage.activity() .setGuidelines(CropImageView.Guidelines.ON) .start(this); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri resultUri = result.getUri(); InputStream image_stream = null; try { image_stream = getContentResolver().openInputStream(resultUri); } catch (FileNotFoundException e) { e.printStackTrace(); } image = BitmapFactory.decodeStream(image_stream); Picasso.get().load(resultUri).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) .networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE).transform(new CircleTransform()).into(pf); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); } } } public void volleyRequest(final Bitmap image, final String name, final String age, final String place, final String date, final String contact, final String gender, final int user_id){ String url= getString(R.string.url)+"/Charity/addMissingRecord.php"; final ProgressDialog loading = ProgressDialog.show(this,"Submitting...","Please wait...",false,false); StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String s) { loading.dismiss(); finish(); Toast.makeText(AddMissingRecord.this, s , Toast.LENGTH_LONG).show(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { loading.dismiss(); Toast.makeText(AddMissingRecord.this, volleyError.getMessage().toString(), Toast.LENGTH_LONG).show(); } }){ @Override protected Map<String, String> getParams() throws AuthFailureError{ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG,100,byteArrayOutputStream); String encodeImage = Base64.encodeToString(byteArrayOutputStream.toByteArray(),Base64.DEFAULT); Map<String,String> params = new Hashtable<>(); params.put("image", encodeImage); params.put("name", name); params.put("age", age); params.put("place", place); params.put("date", date); params.put("contact", contact); params.put("gender", gender); params.put("user_id", Integer.toString(user_id)); return params; } }; stringRequest .setShouldCache(false); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.getCache().clear(); requestQueue.add(stringRequest); } } |
Ambulance.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
package com.mudassar.charityorganizer; import android.Manifest; import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.Context; import android.content.IntentSender; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.Typeface; import android.location.Location; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; import android.os.Handler; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.fragment.app.FragmentActivity; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.PendingResult; import com.google.android.gms.common.api.ResultCallback; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.FusedLocationProviderApi; import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; import com.google.android.gms.location.LocationSettingsRequest; import com.google.android.gms.location.LocationSettingsResult; import com.google.android.gms.location.LocationSettingsStates; import com.google.android.gms.location.LocationSettingsStatusCodes; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.material.snackbar.Snackbar; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.util.HashMap; public class Ambulance extends FragmentActivity implements OnMapReadyCallback,AmbulanceCallback,StatusCallback,CancelCallback,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener,CompleteCallback,MapInterface { private GoogleMap mMap; double lat=0,lon=0; Button request; ImageView back,cancel; int check=0; private GoogleApiClient googleApiClient; private LocationRequest locationRequest; private FusedLocationProviderApi locationProvider; TextView status; Marker m; Toolbar toolbar; int user_id=0; private Handler handler; private Runnable task = new Runnable() { @Override public void run() { ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork=null ; if (cm!=null){ activeNetwork=cm.getActiveNetworkInfo(); } if (activeNetwork!=null){ if (lat!=0&&lon!=0) { StatusBackground statusBackground = new StatusBackground(Ambulance.this, Ambulance.this); statusBackground.setMapInterface(Ambulance.this); statusBackground.execute(user_id); } } else { final Snackbar s= Snackbar.make(findViewById(android.R.id.content),"Your Internet Connection is not Working",Snackbar.LENGTH_INDEFINITE); s.setAction("Dismiss", new View.OnClickListener() { @Override public void onClick(View v) { s.dismiss(); } }).setActionTextColor(Color.GRAY).show(); } handler.postDelayed(task,3000); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ambulance); locationProvider = LocationServices.FusedLocationApi; googleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); final Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Please Turn On Your Location Services and Restart the Application", Snackbar.LENGTH_INDEFINITE); snackbar.setAction("Dismiss", new View.OnClickListener() { @Override public void onClick(View v) { snackbar.dismiss(); } }).setActionTextColor(Color.GRAY); View snackbarView = snackbar.getView(); locationRequest = new LocationRequest(); locationRequest.setInterval(30 * 1000); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setSmallestDisplacement(10); if (locationRequest!=null &&googleApiClient!=null){ LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); if (result != null) { result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(@NonNull LocationSettingsResult locationSettingsResult) { final Status status = locationSettingsResult.getStatus(); final LocationSettingsStates s = locationSettingsResult.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: try { status.startResolutionForResult( Ambulance.this, 1000); snackbar.show(); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: break; } } }); } } SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); request=(Button)findViewById(R.id.amb); back=(ImageView)findViewById(R.id.backq); status=findViewById(R.id.ambstatus); toolbar=(Toolbar)findViewById(R.id.toolbar5); cancel=(ImageView)findViewById(R.id.cancel); cancel.setVisibility(View.GONE); SharedPreferences sharedPref = getSharedPreferences("LogIn", Context.MODE_PRIVATE); user_id= sharedPref.getInt("id",0); } public void finis (View v){ finish(); } public void cancel (View v){ CancelBackground cancelBackground=new CancelBackground(this,this); cancelBackground.execute(user_id); } @SuppressLint("MissingPermission") @Override public void onMapReady(GoogleMap googleMap){ mMap = googleMap; mMap.setMyLocationEnabled(true); m = mMap.addMarker(new MarkerOptions().position(new LatLng(33.7294, 73.0931)).draggable(false)); mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); m.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker1)); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mMap.setMyLocationEnabled(true); mMap.setTrafficEnabled(true); mMap.setIndoorEnabled(true); mMap.setBuildingsEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(false); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker arg0) { return null; } @Override public View getInfoContents(Marker marker) { LinearLayout info = new LinearLayout(Ambulance.this); info.setOrientation(LinearLayout.VERTICAL); TextView title = new TextView(Ambulance.this); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(marker.getTitle()); TextView snippet = new TextView(Ambulance.this); snippet.setTextColor(Color.GRAY); snippet.setText(marker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); } public void send(View v){ ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork=null ; if (cm!=null){ activeNetwork=cm.getActiveNetworkInfo(); } if (activeNetwork!=null){ if (lat!=0&&lon!=0){ AmbulanceBackground ambulanceBackground=new AmbulanceBackground(this,this,user_id); ambulanceBackground.execute(lat,lon); } else { final Snackbar s= Snackbar.make(findViewById(android.R.id.content),"Turn on Your Location Services",Snackbar.LENGTH_INDEFINITE); s.setAction("Dismiss", new View.OnClickListener() { @Override public void onClick(View v) { s.dismiss(); } }).setActionTextColor(Color.GRAY).show(); } } else { final Snackbar s= Snackbar.make(findViewById(android.R.id.content),"Your Internet Connection is not Working",Snackbar.LENGTH_INDEFINITE); s.setAction("Dismiss", new View.OnClickListener() { @Override public void onClick(View v) { s.dismiss(); } }).setActionTextColor(Color.GRAY).show(); } } @Override public void checkRequestStatus(Integer status){ if (status==1){ Toast.makeText(this,"Request Submission Successful",Toast.LENGTH_LONG).show(); toolbar.setBackgroundColor(getResources().getColor(R.color.yellowgreen)); this.status.setText("Waiting"); request.setVisibility(View.GONE); back.setVisibility(View.GONE); cancel.setVisibility(View.VISIBLE); SearchBackground searchBackground=new SearchBackground(this,user_id); searchBackground.execute(lat,lon); } else if (status==0){ Snackbar.make(findViewById(android.R.id.content),"Request Submission Unsuccessful",Snackbar.LENGTH_LONG).show(); } } @Override public void checkStatus(String status){ if (status.equals("normal")){ reset(); toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); this.status.setText("Ambulance Request"); request.setVisibility(View.VISIBLE); back.setVisibility(View.VISIBLE); cancel.setVisibility(View.GONE); } else if (status.equals("waiting")){ toolbar.setBackgroundColor(getResources().getColor(R.color.yellowgreen)); this.status.setText("Waiting"); request.setVisibility(View.GONE); back.setVisibility(View.GONE); cancel.setVisibility(View.VISIBLE); } else if (status.equals("accepted")){ toolbar.setBackgroundColor(getResources().getColor(R.color.green)); this.status.setText("Driver Found"); request.setVisibility(View.GONE); back.setVisibility(View.GONE); cancel.setVisibility(View.GONE); Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Received Help? If Yes Then Kindly Complete The Request.", Snackbar.LENGTH_INDEFINITE) .setAction("Completed", new View.OnClickListener() { @Override public void onClick(View v){ CompleteBackground completeBackground=new CompleteBackground(Ambulance.this,Ambulance.this); completeBackground.execute(user_id); } }) .setActionTextColor(Color.GRAY); View snackbarView = snackbar.getView(); TextView textView = (TextView) snackbarView.findViewById(R.id.snackbar_text); textView.setMaxLines(5); snackbar.show(); } else if (status.equals("fail")){ Snackbar.make(findViewById(android.R.id.content),"No Driver Found",Snackbar.LENGTH_LONG).show(); toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); this.status.setText("Ambulance Request"); request.setVisibility(View.VISIBLE); back.setVisibility(View.VISIBLE); cancel.setVisibility(View.GONE); NormalBackground normalBackground=new NormalBackground(this); normalBackground.execute(user_id); } } @Override protected void onStop(){ super.onStop(); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (handler!=null){ handler.removeCallbacks(task); } } @Override protected void onStart() { super.onStart(); googleApiClient.connect(); } @Override protected void onResume() { super.onResume(); if (googleApiClient.isConnected()) { requestLocationUpdates(); } if (handler == null) { handler = new Handler(); } handler.removeCallbacks(task); handler.post(task); } @Override protected void onPause() { super.onPause(); if (googleApiClient.isConnected()) { LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this); } if (handler!=null){ handler.removeCallbacks(task); } } @Override public void cancelResult(int id) { if (id==1){ Toast.makeText(this,"Request Cancellation Successful",Toast.LENGTH_LONG).show(); toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); this.status.setText("Ambulance Request"); request.setVisibility(View.VISIBLE); back.setVisibility(View.VISIBLE); cancel.setVisibility(View.GONE); } else if (id==0){ Snackbar.make(findViewById(android.R.id.content),"Request Cancellation Unsuccessful",Snackbar.LENGTH_LONG).show(); } } @Override public void onConnected(@Nullable Bundle bundle) { requestLocationUpdates(); } private void requestLocationUpdates() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this); } @Override public void onConnectionSuspended(int i) { } @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Override public void onLocationChanged(Location location){ lat = location.getLatitude(); lon = location.getLongitude(); LatLng pos = new LatLng(lat, lon); if (check == 0 && mMap != null) { CameraUpdate camera = CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 15); mMap.moveCamera(camera); m.setPosition(pos); check++; } } @Override public void isCompleted(int status) { if (status>0){ Snackbar.make(findViewById(android.R.id.content),"Request Completed",Snackbar.LENGTH_SHORT).show(); } } @Override public void setMap(double lat, double lon, String name, String contact){ CameraUpdate camera = CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 15); mMap.moveCamera(camera); Marker l = mMap.addMarker(new MarkerOptions().position(new LatLng(lat, lon)).draggable(false)); l.setTitle("Driver Info"); l.setSnippet("Driver Name: "+name+"\n Driver Contact No: "+contact); l.showInfoWindow(); } public void reset() { mMap.clear(); m = mMap.addMarker(new MarkerOptions().position(new LatLng(lat, lon)).draggable(false)); m.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker1)); CameraUpdate camera = CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 15); mMap.moveCamera(camera); } } class AmbulanceBackground extends AsyncTask<Double,Integer,Integer> { Context c; AmbulanceCallback ambulanceCallback; ProgressDialog progressDialog; int user_id; public AmbulanceBackground(Context c,AmbulanceCallback ambulanceCallback,int user_id){ this.c=c; this.ambulanceCallback=ambulanceCallback; this.user_id=user_id; } @Override protected Integer doInBackground(Double... params){ String url= c.getString(R.string.url)+"/Charity/submit_ambulance_request.php"; int r_status=0; HttpRequest httpRequest= null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("lat",Double.toString(params[0])); value.put("c_id",Integer.toString(user_id)); value.put("lon",Double.toString(params[1])); value.put("status","waiting"); JSONObject jsonObject=httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); r_status=jsonObject.getInt("r_status"); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return r_status; } @Override protected void onPreExecute(){ progressDialog=new ProgressDialog(c); progressDialog.setMessage("Processing......"); progressDialog.show(); } @Override protected void onPostExecute(Integer s) { progressDialog.dismiss(); ambulanceCallback.checkRequestStatus(s); } } interface AmbulanceCallback { public void checkRequestStatus (Integer status); } class SearchBackground extends AsyncTask<Double,Integer,Void>{ int user_id=0; Context c; public SearchBackground(Context c, int user_id){ this.user_id=user_id; this.c=c; } @Override protected Void doInBackground(Double... params){ String url= c.getString(R.string.url)+"searchDriver.php"; HttpRequest httpRequest= null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("c_lat",Double.toString(params[0])); value.put("c_id",Integer.toString(user_id)); value.put("c_lon",Double.toString(params[1])); httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return null; } } class StatusBackground extends AsyncTask<Integer,Integer,String> { Context c; StatusCallback statusCallback; JSONObject jsonObject; MapInterface mapInterface; public StatusBackground(Context c,StatusCallback statusCallback){ this.c=c; this.statusCallback=statusCallback; } public void setMapInterface(MapInterface mapInterface) { this.mapInterface = mapInterface; } @Override protected String doInBackground(Integer... params) { String url= c.getString(R.string.url)+"check_ambulance_request_status.php"; String r_status=""; HttpRequest httpRequest= null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("c_id",Integer.toString(params[0])); jsonObject=httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); r_status=jsonObject.getString("r_status"); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return r_status; } @Override protected void onPreExecute(){ } @Override protected void onPostExecute(String s) { if (jsonObject!=null){ if (s.equals("accepted")){ try { mapInterface.setMap(jsonObject.getDouble("lat"),jsonObject.getDouble("lon"),jsonObject.getString("name"),jsonObject.getString("contact")); } catch (JSONException e) { e.printStackTrace(); } } } statusCallback.checkStatus(s); } } interface StatusCallback { public void checkStatus (String status); } interface MapInterface{ public void setMap(double lat,double lon,String name,String contact); } class CancelBackground extends AsyncTask<Integer,Integer,Integer>{ Context c; ProgressDialog progressDialog; CancelCallback cancelCallback; CancelBackground (Context c,CancelCallback cancelCallback){ this.c=c; this.cancelCallback=cancelCallback; } @Override protected Integer doInBackground(Integer... params) { String url= c.getString(R.string.url)+"cancelAmbulanceRequest.php"; int r_status=0; HttpRequest httpRequest= null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("c_id",Integer.toString(params[0])); JSONObject jsonObject= httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); r_status=jsonObject.getInt("r_status"); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return r_status; } @Override protected void onPreExecute() { progressDialog=new ProgressDialog(c); progressDialog.setMessage("Cancelling......"); progressDialog.show(); } @Override protected void onPostExecute(Integer integer) { progressDialog.dismiss(); cancelCallback.cancelResult(integer); } } interface CancelCallback { public void cancelResult (int id); } class CompleteBackground extends AsyncTask<Integer,Integer,Integer>{ Context context; CompleteCallback completeCallback; JSONObject jsonObject; CompleteBackground (Context context,CompleteCallback completeCallback){ this.context=context; this.completeCallback=completeCallback; } @Override protected Integer doInBackground(Integer... params){ int status = 0; String url= context.getString(R.string.url)+"completeOrder.php"; HttpRequest httpRequest= null; jsonObject=null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("id",Integer.toString(params[0])); jsonObject=httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); status=jsonObject.getInt("status"); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return status; } @Override protected void onPostExecute(Integer status){ completeCallback.isCompleted(status); } } interface CompleteCallback { public void isCompleted (int status); } class NormalBackground extends AsyncTask<Integer,Integer,Integer>{ Context context; JSONObject jsonObject; NormalBackground (Context context){ this.context=context; } @Override protected Integer doInBackground(Integer... params){ String url= context.getString(R.string.url)+"completeOrder.php"; HttpRequest httpRequest= null; jsonObject=null; try { httpRequest = new HttpRequest(url); HashMap<String ,String> value=new HashMap<>(); value.put("id",Integer.toString(params[0])); jsonObject=httpRequest.prepare(HttpRequest.Method.POST).withData(value).sendAndReadJSON(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return null; } } |
Download full Source Code of Charity And Donations Android App
INTRODUCTION
- Our purposed system “CHARITY and DONATIONS Management System Android Application” provides different social services to the user and also assists the non-profitable organizations.
- CHARITY and DONATIONS Management System Android App is based on request respond model any user can post request according to their needs. And these requests are also shown to other users and they can also respond on these request.
Advertisement
- The intended audience of this project who requires social assistance in the time of need.
- Our proposed system will provide free social services to all these needy peoples
- CHARITY and DONATIONS Management System Android App will provide a number of different social services like blood bank, ambulance service, free medical camps, assist in missing person case, online donation and also a platform that will use by non-profitable organizations for their advertisement.
PROJECT OBJECTIVES
- Through CHARITY and DONATIONS Management System Android App user can submit request for any type of social assistance.
- CHARITY and DONATIONS Management System Android App provides a virtual platform to non-profitable organization to advertise their in progress projects in different parts of the country and ask for donations.
- Through this system user can view the available record like blood donors, list of non-profitable organizations and their projects and the requests of other users seeking for help.
Advertisement
- Through CHARITY and DONATIONS Management System Android App user will be able to request for ambulance in medical emergency cases and driver of the ambulance able to trace the location of the recipient through GPS navigator.
- It will provide the detail information like time, location and date about free medical camps conducted by different organizations in his/her surrounding.
- CHARITY and DONATIONS Management System Android App assists the user in missing persons case if any beloved one of user is lost, so user can upload the some personal information of that person and request for help in finding that’s individual.
PROJECT OVERVIEW
- CHARITY and DONATIONS Management System Android App is based on request respond model any user can post request according to their needs. And these requests are also shown to other users and they can also respond on these request.
- CHARITY and DONATIONS Management System Android App will provide a number of different social services like blood bank, ambulance service, free medical camps, assist in missing person case, online donation and also a platform that will use by non-profitable organizations for their advertisement.
PROJECT SCOPE of Charity And Donations Management System Android App
- Through CHARITY and DONATIONS Management System Android App user can submit request for any type of social assistance.
- CHARITY and DONATIONS Management System Android App provides a virtual platform to non-profitable organization to advertise their in progress projects in different parts of the country and ask for donations.
- Through this system user can view the available record like blood donors, list of non-profitable organizations and their projects and the requests of other users seeking for help.
- Through CHARITY and DONATIONS Management System Android App user will be able to request for ambulance in medical emergency cases and driver of the ambulance able to trace the location of the recipient through GPS navigator.
- It will provide the detail information like time, location and date about free medical camps conducted by different organizations in his/her surrounding.
- CHARITY and DONATIONS Management System Android App assists the user in missing persons case if any beloved one of user is lost, so user can upload the some personal information of that person and request for help in finding that’s individual.
STUDY OF EXISTING SYSTEM
Non-profitable organizations still use conventional means like radio, television for their promotions and no any platform exists through which they use it for their advertisement.
Advertisement
- No any system exists which assists the user in missing person’s case if any person is lost .
- No any system exists which help the user in finding the date, time and location of the free medical camps.
- To many application has been available related to the blood bank management system and it is very difficult to find the right donor in critical situation.
- There is no any system exists for the ambulance service through which ambulance driver automatically trace the pin point location of the user.
Disadvantages of the Existing Systems Process
No any system exists which assists the user in missing person’s case if any person is lost .
PROPOSED SYSTEM
- In this project we are going to develop a system that will provide all the social services like blood bank, ambulance service, missing persons record, free medical camps and facilitate online donations.
- Proposed system will be flexible having web based admin panel through which admin can control all the database.
- CHARITY and DONATIONS Management System Android App will provide a list of available blood donors of your city.
- Ambulance driver will be able to find the location of the user.
- Different charitable organizations can use it for their promotions without any cost.
- Proposed system will provide the list of free medical camps, doctors arrival timing, dates and location of these camps.
Benefits of Proposed System
User Friendly Interface
Friendly User Interface Ease to use for needy people.
Time Saving Method
Saves the people precious time.
More Helping Material of Charity And Donations Android App
- Functional and Non Functional Requirements of Charity And Donations Android App
- Code of Charity And Donations Android App
- Use Case Diagram Charity And Donations Android App
- Use Case Descriptions of Charity And Donations Android App
- Database table of Charity And Donations Android App
- Sequence Diagram Charity And Donations Android App
- Class Diagram Charity And Donations Android App
- Entity relationship Diagram Charity And Donations Android App
- Software Testing of Charity And Donations Management system