Skip to content

Commit

Permalink
Merge pull request #10 from UNFPAInnovation/UI-updates
Browse files Browse the repository at this point in the history
Ui updates
  • Loading branch information
codephillip authored Sep 4, 2020
2 parents ace93af + 2716e0e commit 1b0e4a0
Show file tree
Hide file tree
Showing 71 changed files with 1,666 additions and 461 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local.properties
*.iml
.DS_Store
*.sublime-project

collect_app/debug/
# emacs backup files
*.*~

Expand Down
8 changes: 5 additions & 3 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ android {

buildTypes {
debug {
// buildConfigField "String", "DJANGO_BACKEND_URL", '"http://backend.getinmobile.org/"'
// buildConfigField "String", "APP_USER_URL", '"https://odkcentral.getinmobile.org/v1/key/VpxV1j2OKjioeXi3X3tVDaD9F4EE8rOAp8xeV5mdwycmBRvf!CQ$RYvKnnQx8dKf/projects/2"'
buildConfigField "String", "DJANGO_BACKEND_URL", '"http://testbackend.getinmobile.org/"'
buildConfigField "String", "APP_USER_URL", '"https://testcentral.getinmobile.org/v1/key/WCoZ55Bi48dUnENkvbr7HG2MDk2FJVU7A6wCq1cWaDInwiGBwYjnX5Jefx464iFJ/projects/2"'
buildConfigField "String", "MSI_PHONE_NUMBER", '"8228"'
buildConfigField "String", "MSI_HEALTH_FACILITY_ID", '"1719"'
}

release {
buildConfigField "String", "DJANGO_BACKEND_URL", '"http://backend.getinmobile.org/"'
buildConfigField "String", "DJANGO_BACKEND_URL", '"https://backend.getinmobile.org/"'
buildConfigField "String", "APP_USER_URL", '"https://odkcentral.getinmobile.org/v1/key/VpxV1j2OKjioeXi3X3tVDaD9F4EE8rOAp8xeV5mdwycmBRvf!CQ$RYvKnnQx8dKf/projects/2"'
buildConfigField "String", "MSI_PHONE_NUMBER", '"8228"'
buildConfigField "String", "MSI_HEALTH_FACILITY_ID", '"1719"'
}
}

Expand Down
2 changes: 1 addition & 1 deletion collect_app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3865,"versionName":"v1.23.3-131-g481299a40-dirty","enabled":true,"outputFile":"collect-release.apk","fullName":"release","baseName":"release"},"path":"collect-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3867,"versionName":"v1.23.3-142-g66d171d18-dirty","enabled":true,"outputFile":"collect-release.apk","fullName":"release","baseName":"release"},"path":"collect-release.apk","properties":{}}]
26 changes: 16 additions & 10 deletions collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- <uses-permission android:name="android.permission.CAMERA" /> -->
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<!-- <uses-permission android:name="android.permission.GET_ACCOUNTS" /> &lt;!&ndash; <uses-permission android:name="android.permission.SEND_SMS" /> &ndash;&gt; -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<!-- Normal permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Expand Down Expand Up @@ -77,12 +80,6 @@
android:name=".activities.ProfileActivity"
android:label="@string/title_activity_profile"
android:theme="@style/AppTheme.NoActionBar">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->

<!--<category android:name="android.intent.category.DEFAULT" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>

<receiver
Expand Down Expand Up @@ -367,6 +364,15 @@
<activity
android:name=".activities.CallUserViewActivity"
android:theme="@style/Theme.Collect.Activity.FormEntryActivity.Light" />

<receiver
android:name=".widgets.QuestionWidget$SmsReceiver"
android:enabled="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
import android.net.Uri;
import android.os.Bundle;

import com.pixplicity.easyprefs.library.Prefs;

import org.odk.getin.android.R;

import timber.log.Timber;

import static org.odk.getin.android.utilities.ApplicationConstants.VHT_MIDWIFE_PHONE;

