Skip to content

Commit

Permalink
Merge pull request #2762 from dimagi/adjust-case-detail-display-text-…
Browse files Browse the repository at this point in the history
…when-empty

Adjust case detail display text column when empty
  • Loading branch information
avazirna authored Jun 24, 2024
2 parents 5da77f9 + ac51d60 commit 2aaaff2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/src/org/commcare/views/EntityDetailView.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package org.commcare.views;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import androidx.annotation.IdRes;
import android.text.method.LinkMovementMethod;
import android.view.Display;
import android.view.GestureDetector;
Expand All @@ -23,6 +20,9 @@
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.IdRes;
import androidx.appcompat.app.AppCompatActivity;

import org.commcare.activities.CommCareGraphActivity;
import org.commcare.cases.entity.Entity;
import org.commcare.core.graph.model.GraphData;
Expand Down Expand Up @@ -202,9 +202,16 @@ public void setParams(Detail d, Entity e, int index, int detailNumber) {
if (veryLong) {
detailRow.setOrientation(LinearLayout.VERTICAL);
spacer.setVisibility(View.GONE);
if (isLabelEmpty(labelText)) {
label.setVisibility(GONE);
}
label.setLayoutParams(fill);
valuePane.setLayoutParams(fill);
} else {
if (isLabelEmpty(labelText)) {
origLabel.weight = 0;
origValue.weight = detailRow.getWeightSum();
}
if (detailRow.getOrientation() != LinearLayout.HORIZONTAL) {
detailRow.setOrientation(LinearLayout.HORIZONTAL);
spacer.setVisibility(View.INVISIBLE);
Expand All @@ -214,6 +221,12 @@ public void setParams(Detail d, Entity e, int index, int detailNumber) {
}
}

// Empty case detail Display Texts are represented with an HTML non-breaking space (&nbsp). This was expanded
// to also check for blank spaces
private boolean isLabelEmpty(String text) {
return text.replaceAll("\\s| ", "").equals("");
}

private boolean setUpText(String textField) {
data.setText((textField));
updateCurrentView(TEXT, data);
Expand Down

0 comments on commit 2aaaff2

Please sign in to comment.