Skip to content

Commit

Permalink
Replaced lots of words with icons
Browse files Browse the repository at this point in the history
Fixed an issue where default trait value wasn't being saved
Added a dialog when importing trait lists and current list hasn't been exported
Added location trait
  • Loading branch information
trife authored and trife committed Feb 10, 2017
1 parent 0a68507 commit cd6f9d6
Show file tree
Hide file tree
Showing 52 changed files with 605 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public void onClick(DialogInterface dialog, int which) {
}

// Only used for truncating lat long values
private String truncateDecimalString(String v) {
public String truncateDecimalString(String v) {
int count = 0;

boolean found = false;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/fieldbook/tracker/DataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ public Cursor convertDatabaseToTable(String[] col, String[] traits) {

for (int i = 0; i < traits.length; i++) {
traitArgs[i] = "m" + i + ".userValue as '" + traits[i] + "'";
joinArgs = joinArgs + "LEFT JOIN user_traits m" + i + " ON range." + TICK +ep.getString("ImportUniqueName", "")
+TICK + " = m" + i + ".rid AND m" + i + ".parent = '" + traits[i] + "' ";
joinArgs = joinArgs + "LEFT JOIN user_traits m" + i + " ON range." + TICK + ep.getString("ImportUniqueName", "")
+ TICK + " = m" + i + ".rid AND m" + i + ".parent = '" + traits[i] + "' ";
}

query = "SELECT " + convertToCommaDelimited(rangeArgs) + " , " + convertToCommaDelimited(traitArgs) +
" FROM range range " + joinArgs + "GROUP BY range." +TICK + ep.getString("ImportUniqueName", "")+TICK;
" FROM range range " + joinArgs + "GROUP BY range." + TICK + ep.getString("ImportUniqueName", "") + TICK + "ORDER BY range.id";

Log.i("DH", query);

Expand Down
196 changes: 168 additions & 28 deletions app/src/main/java/com/fieldbook/tracker/MainActivity.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public void onClick(View arg0) {

try {
// Create the sql query based on user selection
//TODO add ticks

String sql1 = "select range.id, range." + TICK + ep.getString("ImportFirstName", "") + TICK + "," + " range." + TICK + ep.getString("ImportSecondName", "") + TICK + " from range where range.id is not null ";
String sql2 = "select range.id, range." + TICK + ep.getString("ImportFirstName", "") + TICK + "," + "range." + TICK + ep.getString("ImportSecondName", "") + TICK + " from traits, range, user_traits where user_traits.rid = range." + TICK + ep.getString("ImportUniqueName", "") + TICK + " and user_traits.parent = traits.trait and user_traits.trait = traits.format ";

Expand Down
50 changes: 47 additions & 3 deletions app/src/main/java/com/fieldbook/tracker/Trait/TraitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public long getItemId(int position) {

private class ViewHolder {
TextView name;
TextView format;
ImageView format;
CheckBox visible;
ImageView dragSort;
ImageView menuPopup;
Expand All @@ -77,7 +77,7 @@ public View getView(final int position, View convertView, final ViewGroup parent

holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.text1);
holder.format = (TextView) convertView.findViewById(R.id.text2);
holder.format = (ImageView) convertView.findViewById(R.id.traitType);
holder.visible = (CheckBox) convertView.findViewById(R.id.visible);
holder.dragSort = (ImageView) convertView.findViewById(R.id.dragSort);
holder.menuPopup = (ImageView) convertView.findViewById(R.id.popupMenu);
Expand All @@ -90,7 +90,51 @@ public View getView(final int position, View convertView, final ViewGroup parent
holder.id = getItem(position).id;
holder.realPosition = getItem(position).realPosition;
holder.name.setText(getItem(position).trait);
holder.format.setText(getItem(position).format);

switch (getItem(position).format) {
case "numeric":
holder.format.setBackgroundResource(R.drawable.ic_numeric);
break;
case "categorical":
holder.format.setBackgroundResource(R.drawable.ic_categorical);
break;
case "date":
holder.format.setBackgroundResource(R.drawable.ic_today);
break;
case "percent":
holder.format.setBackgroundResource(R.drawable.ic_percent);
break;
case "boolean":
holder.format.setBackgroundResource(R.drawable.ic_cancel);
break;
case "text":
holder.format.setBackgroundResource(R.drawable.ic_text);
break;
case "photo":
holder.format.setBackgroundResource(R.drawable.ic_camera);
break;
case "audio":
holder.format.setBackgroundResource(R.drawable.ic_audio);
break;
case "counter":
holder.format.setBackgroundResource(R.drawable.ic_counter);
break;
case "disease rating":
holder.format.setBackgroundResource(R.drawable.ic_bug);
break;
case "rust rating":
holder.format.setBackgroundResource(R.drawable.ic_bug);
break;
case "multicat":
holder.format.setBackgroundResource(R.drawable.ic_multicat);
break;
case "location":
holder.format.setBackgroundResource(R.drawable.ic_location);
break;
default:
holder.format.setBackgroundResource(R.drawable.ic_reorder);
break;
}

// Check or uncheck the list items
if (visibility != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ public void onCreate(Bundle savedInstanceState) {

thisActivity = this;

final String[] data = new String[11];
final String[] enData = new String[11];
final String[] data = new String[12];
final String[] enData = new String[12];

data[0] = getString(R.string.numeric);
data[1] = getString(R.string.qualitative);
Expand All @@ -309,6 +309,7 @@ public void onCreate(Bundle savedInstanceState) {
data[8] = getString(R.string.counter);
data[9] = getString(R.string.rustrating);
data[10] = getString(R.string.multicategorical);
data[11] = getString(R.string.location_trait);

enData[0] = "Numeric";
enData[1] = "Categorical";
Expand All @@ -321,6 +322,7 @@ public void onCreate(Bundle savedInstanceState) {
enData[8] = "Counter";
enData[9] = "Disease Rating";
enData[10] = "Multicat";
enData[11] = "Location";

HashMap visibility = MainActivity.dt.getTraitVisibility();
traitList = (DragSortListView) findViewById(R.id.myList);
Expand Down Expand Up @@ -585,6 +587,7 @@ public void onClick(View arg0) {

Editor ed = ep.edit();
ed.putBoolean("CreateTraitFinished", true);
ed.putBoolean("TraitsExported", false);
ed.apply();

loadData();
Expand Down Expand Up @@ -769,6 +772,13 @@ private void prepareFields(int position) {
maxBox.setVisibility(View.GONE);
categoryBox.setVisibility(View.VISIBLE);
break;
case 11: //location
defBox.setVisibility(View.GONE);
minBox.setVisibility(View.GONE);
maxBox.setVisibility(View.GONE);
bool.setVisibility(View.GONE);
categoryBox.setVisibility(View.GONE);
break;
}
}

Expand Down Expand Up @@ -919,7 +929,11 @@ private void importExportDialog() {
public void onItemClick(AdapterView<?> av, View arg1, int which, long arg3) {
switch (which) {
case 0:
showImportDialog();
if(ep.getBoolean("TraitsExported",false)) {
showImportDialog();
} else {
checkTraitExportDialog();
}
break;
case 1:
showExportDialog();
Expand All @@ -941,6 +955,38 @@ public void onClick(View arg0) {
importExport.show();
}

private void checkTraitExportDialog() {
String[] allTraits = MainActivity.dt.getTraitColumnData("trait");

if (allTraits == null) {
makeToast(getString(R.string.createtraitserror));
return;
}

AlertDialog.Builder builder = new AlertDialog.Builder(TraitEditorActivity.this, R.style.AppAlertDialog);
builder.setMessage(getString(R.string.trait_export_check));

builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
showExportDialog();
dialog.dismiss();
}

});

builder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
showImportDialog();
dialog.dismiss();
}

});

AlertDialog alert = builder.create();
alert.show();
}

private void sortDialog() {
String[] allTraits = MainActivity.dt.getTraitColumnData("trait");

Expand Down Expand Up @@ -1088,6 +1134,9 @@ public void onClick(View v) {

public void onClick(View arg0) {
exportTable(exportFile.getText().toString());
Editor ed = ep.edit();
ed.putBoolean("TraitsExported", true);
ed.apply();
exportDialog.dismiss();
}
});
Expand Down
Binary file added app/src/main/res/drawable-hdpi/ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_delete_forever.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_delete_forever.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/ic_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/src/main/res/layout-sw600dp/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
android:gravity="right"
android:paddingRight="10dp"
android:text="@string/range"
android:maxLength="10"
android:textColor="@color/s_text"
android:textSize="@dimen/text_size_xlarge"
android:textStyle="bold" />
Expand All @@ -259,6 +260,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:padding="0dp"
android:maxLength="10"
android:singleLine="true"
android:text=""
android:textColor="#000000"
Expand Down Expand Up @@ -440,6 +442,11 @@
layout="@layout/trait_multicat"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

<include
layout="@layout/trait_location"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>

Expand Down
45 changes: 24 additions & 21 deletions app/src/main/res/layout-sw600dp/trait_audio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,31 @@
android:orientation="vertical"
android:visibility="gone">

<Button
android:id="@+id/record"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minWidth="150dp"
android:text="@string/record"
android:textColor="#000000"
android:textSize="@dimen/text_size_large"
android:textStyle="bold" />
android:gravity="center_horizontal"
android:orientation="horizontal">

<Button
android:id="@+id/clearRecord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minWidth="150dp"
android:text="@string/clear"
android:textColor="#000000"
android:textSize="@dimen/text_size_large"
android:textStyle="bold" />
<ImageButton
android:id="@+id/clearRecord"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:scaleType="fitXY"
android:src="@drawable/ic_delete_forever" />

<ImageButton
android:id="@+id/record"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:scaleType="fitXY"
android:src="@drawable/ic_delete_forever" />

</LinearLayout>
</LinearLayout>
19 changes: 9 additions & 10 deletions app/src/main/res/layout-sw600dp/trait_boolean.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
android:layout_gravity="center_horizontal"
android:src="@drawable/boolean_true" />

<Button
<ImageButton
android:id="@+id/clearBoolean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:minWidth="150dp"
android:text="@string/clear"
android:textColor="#000000"
android:textSize="@dimen/text_size_large"
android:textStyle="bold" />
android:layout_width="75dp"
android:layout_height="75dp"
android:scaleType="fitXY"
android:padding="10dp"
android:layout_gravity="center"
android:src="@drawable/ic_delete_forever"
android:gravity="center" />

</LinearLayout>
18 changes: 8 additions & 10 deletions app/src/main/res/layout-sw600dp/trait_categorical.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,14 @@

</GridLayout>

<Button
<ImageButton
android:id="@+id/clearCatBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="75dp"
android:layout_height="75dp"
android:scaleType="fitXY"
android:padding="10dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:gravity="center"
android:minWidth="@dimen/button_default_width"
android:text="@string/clear"
android:textColor="#000000"
android:textSize="@dimen/text_size_large"
android:textStyle="bold" />
android:src="@drawable/ic_delete_forever"
android:gravity="center" />

</LinearLayout>
Loading

0 comments on commit cd6f9d6

Please sign in to comment.