Commits

edc...@bitbucket.org  committed a6ed8ff

still refactoring

  • Participants
  • Parent commits 23082ae

Comments (0)

Files changed (10)

File android/placeUvote/bin/classes.dex

Binary file modified.

File android/placeUvote/bin/com/placeuvote/puvandroid/EditLocation.class

Binary file modified.

File android/placeUvote/bin/placeUvote.apk

Binary file modified.

File android/placeUvote/bin/resources.ap_

Binary file modified.

File android/placeUvote/src/com/placeuvote/puvandroid/EditLocation.java

 import android.widget.Toast;
 
 import com.placeuvote.puvandroid.PUVDatabase.PollsCursor;
-import com.placeuvote.puvandroid.PUVDatabase.LocationDetailCursor;
+import com.placeuvote.puvandroid.PUVDatabase.LocationsCursor;
 
 
 /**
  */
 public class EditLocation extends ListActivity {
     private static Spinner spnPoll;
-    private static TextView txtTitle;
-    private static TextView txtDescription;
-    private static Integer job_id;
-    private LocationDetailCursor job;
+    private static TextView txtQuestion;
+    private static Integer poll_id;
     private static Button btnUpdate, btnCancel;
     private PUVDatabase db;
-
+    private PollsCursor poll;
+    private LocationsCursor locations;
+    
     private class Poll {
-    	public String employerName;
+    	public String Question;
     	public long id;
-    	Poll( long id, String employerName){
+    	Poll( long id, String Question){
     		this.id = id;
-    		this.employerName = employerName;
+    		this.Question = Question;
     	}
     	@Override
     	public String toString() {
-    		return this.employerName;
+    		return this.Question;
     	}
     }
 
     // Create a button click listener for the Update button.
     private final Button.OnClickListener btnUpdateOnClick = new Button.OnClickListener() {
         public void onClick(View v) {
-        	Poll employer = (Poll)spnPoll.getSelectedItem();
+        	Poll poll = (Poll)spnPoll.getSelectedItem();
 //        	Toast.makeText(
 //        			EditLocation.this, 
 //        			String.format(
 //        					"Location: %d\nPoll: %s (%d)\nTitle: %s\nDesc: %s", 
-//        					job_id,
-//        					employer.employerName, 
+//        					poll_id,
+//        					employer.Question, 
 //        					employer.id,
 //        					txtTitle.getText(),
 //        					txtDescription.getText()
 //        			), 
 //        			Toast.LENGTH_SHORT
 //        	).show();
-        	if (txtTitle.getText().length()==0 || txtDescription.getText().length()==0){
+        	if (txtQuestion.getText().length()==0 || txtDescription.getText().length()==0){
 	        	Toast.makeText(EditLocation.this, "Fill out the form completely first.", Toast.LENGTH_LONG).show();
         	} else {
-	        	db.editLocation((long)job_id, employer.id, txtTitle.getText().toString(), txtDescription.getText().toString());
+	        	db.editLocation((long)poll_id, poll.id, txtTitle.getText().toString(), txtDescription.getText().toString());
 	        	Toast.makeText(EditLocation.this, "Location updated", Toast.LENGTH_SHORT).show();
 	        	finish();
         	}
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.editlocation);
-        txtTitle = (TextView) findViewById(R.id.txtTitle);
-        txtDescription = (TextView) findViewById(R.id.txtDescription);
+        txtQuestion = (TextView) findViewById(R.id.txtQuestion);
         spnPoll = (Spinner) findViewById(R.id.spnPoll);
 
-        // get the job_id for this job from the bundle passed by MicroLocationsDetail
+        // get the poll_id for this poll from the bundle passed by MicroLocationsDetail
         Bundle bIn = this.getIntent().getExtras();
-        job_id = Integer.valueOf(bIn.getInt("_id"));
+        poll_id = Integer.valueOf(bIn.getInt("_id"));
 
         db = new PUVDatabase(this);
-        job = db.getLocationDetails(job_id.longValue());
+        poll = db.getPollDetails(poll_id.longValue());
         
-        txtTitle.setText(job.getColTitle());
-        txtDescription.setText(job.getColDescription());
+        txtQuestion.setText(poll.getColQuestion());
 
         btnUpdate = (Button) findViewById(R.id.btnUpdate);
         btnUpdate.setOnClickListener(btnUpdateOnClick);
         btnCancel.setOnClickListener(btnCancelOnClick);
 
         // spnPoll
-        List<Poll> employersList = new ArrayList<Poll>();
+        List<Poll> pollsList = new ArrayList<Poll>();
         PollsCursor c = db.getPolls();
         int position=0;
         for(int i=0; i<c.getCount(); i++){
         	c.moveToPosition(i);
-        	employersList.add(new Poll(c.getColId(),c.getColPollName()));
-        	if (c.getColId()==job.getColPollsId())
+        	pollsList.add(new Poll(c.getPollId(),c.getColQuestion()));
+        	if (c.getColId()==poll.getColPollId())
         		position=i;
         }
         
         ArrayAdapter<Poll> aspnPolls = new ArrayAdapter<Poll>(
-        		this, android.R.layout.simple_spinner_item, employersList);
+        		this, android.R.layout.simple_spinner_item, pollsList);
         aspnPolls.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         spnPoll.setAdapter(aspnPolls);
         spnPoll.setSelection(position);

File android/placeUvote/src/com/placeuvote/puvandroid/PUVDatabase.java

 			}
 	    }
 	    /* Accessor functions -- one per database column */
-    	public int getColPollsId(){return getInt(getColumnIndexOrThrow("_id"));}
+    	public int getColPollId(){return getInt(getColumnIndexOrThrow("_id"));}
        	public String getColKey(){return getString(getColumnIndexOrThrow("key"));}
       	public int getColPrivate(){return getInt(getColumnIndexOrThrow("private"));}
       	public int getColAnonymous(){return getInt(getColumnIndexOrThrow("anonymous"));}
       	public int getColOneChoice(){return getInt(getColumnIndexOrThrow("onechoice"));}
       	public int getColLocations(){return getInt(getColumnIndexOrThrow("locations"));}
       	public long getColDates(){return getLong(getColumnIndexOrThrow("dates"));}
-     	public long getColCreattedOn(){return getLong(getColumnIndexOrThrow("createdon"));}
+     	public long getColCreatedOn(){return getLong(getColumnIndexOrThrow("createdon"));}
      	public String getColCreatedBy(){return getString(getColumnIndexOrThrow("createdby"));}
      	public long getColLastVote(){return getLong(getColumnIndexOrThrow("lastvote"));}
      	public int getColTotalVotes(){return getInt(getColumnIndexOrThrow("totalvotes"));}
 	    /* Accessor functions -- one per database column */
     	public int getColLocationsId(){return getInt(getColumnIndexOrThrow("_id"));}
     	public String getColLocationsKey(){return getString(getColumnIndexOrThrow("key"));}
-    	public int getColPollsId(){return getInt(getColumnIndexOrThrow("poll_id"));}
+    	public int getColPollId(){return getInt(getColumnIndexOrThrow("poll_id"));}
     	public String getColChoice(){return getString(getColumnIndexOrThrow("choice"));}
     	public long getColLat(){return getLong(getColumnIndexOrThrow("loc_lat"));}
     	public long getColLong(){return getLong(getColumnIndexOrThrow("loc_long"));}
 	    }
     	public int getColDatesId(){return getInt(getColumnIndexOrThrow("_id"));}
     	public String getColDatesKey(){return getString(getColumnIndexOrThrow("key"));}
