diff --git a/FieldNotebook/AndroidManifest.xml b/FieldNotebook/AndroidManifest.xml
index 4286988..635122e 100644
--- a/FieldNotebook/AndroidManifest.xml
+++ b/FieldNotebook/AndroidManifest.xml
@@ -6,7 +6,7 @@
+ android:targetSdkVersion="18" />
+ android:value="AIzaSyBdeI8o1yoFSz6ckRB1_czLCiuXv7FPuzI" />
+
+
\ No newline at end of file
diff --git a/FieldNotebook/project.properties b/FieldNotebook/project.properties
index 928645e..ca7d21b 100644
--- a/FieldNotebook/project.properties
+++ b/FieldNotebook/project.properties
@@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-15
+target=Google Inc.:Google APIs:19
android.library.reference.1=../../android-maps-extensions/android-maps-extensions
diff --git a/FieldNotebook/res/drawable-hdpi/add_picture.png b/FieldNotebook/res/drawable-hdpi/add_picture.png
new file mode 100644
index 0000000..6cf79b5
Binary files /dev/null and b/FieldNotebook/res/drawable-hdpi/add_picture.png differ
diff --git a/FieldNotebook/res/drawable-hdpi/device_access_camera.png b/FieldNotebook/res/drawable-hdpi/device_access_camera.png
new file mode 100644
index 0000000..b119b19
Binary files /dev/null and b/FieldNotebook/res/drawable-hdpi/device_access_camera.png differ
diff --git a/FieldNotebook/res/layout/activity_main.xml b/FieldNotebook/res/layout/activity_main.xml
index bcbdbb6..7e97ec0 100644
--- a/FieldNotebook/res/layout/activity_main.xml
+++ b/FieldNotebook/res/layout/activity_main.xml
@@ -6,7 +6,7 @@
diff --git a/FieldNotebook/res/layout/field.xml b/FieldNotebook/res/layout/field.xml
index 050dc6d..4d33fc7 100644
--- a/FieldNotebook/res/layout/field.xml
+++ b/FieldNotebook/res/layout/field.xml
@@ -31,18 +31,5 @@
android:layout_below="@+id/field_row1"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp">
-
\ No newline at end of file
diff --git a/FieldNotebook/res/layout/fragment_add_field.xml b/FieldNotebook/res/layout/fragment_add_field.xml
index b34b2cc..19f7b6f 100644
--- a/FieldNotebook/res/layout/fragment_add_field.xml
+++ b/FieldNotebook/res/layout/fragment_add_field.xml
@@ -14,14 +14,19 @@
-
+ android:layout_weight="20" />
+
+
+
+
+
+
-
-
-
-
-
-
+ android:gravity="center"
+ android:orientation="horizontal">
+
\ No newline at end of file
diff --git a/FieldNotebook/res/layout/fragment_drawing.xml b/FieldNotebook/res/layout/fragment_drawing.xml
index 044b294..ff4e239 100644
--- a/FieldNotebook/res/layout/fragment_drawing.xml
+++ b/FieldNotebook/res/layout/fragment_drawing.xml
@@ -1,80 +1,81 @@
+ android:background="#EEE"
+ android:clickable="true" >
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_marginBottom="5dp"
+ android:layout_marginTop="5dp" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FieldNotebook/res/layout/fragment_sidebar.xml b/FieldNotebook/res/layout/fragment_sidebar.xml
index d562efe..cf03af9 100644
--- a/FieldNotebook/res/layout/fragment_sidebar.xml
+++ b/FieldNotebook/res/layout/fragment_sidebar.xml
@@ -61,26 +61,6 @@
android:layout_alignParentLeft="true"
android:layout_below="@+id/sidebar_layTitleRow1"
android:paddingBottom ="10dp" >
-
-
+ android:layout_alignParentTop="true"
+ android:visibility="gone">
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ android:layout_height="match_parent"
+ android:layout_below="@+id/sidebar_layMenuFields"/>
-
+
\ No newline at end of file
diff --git a/FieldNotebook/res/layout/note_open.xml b/FieldNotebook/res/layout/note_open.xml
index b633058..688fe45 100644
--- a/FieldNotebook/res/layout/note_open.xml
+++ b/FieldNotebook/res/layout/note_open.xml
@@ -10,7 +10,7 @@
android:id="@+id/note_open_note"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
0) {
- intAcres = Integer.parseInt(strAcres);
- }
- listener.AddFieldDone(name.getText().toString(), intAcres);
+// String strAcres = acres.getText().toString();
+// strAcres = strAcres.replace(" ", "");
+// strAcres = strAcres.replace("ac", "");
+// if (strAcres.length() > 0) {
+// intAcres = Integer.parseInt(strAcres);
+// }
+ listener.AddFieldDone(name.getText().toString());
} else if (v.getId() == R.id.add_field_undo) {
listener.AddFieldUndo();
} else if (v.getId() == R.id.add_field_delete) {
@@ -166,28 +166,34 @@ public void onClick(DialogInterface dialog,
}
}
- public void autoAcres(float acres){
+/* public void autoAcres(float acres){
Log.d("FragmentAddField", "autoAcres:" + Float.toString(acres));
autoAcresValue = acres;
if(this.autoAcres != null && this.autoAcres.isChecked()){
int newAcres = (int) acres;
this.acres.setText(Integer.toString(newAcres) + " ac");
}
- }
+ }*/
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- Log.d("FragmentAddField", "Check click");
- if(buttonView.getId() == R.id.add_field_chkAutoAcres){
- Log.d("FragmentAddField", "Check Auto acres");
- if(isChecked){
- Log.d("FragmentAddField", "Checked");
- int newAcres = (int) autoAcresValue;
- this.acres.setText(Integer.toString(newAcres) + " ac");
- this.acres.setEnabled(false);
- } else {
- this.acres.setEnabled(true);
- }
- }
+ public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
+ // TODO Auto-generated method stub
+
}
+
+// @Override
+// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+// Log.d("FragmentAddField", "Check click");
+// if(buttonView.getId() == R.id.add_field_chkAutoAcres){
+// Log.d("FragmentAddField", "Check Auto acres");
+// if(isChecked){
+// Log.d("FragmentAddField", "Checked");
+// int newAcres = (int) autoAcresValue;
+// this.acres.setText(Integer.toString(newAcres) + " ac");
+// this.acres.setEnabled(false);
+// } else {
+// this.acres.setEnabled(true);
+// }
+// }
+// }
}
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/FragmentDrawing.java b/FieldNotebook/src/com/openatk/fieldnotebook/FragmentDrawing.java
index 65935ff..1d4832d 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/FragmentDrawing.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/FragmentDrawing.java
@@ -16,7 +16,7 @@ public class FragmentDrawing extends Fragment implements OnClickListener {
private ImageButton butPoint = null;
private ImageButton butPolyline = null;
private ImageButton butPolygon = null;
- private ImageButton butColor = null;
+// private ImageButton butColor = null;
private ImageButton butCamera = null;
// Interface for receiving data
@@ -37,9 +37,9 @@ public void setPolylineIcon(int resId){
public void setPolygonIcon(int resId){
this.butPolygon.setImageResource(resId);
}
- public void setColorIcon(int resId){
- this.butColor.setImageResource(resId);
- }
+// public void setColorIcon(int resId){
+// this.butColor.setImageResource(resId);
+// }
public void setCameraIcon(int resId){
this.butCamera.setImageResource(resId);
}
@@ -52,13 +52,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
butPoint = (ImageButton) view.findViewById(R.id.fragment_drawing_butPoint);
butPolyline = (ImageButton) view.findViewById(R.id.fragment_drawing_butLine);
butPolygon = (ImageButton) view.findViewById(R.id.fragment_drawing_butPolygon);
- butColor = (ImageButton) view.findViewById(R.id.fragment_drawing_butColor);
- butCamera = (ImageButton) view.findViewById(R.id.fragment_drawing_butPicture);
+// butColor = (ImageButton) view.findViewById(R.id.fragment_drawing_butColor);
+ butCamera = (ImageButton) view.findViewById(R.id.note_take_picture);
butPoint.setOnClickListener(this);
butPolyline.setOnClickListener(this);
butPolygon.setOnClickListener(this);
- butColor.setOnClickListener(this);
+// butColor.setOnClickListener(this);
butCamera.setOnClickListener(this);
return view;
@@ -93,9 +93,9 @@ public void onClick(View v) {
listener.DrawingClickPolyline();
} else if (v.getId() == R.id.fragment_drawing_butPolygon) {
listener.DrawingClickPolygon();
- } else if (v.getId() == R.id.fragment_drawing_butColor) {
- listener.DrawingClickColor();
- } else if (v.getId() == R.id.fragment_drawing_butPicture) {
+// } else if (v.getId() == R.id.fragment_drawing_butColor) {
+// listener.DrawingClickColor();
+ } else if (v.getId() == R.id.note_take_picture) {
listener.DrawingClickCamera();
}
}
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/MainActivity.java b/FieldNotebook/src/com/openatk/fieldnotebook/MainActivity.java
index 0ca5b81..7e665ea 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/MainActivity.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/MainActivity.java
@@ -5,31 +5,21 @@
import java.util.List;
import android.app.AlertDialog;
-import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Point;
import android.location.Location;
import android.location.LocationManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
-import android.text.Editable;
-import android.text.TextWatcher;
import android.util.Log;
-import android.util.TypedValue;
-import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -38,17 +28,12 @@
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Transformation;
-import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
-import android.widget.ScrollView;
-import android.widget.Spinner;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
@@ -58,12 +43,9 @@
import com.google.android.gms.maps.GoogleMap.OnMarkerDragListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
-import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
-import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolygonOptions;
import com.openatk.fieldnotebook.FragmentAddField.AddFieldListener;
import com.openatk.fieldnotebook.db.DatabaseHelper;
@@ -77,35 +59,32 @@
import com.openatk.fieldnotebook.notelist.NoteListListener;
import com.openatk.fieldnotebook.sidebar.FragmentSidebar;
import com.openatk.fieldnotebook.sidebar.SidebarListener;
-import com.openatk.fieldnotebook.slider.FragmentSlider;
-import com.openatk.fieldnotebook.slider.SliderListener;
public class MainActivity extends FragmentActivity implements OnClickListener,
- OnMapClickListener, OnItemSelectedListener, OnMarkerClickListener, OnMarkerDragListener,
- AddFieldListener, SliderListener, SidebarListener, NoteListListener, FieldListListener, MyPolygonListener {
-
+OnMapClickListener, OnItemSelectedListener, OnMarkerClickListener, OnMarkerDragListener,
+AddFieldListener, SidebarListener, NoteListListener, FieldListListener, MyPolygonListener {
+
private static String TAG = MainActivity.class.getName();
-
+
private SupportMapFragment fragmentMap;
private GoogleMap map;
private UiSettings mapSettings;
-
-
- //Startup position
- private static final float START_LAT = 40.428712f;
- private static final float START_LNG = -86.913819f;
- private static final float START_ZOOM = 17.0f;
+
+
+ //Startup position
+ private static final float START_LAT = 40.428712f;
+ private static final float START_LNG = -86.913819f;
+ private static final float START_ZOOM = 17.0f;
private Menu menu;
private DatabaseHelper dbHelper;
-
+
private int mCurrentState = 0;
-
+
private int sliderIsShowing = 0;
private int addIsShowing = 0;
private int drawingIsShowing = 0;
-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult:" + Integer.toString(requestCode));
@@ -133,38 +112,38 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
private List FieldsOnMap = null;
String addingBoundary = "";
-
+
FragmentAddField fragmentAddField = null;
- FragmentSlider fragmentSlider = null;
+ FragmentSidebar fragmentSlider = null;
FragmentSidebar fragmentSidebar = null;
FragmentDrawing fragmentDrawing = null;
FragmentNoteList fragmentNoteList = null;
FragmentFieldList fragmentFieldList = null;
ViewGroup vgSidebar = null;
-
-
+
+
private static final int STATE_DEFAULT = 0;
private static final int STATE_LIST_VIEW = 1;
-
+
//Trello
- //SyncController syncController;
- //TrelloController trelloController;
-
+ //SyncController syncController;
+ //TrelloController trelloController;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
-
+
dbHelper = new DatabaseHelper(this);
-
+
FragmentManager fm = getSupportFragmentManager();
fragmentMap = (SupportMapFragment) fm.findFragmentById(R.id.map);
- fragmentSlider = (FragmentSlider) fm.findFragmentByTag(FragmentSlider.class.getName());
+ fragmentSlider = (FragmentSidebar) fm.findFragmentByTag(FragmentSidebar.class.getName());
if(fragmentSlider != null){
sliderIsShowing = 1;
}
-
+
if (savedInstanceState == null) {
// First incarnation of this activity.
fragmentMap.setRetainInstance(true);
@@ -177,9 +156,9 @@ protected void onCreate(Bundle savedInstanceState) {
checkGPS();
//Trello
- //trelloController = new TrelloController(getApplicationContext());
- //syncController = new SyncController(getApplicationContext(), trelloController, this);
- //trelloController.setSyncController(syncController);
+ //trelloController = new TrelloController(getApplicationContext());
+ //syncController = new SyncController(getApplicationContext(), trelloController, this);
+ //trelloController.setSyncController(syncController);
// Get last selected operation
if (savedInstanceState != null) {
@@ -187,7 +166,7 @@ protected void onCreate(Bundle savedInstanceState) {
currentField = FindFieldById(savedInstanceState.getInt("currentField"));
this.addingBoundary = savedInstanceState.getString("drawingBoundary", "");
}
-
+
vgSidebar = (ViewGroup) findViewById(R.id.fragment_container_sidebar);
if (vgSidebar != null) {
Log.i(TAG, "onCreate: adding FragmentSidebar to MainActivity");
@@ -202,7 +181,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
setUpMapIfNeeded();
-
+
Intent intent = this.getIntent();
String todo = intent.getStringExtra("todo");
if(todo != null){
@@ -210,7 +189,7 @@ protected void onCreate(Bundle savedInstanceState) {
//trelloController.sync();
}
}
-
+
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
@@ -253,9 +232,9 @@ protected void onSaveInstanceState(Bundle outState) {
outState.putString("drawingBoundary", strNewBoundary);
}
}
-
+
if (currentField != null) outState.putInt("currentField", currentField.getId());
-
+
outState.putInt("mCurrentState", mCurrentState);
outState.putInt("sliderIsShowing",sliderIsShowing);
outState.putInt("addIsShowing",addIsShowing);
@@ -274,7 +253,7 @@ private void setUpMapIfNeeded() {
mapSettings.setZoomControlsEnabled(false);
mapSettings.setMyLocationButtonEnabled(false);
mapSettings.setTiltGesturesEnabled(false);
-
+
map.setOnMapClickListener(this);
map.setOnMarkerClickListener(this);
map.setOnMarkerDragListener(this);
@@ -282,22 +261,22 @@ private void setUpMapIfNeeded() {
map.setMyLocationEnabled(true);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- Float startLat = prefs.getFloat("StartupLat", START_LAT);
- Float startLng = prefs.getFloat("StartupLng", START_LNG);
- Float startZoom = prefs.getFloat("StartupZoom", START_ZOOM);
- map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(startLat,startLng) , startZoom));
+ Float startLat = prefs.getFloat("StartupLat", START_LAT);
+ Float startLng = prefs.getFloat("StartupLng", START_LNG);
+ Float startZoom = prefs.getFloat("StartupZoom", START_ZOOM);
+ map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(startLat,startLng) , startZoom));
}
drawMap();
}
-
-
+
+
@Override
protected void onPause() {
super.onPause();
- //trelloController.stopAutoSync();
-
- CameraPosition myCam = map.getCameraPosition();
+ //trelloController.stopAutoSync();
+
+ CameraPosition myCam = map.getCameraPosition();
if(myCam != null){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = prefs.edit();
@@ -313,7 +292,7 @@ protected void onPause() {
protected void onResume() {
super.onResume();
checkGPS();
- //trelloController.startAutoSync();
+ //trelloController.startAutoSync();
}
@Override
@@ -327,13 +306,13 @@ protected void onNewIntent(Intent intent) {
}
}
-
+
@Override
public void onMapClick(LatLng position) {
if(this.fragmentNoteList == null){
this.fragmentNoteList = this.getFragmentNoteList();
}
-
+
if (addIsShowing == 1 || addingNotePolygon) {
Log.d("HERE", "Here1");
// Add points to polygon
@@ -351,7 +330,7 @@ public void onMapClick(LatLng position) {
if(fragmentSlider != null){
//fragmentSlider.flushChangesAndSave(false); //Save changes to all open notes
}
-
+
// Check if touched a field
Boolean touched = false;
for (int i = 0; i < FieldsOnMap.size(); i++) {
@@ -395,7 +374,7 @@ public void onMapClick(LatLng position) {
}
}
}
-
+
private void ExitField(){
if (this.currentPolygon != null) {
// Set back to unselected
@@ -405,7 +384,7 @@ private void ExitField(){
if(this.fragmentNoteList == null) this.fragmentNoteList = this.getFragmentNoteList();
if(this.fragmentSidebar == null) this.fragmentSidebar = this.getFragmentSidebar();
if(this.fragmentFieldList == null) this.fragmentFieldList = this.getFragmentFieldList();
-
+
if(this.fragmentNoteList != null) this.fragmentNoteList.onClose();
if(this.fragmentSidebar != null) this.fragmentSidebar.populateData(null, this.fragmentMap.getView());
if(this.fragmentFieldList != null) this.fragmentFieldList.populateData(null);
@@ -416,7 +395,7 @@ private void drawMap() {
drawFields();
}
-
+
private void drawFields() {
SQLiteDatabase database = dbHelper.getReadableDatabase();
String[] columns = { TableFields.COL_ID, TableFields.COL_BOUNDARY, TableFields.COL_NAME, TableFields.COL_DELETED };
@@ -426,9 +405,9 @@ private void drawFields() {
while (cursor.moveToNext()) {
String boundary = cursor.getString(cursor.getColumnIndex(TableFields.COL_BOUNDARY));
List points = Field.StringToBoundary(boundary);
-
+
if(points.size() == 0) points = null;
-
+
// Add to list so we can catch click events
Field newField = new Field();
newField.setId(cursor.getInt(cursor.getColumnIndex(TableFields.COL_ID)));
@@ -521,50 +500,50 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
} else if(item.getItemId() == R.id.main_menu_help){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle("Help");
- WebView wv = new WebView(this);
- wv.loadUrl("file:///android_asset/Help.html");
- wv.getSettings().setSupportZoom(true);
- wv.getSettings().setBuiltInZoomControls(true);
- wv.setWebViewClient(new WebViewClient()
- {
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url)
- {
- view.loadUrl(url);
- return true;
- }
- });
- alert.setView(wv);
- alert.setNegativeButton("Close", null);
- alert.show();
+ alert.setTitle("Help");
+ WebView wv = new WebView(this);
+ wv.loadUrl("file:///android_asset/Help.html");
+ wv.getSettings().setSupportZoom(true);
+ wv.getSettings().setBuiltInZoomControls(true);
+ wv.setWebViewClient(new WebViewClient()
+ {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url)
+ {
+ view.loadUrl(url);
+ return true;
+ }
+ });
+ alert.setView(wv);
+ alert.setNegativeButton("Close", null);
+ alert.show();
} else if(item.getItemId() == R.id.main_menu_legal){
CharSequence licence= "The MIT License (MIT)\n" +
- "\n" +
- "Copyright (c) 2013 Purdue University\n" +
- "\n" +
- "Permission is hereby granted, free of charge, to any person obtaining a copy " +
- "of this software and associated documentation files (the \"Software\"), to deal " +
- "in the Software without restriction, including without limitation the rights " +
- "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell " +
- "copies of the Software, and to permit persons to whom the Software is " +
- "furnished to do so, subject to the following conditions:" +
- "\n" +
- "The above copyright notice and this permission notice shall be included in " +
- "all copies or substantial portions of the Software.\n" +
- "\n" +
- "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR " +
- "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " +
- "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " +
- "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " +
- "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, " +
- "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN " +
- "THE SOFTWARE.\n";
+ "\n" +
+ "Copyright (c) 2013 Purdue University\n" +
+ "\n" +
+ "Permission is hereby granted, free of charge, to any person obtaining a copy " +
+ "of this software and associated documentation files (the \"Software\"), to deal " +
+ "in the Software without restriction, including without limitation the rights " +
+ "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell " +
+ "copies of the Software, and to permit persons to whom the Software is " +
+ "furnished to do so, subject to the following conditions:" +
+ "\n" +
+ "The above copyright notice and this permission notice shall be included in " +
+ "all copies or substantial portions of the Software.\n" +
+ "\n" +
+ "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR " +
+ "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " +
+ "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " +
+ "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " +
+ "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, " +
+ "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN " +
+ "THE SOFTWARE.\n";
new AlertDialog.Builder(this)
- .setTitle("Legal")
- .setMessage(licence)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setPositiveButton("Close", null).show();
+ .setTitle("Legal")
+ .setMessage(licence)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setPositiveButton("Close", null).show();
}
return true;
}
@@ -707,7 +686,7 @@ private void hideAdd(Boolean transition) {
this.invalidateOptionsMenu();
}
-
+
private Void showSlider(Boolean transition) {
if(addIsShowing == 1){
hideAdd(false);
@@ -716,33 +695,43 @@ private Void showSlider(Boolean transition) {
sliderIsShowing = 1;
// Set height back to wrap, in case add buttons or something
FrameLayout layout = (FrameLayout) findViewById(R.id.fragment_container_slider);
+
if(layout != null){
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
- params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
- layout.setLayoutParams(params);
- FragmentManager fm = getSupportFragmentManager();
- this.fragmentSlider = new FragmentSlider();
- FragmentTransaction ft = fm.beginTransaction();
- if (transition) ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down);
- ft.add(R.id.fragment_container_slider, this.fragmentSlider, FragmentSlider.class.getName());
- ft.commit();
- Log.d("MainActivity", "Showing Slider:" + FragmentSlider.class.getName());
+ if (fragmentSlider == null) {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
+ params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
+ layout.setLayoutParams(params);
+ FragmentManager fm = getSupportFragmentManager();
+ this.fragmentSlider = new FragmentSidebar();
+ FragmentTransaction ft = fm.beginTransaction();
+ if (transition) ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down);
+ ft.add(R.id.fragment_container_slider, this.fragmentSlider, FragmentSidebar.class.getName());
+ ft.commit();
+ } else {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
+ params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
+ layout.setLayoutParams(params);
+ FragmentManager fm = getSupportFragmentManager();
+ FragmentTransaction ft = fm.beginTransaction();
+ if (transition) ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down);
+ ft.show(this.fragmentSlider);
+ ft.commit();
+ }
}
}
this.invalidateOptionsMenu();
return null;
}
- private void hideSlider(Boolean transition) {
+ void hideSlider(Boolean transition) {
if (sliderIsShowing == 1) {
sliderIsShowing = 0;
if(fragmentNoteList == null){
this.fragmentNoteList = this.getFragmentNoteList();
}
- if(fragmentNoteList != null) fragmentNoteList.onClose();
-
+ //if(fragmentNoteList != null) fragmentNoteList.onClose();
FragmentManager fm = getSupportFragmentManager();
- FragmentSlider fragment = (FragmentSlider) fm.findFragmentByTag(FragmentSlider.class.getName());
+ FragmentSidebar fragment = (FragmentSidebar) fm.findFragmentByTag(FragmentSidebar.class.getName());
// Set height so transition works TODO 3 different heights?? Get from fragment, fragment.getMyHeight?
FrameLayout layout = (FrameLayout) findViewById(R.id.fragment_container_slider);
if(layout != null){
@@ -753,16 +742,16 @@ private void hideSlider(Boolean transition) {
// Do transition
FragmentTransaction ft = fm.beginTransaction();
if (transition) ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down);
- ft.remove(fragment);
+ ft.hide(fragment);
ft.commit();
}
- fragmentSlider = null;
+ // fragmentSlider = null;
}
this.invalidateOptionsMenu();
}
-
-
-
+
+
+
@Override
public Field AddFieldGetCurrentField() {
return this.currentField;
@@ -774,7 +763,7 @@ public void AddFieldUndo() {
}
@Override
- public void AddFieldDone(String name, Integer acres) {
+ public void AddFieldDone(String name) {
// Check if field name is valid and doesn't exist already
if (name.length() == 0) {
// Tell them to input a name
@@ -790,7 +779,7 @@ public void AddFieldDone(String name, Integer acres) {
this.currentPolygon.complete();
this.currentPolygon.setLabel(name, true);
this.currentPolygon.setFillColor(Field.FILL_COLOR_NOT_PLANNED);
-
+
List points = this.currentPolygon.getPoints();
Boolean wasAnEdit = false;
if (currentField == null) {
@@ -800,9 +789,9 @@ public void AddFieldDone(String name, Integer acres) {
wasAnEdit = true;
}
currentField.setName(name);
- currentField.setAcres(acres);
+ // currentField.setAcres(acres);
- Log.d("MainActivity", "Acres:" + Integer.toString(acres));
+ // Log.d("MainActivity", "Acres:" + Integer.toString(acres));
String strNewBoundary = "";
if(points != null && points.isEmpty() == false){
// Generate boundary
@@ -822,9 +811,9 @@ public void AddFieldDone(String name, Integer acres) {
ContentValues values = new ContentValues();
values.put(TableFields.COL_NAME, currentField.getName());
- values.put(TableFields.COL_ACRES, currentField.getAcres());
+// values.put(TableFields.COL_ACRES, currentField.getAcres());
values.put(TableFields.COL_BOUNDARY, strNewBoundary);
-
+
//TODO only update if something changed
values.put(TableFields.COL_HAS_CHANGED, 1);
values.put(TableFields.COL_DATE_CHANGED, DatabaseHelper.dateToStringUTC(new Date()));
@@ -839,7 +828,7 @@ public void AddFieldDone(String name, Integer acres) {
values,
TableFields.COL_ID + " = "
+ Integer.toString(currentField.getId()),
- null);
+ null);
}
dbHelper.close();
@@ -853,14 +842,14 @@ public void AddFieldDone(String name, Integer acres) {
if (FieldsOnMap.get(i).getId() == currentField.getId()) {
FieldsOnMap.get(i).setName(name);
FieldsOnMap.get(i).setPolygon(this.currentPolygon);
- FieldsOnMap.get(i).setAcres(acres);
+ // FieldsOnMap.get(i).setAcres(acres);
FieldsOnMap.get(i).setBoundary(points);
}
}
}
-
+
showSlider(true);
-
+
// add or update in list view
//if (this.fragmentListView != null) this.fragmentListView.getData();
//this.trelloController.syncDelayed();
@@ -880,7 +869,7 @@ public void AddFieldDelete() {
values.put(TableFields.COL_DATE_CHANGED, DatabaseHelper.dateToStringUTC(new Date()));
String where = TableFields.COL_ID + " = "+ Integer.toString(currentField.getId());
database.update(TableFields.TABLE_NAME, values, where, null);
-
+
dbHelper.close();
for(int i=0; i arg0, View arg1, int arg2,
@Override
public void onNothingSelected(AdapterView> arg0) {
-
+
}
-
+
// --------------------------------- FragmentNoteList ----------------------------------
private MyPolygon saveFieldPolygon = null;
private Boolean addingNotePolygon = false;
@@ -1026,6 +1015,18 @@ private FragmentNoteList getFragmentNoteList(){
return (FragmentNoteList) fm.findFragmentByTag(FragmentNoteList.class.getName());
}
+ @Override
+ public void NoteListUpdatePolygon(int fieldId, PolygonOptions polygonOptions){
+ for(int i=0; i boundary;
private LatLngBounds boundingBox = null;
private Integer deleted = 0;
@@ -125,9 +125,9 @@ public String getName() {
return name;
}
- public Integer getAcres() {
- return acres;
- }
+// public Integer getAcres() {
+// return acres;
+// }
public List getBoundary() {
return boundary;
@@ -161,9 +161,9 @@ public void setName(String name) {
this.name = name;
}
- public void setAcres(Integer acres) {
- this.acres = acres;
- }
+// public void setAcres(Integer acres) {
+// this.acres = acres;
+// }
public void setBoundary(List boundary) {
this.boundary = boundary;
@@ -201,7 +201,7 @@ public static Field cursorToField(Cursor cursor){
field.setDateChanged(cursor.getString(cursor.getColumnIndex(TableFields.COL_DATE_CHANGED)));
String boundary = cursor.getString(cursor.getColumnIndex(TableFields.COL_BOUNDARY));
field.setBoundary(Field.StringToBoundary(boundary));
- field.setAcres(cursor.getInt(cursor.getColumnIndex(TableFields.COL_ACRES)));
+// field.setAcres(cursor.getInt(cursor.getColumnIndex(TableFields.COL_ACRES)));
field.setName(cursor.getString(cursor.getColumnIndex(TableFields.COL_NAME)));
field.setDeleted(cursor.getInt(cursor.getColumnIndex(TableFields.COL_DELETED)));
return field;
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/db/Note.java b/FieldNotebook/src/com/openatk/fieldnotebook/db/Note.java
index 6e628f8..80c1c71 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/db/Note.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/db/Note.java
@@ -8,8 +8,10 @@
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Color;
+import android.util.Log;
import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolygonOptions;
import com.google.android.gms.maps.model.PolylineOptions;
@@ -34,8 +36,10 @@ public class Note {
private List polylines = null;
private String strMarkers = null;
+ private String strImageMarkers;
private List myMarkers = new ArrayList();
private List images = new ArrayList();
+ private List imageMarkers = new ArrayList();
//private List lines;
@@ -127,6 +131,9 @@ public void removePolyline(MyPolyline poly){
public void addMyMarker(MyMarker marker){
this.myMarkers.add(marker);
}
+ public void addImageMarker(Marker imageMarker) {
+ this.imageMarkers.add(imageMarker);
+ }
public void myMarkersToStringMarkers(){
StringBuilder build = new StringBuilder();
for(int i=0; i 0){
+ build.deleteCharAt(build.length() - 1);
+ }
+ this.strImageMarkers = build.toString();
+ }
+
+ public void removeImageMarkers(){
+ for(int i=0; i getMyPolylines() {
return this.myPolylines;
}
+ public String getStrImageMarkers() {
+ return this.strImageMarkers;
+ }
public String getStrMarkers() {
return this.strMarkers;
@@ -255,6 +291,27 @@ public List getMarkers() {
}
return markers;
}
+ public List getImageMarkers() {
+ //Convert strImageMarkers to markers
+ List markers = new ArrayList();
+ String all = this.getStrImageMarkers();
+ if (all != null) {
+ Log.w("all", all);
+ } else {
+ Log.w("all", "all null");
+ }
+ if(all != null){
+ StringTokenizer tokensPoints = new StringTokenizer(all, ",");
+ while (tokensPoints.hasMoreTokens()) {
+ MarkerOptions options = new MarkerOptions();
+ String lat = tokensPoints.nextToken();
+ String lng = tokensPoints.nextToken();
+ options.position(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)));
+ markers.add(options);
+ }
+ }
+ return markers;
+ }
public List getMyMarkers() {
return this.myMarkers;
}
@@ -307,6 +364,9 @@ public void setPolylines(List polys) {
public void setStrMarkers(String str) {
this.strMarkers = str;
}
+ public void setStrImageMarkers(String str) {
+ this.strImageMarkers = str;
+ }
public void setColor(Integer color) {
for(int i=0; i notes = null;
-
+
private DatabaseHelper dbHelper;
private Note currentNote = null;
OpenNoteView currentOpenNoteView = null;
private RelativeLayout currentNoteView = null;
-
+ private Bitmap imageBitmap;
+ private Bitmap bitmap;
+ private File image;
+
LayoutInflater vi;
-
+
private Boolean addingPolygon = false;
private Boolean addingPolyline = false;
private Boolean addingPoint = false;
private Boolean addingNote = false; //Or editing note
-
+
private MyPolyline currentPolyline = null;
private MyMarker currentPoint = null;
private String imagePath = null;
private Image currentImage = null; //Current image for imageviewer
-
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -121,19 +133,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
false);
me = this;
-
+
svNotes = (ScrollAutoView) view.findViewById(R.id.note_list_scrollView);
listNotes = (LinearLayout) view.findViewById(R.id.note_list_listNotes);
-
+
dbHelper = new DatabaseHelper(this.getActivity());
vi = (LayoutInflater) this.getActivity().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return view;
}
-
+
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
-
+
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof NoteListListener) {
// Check if parent fragment (if there is one) is listener
@@ -154,7 +166,7 @@ else if (listener == null) {
}
Log.d("FragmentNoteList", "Attached");
}
-
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -164,39 +176,48 @@ public void onActivityCreated(Bundle savedInstanceState) {
public void populateData(Integer currentFieldId, GoogleMap map) {
Log.d("FragmentNoteList", "PopulateData");
this.map = map;
-
- //Clear current
+
+ // Clear current
listNotes.removeAllViews();
this.onClose();
-
- //Get current field
+
+ // Get current field
currentField = null;
- if(currentFieldId != null){
+ if (currentFieldId != null) {
currentField = Field.FindFieldById(dbHelper.getReadableDatabase(), currentFieldId);
dbHelper.close();
}
if (currentField != null) {
+
//Add all notes for this field
notes = Note.FindNotesByFieldName(dbHelper.getReadableDatabase(), currentField.getName());
dbHelper.close();
- for(int i=0; i myPolygons = note.getMyPolygons();
if(myPolygons.isEmpty()){
@@ -248,19 +273,21 @@ private View inflateNote(Note note){
note.addMyPolygon(new MyPolygon(map, newPolygon)); //Adds back my polygons
}
} else {
- for(int i =0; i myPolylines = note.getMyPolylines();
- if(myPolylines.isEmpty()){
- List polylines = note.getPolylines(); //Gets map polygons
- for(int i=0; i polylines = note.getPolylines(); // Gets map
+ // polygons
+ for (int i = 0; i < polylines.size(); i++) {
+ note.addMyPolyline(new MyPolyline(map.addPolyline(polylines
+ .get(i)), map)); // Adds back my polygons
}
} else {
- for(int i =0; i images = note.getImages();
+ for (int i = 0; i < images.size(); i++) {
+ try {
+ ExifInterface exifInt = new ExifInterface(images.get(i).getPath());
+ imageBitmap = BitmapFactory.decodeByteArray(exifInt.getThumbnail(),0,exifInt.getThumbnail().length);
+ imageBitmap = Bitmap.createScaledBitmap(imageBitmap, imageBitmap.getWidth()/2,imageBitmap.getHeight()/2, false);
+ float[] ltlng = new float[2];
+ exifInt.getLatLong(ltlng);
+ LatLng picLoc = new LatLng(ltlng[0],ltlng[1]);
+ Log.w("bitmap null", Boolean.toString(imageBitmap == null));
+ Log.w("bitmap descriptor", Boolean.toString(BitmapDescriptorFactory.fromBitmap(imageBitmap) == null));
+// map.addMarker(new MarkerOptions().position(picLoc).icon(BitmapDescriptorFactory.fromBitmap(imageBitmap)));
+ note.addImageMarker(map.addMarker(new MarkerOptions().position(picLoc).icon(BitmapDescriptorFactory.fromBitmap(imageBitmap))));
+// note.addMyMarker(new MyMarker(marker, map));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
note.setColor(note.getColor());
noteView.imgColor.setBackgroundColor(note.getColor());
-
+
+
//Show icon and draw number on icon
Integer numberOfPolygons = note.getMyPolygons().size();
if(numberOfPolygons == 0){
@@ -328,18 +377,19 @@ private View inflateNote(Note note){
BitmapDrawable ob = new BitmapDrawable(getResources(), bitmap);
noteView.imgPoints.setBackgroundDrawable(ob);
}
-
noteView.me = view;
view.setTag(noteView);
return view;
}
-
- private OnClickListener noteClickListener = new OnClickListener(){
+
+ // a random comment
+
+ private OnClickListener noteClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
NoteView noteView = (NoteView) v.getTag();
if(v.getId() == R.id.note_butShowHide){
-
+
} else if(v.getId() == R.id.note_txtComment){
if(addingNote == false){
addingNote = true;
@@ -348,18 +398,22 @@ public void onClick(View v) {
newView.etComment.requestFocus();
//Show keyboard
InputMethodManager inputMethodManager = (InputMethodManager) me.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- if (inputMethodManager != null) {
- inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
- }
+ if (inputMethodManager != null) {
+ inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
}
} else if(v.getId() == R.id.note){
if(addingNote == false){
addingNote = true;
+
openNote(noteView);
+
}
+
}
+
}
-
+
private OpenNoteView openNote(NoteView noteView){
svNotes.setScrollingEnabled(false);
svNotes.scrollToAfterAdd(noteView.me.getTop());
@@ -377,9 +431,10 @@ private OpenNoteView openNote(NoteView noteView){
return currentOpenNoteView;
}
};
-
+
+
static class NoteView
- {
+ {
ImageView imgColor;
ImageButton butShowHide;
TextView tvComment;
@@ -391,9 +446,11 @@ static class NoteView
RelativeLayout layNote;
Note note;
View me;
- }
-
+
+ }
+
private View inflateOpenNote(Note note){
+
View view = vi.inflate(R.layout.note_open, null);
final OpenNoteView noteView = new OpenNoteView();
noteView.layFullNote = (RelativeLayout) view.findViewById(R.id.note_open_note);
@@ -406,11 +463,11 @@ private View inflateOpenNote(Note note){
noteView.svObjects = (HorizontalScrollView) view.findViewById(R.id.note_open_sv_objects);
noteView.etComment.setText(note.getComment());
-
+
List polygons = note.getMyPolygons();
List polylines = note.getMyPolylines();
List markers = note.getMyMarkers();
-
+
for(int i=0; i images = note.getImages();
if(images != null){
@@ -434,11 +491,10 @@ private View inflateOpenNote(Note note){
for(int i=0; i allNotes = Note.FindNotesByFieldName(dbHelper.getReadableDatabase(), note.getFieldName());
+ for (int z = 0; z < allNotes.size(); z++) {
+ Note aNote = allNotes.get(z);
+ if(aNote.getId() != note.getId()) {
+ // Get all the polygons, add their vertices to the bounding box
+ List listPolygons = aNote.getPolygons();
+ Log.w("ListPolygons is empty:", Boolean.toString(listPolygons.isEmpty()) + " " + note.getComment());
+ for (int i = 0; i < listPolygons.size(); i++) {
+ List points = listPolygons.get(i).getPoints();
+ for (int j = 0; j < points.size(); j++) {
+ builder.include(points.get(j));
+ }
+ }
+
+ // Do the same thing with the polylines
+ List listPolyline = aNote.getPolylines();
+ for (int p = 0; p < listPolyline.size(); p++) {
+ List points = listPolyline.get(p).getPoints();
+ for (int u = 0; u < points.size(); u++) {
+ builder.include(points.get(u));
+ }
+ }
+
+ // Do the same thing with the markers
+ List listMyMarker= aNote.getMarkers();
+ for (int p = 0; p < listMyMarker.size(); p++) {
+ builder.include(listMyMarker.get(p).getPosition());
+ }
+
+ List listImageMarker = aNote.getImageMarkers();
+ Log.w("imagemarkers A", listImageMarker.toString());
+ for (int p = 0; p < listImageMarker.size(); p++) {
+ builder.include(listImageMarker.get(p).getPosition());
+ }
+ }
+ }
+
+ // Get all the polygons, add their vertices to the bounding box
+ List listPolygons = note.getMyPolygons();
+ for (int i = 0; i < listPolygons.size(); i++) {
+ List points = listPolygons.get(i).getPoints();
+ for (int j = 0; j < points.size(); j++) {
+ builder.include(points.get(j));
+ }
+ }
+
+ // Do the same thing with the polylines
+ List listPolyline = note.getMyPolylines();
+ for (int p = 0; p < listPolyline.size(); p++) {
+ List points = listPolyline.get(p).getPoints();
+ for (int u = 0; u < points.size(); u++) {
+ builder.include(points.get(u));
+ }
+ }
+
+ // Do the same thing with the markers
+ List listMyMarker= note.getMyMarkers();
+ for (int p = 0; p < listMyMarker.size(); p++) {
+ builder.include(listMyMarker.get(p).getPosition());
+ }
+
+ List listImageMarker = note.getImageMarkers();
+ Log.w("imagemarkers B", listImageMarker.toString());
+ for (int p = 0; p < listImageMarker.size(); p++) {
+ builder.include(listImageMarker.get(p).getPosition());
+ }
+
+ // Create the boundary, get the borders, convert to a string
+ try {
+ LatLngBounds bounds = builder.build();
+ LatLng northeast = bounds.northeast;
+ LatLng southwest = bounds.southwest;
+ String newFieldBoundary = Double.toString(southwest.latitude) + ","
+ + Double.toString(southwest.longitude) + ","
+ + Double.toString(southwest.latitude) + ","
+ + Double.toString(northeast.longitude) + ","
+ + Double.toString(northeast.latitude) + ","
+ + Double.toString(northeast.longitude) + ","
+ + Double.toString(northeast.latitude) + ","
+ + Double.toString(southwest.longitude);// and so on
+
+ // Update the database with the new boundary value:
+ ContentValues valuesField = new ContentValues();
+ valuesField.put(TableFields.COL_BOUNDARY, newFieldBoundary);
+ String whereField = TableFields.COL_NAME + "= '" + note.getFieldName()
+ + "'";
+ database.update(TableFields.TABLE_NAME, valuesField, whereField, null);
+
+ // Now draw this field
+ // Create polygon
+
+ List points = Field.StringToBoundary(newFieldBoundary);
+
+ if(points != null && points.isEmpty() == false) {
+ PolygonOptions polygonOptions = new PolygonOptions();
+ polygonOptions.fillColor(Field.FILL_COLOR_NOT_PLANNED);
+ polygonOptions.strokeWidth(Field.STROKE_WIDTH);
+ polygonOptions.strokeColor(Field.STROKE_COLOR);
+ for (int i = 0; i < points.size(); i++) {
+ polygonOptions.add(points.get(i));
+ }
+ if (currentField == null) {
+ Log.w("currentfield", "sdf");
+ } else if (currentField.getPolygon() == null) {
+ Log.w("currentfield get poly", "ok");
+ }
+ this.listener.NoteListUpdatePolygon(currentField.getId(), polygonOptions);
+ }
+ }
+ catch (IllegalStateException e){
+ }
+
//TODO more stuff
if(note.getId() == null){
//New note
Integer newId = (int) database.insert(TableNotes.TABLE_NAME, null, values);
note.setId(newId);
} else {
- //Editing note
+ // Editing note
String where = TableNotes.COL_ID + " = " + note.getId();
database.update(TableNotes.TABLE_NAME, values, where, null);
}
-
+
List images = note.getImages();
if(images != null){
for(int i=0; i 0){
+
+ public boolean hasNotes() {
+ if (notes != null && notes.size() > 0) {
return true;
} else {
return false;
}
}
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.slider_butShowElevation) {
-
- } else if (v.getId() == R.id.slider_butShowSoilType) {
-
- }
- }
-
+ // @Override
+ // public void onClick(View v) {
+ //
+ // if (v.getId() == R.id.slider_butShowElevation) {
+ //
+ //
+ // } else if (v.getId() == R.id.slider_butShowSoilType) {
+ //
+ // }
+ // }
+
+
public boolean isAddingNote(){
+
return this.addingNote;
}
-
+
private OnMapClickListener sliderMapClickListener = new OnMapClickListener(){
@Override
public void onMapClick(LatLng arg0) {
@@ -731,9 +938,8 @@ public void DrawingClickPolyline() {
map.setOnMapClickListener((OnMapClickListener) listener);
map.setOnMarkerClickListener((OnMarkerClickListener) listener);
map.setOnMarkerDragListener((OnMarkerDragListener) listener);
-
+
if(currentNote != null){
- //TODO handle edit finish? Maybe not, i think i removed on edit?
currentPolyline.setColor(Field.STROKE_COLOR);
currentNote.addMyPolyline(currentPolyline); //Adds a myPolyline
}
@@ -761,24 +967,24 @@ public void DrawingClickColor() {
builder.setTitle("Pick a color");
CharSequence colors[] = {"Red", "Yellow", "Blue", "Green"};
builder.setItems(colors, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- int intColor = Color.GREEN;
- if(which == 0){
- //Red
- intColor = Color.RED;
- } else if(which == 1){
- //Yellow
- intColor = Color.YELLOW;
- } else if(which == 2){
- //Blue
- intColor = Color.BLUE;
- } else {
- //Green
- intColor = Color.GREEN;
- }
- //redraw polygons/polylines/points with new color
- currentNote.setColor(intColor);
- }
+ public void onClick(DialogInterface dialog, int which) {
+ int intColor = Color.GREEN;
+ if(which == 0){
+ //Red
+ intColor = Color.RED;
+ } else if(which == 1){
+ //Yellow
+ intColor = Color.YELLOW;
+ } else if(which == 2){
+ //Blue
+ intColor = Color.BLUE;
+ } else {
+ //Green
+ intColor = Color.GREEN;
+ }
+ //redraw polygons/polylines/points with new color
+ currentNote.setColor(intColor);
+ }
});
AlertDialog dialog = builder.create();
dialog.show();
@@ -786,154 +992,167 @@ public void onClick(DialogInterface dialog, int which) {
@Override
public void DrawingClickCamera() {
- // path to /data/data/yourapp/app_data/imageDir
- String file = UUID.randomUUID().toString() + ".jpg"; //Random filename
- // Create imageDir
- File f = new File(this.getActivity().getFilesDir(), file);
- imagePath = f.getAbsolutePath();
- //Create new file
- FileOutputStream fos;
+ // path to /data/data/yourapp/app_data/imageDir
+ String file = UUID.randomUUID().toString() + ".jpg"; //Random filename
+ // Create imageDir
+ File f = new File(this.getActivity().getFilesDir(), file);
+ imagePath = f.getAbsolutePath();
+ //Create new file
+ FileOutputStream fos;
+ try {
+ fos = this.getActivity().openFileOutput(file, Context.MODE_WORLD_WRITEABLE);
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ //Get reference to the file
+ File newf = new File(this.getActivity().getFilesDir(), file);
+
+ Uri outputFileUri = Uri.fromFile(newf);
+ Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
+ this.getActivity().startActivityForResult(cameraIntent, 999);
+}
+public void ImageCaptured(){
+ if(imagePath != null){
+ Log.d(TAG, "ImageCaptured");
+ Bitmap fullImage = BitmapFactory.decodeFile(imagePath);
+ Bitmap thumb = ThumbnailUtils.extractThumbnail(fullImage, 100, 100);
+ ImageView img = new ImageView(this.getActivity());
+ img.setOnClickListener(imageClickListener);
+ img.setTag(new Image(thumb, imagePath));
+
+ float scale = getResources().getDisplayMetrics().density;
+ int dpAsPixels = (int) (7*scale + 0.5f); //Margin
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ layoutParams.setMargins(dpAsPixels, 0, dpAsPixels, 0);
+
+ Drawable d = new BitmapDrawable(getResources(), thumb);
+ img.setBackgroundDrawable(d);
+ this.currentOpenNoteView.layObjects.addView(img, layoutParams);
+
+ //Save path and thumbnail in database
+ if(currentNote != null){
+ currentNote.addImage(thumb, imagePath);
+ }
try {
- fos = this.getActivity().openFileOutput(file, Context.MODE_WORLD_WRITEABLE);
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
+ ExifInterface exifInt = new ExifInterface(imagePath);
+ imageBitmap = Bitmap.createScaledBitmap(thumb, thumb.getWidth()/2,thumb.getHeight()/2, false);
+ float[] ltlng = new float[2];
+ exifInt.getLatLong(ltlng);
+ LatLng picLoc = new LatLng(ltlng[0],ltlng[1]);
+ currentNote.addImageMarker(map.addMarker(new MarkerOptions().position(picLoc).icon(BitmapDescriptorFactory.fromBitmap(imageBitmap))));
} catch (IOException e) {
e.printStackTrace();
}
- //Get reference to the file
- File newf = new File(this.getActivity().getFilesDir(), file);
-
- Uri outputFileUri = Uri.fromFile(newf);
- Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
- this.getActivity().startActivityForResult(cameraIntent, 999);
}
- public void ImageCaptured(){
- if(imagePath != null){
- Log.d(TAG, "ImageCaptured");
- Bitmap fullImage = BitmapFactory.decodeFile(imagePath);
- Bitmap thumb = ThumbnailUtils.extractThumbnail(fullImage, 100, 100);
- ImageView img = new ImageView(this.getActivity());
- img.setOnClickListener(imageClickListener);
- img.setTag(new Image(thumb, imagePath));
-
- float scale = getResources().getDisplayMetrics().density;
- int dpAsPixels = (int) (7*scale + 0.5f); //Margin
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- layoutParams.setMargins(dpAsPixels, 0, dpAsPixels, 0);
-
- Drawable d = new BitmapDrawable(getResources(), thumb);
- img.setBackgroundDrawable(d);
- this.currentOpenNoteView.layObjects.addView(img, layoutParams);
-
- //Save path and thumbnail in database
- if(currentNote != null){
- currentNote.addImage(thumb, imagePath);
- }
- }
- }
- private OnClickListener imageClickListener = new OnClickListener(){
- @Override
- public void onClick(View v) {
- currentImage = (Image) v.getTag();
- int height = currentOpenNoteView.layFullNote.getHeight();
- currentOpenNoteView.layFullNote.setVisibility(View.GONE);
- currentOpenNoteView.layImageView.setVisibility(View.VISIBLE);
- //currentOpenNoteView.me.setBackgroundResource(R.drawable.note_image_viewer);
-
- // Gets the layout params that will allow you to resize the layout
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) currentOpenNoteView.layImageView.getLayoutParams();
- // Changes the height and width to the specified *pixels*
- params.height = height;
- currentOpenNoteView.layImageView.setLayoutParams(params);
-
- // Prepare a transaction to add fragments to this fragment
- FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
- // Add the list fragment to this fragment's layout
- Log.i(TAG, "onCreate: adding FragmentNoteList to FragmentSidebar");
- // Add the fragment to the this fragment's container layout
- FragmentImageViewer fragmentImageViewer = new FragmentImageViewer();
- fragmentTransaction.replace(currentOpenNoteView.layImageView.getId(), fragmentImageViewer, FragmentImageViewer.class.getName());
- // Commit the transaction
- fragmentTransaction.commit();
- }
- };
+}
+private OnClickListener imageClickListener = new OnClickListener(){
@Override
- public void ImageViewerRequestData(FragmentImageViewer requester) {
- if(this.currentNote != null){
- requester.populateData(this.currentNote.getImages(), currentImage);
- }
- }
- @Override
- public void ImageViewerDone(Image image) {
- currentOpenNoteView.layFullNote.setVisibility(View.VISIBLE);
- currentOpenNoteView.layImageView.setVisibility(View.GONE);
- //currentOpenNoteView.me.setBackgroundResource(R.drawable.note);
- }
- public Boolean AddNote() {
- if(addingNote == false){
- Log.d("FragmentNoteList", "AddNote");
- this.addingNote = true;
- //Add a new note
- Note newNote = new Note(currentField.getName());
- notes.add(newNote);
- currentNote = newNote;
-
- View newView = inflateOpenNote(newNote);
- currentOpenNoteView = (OpenNoteView) newView.getTag();
- listNotes.addView(newView, 0);
- listener.NoteListAddNote();
-
- svNotes.scrollTo(0, 0);
- //InputMethodManager inputMethodManager = (InputMethodManager) this.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- //inputMethodManager.showSoftInput(newOpenNote.etComment, 0);
-
- //Show drawing fragment
- fragmentDrawing = listener.NoteListShowDrawing();
- fragmentDrawing.setListener(me);
- return true;
- }
- return false;
+ public void onClick(View v) {
+ currentImage = (Image) v.getTag();
+ int height = currentOpenNoteView.layFullNote.getHeight();
+ currentOpenNoteView.layFullNote.setVisibility(View.GONE);
+ currentOpenNoteView.layImageView.setVisibility(View.VISIBLE);
+ //currentOpenNoteView.me.setBackgroundResource(R.drawable.note_image_viewer);
+ // Gets the layout params that will allow you to resize the layout
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) currentOpenNoteView.layImageView.getLayoutParams();
+ // Changes the height and width to the specified *pixels*
+ params.height = height;
+ currentOpenNoteView.layImageView.setLayoutParams(params);
+
+ // Prepare a transaction to add fragments to this fragment
+ FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
+ // Add the list fragment to this fragment's layout
+ Log.i(TAG, "onCreate: adding FragmentNoteList to FragmentSidebar");
+ // Add the fragment to the this fragment's container layout
+ FragmentImageViewer fragmentImageViewer = new FragmentImageViewer();
+ fragmentTransaction.replace(currentOpenNoteView.layImageView.getId(), fragmentImageViewer, FragmentImageViewer.class.getName());
+ // Commit the transaction
+ fragmentTransaction.commit();
}
-
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static Bitmap decodeMutableBitmapFromResourceId(final Context context, final int bitmapResId) {
- final Options bitmapOptions = new Options();
- if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB)
- bitmapOptions.inMutable = true;
- Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), bitmapResId, bitmapOptions);
- if (!bitmap.isMutable())
- bitmap = convertToMutable(context, bitmap);
- return bitmap;
+};
+@Override
+public void ImageViewerRequestData(FragmentImageViewer requester) {
+ if(this.currentNote != null){
+ requester.populateData(this.currentNote.getImages(), currentImage);
}
+}
+@Override
+public void ImageViewerDone(Image image) {
+ currentOpenNoteView.layFullNote.setVisibility(View.VISIBLE);
+ currentOpenNoteView.layImageView.setVisibility(View.GONE);
+ //currentOpenNoteView.me.setBackgroundResource(R.drawable.note);
+}
+public Boolean AddNote() {
+ if(addingNote == false){
+ Log.d("FragmentNoteList", "AddNote");
+ this.addingNote = true;
+ //Add a new note
+ Note newNote = new Note(currentField.getName());
+ notes.add(newNote);
+ currentNote = newNote;
+
+ View newView = inflateOpenNote(newNote);
+ currentOpenNoteView = (OpenNoteView) newView.getTag();
+ listNotes.addView(newView, 0);
+ listener.NoteListAddNote();
+
+ svNotes.scrollTo(0, 0);
+ //InputMethodManager inputMethodManager = (InputMethodManager) this.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ //inputMethodManager.showSoftInput(newOpenNote.etComment, 0);
- @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
- public static Bitmap convertToMutable(final Context context, final Bitmap imgIn) {
- final int width = imgIn.getWidth(), height = imgIn.getHeight();
- final Config type = imgIn.getConfig();
- File outputFile = null;
- final File outputDir = context.getCacheDir();
- try {
- outputFile = File.createTempFile(Long.toString(System.currentTimeMillis()), null, outputDir);
- outputFile.deleteOnExit();
- final RandomAccessFile randomAccessFile = new RandomAccessFile(outputFile, "rw");
- final FileChannel channel = randomAccessFile.getChannel();
- final MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, imgIn.getRowBytes() * height);
- imgIn.copyPixelsToBuffer(map);
- imgIn.recycle();
- final Bitmap result = Bitmap.createBitmap(width, height, type);
- map.position(0);
- result.copyPixelsFromBuffer(map);
- channel.close();
- randomAccessFile.close();
- outputFile.delete();
- return result;
- } catch (final Exception e) {
- } finally {
- if (outputFile != null)
- outputFile.delete();
- }
- return null;
+ //Show drawing fragment
+ fragmentDrawing = listener.NoteListShowDrawing();
+ fragmentDrawing.setListener(me);
+ return true;
+ }
+ return false;
+}
+
+@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+public static Bitmap decodeMutableBitmapFromResourceId(final Context context, final int bitmapResId) {
+ final Options bitmapOptions = new Options();
+ if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB)
+ bitmapOptions.inMutable = true;
+ Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), bitmapResId, bitmapOptions);
+ if (!bitmap.isMutable())
+ bitmap = convertToMutable(context, bitmap);
+ return bitmap;
+}
+
+@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+public static Bitmap convertToMutable(final Context context, final Bitmap imgIn) {
+ final int width = imgIn.getWidth(), height = imgIn.getHeight();
+ final Config type = imgIn.getConfig();
+ File outputFile = null;
+ final File outputDir = context.getCacheDir();
+ try {
+ outputFile = File.createTempFile(Long.toString(System.currentTimeMillis()), null, outputDir);
+ outputFile.deleteOnExit();
+ final RandomAccessFile randomAccessFile = new RandomAccessFile(outputFile, "rw");
+ final FileChannel channel = randomAccessFile.getChannel();
+ final MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, imgIn.getRowBytes() * height);
+ imgIn.copyPixelsToBuffer(map);
+ imgIn.recycle();
+ final Bitmap result = Bitmap.createBitmap(width, height, type);
+ map.position(0);
+ result.copyPixelsFromBuffer(map);
+ channel.close();
+ randomAccessFile.close();
+ outputFile.delete();
+ return result;
+ } catch (final Exception e) {
+ } finally {
+ if (outputFile != null)
+ outputFile.delete();
}
+ return null;
+}
+
+@Override
+public void onClick(View arg0) {
+}
}
\ No newline at end of file
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/notelist/NoteListListener.java b/FieldNotebook/src/com/openatk/fieldnotebook/notelist/NoteListListener.java
index 525bb23..12f81cf 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/notelist/NoteListListener.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/notelist/NoteListListener.java
@@ -1,6 +1,8 @@
package com.openatk.fieldnotebook.notelist;
+import com.google.android.gms.maps.model.PolygonOptions;
import com.openatk.fieldnotebook.FragmentDrawing;
+import com.openatk.fieldnotebook.db.Field;
import com.openatk.fieldnotebook.drawing.MyPolygon;
/**
@@ -25,5 +27,5 @@ public interface NoteListListener {
public FragmentDrawing NoteListShowDrawing();
public void NoteListHideDrawing();
public void NoteListAddNote();
-
+ public void NoteListUpdatePolygon(int fieldId, PolygonOptions polygonOptions);
}
\ No newline at end of file
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/FragmentSidebar.java b/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/FragmentSidebar.java
index a4449ab..3af6c7f 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/FragmentSidebar.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/FragmentSidebar.java
@@ -3,10 +3,10 @@
import com.openatk.fieldnotebook.R;
import com.openatk.fieldnotebook.MainActivity.DropDownAnim;
import com.openatk.fieldnotebook.db.Field;
-import com.openatk.fieldnotebook.fieldlist.FieldListListener;
import com.openatk.fieldnotebook.fieldlist.FragmentFieldList;
import com.openatk.fieldnotebook.notelist.FragmentNoteList;
-import com.openatk.fieldnotebook.notelist.NoteListListener;
+import com.openatk.fieldnotebook.sidebar.FragmentSidebar;
+import com.openatk.fieldnotebook.sidebar.SidebarListener;
import android.app.Activity;
import android.graphics.Point;
@@ -36,22 +36,19 @@ public class FragmentSidebar extends Fragment implements OnClickListener, OnTouc
private TextView tvName;
- private TextView tvAcres;
private ImageButton butEditField;
private Button butAddNote;
private ImageButton butBackToFields;
+ private ViewGroup fieldMenu;
+ private ViewGroup noteMenu;
private SidebarListener listener;
private Field currentField = null;
private View container = null;
-
private Boolean initialCreate;
private ViewGroup noteListContainer;
private ViewGroup fieldListContainer;
- private ViewGroup fieldMenu;
- private ViewGroup noteMenu;
-
FragmentNoteList fragmentNoteList;
FragmentFieldList fragmentFieldList;
@@ -69,10 +66,9 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_sidebar, container, false);
+ View view = inflater.inflate(R.layout.fragment_slider, container, false);
tvName = (TextView) view.findViewById(R.id.sidebar_tvName);
- tvAcres = (TextView) view.findViewById(R.id.sidebar_tvAcres);
//view.setOnTouchListener(this);
//tvName.setOnTouchListener(this);
@@ -95,9 +91,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
initialCreate = false;
// Prepare a transaction to add fragments to this fragment
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
-
+ Log.w("fragtrans", fragmentTransaction.toString());
// Add the list fragment to this fragment's layout
+ Log.w("fieldListContainer", Boolean.toString(fieldListContainer == null));
+ Log.w("fragmentFieldList", Boolean.toString(fragmentFieldList == null));
+ Log.w("noteListContainer", Boolean.toString(noteListContainer == null));
+ Log.w("fragmentNoteList", Boolean.toString(fragmentNoteList == null));
+
if (fieldListContainer != null) {
+
Log.i(TAG, "onCreate: adding FragmentFieldList to FragmentSidebar");
// Add the fragment to the this fragment's container layout
fragmentFieldList = new FragmentFieldList();
@@ -109,9 +111,29 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
fragmentNoteList = new FragmentNoteList();
fragmentTransaction.replace(noteListContainer.getId(), fragmentNoteList, FragmentNoteList.class.getName());
}
+ Log.w("fragtrans", fragmentTransaction.toString());
// Commit the transaction
fragmentTransaction.commit();
}
+
+ // If this is the first creation of the fragment, add child fragments
+// if (initialCreate) {
+// initialCreate = false;
+// // Prepare a transaction to add fragments to this fragment
+// FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
+//
+// // Add the list fragment to this fragment's layout
+// noteListContainer = (ViewGroup) view.findViewById(R.id.sidebar_fragment_listNotes_container);
+// if (noteListContainer != null) {
+// Log.i(TAG, "onCreate: adding FragmentNoteList to Fragmentsidebar");
+//
+// // Add the fragment to the this fragment's container layout
+// fragmentNoteList = new FragmentNoteList();
+// fragmentTransaction.replace(noteListContainer.getId(), fragmentNoteList, FragmentNoteList.class.getName());
+// }
+// // Commit the transaction
+// fragmentTransaction.commit();
+// }
return view;
}
@@ -131,7 +153,7 @@ public void onAttach(Activity activity) {
throw new ClassCastException(activity.toString() + " must implement FragmentSlider.SliderListener");
}
Log.d("FragmentSlider", "Attached");
- }
+ }
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -146,14 +168,12 @@ public void populateData(Field theField, View container) {
this.container = container;
if (currentField != null) {
tvName.setText(currentField.getName());
- tvAcres.setText(Integer.toString(currentField.getAcres()) + " ac");
fieldListContainer.setVisibility(View.GONE);
fieldMenu.setVisibility(View.GONE);
noteListContainer.setVisibility(View.VISIBLE);
noteMenu.setVisibility(View.VISIBLE);
} else {
tvName.setText("");
- tvAcres.setText("");
fieldListContainer.setVisibility(View.VISIBLE);
fieldMenu.setVisibility(View.VISIBLE);
noteListContainer.setVisibility(View.GONE);
@@ -214,7 +234,7 @@ public boolean onTouch(View v, MotionEvent event) {
private void SliderDragDown(int start) {
if(container != null){
int height = container.getHeight();
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
sliderStartDrag = height - start - params.height;
sliderHeightStart = params.height;
@@ -225,7 +245,7 @@ private void SliderDragDragging(int whereY) {
if(container != null){
int height = container.getHeight();
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if((height - whereY - sliderStartDrag) > 0){
@@ -253,7 +273,7 @@ private void SliderDragUp(int whereY) {
Log.d("SliderDragUp", "closed");
}
//Find end height
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if(params.height > sliderHeightStart){
//Make bigger
@@ -269,7 +289,7 @@ private void SliderDragUp(int whereY) {
private void SliderShrink(){
if(container != null){
int oneThirdHeight = container.getHeight() / 3;
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if(sliderPosition == 2 || sliderPosition == 1){
//Middle -> Small
@@ -299,9 +319,9 @@ private void SliderShrink(){
private void SliderGrow(){
if(container != null){
int oneThirdHeight = container.getHeight() / 3;
- RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.slider_layMenu);
+ RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.sidebar_layMenuFields);
Log.d("layMenu:", Integer.toString(relAdd.getHeight()));
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if(sliderPosition == 0 || sliderPosition == 1){
//Small -> Middle
@@ -321,9 +341,9 @@ private void SliderGrow(){
}
}
private void SliderOneNote(){
- RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.slider_layMenu);
+ RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.sidebar_layMenuFields);
Log.d("layMenu:", Integer.toString(relAdd.getHeight()));
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
+ FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.sidebar_fragment_listFields_container);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
DropDownAnim an = new DropDownAnim(layout, params.height, this.oneNoteHeight());
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/SidebarListener.java b/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/SidebarListener.java
index d6b2633..69d6d33 100644
--- a/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/SidebarListener.java
+++ b/FieldNotebook/src/com/openatk/fieldnotebook/sidebar/SidebarListener.java
@@ -1,5 +1,7 @@
package com.openatk.fieldnotebook.sidebar;
+import com.openatk.fieldnotebook.sidebar.FragmentSidebar;
+
/**
* Interface to dispatch image selections.
*
@@ -14,8 +16,11 @@ public interface SidebarListener {
* @param position
*/
public void SidebarAddNote();
- public void SidebarRequestData(FragmentSidebar requester);
+ public void SidebarRequestData(FragmentSidebar fragmentSlider);
public void SidebarEditField();
public void SidebarBackToFieldsList();
public void SidebarAddField();
+ public void SliderAddNote();
+ public void SliderRequestData(FragmentSidebar requester);
+ public void SliderEditField();
}
\ No newline at end of file
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/slider/FragmentSlider.java b/FieldNotebook/src/com/openatk/fieldnotebook/slider/FragmentSlider.java
deleted file mode 100644
index efbd58a..0000000
--- a/FieldNotebook/src/com/openatk/fieldnotebook/slider/FragmentSlider.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package com.openatk.fieldnotebook.slider;
-
-import com.openatk.fieldnotebook.R;
-import com.openatk.fieldnotebook.MainActivity.DropDownAnim;
-import com.openatk.fieldnotebook.db.Field;
-import com.openatk.fieldnotebook.notelist.FragmentNoteList;
-
-import android.app.Activity;
-import android.graphics.Point;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-import android.util.Log;
-import android.view.Display;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnTouchListener;
-import android.view.animation.Animation;
-import android.view.animation.Transformation;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageButton;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-
-public class FragmentSlider extends Fragment implements OnClickListener, OnTouchListener {
- private static final String TAG = FragmentSlider.class.getSimpleName();
-
-
- private TextView tvName;
- private TextView tvAcres;
- private ImageButton butEditField;
- private Button butShowElevation;
- private Button butShowSoilType;
- private Button butAddNote;
-
- private SliderListener listener;
- private Field currentField = null;
- private View container = null;
-
-
- private Boolean initialCreate;
- private ViewGroup noteListContainer;
- FragmentNoteList fragmentNoteList;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- if(savedInstanceState == null){
- initialCreate = true;
- } else {
- initialCreate = false;
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_slider, container, false);
-
- tvName = (TextView) view.findViewById(R.id.slider_tvName);
- tvAcres = (TextView) view.findViewById(R.id.slider_tvAcres);
-
- view.setOnTouchListener(this);
- tvName.setOnTouchListener(this);
- tvAcres.setOnTouchListener(this);
-
- butEditField = (ImageButton) view.findViewById(R.id.slider_butEditField);
- butShowElevation = (Button) view.findViewById(R.id.slider_butShowElevation);
- butShowSoilType = (Button) view.findViewById(R.id.slider_butShowSoilType);
- butAddNote = (Button) view.findViewById(R.id.slider_butAddNote);
-
-
- butEditField.setOnClickListener(this);
- butShowElevation.setOnClickListener(this);
- butShowSoilType.setOnClickListener(this);
- butAddNote.setOnClickListener(this);
-
- // If this is the first creation of the fragment, add child fragments
- if (initialCreate) {
- initialCreate = false;
- // Prepare a transaction to add fragments to this fragment
- FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
-
- // Add the list fragment to this fragment's layout
- noteListContainer = (ViewGroup) view.findViewById(R.id.slider_fragment_listNotes_container);
- if (noteListContainer != null) {
- Log.i(TAG, "onCreate: adding FragmentNoteList to FragmentSlider");
-
- // Add the fragment to the this fragment's container layout
- fragmentNoteList = new FragmentNoteList();
- fragmentTransaction.replace(noteListContainer.getId(), fragmentNoteList, FragmentNoteList.class.getName());
- }
- // Commit the transaction
- fragmentTransaction.commit();
- }
-
- return view;
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
-
- Fragment parentFragment = getParentFragment();
- if (parentFragment != null && parentFragment instanceof SliderListener) {
- // Check if parent fragment (if there is one) is listener
- listener = (SliderListener) parentFragment;
- } else if (activity != null && activity instanceof SliderListener) {
- // Otherwise, check if parent activity is the listener
- listener = (SliderListener) activity;
- } else {
- throw new ClassCastException(activity.toString() + " must implement FragmentSlider.SliderListener");
- }
- Log.d("FragmentSlider", "Attached");
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- listener.SliderRequestData(this);
- }
-
- public void populateData(Field theField, View container) {
- Log.d("FragmentSlider", "Populate Data");
- //Get current field
- currentField = theField;
- this.container = container;
-
- if (currentField != null) {
- tvName.setText(currentField.getName());
- tvAcres.setText(Integer.toString(currentField.getAcres()) + " ac");
- } else {
- tvName.setText("");
- tvAcres.setText("");
- }
- }
-
- public int getHeight() {
- // Method so close transition can work
- return getView().getHeight();
- }
-
- public int oneNoteHeight() {
- //TODO return get from FragmentNoteList
- return 0;
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.slider_butEditField) {
- listener.SliderEditField();
- } else if (v.getId() == R.id.slider_butAddNote) {
- listener.SliderAddNote();
- } else if (v.getId() == R.id.slider_butShowElevation) {
-
- } else if (v.getId() == R.id.slider_butShowSoilType) {
-
- }
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- float eventY = event.getRawY();
-
- switch (event.getAction())
- {
- case MotionEvent.ACTION_DOWN:
- {
- this.SliderDragDown((int)eventY);
- break;
- }
- case MotionEvent.ACTION_UP:
- {
- this.SliderDragUp((int)(eventY));
- break;
- }
- case MotionEvent.ACTION_MOVE:
- {
- this.SliderDragDragging((int)(eventY));
- break;
- }
- }
- return true;
- }
-
- private int sliderStartDrag = 0;
- private int sliderHeightStart = 0;
- private void SliderDragDown(int start) {
- if(container != null){
- int height = container.getHeight();
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
- sliderStartDrag = height - start - params.height;
- sliderHeightStart = params.height;
- }
- }
-
- private void SliderDragDragging(int whereY) {
- if(container != null){
- int height = container.getHeight();
-
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
-
- if((height - whereY - sliderStartDrag) > 0){
- params.height = height - whereY - sliderStartDrag;
- } else {
- params.height = 0;
- }
- layout.setLayoutParams(params);
- }
- }
-
- private void SliderDragUp(int whereY) {
- //Slider done dragging snap to 1 of 3 positions
- if(container != null){
- int oneThirdHeight = container.getHeight() / 3;
- if(whereY < oneThirdHeight){
- //Fullscreen
- Log.d("SliderDragUp", "fullscreen");
- } else if(whereY < oneThirdHeight * 2) {
- //Middle
- Log.d("SliderDragUp", "middle");
-
- } else {
- //Closed
- Log.d("SliderDragUp", "closed");
- }
- //Find end height
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
- if(params.height > sliderHeightStart){
- //Make bigger
- SliderGrow();
- } else {
- //Make smaller
- SliderShrink();
- }
- }
- }
-
- private int sliderPosition = 0;
- private void SliderShrink(){
- if(container != null){
- int oneThirdHeight = container.getHeight() / 3;
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
- if(sliderPosition == 2 || sliderPosition == 1){
- //Middle -> Small
- //OneNote -> Small
- DropDownAnim an = new DropDownAnim(layout, params.height, 0);
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 0;
- } else if(sliderPosition == 3){
- //Fullscreen -> Middle if has notes
- //Fullscreen -> Small if no notes
- if(this.fragmentNoteList != null && this.fragmentNoteList.hasNotes()){
- DropDownAnim an = new DropDownAnim(layout, params.height, oneThirdHeight);
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 2;
- } else {
- DropDownAnim an = new DropDownAnim(layout, params.height, 0);
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 0;
- }
- }
- layout.setLayoutParams(params);
- }
- }
- private void SliderGrow(){
- if(container != null){
- int oneThirdHeight = container.getHeight() / 3;
- RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.slider_layMenu);
- Log.d("layMenu:", Integer.toString(relAdd.getHeight()));
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
- if(sliderPosition == 0 || sliderPosition == 1){
- //Small -> Middle
- //OneNote -> Middle
- DropDownAnim an = new DropDownAnim(layout, params.height, oneThirdHeight);
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 2;
- } else if(sliderPosition == 2){
- //Middle -> Fullscreen
- DropDownAnim an = new DropDownAnim(layout, params.height, (container.getHeight() - relAdd.getHeight()));
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 3;
- }
- layout.setLayoutParams(params);
- }
- }
- private void SliderOneNote(){
- RelativeLayout relAdd = (RelativeLayout) this.getView().findViewById(R.id.slider_layMenu);
- Log.d("layMenu:", Integer.toString(relAdd.getHeight()));
- FrameLayout layout = (FrameLayout) this.getView().findViewById(R.id.slider_fragment_listNotes_container);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
-
- DropDownAnim an = new DropDownAnim(layout, params.height, this.oneNoteHeight());
- an.setDuration(300);
- layout.startAnimation(an);
- sliderPosition = 1;
-
- layout.setLayoutParams(params);
- }
- public void SliderSizeMiddle(){
- if(sliderPosition == 3){
- this.SliderShrink();
- } else if(sliderPosition == 0){
- this.SliderGrow();
- }
- }
-
- private class DropDownAnim extends Animation {
- int targetHeight;
- int startHeight;
- View view;
-
- public DropDownAnim(View view, int startHeight, int targetHeight) {
- this.view = view;
- this.startHeight = startHeight;
- this.targetHeight = targetHeight;
- }
-
- @Override
- protected void applyTransformation(float interpolatedTime, Transformation t) {
- int newHeight = (int) (startHeight - ((startHeight - targetHeight) * interpolatedTime));
- view.getLayoutParams().height = newHeight;
- view.requestLayout();
- }
-
- @Override
- public void initialize(int width, int height, int parentWidth,
- int parentHeight) {
- super.initialize(width, height, parentWidth, parentHeight);
- }
-
- @Override
- public boolean willChangeBounds() {
- return true;
- }
- }
-
-}
\ No newline at end of file
diff --git a/FieldNotebook/src/com/openatk/fieldnotebook/slider/SliderListener.java b/FieldNotebook/src/com/openatk/fieldnotebook/slider/SliderListener.java
deleted file mode 100644
index 1ebf0b1..0000000
--- a/FieldNotebook/src/com/openatk/fieldnotebook/slider/SliderListener.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.openatk.fieldnotebook.slider;
-
-/**
- * Interface to dispatch image selections.
- *
- * @author Cyrus Bowman
- */
-public interface SliderListener {
-
- /**
- * Inform the listener that an image has been selected.
- *
- * @param imageItem
- * @param position
- */
- public void SliderAddNote();
- public void SliderRequestData(FragmentSlider requester);
- public void SliderEditField();
-}
\ No newline at end of file