Skip to content

Commit

Permalink
Merge pull request #3 from simonpoole/fix_resources
Browse files Browse the repository at this point in the history
Use unique ids for strings and colors
  • Loading branch information
zedlabs authored Nov 12, 2021
2 parents 5e0beee + ae1d451 commit 8bb7604
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,22 @@ void addTagTable(TableLayout tl, Map<String, String> tagsA, Map<String, String>
//b also contains - add without bg color, add with change color for value change
TableRow tr = addTableRow(s.getKey(), s.getValue(), tagsB.get(s.getKey()), getActivity());
if (!s.getValue().equals(tagsB.get(s.getKey()))) {
tr.setBackgroundColor(getResources().getColor(R.color.color_table_change));
tr.setBackgroundColor(getResources().getColor(R.color.zed_ehd_color_table_change));
}
tl.addView(tr);

} else {
//b does not contain - add with red colo
TableRow tr = addTableRow(s.getKey(), s.getValue(), "", getActivity());
tr.setBackgroundColor(getResources().getColor(R.color.color_table_deletion));
tr.setBackgroundColor(getResources().getColor(R.color.zed_ehd_color_table_deletion));
tl.addView(tr);
}
}
for (Map.Entry<String, String> s : tagsB.entrySet()) {
if (!tagsA.containsKey(s.getKey())) {
//b contains a does not - add with green color
TableRow tr = addTableRow(s.getKey(), "", s.getValue(), getActivity());
tr.setBackgroundColor(getResources().getColor(R.color.color_table_addition));
tr.setBackgroundColor(getResources().getColor(R.color.zed_ehd_color_table_addition));
tl.addView(tr);
}
}
Expand All @@ -235,8 +235,8 @@ private void displayRelationData(View view) {
tl.setStretchAllColumns(true);
tl.addView(getCustomTableRow(
Arrays.asList(
getString(R.string.no_text), getString(R.string.role_text), getString(R.string.object_text),
getString(R.string.no_text), getString(R.string.role_text), getString(R.string.object_text)
getString(R.string.zed_ehd_no_text), getString(R.string.zed_ehd_role_text), getString(R.string.zed_ehd_object_text),
getString(R.string.zed_ehd_no_text), getString(R.string.zed_ehd_role_text), getString(R.string.zed_ehd_object_text)
),
getActivity()
)
Expand All @@ -255,21 +255,21 @@ void addRelationTableRows(TableLayout tl, List<RelationMember> a, List<RelationM
if (findInRelationList(b, a.get(i))) {
if (getIndexInList(b, a.get(i)) != -1) visited[getIndexInList(b, a.get(i))] = true;
//no change
String objectA = String.format(getString(R.string.relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
String objectB = String.format(getString(R.string.relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
tl.addView(getRelationTableRow(i, i, a.get(i).getRole(), a.get(i).getRole(), objectA, objectB, getResources().getColor(R.color.white)));
String objectA = String.format(getString(R.string.zed_ehd_relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
String objectB = String.format(getString(R.string.zed_ehd_relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
tl.addView(getRelationTableRow(i, i, a.get(i).getRole(), a.get(i).getRole(), objectA, objectB, getResources().getColor(R.color.zed_ehd_white)));
} else {
// value deleted
String objectA = String.format(getString(R.string.relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
tl.addView(getRelationTableRow(i, -1, a.get(i).getRole(), "-", objectA, "-", getResources().getColor(R.color.color_table_deletion)));
String objectA = String.format(getString(R.string.zed_ehd_relation_object_notation), a.get(i).getType(), String.valueOf(a.get(i).getRef()));
tl.addView(getRelationTableRow(i, -1, a.get(i).getRole(), "-", objectA, "-", getResources().getColor(R.color.zed_ehd_color_table_deletion)));
}
}

for (int i = 0; i < b.size(); i++) {
//value added
if (!visited[i]) {
String objectB = String.format(getString(R.string.relation_object_notation), b.get(i).getType(), String.valueOf(b.get(i).getRef()));
tl.addView(getRelationTableRow(-1, i, "-", b.get(i).getRole(), "-", objectB, getResources().getColor(R.color.color_table_addition)));
String objectB = String.format(getString(R.string.zed_ehd_relation_object_notation), b.get(i).getType(), String.valueOf(b.get(i).getRef()));
tl.addView(getRelationTableRow(-1, i, "-", b.get(i).getRole(), "-", objectB, getResources().getColor(R.color.zed_ehd_color_table_addition)));
}
}

Expand Down Expand Up @@ -298,7 +298,7 @@ private void displayWayData(View view) {

TableLayout tl = parent.findViewById(R.id.node_list_table);
tl.setStretchAllColumns(true);
tl.addView(getCustomTableRow(Arrays.asList(getString(R.string.no_text), getString(R.string.nodes_text), getString(R.string.no_text), getString(R.string.nodes_text)), getActivity()));
tl.addView(getCustomTableRow(Arrays.asList(getString(R.string.zed_ehd_no_text), getString(R.string.zed_ehd_nodes_text), getString(R.string.zed_ehd_no_text), getString(R.string.zed_ehd_nodes_text)), getActivity()));

List<String> nodesA = ((Way) elementA).getWayNodes();
List<String> nodesB = ((Way) elementB).getWayNodes();
Expand All @@ -313,33 +313,33 @@ void addWayTableRows(TableLayout tl, List<String> a, List<String> b) {
if (j < a.size() && k < b.size()) {
if (a.get(j).equals(b.get(k))) {
//no change
tl.addView(getWayTableRow(j, k, a.get(j), b.get(k), getResources().getColor(R.color.white)));
tl.addView(getWayTableRow(j, k, a.get(j), b.get(k), getResources().getColor(R.color.zed_ehd_white)));
j++;
k++;
} else if (!a.get(j).equals(b.get(k)) && !b.contains(a.get(j))) {
if (j == k && !a.contains(b.get(k))) {
// value change
tl.addView(getWayTableRow(j, k, a.get(j), b.get(k), getResources().getColor(R.color.color_table_change)));
tl.addView(getWayTableRow(j, k, a.get(j), b.get(k), getResources().getColor(R.color.zed_ehd_color_table_change)));
j++;
k++;
} else {
// value deleted
tl.addView(getWayTableRow(j, -1, a.get(j), "-", getResources().getColor(R.color.color_table_deletion)));
tl.addView(getWayTableRow(j, -1, a.get(j), "-", getResources().getColor(R.color.zed_ehd_color_table_deletion)));
j++;
}
} else if (!a.get(j).equals(b.get(k)) && b.contains(a.get(j))) {
//value added
tl.addView(getWayTableRow(-1, k, "-", b.get(k), getResources().getColor(R.color.color_table_addition)));
tl.addView(getWayTableRow(-1, k, "-", b.get(k), getResources().getColor(R.color.zed_ehd_color_table_addition)));
k++;
}
} else {
if (k < b.size() && !a.contains(b.get(k))) {
//value added
tl.addView(getWayTableRow(-1, k, "-", b.get(k), getResources().getColor(R.color.color_table_addition)));
tl.addView(getWayTableRow(-1, k, "-", b.get(k), getResources().getColor(R.color.zed_ehd_color_table_addition)));
k++;
} else if (j < a.size() && !b.contains(a.get(j))) {
// value deleted
tl.addView(getWayTableRow(j, -1, a.get(j), "-", getResources().getColor(R.color.color_table_deletion)));
tl.addView(getWayTableRow(j, -1, a.get(j), "-", getResources().getColor(R.color.zed_ehd_color_table_deletion)));
j++;
}
}
Expand Down Expand Up @@ -373,16 +373,16 @@ private void displayNodeData(View view) {
LinearLayout distance = ll.findViewById(R.id.distance_details);

if (((Node) elementA).getLat() == 0 && ((Node) elementA).getLon() == 0) {
lat1.setText(R.string.none);
lon1.setText(R.string.none);
lat1.setText(R.string.zed_ehd_none);
lon1.setText(R.string.zed_ehd_none);
} else {
lat1.setText(prettyPrint(((Node) elementA).getLat()));
lon1.setText(prettyPrint(((Node) elementA).getLon()));
}

if (((Node) elementB).getLat() == 0 && ((Node) elementB).getLon() == 0) {
lat2.setText(R.string.none);
lon2.setText(R.string.none);
lat2.setText(R.string.zed_ehd_none);
lon2.setText(R.string.zed_ehd_none);
} else {
lat2.setText(prettyPrint(((Node) elementB).getLat()));
lon2.setText(prettyPrint(((Node) elementB).getLon()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

c.setOnClickListener(v -> {
if (positionA == -1 || positionB == -1) {
Toast.makeText(requireContext(), R.string.select_a_b_toast, Toast.LENGTH_SHORT).show();
Toast.makeText(requireContext(), R.string.zed_ehd_select_a_b_toast, Toast.LENGTH_SHORT).show();
} else {
//navigate to comparison screen
OsmElement elementA = osmParser.getStorage().getAll().get(positionA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public static TableRow addTagTableHeading(Context ctx) {
TextView tv2 = new TextView(ctx);
TextView tv3 = new TextView(ctx);

tv1.setText(R.string.key_text);
tv2.setText(ctx.getString(R.string.version_a));
tv3.setText(ctx.getString(R.string.version_b));
tv1.setText(R.string.zed_ehd_key_text);
tv2.setText(ctx.getString(R.string.zed_ehd_version_a));
tv3.setText(ctx.getString(R.string.zed_ehd_version_b));

tv1.setTypeface(null, Typeface.BOLD);
tv2.setTypeface(null, Typeface.BOLD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
android:id="@+id/back_button_comparison"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:backgroundTint="@color/zed_ehd_white"
android:src="@drawable/back_arrow" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Element Comparison"
android:text="@string/zed_ehd_element_comparison_title"
android:textSize="18sp" />
</LinearLayout>
<ScrollView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:orientation="vertical">

<TextView
android:text="@string/selected_element_deleted"
android:text="@string/zed_ehd_selected_element_deleted"
android:layout_width="match_parent"
android:textAlignment="center"
android:textSize="20sp"
Expand All @@ -33,7 +33,7 @@
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/go_back"/>
android:text="@string/zed_ehd_go_back"/>

</LinearLayout>

Expand All @@ -59,7 +59,7 @@
android:gravity="center_horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="@string/version_text"
android:text="@string/zed_ehd_version_text"
android:textAlignment="center" />

<TextView
Expand All @@ -69,7 +69,7 @@
android:background="@drawable/table_header_border"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="@string/version_a"
android:text="@string/zed_ehd_version_a"
android:textAlignment="center" />

<TextView
Expand All @@ -79,7 +79,7 @@
android:background="@drawable/table_header_border"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="@string/version_b"
android:text="@string/zed_ehd_version_b"
android:textAlignment="center" />

<TextView
Expand All @@ -92,7 +92,7 @@
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:singleLine="true"
android:text="@string/user_text" />
android:text="@string/zed_ehd_user_text" />

<TextView
android:layout_width="0dp"
Expand All @@ -104,7 +104,7 @@
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:singleLine="true"
android:text="@string/date_text" />
android:text="@string/zed_ehd_date_text" />
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
Expand All @@ -126,13 +126,13 @@
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/compare_text" />
android:text="@string/zed_ehd_compare_text" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/exit_text" />
android:text="@string/zed_ehd_exit_text" />
</LinearLayout>

</LinearLayout>
Expand Down
12 changes: 6 additions & 6 deletions ElementHistoryDialog/src/main/res/layout/element_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:id="@+id/version_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/version" />
android:text="@string/zed_ehd_version" />

<TextView
android:id="@+id/version_number"
Expand All @@ -30,7 +30,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:text="@string/created_on" />
android:text="@string/zed_ehd_created_on" />

<TextView
android:id="@+id/date_created"
Expand All @@ -53,7 +53,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="@string/user" />
android:text="@string/zed_ehd_user" />

<TextView
android:id="@+id/username"
Expand All @@ -75,7 +75,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="@string/changeset" />
android:text="@string/zed_ehd_changeset" />

<TextView
android:id="@+id/changeset_version"
Expand Down Expand Up @@ -107,7 +107,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="@string/source" />
android:text="@string/zed_ehd_source" />

<TextView
android:id="@+id/source"
Expand All @@ -130,7 +130,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="@string/imagery" />
android:text="@string/zed_ehd_imagery" />

<TextView
android:id="@+id/imagery"
Expand Down
10 changes: 5 additions & 5 deletions ElementHistoryDialog/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_table_addition">#BFFABD</color>
<color name="color_table_deletion">#F38F8F</color>
<color name="color_table_change">#FBDEDE</color>
<color name="gray">#656262</color>
<color name="white">#FBFBFB</color>
<color name="zed_ehd_color_table_addition">#BFFABD</color>
<color name="zed_ehd_color_table_deletion">#F38F8F</color>
<color name="zed_ehd_color_table_change">#FBDEDE</color>
<color name="zed_ehd_gray">#656262</color>
<color name="zed_ehd_white">#FBFBFB</color>
</resources>
49 changes: 25 additions & 24 deletions ElementHistoryDialog/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="version">Version #</string>
<string name="created_on">Created on: </string>
<string name="user">User: </string>
<string name="changeset">Changeset: </string>
<string name="source">Source: </string>
<string name="imagery">Imagery: </string>
<string name="version_text">Ver</string>
<string name="version_a">A</string>
<string name="version_b">B</string>
<string name="user_text">User</string>
<string name="date_text">Date</string>
<string name="compare_text">Compare</string>
<string name="exit_text">Exit</string>
<string name="none">(none)</string>
<string name="relation_object_notation">%s %s</string>
<string name="empty_field">-</string>
<string name="key_text">KEY</string>
<string name="no_text">NO.</string>
<string name="role_text">ROLE</string>
<string name="object_text">OBJECT</string>
<string name="nodes_text">NODES</string>
<string name="go_back">Go Back</string>
<string name="selected_element_deleted">The Selected element has been deleted</string>
<string name="select_a_b_toast">Select version A &amp; B for comparison</string>
<string name="zed_ehd_version">Version #</string>
<string name="zed_ehd_created_on">Created on: </string>
<string name="zed_ehd_user">User: </string>
<string name="zed_ehd_changeset">Changeset: </string>
<string name="zed_ehd_source">Source: </string>
<string name="zed_ehd_imagery">Imagery: </string>
<string name="zed_ehd_version_text">Ver</string>
<string name="zed_ehd_version_a">A</string>
<string name="zed_ehd_version_b">B</string>
<string name="zed_ehd_user_text">User</string>
<string name="zed_ehd_date_text">Date</string>
<string name="zed_ehd_compare_text">Compare</string>
<string name="zed_ehd_exit_text">Exit</string>
<string name="zed_ehd_none">(none)</string>
<string name="zed_ehd_relation_object_notation">%s %s</string>
<string name="zed_ehd_empty_field">-</string>
<string name="zed_ehd_key_text">KEY</string>
<string name="zed_ehd_no_text">NO.</string>
<string name="zed_ehd_role_text">ROLE</string>
<string name="zed_ehd_object_text">OBJECT</string>
<string name="zed_ehd_nodes_text">NODES</string>
<string name="zed_ehd_go_back">Go Back</string>
<string name="zed_ehd_selected_element_deleted">The Selected element has been deleted</string>
<string name="zed_ehd_select_a_b_toast">Select version A &amp; B for comparison</string>
<string name="zed_ehd_element_comparison_title">Element Comparison</string>
</resources>

0 comments on commit 8bb7604

Please sign in to comment.