-    	public int getColPollsId(){return getInt(getColumnIndexOrThrow("poll_id"));}
+    	public int getColPollId(){return getInt(getColumnIndexOrThrow("poll_id"));}
     	public long getColDateTime(){return getLong(getColumnIndexOrThrow("datetime"));}
     	public long getColDateOrTime(){return getLong(getColumnIndexOrThrow("dateortime"));}
     	public long getColVotes(){return getLong(getColumnIndexOrThrow("votes"));}
     }
 
     /**
-     * Provides self-contained query-specific cursor for Worker info.  
+     * Provides self-contained query-specific cursor for Polls info.  
      * The query and all accessor methods are in the class.
      * Note: for now there is only one record in this table, so this is a lot of 
      * work to store/retrieve that data.  We do it this way in anticipation of a
-     * day when there would be more than one worker in the table.
+     * day when there would be more than one Polls in the table.
      */
     public static class VoterCursor extends SQLiteCursor{
     	/** The query for this cursor */
 	    /* Accessor functions -- one per database column */
     	public int getColVoterId(){return getInt(getColumnIndexOrThrow("_id"));}
     	public String getColVoterKey(){return getString(getColumnIndexOrThrow("key"));}
-    	public int getColPollsId(){return getInt(getColumnIndexOrThrow("poll_id"));}
+    	public int getColPollId(){return getInt(getColumnIndexOrThrow("poll_id"));}
     	public int getColLoctionsId(){return getInt(getColumnIndexOrThrow("choice_id"));}
     	public int getColDatesId(){return getInt(getColumnIndexOrThrow("datechoice_id"));}
      	public String getColCreatedBy(){return getString(getColumnIndexOrThrow("createdby"));}
-     	public long getColCreattedOn(){return getLong(getColumnIndexOrThrow("createdon"));}
+     	public long getColCreatedOn(){return getLong(getColumnIndexOrThrow("createdon"));}
     }
 	
     /** Constructor */