/**
* Responsible for launching the android call app with the given number.
* This activity only requests for permissions and delegates the calling functionality to the call app.
Expand All @@ -26,8 +30,7 @@
public class EmergencyCallActivity extends CollectAbstractActivity {

private static final int REQUEST_PHONE_CALL = 89;
//todo get midwife's number
String phoneNumber = "0756878111";
String phoneNumber = Prefs.getString(VHT_MIDWIFE_PHONE, "0787228913");

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@
import static org.odk.getin.android.utilities.ApplicationConstants.APPOINTMENT_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.EDIT_GIRL;
import static org.odk.getin.android.utilities.ApplicationConstants.GIRL_NAME;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ADJUMANI_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ADJUMANI_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ARUA_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ARUA_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_BUNDIBUGYO_FORM_ID;
Expand All @@ -207,6 +209,10 @@
import static org.odk.getin.android.utilities.ApplicationConstants.GIRL_LAST_NAME;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_KAMPALA_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_KAMPALA_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_MOYO_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_MOYO_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_YUMBE_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_YUMBE_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.POSTNATAL_FORM_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.POSTNATAL_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.RequestCodes;
Expand Down Expand Up @@ -1196,7 +1202,13 @@ private View createView(int event, boolean advancingPage) {
case MAP_GIRL_KAMPALA_FORM_CHEW_ID:
case MAP_GIRL_KAMPALA_FORM_MIDWIFE_ID:
case MAP_GIRL_ARUA_FORM_CHEW_ID:
case MAP_GIRL_ARUA_FORM_MIDWIFE_ID: {
case MAP_GIRL_ARUA_FORM_MIDWIFE_ID:
case MAP_GIRL_MOYO_FORM_CHEW_ID:
case MAP_GIRL_ADJUMANI_FORM_CHEW_ID:
case MAP_GIRL_YUMBE_FORM_CHEW_ID:
case MAP_GIRL_MOYO_FORM_MIDWIFE_ID:
case MAP_GIRL_ADJUMANI_FORM_MIDWIFE_ID:
case MAP_GIRL_YUMBE_FORM_MIDWIFE_ID: {
title = "Map a girl";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;

import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.firebase.iid.FirebaseInstanceId;
Expand All @@ -64,13 +63,11 @@
import org.odk.getin.android.R;
import org.odk.getin.android.application.Collect;
import org.odk.getin.android.dao.InstancesDao;
import org.odk.getin.android.preferences.AdminKeys;
import org.odk.getin.android.preferences.AdminPreferencesActivity;
import org.odk.getin.android.preferences.AdminSharedPreferences;
import org.odk.getin.android.preferences.AutoSendPreferenceMigrator;
import org.odk.getin.android.preferences.GeneralSharedPreferences;
import org.odk.getin.android.preferences.GeneralKeys;
import org.odk.getin.android.preferences.PreferencesActivity;
import org.odk.getin.android.preferences.Transport;
import org.odk.getin.android.provider.FormsProviderAPI;
import org.odk.getin.android.provider.InstanceProviderAPI.InstanceColumns;
Expand Down Expand Up @@ -105,12 +102,18 @@

import static org.odk.getin.android.preferences.GeneralKeys.KEY_SUBMISSION_TRANSPORT_TYPE;
import static org.odk.getin.android.utilities.ApplicationConstants.CHEW_ROLE;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ADJUMANI_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ADJUMANI_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ARUA_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_ARUA_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_BUNDIBUGYO_FORM_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_BUNDIBUGYO_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_KAMPALA_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_KAMPALA_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_MOYO_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_MOYO_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_YUMBE_FORM_CHEW_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.MAP_GIRL_YUMBE_FORM_MIDWIFE_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.USER_DISTRICT;
import static org.odk.getin.android.utilities.ApplicationConstants.USER_ID;
import static org.odk.getin.android.utilities.ApplicationConstants.USER_LOGGED_IN;
Expand All @@ -128,6 +131,7 @@
public class MainMenuActivity extends CollectAbstractActivity {
private static final boolean EXIT = true;
private static final String TASK_ID = "NotificationWorker";
private static final int REQUEST_SEND_SMS = 35;
// buttons
private Button callMidwifeOrChewButton;
private Button callAmbulanceButton;
Expand Down Expand Up @@ -188,10 +192,6 @@ protected void onCreate(Bundle savedInstanceState) {
});

disableSmsIfNeeded();
Timber.d("User role");
Timber.d(Prefs.getString(USER_ROLE, CHEW_ROLE));
Timber.d("Midwife id: " + Prefs.getString(VHT_MIDWIFE_ID, ""));
Timber.d(String.valueOf(Prefs.getString(USER_ROLE, CHEW_ROLE).equals(CHEW_ROLE)));

// download data from django server; mapped girls
Intent intent = new Intent(this, SetupIntentService.class);
Expand All @@ -210,13 +210,25 @@ public void onClick(View v) {
startFormActivity(MAP_GIRL_BUNDIBUGYO_FORM_ID);
else if (Prefs.getString(USER_DISTRICT, "Kampala").equals("Kampala"))
startFormActivity(MAP_GIRL_KAMPALA_FORM_CHEW_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Moyo"))
startFormActivity(MAP_GIRL_MOYO_FORM_CHEW_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Adjumani"))
startFormActivity(MAP_GIRL_ADJUMANI_FORM_CHEW_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Yumbe"))
startFormActivity(MAP_GIRL_YUMBE_FORM_CHEW_ID);
else
startFormActivity(MAP_GIRL_ARUA_FORM_CHEW_ID);
} else {
if (Prefs.getString(USER_DISTRICT, "BUNDIBUGYO").equals("BUNDIBUGYO"))
startFormActivity(MAP_GIRL_BUNDIBUGYO_FORM_MIDWIFE_ID);
else if (Prefs.getString(USER_DISTRICT, "Kampala").equals("Kampala"))
startFormActivity(MAP_GIRL_KAMPALA_FORM_MIDWIFE_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Moyo"))
startFormActivity(MAP_GIRL_MOYO_FORM_MIDWIFE_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Adjumani"))
startFormActivity(MAP_GIRL_ADJUMANI_FORM_MIDWIFE_ID);
else if (Prefs.getString(USER_DISTRICT, "Moyo").equals("Yumbe"))
startFormActivity(MAP_GIRL_YUMBE_FORM_MIDWIFE_ID);
else
startFormActivity(MAP_GIRL_ARUA_FORM_MIDWIFE_ID);
}
Expand Down Expand Up @@ -345,6 +357,7 @@ public void onClick(View v) {
}
viewSentCount = viewSentCursor != null ? viewSentCursor.getCount() : 0;
setupGoogleAnalytics();
requestSmsPermissions();
}

public void networkStatusCheckTimer() {
Expand Down Expand Up @@ -668,6 +681,21 @@ private void callGetInHelpUser() {
}
}

public void requestSmsPermissions() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_SMS},
REQUEST_SEND_SMS);
}
}
}

public void logoutDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainMenuActivity.this);
alertDialog.setTitle("Confirm Logout");
Expand All @@ -684,6 +712,7 @@ public void logoutDialog() {
e.printStackTrace();
} finally {
finish();
startActivity(new Intent(this, SplashScreenActivity.class));
}
});

Expand Down
Loading

0 comments on commit 1b0e4a0

Please sign in to comment.