Skip to content

Commit

Permalink
fix translation bugs
Browse files Browse the repository at this point in the history
make satellitestreet layer default
add flexbox layout to wrap views
use jsonformactivity for flagproblem form (disable wizard form)
fix layout issue on treeviewdialog on small devices
update logout message on new assignments
  • Loading branch information
bennsimon committed Sep 9, 2021
1 parent eddde12 commit c140711
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 129 deletions.
4 changes: 2 additions & 2 deletions opensrp-eusm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ android {
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode 1
versionName "0.1.1"
versionName "0.1.2"
multiDexEnabled true
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "false"
Expand Down Expand Up @@ -218,7 +218,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation('org.smartregister:opensrp-client-native-form:2.1.3-r12-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:2.1.8-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
Expand Down
7 changes: 6 additions & 1 deletion opensrp-eusm/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />

<activity
android:name="com.vijay.jsonwizard.activities.JsonFormActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
Expand Down
3 changes: 3 additions & 0 deletions opensrp-eusm/src/main/assets/json.form/flag_problem.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"step1": {
"title": "{{flag_problem.step1.title}}",
"next": "step2",
"bottom_navigation": true,
"fields": [
{
"key": "flag_problem",
Expand Down Expand Up @@ -94,6 +95,8 @@
},
"step2": {
"title": "{{flag_problem.step2.title}}",
"bottom_navigation": true,
"previous": "step1",
"fields": [
{
"key": "product_picture",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.activities.JsonWizardFormActivity;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;
Expand Down Expand Up @@ -206,14 +207,14 @@ protected void openLooksGoodConfirmationDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.mark_as_looks_good_title);
builder.setMessage(R.string.looks_good_dialog_message);
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Do nothing
}
});

builder.setPositiveButton("Looks Good!", new DialogInterface.OnClickListener() {
builder.setPositiveButton(getString(R.string.looks_good_button_text), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//TODO add logic to update
Expand Down Expand Up @@ -257,15 +258,15 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
@Override
public void startForm(JSONObject jsonForm) {
Form form = new Form();
form.setWizard(true);
form.setWizard(false);
form.setName(getString(R.string.flag_problem_form_name));
form.setBackIcon(R.drawable.ic_action_close);
form.setSaveLabel(getString(R.string.save));
form.setActionBarBackground(R.color.primaryDark);
form.setNavigationBackground(R.color.primaryDark);
form.setHideSaveLabel(true);

Intent intent = new Intent(getActivity(), JsonWizardFormActivity.class);
Intent intent = new Intent(getActivity(), JsonFormActivity.class);
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, jsonForm.toString());
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form);
intent.putExtra(JsonFormConstants.PERFORM_FORM_TRANSLATION, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ public Pair<Double, Double> getMinMaxZoomMapDownloadPair() {
public List<BaseLayerSwitchModel> getBaseLayers() {
return Arrays.asList(
BaseLayerSwitchModel.builder().baseLayer(new DigitalGlobeLayer()).build(),
BaseLayerSwitchModel.builder().baseLayer(new MapBoxLayer()).isDefault(true).build(),
BaseLayerSwitchModel.builder().baseLayer(new MapBoxLayer()).build(),
BaseLayerSwitchModel.builder().baseLayer(new StreetsBaseLayer(EusmApplication.getInstance().getBaseContext())).build(),
BaseLayerSwitchModel.builder().baseLayer(new SatelliteStreetsLayer(EusmApplication.getInstance().getBaseContext())).build()
BaseLayerSwitchModel.builder().baseLayer(new SatelliteStreetsLayer(EusmApplication.getInstance().getBaseContext())).isDefault(true).build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.RasterSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.VectorSource;

Expand All @@ -31,14 +32,17 @@ public class SatelliteStreetsLayer extends BaseLayer {
private String streetSourceId = "composite";
private ArrayList<Source> sourcesList = new ArrayList<>();
private LinkedHashSet<Layer> layers = new LinkedHashSet<>();
private String satelliteSourceId = "mapbox://mapbox.satellite";

public SatelliteStreetsLayer(@NonNull Context context) {
createLayersAndSources(context);
}

protected void createLayersAndSources(@NonNull Context context) {
RasterSource rasterSource = new RasterSource(satelliteSourceId, satelliteSourceId, 256);
VectorSource streetSource = new VectorSource(streetSourceId, "mapbox://mapbox.mapbox-streets-v8,mapbox.mapbox-terrain-v2");
sourcesList.add(streetSource);
sourcesList.add(rasterSource);

LayerUtil layerUtil = new LayerUtil();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import androidx.annotation.NonNull;

import org.smartregister.eusm.helper.AppValidateAssignmentHelper;
import org.smartregister.eusm.util.EusmSyncUtils;
import org.smartregister.sync.intent.SyncIntentService;
import org.smartregister.util.SyncUtils;

public class AppSyncIntentService extends SyncIntentService {

@Override
protected void init(@NonNull Context context) {
super.init(context);
validateAssignmentHelper = new AppValidateAssignmentHelper(new SyncUtils(getBaseContext()));
validateAssignmentHelper = new AppValidateAssignmentHelper(new EusmSyncUtils(getBaseContext()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.smartregister.eusm.util;

import android.content.Context;
import android.content.Intent;

import androidx.annotation.NonNull;

import org.smartregister.AllConstants;
import org.smartregister.eusm.R;
import org.smartregister.util.SyncUtils;

import static org.smartregister.AllConstants.ACCOUNT_DISABLED;

public class EusmSyncUtils extends SyncUtils {

private Context context;

public EusmSyncUtils(Context context) {
super(context);
this.context = context;
}

@NonNull
@Override
protected Intent getLogoutUserIntent(int logoutMessage) {
Intent intent = super.getLogoutUserIntent(logoutMessage);
intent.removeExtra(ACCOUNT_DISABLED);
intent.putExtra(AllConstants.INTENT_KEY.DIALOG_MESSAGE, context.getString(logoutMessage));
intent.putExtra(AllConstants.INTENT_KEY.DIALOG_TITLE, context.getString(R.string.new_assignment_dialog_title));
return intent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public TreeNode.BaseNodeViewHolder<String> getNodeViewHolder(Context context, JS

@Override
public void updateTreeNode(int level, TreeNode curNode, TreeNode parentNode) {
curNode.setSelectable(level > 2);
curNode.setSelectable(level == 3);
boolean isSelected = operationalAreas.contains(curNode.getValue().toString());
curNode.setSelected(isSelected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand All @@ -25,6 +27,7 @@
import org.smartregister.tasking.util.PreferencesUtil;
import org.smartregister.tasking.view.DrawerMenuView;
import org.smartregister.util.LangUtils;
import org.smartregister.util.NetworkUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -162,17 +165,35 @@ public void showOperationalAreaSelector(Pair<String, ArrayList<String>> location
LinearLayout buttonLayout = new LinearLayout(getContext());
buttonLayout.setGravity(Gravity.CENTER);

LinearLayout.LayoutParams treeViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
LinearLayout treeViewLayout = new LinearLayout(getContext());
treeViewLayout.setOrientation(LinearLayout.VERTICAL);
treeViewLayout.setGravity(Gravity.CENTER);
treeViewLayout.setLayoutParams(treeViewLayoutParams);


LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Button okButton = new Button(getContext());
okButton.setLayoutParams(buttonLayoutParams);
okButton.setText(R.string.ok_text);
okButton.setTypeface(Typeface.DEFAULT_BOLD);
okButton.setTextColor(getContext().getResources().getColor(R.color.white));
okButton.setBackgroundResource(com.vijay.jsonwizard.R.drawable.btn_bg);
okButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, getContext().getResources()
.getDimension(com.vijay.jsonwizard.R.dimen.button_text_size));
okButton.setHeight(getContext().getResources().getDimensionPixelSize(com.vijay.jsonwizard.R.dimen.button_height));

buttonLayout.addView(okButton);
linearLayout.addView(buttonLayout);

ScrollView scrollView = (ScrollView) linearLayout.getChildAt(0);
View androidTreeView = scrollView.getChildAt(0);
scrollView.removeView(androidTreeView);
treeViewLayout.addView(androidTreeView);
treeViewLayout.addView(buttonLayout);
scrollView.addView(treeViewLayout);
linearLayout.removeView(scrollView);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(scrollView);

okButton.setOnClickListener(v -> {
List<String> selectedValues = treeViewDialog.getTreeView().getSelectedValues(String.class);
getPresenter().onOperationalAreaSelectorClicked(new ArrayList<>(selectedValues));
Expand All @@ -195,4 +216,11 @@ public void onDrawerOpened(@NonNull View drawerView) {
}
}
}

@Override
public void toggleProgressBarView(boolean syncing) {
super.toggleProgressBarView(syncing);
View flexBox = this.activity.getActivity().findViewById(R.id.flex_box);
flexBox.setVisibility((syncing && NetworkUtils.isNetworkAvailable()) ? View.GONE : View.VISIBLE);
}
}
56 changes: 35 additions & 21 deletions opensrp-eusm/src/main/res/layout/activity_product_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,33 @@
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="70dp"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="5dp"
android:weightSum="1">

<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/layout_product_looks_good"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="0.5"
android:background="@drawable/login_button_bg"
android:gravity="center"
android:paddingStart="11dp"
android:id="@+id/layout_product_looks_good"
android:paddingEnd="11dp">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:text="@string/looks_good_button_text"
android:textAllCaps="false"
android:textColor="@color/white"
Expand All @@ -174,29 +177,40 @@

<LinearLayout
android:id="@+id/layout_flag_problem"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:layout_weight="0.44"
android:layout_weight="0.5"
android:background="@drawable/structure_task_action_bg"
android:gravity="center"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_baseline_warning"
android:textAllCaps="false" />
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/flex_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
app:justifyContent="center">

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/flag_problem_button_text"
android:textColor="#FFB000"
android:textSize="@dimen/activity_title_size"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="3dp"
android:src="@drawable/ic_baseline_warning" />

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:gravity="center"
android:paddingBottom="3dp"
android:text="@string/flag_problem_button_text"
android:textColor="#FFB000"
android:textSize="@dimen/activity_title_size"
android:textStyle="bold" />
</com.google.android.flexbox.FlexboxLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Expand Down
Loading

0 comments on commit c140711

Please sign in to comment.