File android/placeUvote/src/com/placeuvote/puvandroid/PUVMap.java

 import com.google.android.maps.MapView;
 import com.google.android.maps.MyLocationOverlay;
 import com.google.android.maps.OverlayItem;
-import com.placeuvote.puvandroid.PUVDatabase.LocationDetailCursor;
 import com.placeuvote.puvandroid.PUVDatabase.LocationsCursor;
-import com.placeuvote.puvandroid.PUVDatabase.WorkerCursor;
+import com.placeuvote.puvandroid.PUVDatabase.LocationsCursor;
+import com.placeuvote.puvandroid.PUVDatabase.PollsCursor;
 /**
- * MicroLocations
+ * Poll Locations
  */
 public class PUVMap extends MapActivity {
     /**
 	/** 
 	 * Database cursor to access user information
 	 */
-	private WorkerCursor worker;
-	
+	private LocationsCursor Locations;
+	private Long poll_id;
     /**
-     * MJLocationsOverlay
+     * LocationsOverlay
      */
     private class PUVOverlay extends ItemizedOverlay<OverlayItem> {
 
          */
         @Override
         public int size() {
-        	int size = db.getLocationsCount();
+        	int size = db.getLocationsCount(poll_id);
         	return size;
         }
 
          */
         @Override
         protected OverlayItem createItem(int i) {
-        	LocationDetailCursor c = db.getLocationDetails(i+1);
-        	String contactName = c.getColContactName();
-        	String description = c.getColDescription();
-        	int lat = (int) c.getColLatitude();
-        	int lon = (int) c.getColLongitude();
+        	LocationsCursor c = db.getLocations(i+1);
+        	String contactName = c.getColChoice();
+        	String description = c.getColAddress();
+        	int lat = (int) c.getColLat();
+        	int lon = (int) c.getColLong();
         	return new OverlayItem(new GeoPoint(lat, lon), contactName, description);
         }
 
             long lon = p.getLongitudeE6();
           
             long rowid = -1;
-            LocationsCursor c = db.getLocations(LocationsCursor.SortBy.title);
+            LocationsCursor c = db.getLocations(poll_id); //LocationsCursor.SortBy.title
             for( int i=0; i<c.getCount(); i++){
-            	if (Math.abs(c.getColLatitude()-lat)<1000 && Math.abs(c.getColLongitude()-lon)<1000){
+            	if (Math.abs(c.getColLat()-lat)<1000 && Math.abs(c.getColLong()-lon)<1000){
             		rowid = c.getColLocationsId();
             		break;
             	} else {
         hmLocations.put("Current Location", new GeoPoint(latitude, longitude));
         lsLocations.add("Current Location");
 
-        // Add favorite locations from this user's record in workers table
-        worker = db.getWorker();
-        hmLocations.put(worker.getColLoc1Name(), new GeoPoint((int)worker.getColLoc1Lat(), (int)worker.getColLoc1Long()));
-        lsLocations.add(worker.getColLoc1Name());
-        hmLocations.put(worker.getColLoc2Name(), new GeoPoint((int)worker.getColLoc2Lat(), (int)worker.getColLoc2Long()));
-        lsLocations.add(worker.getColLoc2Name());
-        hmLocations.put(worker.getColLoc3Name(), new GeoPoint((int)worker.getColLoc3Lat(), (int)worker.getColLoc3Long()));
-        lsLocations.add(worker.getColLoc3Name());
+        // Add favorite locations from this user's record in Polls table
+        Locations = db.getLocations(poll_id);
+        for( int rowNum=0; rowNum<Locations.getCount(); rowNum++){
+        	Locations.moveToPosition(rowNum);
+         	hmLocations.put(Locations.getColAddress(), new GeoPoint((int)Locations.getColLat(), (int)Locations.getColLong()));
+            lsLocations.add(Locations.getColChoice());
+        }
         
         ArrayAdapter<String> aspnLocations
             = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, lsLocations);

File android/placeUvote/src/com/placeuvote/puvandroid/PollDetail.java

 import android.widget.Button;
 import android.widget.ImageButton;
 import android.widget.TextView;
+import android.widget.CheckBox;
 
 import com.placeuvote.puvandroid.PUVDatabase.PollsCursor;
 
 	    }
 	});
     */
+	public boolean IntToBool(int intValue)
+	{
+	    return (intValue != 0);
+	}
+    
     /**
      * Called when the activity is first created.
      *
         super.onCreate(savedInstanceState);
         setContentView(R.layout.puvdetail);
         txtKey = (TextView) findViewById(R.id.txtKey);
-	chkPrivate = (CheckBox) findViewById(R.id.chkPrivate);
-	chkAnonymous = (CheckBox) findViewById(R.id.chkAnonymous);
-	chkOneChoice = (CheckBox) findViewById(R.id.chkOneChoice);
+        chkPrivate = (CheckBox) findViewById(R.id.chkPrivate);
+        chkAnonymous = (CheckBox) findViewById(R.id.chkAnonymous);
+        chkOneChoice = (CheckBox) findViewById(R.id.chkOneChoice);
         numLocations = (TextView) findViewById(R.id.numLocations);
         numDates = (TextView) findViewById(R.id.numDates);
         dateCreatedOn = (TextView) findViewById(R.id.dateCreatedOn);
         poll_id = Integer.valueOf(bIn.getInt("_id"));
 
         db = new PUVDatabase(this);
-        job = db.getLocationDetails(poll_id.longValue());
+        poll = db.getPollDetails(poll_id.longValue());
 
-	public boolean IntToBool(int intValue)
-	{
-	    return (intValue != 0);
-	}
-
-	java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
-        // fill in the form and display
-	txtKey.setText(poll.getColKey());
-	chkPrivate.setChecked(IntToBool(poll.getColPrivate()));
-	chkAnonymous.setChecked(IntToBool(poll.getColAnonymous()));
-	chkOneChoice.setChecked(IntToBool(poll.getColOneChoice()));
-	numLocations.setText(poll.getLocations());
-	numDates.setText(poll.getColDates());
-	dateCreatedOn.setText("Created: " + dateFormat.format(poll.getColCreatedOn()));
-	txtCreatedBy.setText(poll.getColCreatedBy());
-	dateLastVote.setText(poll.getColLastVote());
-	numTotalVotes.setText(poll.getColTotalVotes());
+		java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
+	        // fill in the form and display
+		txtKey.setText(poll.getColKey());
+		chkPrivate.setChecked(IntToBool(poll.getColPrivate()));
+		chkAnonymous.setChecked(IntToBool(poll.getColAnonymous()));
+		chkOneChoice.setChecked(IntToBool(poll.getColOneChoice()));
+		numLocations.setText(Long.toString(poll.getColLocations()));
+		numDates.setText(Long.toString(poll.getColDates()));
+		dateCreatedOn.setText("Created: " + dateFormat.format(poll.getColCreatedOn()));
+		txtCreatedBy.setText(poll.getColCreatedBy());
+		dateLastVote.setText("Last vote: " + dateFormat.format(poll.getColLastVote()));
+		numTotalVotes.setText(poll.getColTotalVotes());
         txtUser.setText(poll.getColUser());
         txtEmail.setText(poll.getColEmail());
         txtQuestion.setText(poll.getColQuestion());
                 rejectMsg.what = CANCEL_DELETE;
 
                 new AlertDialog.Builder(this)
-                  .setMessage("Are you sure you want to delete this job?")
+                  .setMessage("Are you sure you want to delete this poll?")
                   .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                 	  public void onClick(DialogInterface dialog, int value) {
                 		  rejectMsg.sendToTarget();
             	return true;
             case 3:
             	// Edit this job
-            	// Start the Edit Location Activity, passing this job's id
+            	// Start the Edit Location Activity, passing this poll's id
                 Intent iEdit = new Intent(PollDetail.this, EditPoll.class);
                 Bundle bEdit = new Bundle();
                 bEdit.putInt("_id", poll_id);

File android/placeUvote/src/com/placeuvote/puvandroid/PollList.java

             Bundle b = new Bundle();
             puvButton vb = (puvButton) v;
             cursor.moveToPosition(vb.jrow);
-            b.putInt("_id", (int) cursor.getColPollsId());
+            b.putInt("_id", (int) cursor.getColPollId());
             i.putExtras(b);
 
             startActivity(i);
                 fillData(PollsCursor.SortBy.CreatedOn);
                 return true;
             case 3:
-            	// Add a new job
-                Intent i = new Intent(PollList.this, AddPoll.class);
+            	// Add a new location
+                Intent i = new Intent(PollList.this, AddLocation.class);
                 startActivity(i);
                  	return true;
         }

File android/placeUvote/src/com/placeuvote/puvandroid/VoterDetail.java

         Bundle b = this.getIntent().getExtras();
         voter_id = Integer.valueOf(b.getInt("_id"));
         PUVDatabase db = new PUVDatabase(this);
-        voter = db.getVoterDetails(voter_id.longValue());
+        voter = db.getVoter(voter_id.longValue());
 
         // fill in the form and display
         txtVoter.setText(voter.getColCreatedBy());
         txtKey.setText(voter.getColVoterKey());
-	java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
-	createdon.setText("Created: " + dateFormat.format(voter.getColCreatedOn()));
+        java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
+        createdon.setText("Created: " + dateFormat.format(voter.getColCreatedOn()));
      }
 
     /**