diff --git a/app/src/main/assets/PCSA_Phone_Numbers.csv b/app/src/main/assets/PCSA_Phone_Numbers.csv new file mode 100644 index 0000000..9e49a87 --- /dev/null +++ b/app/src/main/assets/PCSA_Phone_Numbers.csv @@ -0,0 +1,68 @@ +Country,SSM,SARL,PCMO,General DUTY,Region,Notes,SSM Contact Type +Albania,355-69-20-84-291,??,355-69-20-88295,355-69-685-4689,EMA,There is no general number for SARL listed, +Armenia,374-98-413-156,374-98-123-384,374-98-409-642,374-98-12-3391,EMA,, +Azerbaijan,??,??,99-450-200-9031,99-450-203-3255,EMA,"Suspended, so no staff", +Belize,??,??,501-822-1687,501-610-883,IAP,"No SARL, or SSM listed in pdf", +Benin,229-97-97-69-33,??,229-98-10-48-30,229-97-97-69-49,AF,229-97-97-69-32- second medical duty phone,cell +Botswana,267-7132-2888,267-740-64-745,267-71-222-666,267-71-323-999,AF,no SSM duty number listed,cell +Burkina Faso,226-76-20-23-85,226-64-66-43-43,226-76-20-24-6,226-76-20-24-5,AF,no SSM duty number listed,cell +Cambodia,855-12-831-912,855-12-436-33,855-12-941-68,855-12-934-583,EMA,no SSM duty number listed,cell +Cameroon,237-675-29-91-0,237-679-505-377,237-677-709-480,237-677-709-495,AF,, +China,86-139-8063-6210,86-135-6898-3341,86-139-8095-6692,86-139-8005-9990,EMA,,cell +Colombia,57-315-636-7188,??,57-310-247-7200,57-312-451-4301,IAP,no duty numbers for SSM or SARL,cell +Comoros,269-360-1-18,??,269-360-1-8,269-360-1-14,AF,no duty number for SARL, +Costa Rica,57-315-636-7188,506-8913-2796,506-8913-2627,506-8913-2400,IAP,no duty number for SSM,cell +Dominican Republic,809-723-9947,809-723-7847,809-723-9945,809-723-9944,IAP,no duty number for SSM,cell +Eastern Caribbean,758-484-1397,758-285-9732,??,??,IAP,only SARL and SSM numbers listed,cell +Ecuador,593-9-9449-7380,??,593-9-9939-1612,593-2-227-3759,IAP,593-9-9949-4025 - second duty number. others not found, +El Salvador,??,??,503-7888-1871,503-7737-2533,IAP,Suspended, +Ethiopa,251-911-222-385,251-93-540-1125,251-911-237-182,251-911-254-159,AF,, +Fiji,679-777-914,679-777-924,??,679-777-998,IAP,no duty numbers for SSM or PCMO,alternate +FSM and Palau,691-920-1829,691-925-2582,691-920-6510,691-920-2502,IAP,no duty number for SSM,emergancy +Georgia,995-599-974-348,995-595-14-732,995-599-97-33-88,995-599-96-1004,EMA,no duty number for SSM,yes +Ghana,233-30-274-4600,??,233-24-432-5603,233-50-12-99-802,AF,no duty numbers for SSM or SARL,alternate +Guatemala,502-5203-8678,??,502-5202-825,502-5202-2322,IAP,no duty numbers for SSM or SARL,cell +Guinea,224-622-35-2-48,??,224-62-200-14-26,224-62-525-2-83,AF,no duty numbers for SSM or SARL,cell +Guyana,592-600-3763,??,592-624-6355,??,IAP,only PCMO duty number provided,cell +Honduras,??,??,504-9970-394,504-9990-1980,IAP,Suspended so no staff, +Indonesia,62-31-561-5808,62-811-304-6330,62-811-3611-571,62-811-3611-610,IAP,no duty number for SSM,"alternate, also '+62-811-3611-609" +Jamaica,876-371-601,??,876-579-7392,876-383-6904,IAP,"+876-579-7486 second duty phone, no SSM or SARL",cell +Jordon,??,??,962-79-554-357,876-579-7392,EMA,Suspended so no staff, +Kenya,254-724-253-395,254-704-407-685,254-722-515-16,254-722-200-765,AF,no duty number for SSM,cell +Kosovo,??,??,??,+386 49 817 100,EMA,Suspended so no staff, +Kyrgyz Republic,996-555-756-130,996-555-750-538,996-555-756-137,996-555-756-139,EMA,, +Lesotho,266-62-856-636,266-62-856-468,266-62-851-3,266-6285-2058,AF,no duty number for SSM,emergancy +Liberia,231-777-335-309,??,231-880-651-138,231-777-265-194,AF,+231-880-651-138 second duty number/'+231-880-517-421 second PCMO,cell +Macedonia,389-70-30-60-39,??,389-70-23-15-91,389-70-22-82-49,EMA,no duty numbers for SSM or SARL,cell +Madagascar,261-33-11-85-33,?? ,261-33-11-97-92,261-33-11-85-34,AF,+261-33-11-406-74 second PCMO. no SSM or SARL,cell +Malawi,265-888-324-492,??,265-999-960-0,265-999-967-777,AF,no duty numbers for SSM or SARL,emergancy +Mali,??,??,??,??,AF,closed,cell +Mexico,52-1-442-359-8360,??,521-442-359-8353,521-442-359-8361,IAP,no duty numbers for SSM or SARL, +Moldova,373-692-95-955,373-69-11-11-6,373-600-66-844,373-69-11-11-5,EMA,no duty number for SSM,cell for back-up SSM +Mongolia,976-9501-2309,976-999-1-32,976-9907-2322,976-9901-6277,EMA,no duty number for SSM,cell +Morocco,??,212-662-72-67-36,212-6-61-18-71-77,212-6-61-37-37-67,AF,no duty number for SSM,no SSM listed +Mozambique,258-84-380-3359,??,258-82-30-75-270,258-82-307-5260,AF,"+258-82-301-1570 (PST Duty Officer), '+258-82-72-53-236 (Maputo Med cell #), +258-84-40-88-330 (Nampula - Vodacom#)",Blackberry +Myanmar,+09 97-652-1287,??,??,??,IAP,no duty numbers listed,cell +Namibia,264-811-286-126,264-814-201-98,264-811-278-152,??,AF,no duty numbers for SSM or general ,cell +Nepal,977-980-200-3104,977-980-200-3125,977-980-200-3258,977-98-200-3120,EMA,no duty number for SSM,cell +Nicaragua,??,??,505-8853-3685,505-8853-3686,IAP,no duty number for SSM or SARL,no SSM listed +Panama,11-507-6671-2552,??,11-507-6671-2547,11-507-6676-3131,IAP,no duty number for SSM or SARL,emergancy +Paraguay,595-984-610-16,??,595-981-444-312,595-984-152-162,IAP,no duty number for SSM or SARL,cell +Peru,51-9-9620-135,??,51-95956-9678,51-99999-1711,IAP,no duty number for SSM or SARL,cell +Philippines,63-998-842-609,63-908-897-9676,63-920-913-8453,63-918-916-3865,IAP,no duty number for SSM,cell +Rwanda,250-788-301-697,250-788-381-119,250-788-301-781,250-788-301-749,AF,no duty number for SSM '+250-788-309-207 second PCMO duty,cell +Samoa,685-777-345,685-777-348,685-777-344,685-770-345,IAP,no duty number for SSM,residence +Senegal,221-77-332-67-11,??,221-77-639-87-11,221-77-99-42-24,AF,no duty number for SSM or SARL,cell +Sierra Leone,232-78-612-1,??,232-78-716-525,232-78-200-892,AF,no duty number for SSM or SARL,cell +South Africa,27-79-111-6073,27-79-564-5446,27-79-111-5808,27-79-111-5810,AF,no duty number for SSM,cell +Swaziland,268-7602-8525,268-7802-5102,??,268-7602-8534,AF,no duty number for SSM or PCMO,cell +Tanzania,255-782-783-62,255-689-122-431,255-783-783-51,255-782-783-53,AF,no duty number for SSM,cell +Thailand,668-1-907-2636,??,668-1-811-5855,668-1-721-9012,IAP,no duty number for SSM or SARL,cell (double check) +The Gambia,220-390-4011,??,220-775-5606,220-439-1803,AF,no duty number for SSM or SARL,cell +Timor-Leste,670-7723-9111,670-7739-5853,670-77127883,670-77395879,IAP,no duty number for SSM,alternate +Togo,228-9036-6065,??,228-9011-7392,228-9004-3422,AF,no duty number for SSM or SARL,cell +Tonga,676-886-3134,676-886-3004,676-886-3129,676-786-3008,IAP,"+676-886-8511 second general duty, no SSM","cell, backup SSM" +Uganda,256-772-139848,256-772-139-836,256-757-700-538,256-772-139-834,AF,no duty number for SSM,cell +Ukraine,??,38-50-315-8753,380-50-330-2122,380-50-335-8816,EMA,no duty number for SSM,No SSM listed +Vanuatu,678-55-83-759,??,678-561-963,678-710-138,IAP,"+678-555-4742, '+678-5508911,'+678-7758911, other duty numbers, '+678-773-3287 other med duty number","cell, '+678-77-85-696 2nd cell" +Zambia,260-96-678-2327,??,260-96-609-3444,260-976-645-444,AF,no SSM or SARL duty number,"cell, +60-97-735-1717 2nd cell" diff --git a/app/src/main/java/com/peacecorps/pcsa/get_help_now/ContactPostStaff.java b/app/src/main/java/com/peacecorps/pcsa/get_help_now/ContactPostStaff.java index a3240dd..ff8dcde 100644 --- a/app/src/main/java/com/peacecorps/pcsa/get_help_now/ContactPostStaff.java +++ b/app/src/main/java/com/peacecorps/pcsa/get_help_now/ContactPostStaff.java @@ -2,6 +2,7 @@ import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.AssetManager; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; @@ -19,6 +20,10 @@ import com.peacecorps.pcsa.MainActivity; import com.peacecorps.pcsa.R; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -31,15 +36,32 @@ */ public class ContactPostStaff extends Fragment implements AdapterView.OnItemClickListener { - public static final String TAG = ContactPostStaff.class.getSimpleName() ; + public static final String TAG = ContactPostStaff.class.getSimpleName(); + + private final String PCSA_PHONE_NUMBERS_FILE_NAME = "PCSA_Phone_Numbers.csv"; + private String numberToContact; + + private static final Map locationDetails; + private static BufferedReader br; + private static AssetManager assetManager; + private static String selectedCountry; + private static String pcmoNumber; + private static String ssmNumber; + private static String sarlNumber; SharedPreferences sharedPreferences; + LocationDetails selectedLocationDetails; + + ArrayList countryNameArray = new ArrayList<>(); + ArrayList countryPCMONumberArray = new ArrayList<>(); + ArrayList countrySSMNumberArray = new ArrayList<>(); + ArrayList countrySARLNumberArray = new ArrayList<>(); TextView currentLocation; - LocationDetails selectedLocationDetails; - private String numberToContact; + Button contactPcmo; + Button contactSsm; + Button contactSarl; - private static final Map locationDetails; static { locationDetails = new HashMap<>(); } @@ -48,32 +70,38 @@ public class ContactPostStaff extends Fragment implements AdapterView.OnItemClic @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_reporting_contact_post_staff,container,false); + View rootView = inflater.inflate(R.layout.fragment_reporting_contact_post_staff, container, false); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - locationDetails.put(getResources().getString(R.string.loc1_name), new LocationDetails(getResources().getString(R.string.loc1_name), getResources().getString(R.string.loc1_pcmo), getResources().getString(R.string.loc1_ssm), getResources().getString(R.string.loc1_sarl))); - locationDetails.put(getResources().getString(R.string.loc2_name), new LocationDetails(getResources().getString(R.string.loc2_name), getResources().getString(R.string.loc2_pcmo), getResources().getString(R.string.loc2_ssm), getResources().getString(R.string.loc2_sarl))); - locationDetails.put(getResources().getString(R.string.loc3_name), new LocationDetails(getResources().getString(R.string.loc3_name), getResources().getString(R.string.loc3_pcmo), getResources().getString(R.string.loc3_ssm), getResources().getString(R.string.loc3_sarl))); + assetManager = getContext().getAssets(); - Button contactPcmo = (Button) rootView.findViewById(R.id.post_staff_pcmo); - Button contactSsm = (Button) rootView.findViewById(R.id.post_staff_ssm); - Button contactSarl = (Button) rootView.findViewById(R.id.post_staff_sarl); + contactPcmo = (Button) rootView.findViewById(R.id.post_staff_pcmo); + contactSsm = (Button) rootView.findViewById(R.id.post_staff_ssm); + contactSarl = (Button) rootView.findViewById(R.id.post_staff_sarl); currentLocation = (TextView) rootView.findViewById(R.id.post_staff_current_location); - currentLocation.setText(getString(R.string.reporting_current_location) + " " + sharedPreferences.getString(getString(R.string.key_country),"") + getString(R.string.reporting_current_post)); + currentLocation.setText(getString(R.string.reporting_current_location) + " " + sharedPreferences.getString(getString(R.string.key_country), "") + getString(R.string.reporting_current_post)); ImageView contactOtherStaff = (ImageView) rootView.findViewById(R.id.link_to_other_staff); contactPcmo.setText(R.string.contact_pcmo); contactSsm.setText(R.string.contact_ssm); contactSarl.setText(R.string.contact_sarl); + readPhoneNumbersCSV(PCSA_PHONE_NUMBERS_FILE_NAME); + + for (int i = 0; i < countryNameArray.size(); i++) { + locationDetails.put(countryNameArray.get(i), + new LocationDetails(countryNameArray.get(i), countryPCMONumberArray.get(i), + countrySSMNumberArray.get(i), countrySARLNumberArray.get(i))); + } + contactPcmo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { numberToContact = selectedLocationDetails.getPcmoContact(); ContactOptionsDialogBox contactOptionsDialogBox = ContactOptionsDialogBox.newInstance(getString(R.string.contact_pcmo_via), - getActivity(),ContactPostStaff.this); - contactOptionsDialogBox.show(getActivity().getSupportFragmentManager(),getString(R.string.dialog_tag)); + getActivity(), ContactPostStaff.this); + contactOptionsDialogBox.show(getActivity().getSupportFragmentManager(), getString(R.string.dialog_tag)); } }); @@ -82,7 +110,7 @@ public void onClick(View v) { public void onClick(View v) { numberToContact = selectedLocationDetails.getSsmContact(); ContactOptionsDialogBox contactOptionsDialogBox = ContactOptionsDialogBox.newInstance(getString(R.string.contact_ssm_via), - getActivity(),ContactPostStaff.this); + getActivity(), ContactPostStaff.this); contactOptionsDialogBox.show(getActivity().getSupportFragmentManager(), getString(R.string.dialog_tag)); } }); @@ -92,44 +120,61 @@ public void onClick(View v) { public void onClick(View v) { numberToContact = selectedLocationDetails.getSarlContact(); ContactOptionsDialogBox contactOptionsDialogBox = ContactOptionsDialogBox.newInstance(getString(R.string.contact_sarl_via), - getActivity(),ContactPostStaff.this); + getActivity(), ContactPostStaff.this); contactOptionsDialogBox.show(getActivity().getSupportFragmentManager(), getString(R.string.dialog_tag)); } }); - + contactOtherStaff.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Swapping ContactOtherStaff into the fragment container dynamically Fragment contactOtherStaffFragment = new ContactOtherStaff(); - MainActivity.swapFragmentIn(getActivity(),contactOtherStaffFragment,ContactOtherStaff.TAG,true); + MainActivity.swapFragmentIn(getActivity(), contactOtherStaffFragment, ContactOtherStaff.TAG, true); } }); - ((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(R.string.reporting_get_help); + ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.reporting_get_help); return rootView; } - + + public void readPhoneNumbersCSV(String filename) { + + try { + br = new BufferedReader(new InputStreamReader(assetManager.open(filename))); + String reader; + while ((reader = br.readLine()) != null) { + String[] rowData = reader.split(","); + countryNameArray.add(rowData[0]); + countrySSMNumberArray.add(rowData[1]); + countrySARLNumberArray.add(rowData[2]); + countryPCMONumberArray.add(rowData[3]); + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + /** * Interface definition for a callback to be invoked when an item in this AdapterView has been clicked. * - * @param parent The AdapterView where the click happened. - * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) + * @param parent The AdapterView where the click happened. + * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. - * @param id The row id of the item that was clicked. + * @param id The row id of the item that was clicked. */ @Override public void onItemClick(AdapterView parent, View view, int position, long id) { //For Voice Call - if(position == 1) - { + if (position == 1) { Intent callingIntent = new Intent(Intent.ACTION_CALL); callingIntent.setData(Uri.parse("tel:" + numberToContact)); startActivity(callingIntent); } //For Message - else if(position == 2) { + else if (position == 2) { Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse("sms:" + numberToContact)); startActivity(smsIntent); @@ -139,8 +184,38 @@ else if(position == 2) { @Override public void onResume() { super.onResume(); - selectedLocationDetails = locationDetails.get(sharedPreferences.getString(getString(R.string.key_country),getString(R.string.country_default))); - if(currentLocation != null) - currentLocation.setText(getString(R.string.reporting_current_location) + " " + sharedPreferences.getString(getString(R.string.key_country),"")+ getString(R.string.reporting_current_post)); + selectedLocationDetails = locationDetails.get(sharedPreferences.getString(getString(R.string.key_country), getString(R.string.country_default))); + if (currentLocation != null) + currentLocation.setText(getString(R.string.reporting_current_location) + " " + sharedPreferences.getString(getString(R.string.key_country), "") + getString(R.string.reporting_current_post)); + + selectedCountry = sharedPreferences.getString(getString(R.string.key_country), ""); + + pcmoNumber = locationDetails.get(selectedCountry).getPcmoContact(); + + if (pcmoNumber.equals("??")) { + contactPcmo.setTextColor(getResources().getColor(R.color.disabled_button_text)); + contactPcmo.setEnabled(false); + } else { + contactPcmo.setTextColor(getResources().getColor(R.color.textColorPrimary)); + contactPcmo.setEnabled(true); + } + + ssmNumber = locationDetails.get(selectedCountry).getSsmContact(); + if (ssmNumber.equals("??")) { + contactSsm.setTextColor(getResources().getColor(R.color.disabled_button_text)); + contactSsm.setEnabled(false); + } else { + contactSsm.setTextColor(getResources().getColor(R.color.textColorPrimary)); + contactSsm.setEnabled(true); + } + + sarlNumber = locationDetails.get(selectedCountry).getSarlContact(); + if (sarlNumber.equals("??")) { + contactSarl.setTextColor(getResources().getColor(R.color.disabled_button_text)); + contactSarl.setEnabled(false); + } else { + contactSarl.setTextColor(getResources().getColor(R.color.textColorPrimary)); + contactSarl.setEnabled(true); + } } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 158397e..9ce975f 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,15 +1,147 @@ + Albania + Armenia + Azerbaijan + Belize + Benin + Botswana + Burkina Faso + Cambodia + Cameroon + China + Colombia + Comoros + Costa Rica + Dominican Republic + Eastern Caribbean + Ecuador + El Salvador + Ethiopa + Fiji + FSM and Palau + Georgia + Ghana + Guatemala + Guinea + Guyana + Honduras + Indonesia + Jamaica + Jordon + Kenya + Kosovo + Kyrgyz Republic + Lesotho + Liberia + Macedonia + Madagascar + Malawi + Mali + Mexico + Moldova + Mongolia + Morocco + Mozambique + Myanmar + Namibia + Nepal + Nicaragua + Panama + Paraguay + Peru + Philippines + Rwanda + Samoa + Senegal + Sierra Leone + South Africa + Swaziland + Tanzania + Thailand + The Gambia + Timor-Leste + Togo + Tonga + Uganda Uganda Syria Tunisia + Vanuatu + Zambia + Albania + Armenia + Azerbaijan + Belize + Benin + Botswana + Burkina Faso + Cambodia + Cameroon + China + Colombia + Comoros + Costa Rica + Dominican Republic + Eastern Caribbean + Ecuador + El Salvador + Ethiopa + Fiji + FSM and Palau + Georgia + Ghana + Guatemala + Guinea + Guyana + Honduras + Indonesia + Jamaica + Jordon + Kenya + Kosovo + Kyrgyz Republic + Lesotho + Liberia + Macedonia + Madagascar + Malawi + Mali + Mexico + Moldova + Mongolia + Morocco + Mozambique + Myanmar + Namibia + Nepal + Nicaragua + Panama + Paraguay + Peru + Philippines + Rwanda + Samoa + Senegal + Sierra Leone + South Africa + Swaziland + Tanzania + Thailand + The Gambia + Timor-Leste + Togo + Tonga + Uganda Uganda Syria Tunisia + Vanuatu + Zambia diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1b3cf39..ae562a3 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -37,7 +37,7 @@ @color/dot_dark_screen3 @color/dot_dark_screen4 - + #424242 \ No newline at end of file