Skip to content

Commit

Permalink
Merge branch 'master' into feature/givewell
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1g5 committed Sep 4, 2024
2 parents 28f33c9 + c870772 commit 6d210ad
Show file tree
Hide file tree
Showing 33 changed files with 301 additions and 75 deletions.
2 changes: 1 addition & 1 deletion app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="106"
android:versionName="2.54">
android:versionName="2.55">

<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ custom.restore.file.not.set=Custom restore file path is not set in preferences
custom.restore.error=Error loading custom sync

start.recording=Start Recording
start.recording.failed=Unable to start recording while another application is recording!
start.recording.failed=Unable to start recording while another application is using the microphone!
stop.recording=Stop Recording
recording.header=Record a sound
before.recording=Tap to start recording
Expand Down
18 changes: 14 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ dependencies {
implementation fileTree(include: '*.jar', exclude: 'regexp-me.jar', dir: 'libs')
implementation(name: 'htmlspanner-custom', ext: 'aar')
implementation 'com.github.dimagi:zebra-print-android:v1.3'
implementation 'com.simprints:LibSimprints:1.0.12'
implementation (name: 'LibSimprints-1.0.12', ext: 'aar')
implementation (name: 'mapbox-android-accounts-0.2.0', ext: 'aar')
implementation (name: 'realm-android-library-4.1.1', ext: 'aar')
implementation (name: 'volley-1.1.0', ext: 'aar')
implementation (name: 'storage-2.1.0', ext: 'aar')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
Expand Down Expand Up @@ -98,7 +102,7 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'com.duolingo.open:rtl-viewpager:2.0.0'
implementation (name: 'rtl-viewpager-2.0.0', ext: 'aar')
implementation('com.github.bumptech.glide:glide:4.9.0') {
exclude group: 'com.android.support'
}
Expand All @@ -114,6 +118,10 @@ dependencies {

implementation('io.ona.kujaku:library:0.9.0') {
exclude module: 'xpp3'
exclude module: 'volley'
exclude module: 'storage'
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-accounts'
exclude group: 'io.realm'
}
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.work:work-runtime-ktx:2.7.1'
Expand Down Expand Up @@ -277,8 +285,6 @@ android {
buildConfigField 'String', 'ANALYTICS_TRACKING_ID_DEV', "\"${project.ext.ANALYTICS_TRACKING_ID_DEV}\""
buildConfigField 'String', 'MAPBOX_SDK_API_KEY', "\"${project.ext.MAPBOX_SDK_API_KEY}\""

buildConfigField "String", "HQ_API_USERNAME", "\"${project.ext.HQ_API_USERNAME}\""
buildConfigField "String", "HQ_API_PASSWORD", "\"${project.ext.HQ_API_PASSWORD}\""
buildConfigField "String", "FIREBASE_DATABASE_URL", "\"${project.ext.FIREBASE_DATABASE_URL}\""

buildConfigField 'String', 'CCC_HOST', "\"connect.dimagi.com\""
Expand Down Expand Up @@ -559,6 +565,10 @@ tasks.whenTaskAdded { task ->
&& "true" == isConsumerApp && "true" == runDownloadScripts) {
task.dependsOn downloadRestoreFile
}
if (task.name == 'assembleCommcareReleaseAndroidTest' || task.name == 'assembleCommcareDebugAndroidTest') {
android.defaultConfig.buildConfigField "String", "HQ_API_USERNAME", "\"${project.ext.HQ_API_USERNAME}\""
android.defaultConfig.buildConfigField "String", "HQ_API_PASSWORD", "\"${project.ext.HQ_API_PASSWORD}\""
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import org.commcare.CommCareInstrumentationTestApplication
import org.commcare.activities.InstallFromListActivity
import org.commcare.android.database.global.models.AppAvailableToInstall
import org.commcare.annotations.BrowserstackTests
import org.commcare.dalvik.BuildConfig
import org.commcare.dalvik.R
import org.commcare.dalvik.test.BuildConfig
import org.commcare.utils.CustomMatchers
import org.commcare.utils.InstrumentationUtility
import org.commcare.utils.isPresent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.commcare.core.network.AuthInfo;
import org.commcare.core.network.CommCareNetworkService;
import org.commcare.core.network.CommCareNetworkServiceGenerator;
import org.commcare.dalvik.BuildConfig;
import org.commcare.dalvik.test.BuildConfig;
import org.commcare.modern.util.Pair;
import org.commcare.network.HttpUtils;
import org.joda.time.DateTime;
Expand Down
Binary file added app/libs/LibSimprints-1.0.12.aar
Binary file not shown.
Binary file added app/libs/mapbox-android-accounts-0.2.0.aar
Binary file not shown.
Binary file added app/libs/realm-android-library-4.1.1.aar
Binary file not shown.
Binary file added app/libs/rtl-viewpager-2.0.0.aar
Binary file not shown.
Binary file added app/libs/storage-2.1.0.aar
Binary file not shown.
Binary file added app/libs/volley-1.1.0.aar
Binary file not shown.
8 changes: 8 additions & 0 deletions app/res/drawable/incomplete_nav_drawer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector android:alpha="0.6" android:height="100dp"
android:viewportHeight="100" android:viewportWidth="100"
android:width="100dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#343434" android:pathData="m88.52,40.04v-0c-0.08,-0.14 -0.19,-0.26 -0.31,-0.35l-5.78,-4.34v-13.48c0,-0.65 -0.52,-1.17 -1.17,-1.17h-18.36l-12.19,-9.14c-0.02,-0.02 -0.04,-0.02 -0.06,-0.03v-0c-0.07,-0.04 -0.14,-0.07 -0.21,-0.1 -0.07,-0.03 -0.14,-0.05 -0.21,-0.07 -0.3,-0.04 -0.61,0.02 -0.86,0.18 -0.02,0.01 -0.04,0.02 -0.06,0.03l-12.19,9.14h-18.36c-0.65,0 -1.17,0.52 -1.17,1.17v13.48l-5.78,4.34c-0.13,0.09 -0.23,0.21 -0.31,0.35l-0,0.01 0,-0c-0.09,0.16 -0.13,0.34 -0.14,0.52 0,0.02 -0.02,0.04 -0.02,0.06v46.88c0,0.02 0,0.03 0.01,0.05 0,0.1 0.02,0.2 0.05,0.29l0,0.03c0.01,0.03 0.03,0.05 0.04,0.09l0,0c0.07,0.17 0.18,0.32 0.33,0.44 0.04,0.03 0.08,0.06 0.12,0.09 0.02,0.02 0.04,0.04 0.07,0.05 0.02,0.01 0.04,0 0.06,0.02v-0c0.16,0.08 0.32,0.12 0.5,0.13h75c0.17,-0 0.34,-0.05 0.5,-0.13 0.02,-0.01 0.04,-0 0.06,-0.02 0.02,-0.01 0.04,-0.04 0.07,-0.05v0c0.1,-0.06 0.18,-0.14 0.26,-0.23 0.08,-0.09 0.15,-0.19 0.19,-0.3 0.01,-0.03 0.04,-0.05 0.04,-0.09l0,-0.03h0c0.03,-0.1 0.04,-0.2 0.05,-0.29 0,-0.02 0.01,-0.03 0.01,-0.05v-46.88c0,-0.02 -0.02,-0.04 -0.02,-0.06 -0.01,-0.18 -0.05,-0.36 -0.14,-0.52zM80.08,35.94v7.66l-27.65,16.13 -1.72,-1.29c-0.42,-0.31 -0.99,-0.31 -1.41,0l-1.72,1.29 -27.65,-16.13v-20.55h60.16z"/>
<path android:fillColor="#343434" android:pathData="m26.95,31.25c0,0.65 0.52,1.17 1.17,1.17h43.75c0.65,0 1.17,-0.52 1.17,-1.17s-0.52,-1.17 -1.17,-1.17h-43.75c-0.65,0 -1.17,0.52 -1.17,1.17z"/>
<path android:fillColor="#343434" android:pathData="m71.88,36.33h-43.75c-0.65,0 -1.17,0.52 -1.17,1.17 0,0.64 0.52,1.17 1.17,1.17h43.75c0.65,0 1.17,-0.53 1.17,-1.17 0,-0.65 -0.52,-1.17 -1.17,-1.17z"/>
<path android:fillColor="#343434" android:pathData="m71.88,42.57h-43.75c-0.65,0 -1.17,0.53 -1.17,1.17 0,0.65 0.52,1.17 1.17,1.17h43.75c0.65,0 1.17,-0.52 1.17,-1.17 0,-0.64 -0.52,-1.17 -1.17,-1.17z"/>
</vector>
13 changes: 8 additions & 5 deletions app/res/layout/nav_drawer_item_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal" >
android:orientation="horizontal"
android:weightSum="5">

<ImageView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/drawer_icon"
android:layout_marginRight="@dimen/standard_spacer_double"
android:layout_marginEnd="@dimen/standard_spacer_double" />
android:layout_marginEnd="@dimen/standard_spacer_double"
android:layout_weight="1"/>

<TextView
android:id="@+id/drawer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"/>

</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dimen name="list_icon_bounding_dimen">60dp</dimen>
<dimen name="list_grid_bounding_dimension">180dp</dimen>

<dimen name="numeric_badge_width_for_list">20dp</dimen>
<dimen name="numeric_badge_width_for_list">28dp</dimen>
<dimen name="numeric_badge_font_size_list">10dp</dimen>

<dimen name="menu_grid_icon_size">120dp</dimen>
Expand Down
9 changes: 8 additions & 1 deletion app/src/org/commcare/activities/HomeButtons.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ private static View.OnClickListener getSyncButtonSubTextListener(final StandardH

private static TextSetter getSyncButtonTextSetter(final StandardHomeActivity activity) {
return (cardDisplayData, squareButtonViewHolder, context, notificationText) -> {
SyncDetailCalculations.updateSubText(activity, squareButtonViewHolder, cardDisplayData, notificationText);
try {
SyncDetailCalculations.updateSubText(activity, squareButtonViewHolder, cardDisplayData,
notificationText);
} catch (SessionUnavailableException e) {
// stop button setup, since redirection to login is imminent
return;
}

squareButtonViewHolder.subTextView.setBackgroundColor(activity.getResources().getColor(cardDisplayData.subTextBgColor));
squareButtonViewHolder.textView.setTextColor(context.getResources().getColor(cardDisplayData.textColor));
squareButtonViewHolder.textView.setText(cardDisplayData.text);
Expand Down
20 changes: 17 additions & 3 deletions app/src/org/commcare/activities/HomeNavDrawerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class HomeNavDrawerController {
private static final String LOGOUT_DRAWER_ITEM_ID = "home-logout";
private static final String TRAINING_DRAWER_ITEM_ID = "training";
private static final String UPDATE_CC_DRAWER_ITEM_ID = "update-cc";
private static final String INCOMPLETE_FORMS_ITEM_ID = "incomplete-forms";

protected static final String KEY_DRAWER_WAS_OPEN = "drawer-open-before-rotation";

Expand Down Expand Up @@ -104,27 +105,32 @@ private void determineDrawerItemsToInclude() {
boolean hideSavedFormsItem = !HiddenPreferences.isSavedFormsEnabled();
boolean hideChangeLanguageItem = ChangeLocaleUtil.getLocaleNames().length <= 1;
boolean hideTrainingItem = !CommCareApplication.instance().getCurrentApp().hasVisibleTrainingContent();
boolean hideIncompleteFormsItem = !HiddenPreferences.isIncompleteFormsEnabled();
int numItemsToInclude = allDrawerItems.size()
- (hideChangeLanguageItem ? 1 : 0)
- (hideSavedFormsItem ? 1 : 0)
- (hideTrainingItem ? 1 : 0)
- (hideIncompleteFormsItem ? 1 : 0)
- (activity.showCommCareUpdateMenu ? 0 : 1);

drawerItemsShowing = new NavDrawerItem[numItemsToInclude];
int index = 0;
for (String id : getAllItemIdsInOrder()) {
NavDrawerItem item = allDrawerItems.get(id);
if (!excludeItem(id, hideChangeLanguageItem, hideSavedFormsItem, hideTrainingItem, !activity.showCommCareUpdateMenu)) {
if (!excludeItem(id, hideChangeLanguageItem, hideSavedFormsItem, hideTrainingItem,
!activity.showCommCareUpdateMenu, hideIncompleteFormsItem)) {
drawerItemsShowing[index] = item;
index++;
}
}
}

private boolean excludeItem(String itemId, boolean hideChangeLanguageItem,
boolean hideSavedFormsItem, boolean hideTrainingItem, boolean hideCCUpdateItem) {
boolean hideSavedFormsItem, boolean hideTrainingItem, boolean hideCCUpdateItem,
boolean hideIncompleteFormsItem) {
return (itemId.equals(CHANGE_LANGUAGE_DRAWER_ITEM_ID) && hideChangeLanguageItem) ||
(itemId.equals(SAVED_FORMS_ITEM_ID) && hideSavedFormsItem) ||
(itemId.equals(INCOMPLETE_FORMS_ITEM_ID) && hideIncompleteFormsItem) ||
(itemId.equals(TRAINING_DRAWER_ITEM_ID) && hideTrainingItem) ||
(itemId.equals(UPDATE_CC_DRAWER_ITEM_ID) && hideCCUpdateItem);
}
Expand Down Expand Up @@ -163,6 +169,9 @@ private ListView.OnItemClickListener getNavDrawerClickListener() {
case UPDATE_CC_DRAWER_ITEM_ID:
activity.startCommCareUpdate();
break;
case INCOMPLETE_FORMS_ITEM_ID:
activity.goToFormArchive(true);
break;
}
};
}
Expand All @@ -171,7 +180,8 @@ private static String[] getAllItemIdsInOrder() {
return new String[]{
ABOUT_CC_DRAWER_ITEM_ID, TRAINING_DRAWER_ITEM_ID, SETTINGS_DRAWER_ITEM_ID,
ADVANCED_DRAWER_ITEM_ID, CHANGE_LANGUAGE_DRAWER_ITEM_ID, SAVED_FORMS_ITEM_ID,
UPDATE_DRAWER_ITEM_ID, SYNC_DRAWER_ITEM_ID, UPDATE_CC_DRAWER_ITEM_ID, LOGOUT_DRAWER_ITEM_ID};
INCOMPLETE_FORMS_ITEM_ID, UPDATE_DRAWER_ITEM_ID, SYNC_DRAWER_ITEM_ID, UPDATE_CC_DRAWER_ITEM_ID,
LOGOUT_DRAWER_ITEM_ID};
}

private static String getItemTitle(String id) {
Expand All @@ -190,6 +200,8 @@ private static String getItemTitle(String id) {
return Localization.get("home.sync");
case SAVED_FORMS_ITEM_ID:
return Localization.get("home.menu.saved.forms");
case INCOMPLETE_FORMS_ITEM_ID:
return Localization.get("app.workflow.incomplete.heading");
case LOGOUT_DRAWER_ITEM_ID:
return Localization.get("home.logout");
case TRAINING_DRAWER_ITEM_ID:
Expand All @@ -216,6 +228,8 @@ private static int getItemIcon(String id) {
return R.drawable.ic_sync_nav_drawer;
case SAVED_FORMS_ITEM_ID:
return R.drawable.ic_saved_forms_nav_drawer;
case INCOMPLETE_FORMS_ITEM_ID:
return R.drawable.incomplete_nav_drawer;
case LOGOUT_DRAWER_ITEM_ID:
return R.drawable.ic_logout_nav_drawer;
case TRAINING_DRAWER_ITEM_ID:
Expand Down
31 changes: 14 additions & 17 deletions app/src/org/commcare/activities/InstallFromListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -12,13 +11,11 @@
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.ToggleButton;

import androidx.appcompat.widget.SwitchCompat;

import org.commcare.CommCareApplication;
import org.commcare.android.database.global.models.AppAvailableToInstall;
Expand All @@ -27,7 +24,6 @@
import org.commcare.core.network.AuthenticationInterceptor;
import org.commcare.dalvik.R;
import org.commcare.models.database.SqlStorage;
import org.commcare.modern.util.Pair;
import org.commcare.network.CommcareRequestGenerator;
import org.commcare.preferences.GlobalPrivilegesManager;
import org.commcare.tasks.ModernHttpTask;
Expand All @@ -48,11 +44,8 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import androidx.appcompat.widget.SwitchCompat;

import com.google.common.collect.ImmutableMultimap;

/**
Expand Down Expand Up @@ -95,14 +88,14 @@ public class InstallFromListActivity<T> extends CommCareActivity<T> implements H
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setInitialValues(savedInstanceState);
setupUI();
setupUi();
if (errorMessage != null) {
enterErrorState(errorMessage);
}
loadPreviouslyRetrievedAvailableApps();
}

private void setupUI() {
private void setupUi() {
setContentView(R.layout.user_get_available_apps);
errorMessageBox = findViewById(R.id.error_message);
authenticateView = findViewById(R.id.authenticate_view);
Expand Down Expand Up @@ -228,10 +221,11 @@ protected void onSaveInstanceState(Bundle savedInstanceState) {
}

/**
* Initiates remote request for an updated app list
* @return whether a request was initiated
*/
private boolean requestAppList(String username, String password) {
String urlToTry = getURLToTry();
String urlToTry = getUrlToTry();
if (urlToTry != null) {
this.lastUsernameUsed = username;
this.lastPasswordUsed = password;
Expand Down Expand Up @@ -286,7 +280,7 @@ private void setAttemptedRequestFlag() {
}
}

private String getURLToTry() {
private String getUrlToTry() {
if (!requestedFromProd) {
urlCurrentlyRequestingFrom = PROD_URL;
} else if (!requestedFromIndia) {
Expand All @@ -306,7 +300,7 @@ private void enterErrorState(String message) {
}

@Override
public void processSuccess(int responseCode, InputStream responseData) {
public void processSuccess(int responseCode, InputStream responseData, String apiVersion) {
processResponseIntoAppsList(responseData);
saveLastSuccessfulCredentials();
repeatRequestOrShowResultsAfterSuccess();
Expand All @@ -317,7 +311,8 @@ private void processResponseIntoAppsList(InputStream responseData) {
KXmlParser baseParser = ElementParser.instantiateParser(responseData);
List<AppAvailableToInstall> apps = (new AvailableAppsParser(baseParser)).parse();
availableApps.addAll(apps);
} catch (IOException | InvalidStructureException | XmlPullParserException | UnfullfilledRequirementsException e) {
} catch (IOException | InvalidStructureException |
XmlPullParserException |UnfullfilledRequirementsException e) {
Logger.log(LogTypes.TYPE_RESOURCES, "Error encountered while parsing apps available for install");
}
}
Expand Down Expand Up @@ -346,7 +341,8 @@ public void processOther(int responseCode) {
@Override
public void handleIOException(IOException exception) {
if (exception instanceof AuthenticationInterceptor.PlainTextPasswordException) {
Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE, "Encountered PlainTextPasswordException while sending get available apps request: Sending password over HTTP");
Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE,
"Encountered PlainTextPasswordException while sending get available apps request: Sending password over HTTP");
new UserfacingErrorHandling<>().createErrorDialog(this, Localization.get("auth.over.http"), true);
} else if (exception instanceof IOException) {
Logger.log(LogTypes.TYPE_ERROR_SERVER_COMMS,
Expand Down Expand Up @@ -418,7 +414,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
}

private void sortAppList() {
Collections.sort(this.availableApps, (o1, o2) -> o1.getAppName().toLowerCase().compareTo(o2.getAppName().toLowerCase()));
Collections.sort(this.availableApps,
(o1, o2) -> o1.getAppName().toLowerCase().compareTo(o2.getAppName().toLowerCase()));
}

@Override
Expand Down
Loading

0 comments on commit 6d210ad

Please sign in to comment.