Anonymous avatar Anonymous committed 3ed11b0

Getting the database to work

Comments (0)

Files changed (9)

Add a comment to this file

android/placeUvote/bin/classes.dex

Binary file modified.

Add a comment to this file

android/placeUvote/bin/placeUvote.apk

Binary file modified.

Add a comment to this file

android/placeUvote/bin/resources.ap_

Binary file modified.

android/placeUvote/res/layout/pollvote.xml

-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
-android:layout_width="fill_parent"
-android:layout_height="fill_parent"
-xmlns:android="http://schemas.android.com/apk/res/android"
-android:orientation="vertical"
->
-<!-- android:background="#4000ffff" -->
-      <TextView
-			android:id="@+id/txtQuestion"
-			android:layout_width="300px"
-			android:layout_height="wrap_content"
-			android:paddingLeft="10px"
-			android:text="Question"
-			></TextView>  
-<TextView android:id="@+id/txtKey" android:textStyle="bold" android:paddingLeft="10px" 
-android:layout_height="wrap_content" android:text="Key" android:layout_width="300px" 
-		    android:layout_below="@+id/txtQuestion"
-></TextView>
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+android:id="@+id/widget88"
+android:layout_width="fill_parent"
+android:layout_height="fill_parent"
+xmlns:android="http://schemas.android.com/apk/res/android"
+>
+<TextView
+android:id="@+id/txtQuestion"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="Question"
+android:layout_alignParentTop="true"
+android:layout_alignParentLeft="true"
+>
+</TextView>
+<TextView
+android:id="@+id/numTotalVotes"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="Total votes"
+android:textStyle="bold"
+android:layout_below="@+id/dateLastVote"
+android:layout_alignParentLeft="true"
+>
+</TextView>
+<TextView
+android:id="@+id/dateLastVote"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="Last vote"
+android:textStyle="bold"
+android:layout_below="@+id/txtCreatedBy"
+android:layout_alignParentLeft="true"
+>
+</TextView>
+<TextView
+android:id="@+id/txtCreatedBy"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="Created by"
+android:textStyle="bold"
+android:layout_below="@+id/dateCreatedOn"
+android:layout_alignParentLeft="true"
+>
+</TextView>
+<CheckBox
+android:id="@+id/chkPrivate"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:text="Private"
+android:layout_above="@+id/chkAnonymous"
+android:layout_alignParentLeft="true"
+>
+</CheckBox>
+<CheckBox
+android:id="@+id/chkOneChoice"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:text="Single choice only"
+android:layout_below="@+id/chkAnonymous"
+android:layout_alignParentLeft="true"
+>
+</CheckBox>
+<CheckBox
+android:id="@+id/chkAnonymous"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:text="Anonymous voting"
+android:layout_centerVertical="true"
+android:layout_alignParentLeft="true"
+>
+</CheckBox>
+<TextView
+android:id="@+id/dateCreatedOn"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="Created on"
+android:textStyle="bold"
+android:layout_below="@+id/txtQuestion"
+android:layout_alignParentLeft="true"
+>
+</TextView>
+<TextView
+android:id="@+id/txtKey"
+android:layout_width="300px"
+android:layout_height="wrap_content"
+android:text="URL key"
+android:textStyle="bold"
+android:layout_below="@+id/chkOneChoice"
+android:layout_alignParentLeft="true"
+>
+</TextView>
 
-<TextView android:id="@+id/dateCreatedOn" android:textStyle="bold" android:paddingLeft="10px" 
-android:layout_height="wrap_content" android:text="dateCreatedOn" android:layout_width="300px" 
-		    android:layout_below="@+id/txtKey"
-></TextView>
-<TextView android:id="@+id/txtCreatedBy" android:textStyle="bold" android:paddingLeft="10px" 
-android:layout_height="wrap_content" android:text="CreatedBy" android:layout_width="300px" 
-		    android:layout_below="@+id/dateCreatedOn"
-></TextView>
-<TextView android:id="@+id/dateLastVote" android:textStyle="bold" android:paddingLeft="10px" 
-android:layout_height="wrap_content" android:text="dateLastVote" android:layout_width="300px" 
-		    android:layout_below="@+id/txtCreatedBy"
-></TextView>
-<TextView android:id="@+id/numTotalVotes" android:textStyle="bold" android:paddingLeft="10px" 
-android:layout_height="wrap_content" android:text="numTotalVotes" android:layout_width="300px" 
-		    android:layout_below="@+id/dateLastVote"
-></TextView>
-<CheckBox android:layout_height="wrap_content" android:text="@+id/chkPrivate" 
-android:layout_below="@+id/txtKey" android:id="@+id/chkPrivate" android:layout_width="wrap_content" 
-android:layout_alignLeft="@+id/txtKey"></CheckBox>
-<CheckBox android:layout_height="wrap_content" 
-android:layout_width="wrap_content" 
-android:text="@+id/chkAnonymous" 
-android:id="@+id/chkAnonymous"
-android:layout_below="@+id/chkPrivate"></CheckBox>
-<CheckBox android:layout_height="wrap_content" 
-android:layout_width="wrap_content" 
-android:text="@+id/chkOneChoice" 
-android:id="@+id/chkOneChoice"
-android:layout_below="@+id/chkAnonymous"></CheckBox>
-
-
+<Button
+android:id="@+id/btnBack"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:layout_marginLeft="10px"
+android:layout_marginRight="10px"
+android:textStyle="bold"
+android:text="Back"
+android:layout_alignParentBottom="true"
+android:layout_alignParentRight="true"
+>
+</Button>
+<Button
+android:id="@+id/btnVote"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:text="Vote"
+android:layout_marginLeft="10px"
+android:layout_marginRight="10px"
+android:textStyle="bold"
+android:layout_alignParentBottom="true"
+android:layout_centerHorizontal="true"
+>
+</Button>
+<Button
+android:id="@+id/btnMap"
+android:layout_width="wrap_content"
+android:layout_height="wrap_content"
+android:layout_marginLeft="10px"
+android:layout_marginRight="10px"
+android:textStyle="bold"
+android:text="Map"
+android:layout_alignParentBottom="true"
+android:layout_alignParentLeft="true"
+>
+</Button>
 
-<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tblRating" 
-    android:layout_width="fill_parent" 
-    android:layout_height="wrap_content" 
-    android:layout_below="@+id/chkOneChoice"
-    >
-     <TableRow 
-          android:layout_width="fill_parent" 
-          android:layout_height="wrap_content"> 
-			<TextView
-			android:id="@+id/lblRating"
-			android:layout_width="300px"
-			android:layout_height="wrap_content"
-			android:text="Rating"
-			android:textStyle="bold"
-			>
-			</TextView>
-			<TextView
-			android:id="@+id/txtRating"
-			android:layout_width="300px"
-			android:layout_height="wrap_content"
-			android:paddingLeft="10px"
-			>
-			<!-- android:background="#ffffffff" -->
-			</TextView>
-     </TableRow> 
-</TableLayout>
 
-
-
-
-</RelativeLayout>
+</RelativeLayout>

android/placeUvote/res/values/strings.xml

-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
 <resources>
     <string name="app_name">placeUvote</string>
-    <string name="poll_map">Poll map</string>
-    <string name="show_list">Show list of locations</string>
-    <string name="list_name">List of polls</string>
-    <string name="location_name">Location details</string>
-    <string name="poll_name">Poll details</string>
-    <string name="add_location">Add location</string>
-    <string name="edit_location">Edit location</string>
-    <string name="map_menu_zoom_in">Zoom in</string> 
-    <string name="map_menu_zoom_out">Zoom out</string> 
-    <string name="map_menu_show_list">List locations</string> 
-    <string name="map_menu_set_satellite">Toggle Satellite</string>
-    <string name="map_menu_set_map">Toggle Street View</string>
-    <string name="map_menu_set_traffic">Toggle Traffic View</string>
-    <string name="list_menu_back_to_map">Back to Map</string>
-    <string name="list_menu_sort_by_title">Sort by location name</string>
+    <string name="poll_map">Poll map</string>
+    <string name="show_list">Show list of locations</string>
+    <string name="list_name">List of polls</string>
+    <string name="location_name">Location details</string>
+    <string name="poll_name">Poll details</string>
+    <string name="add_location">Add location</string>
+    <string name="edit_location">Edit location</string>
+    <string name="map_menu_zoom_in">Zoom in</string> 
+    <string name="map_menu_zoom_out">Zoom out</string> 
+    <string name="map_menu_show_list">List locations</string> 
+    <string name="map_menu_set_satellite">Toggle Satellite</string>
+    <string name="map_menu_set_map">Toggle Street View</string>
+    <string name="map_menu_set_traffic">Toggle Traffic View</string>
+    <string name="list_menu_back_to_map">Back to Map</string>
+    <string name="list_menu_sort_by_title">Sort by location name</string>
     <string name="list_menu_sort_by_poll">Sort by poll</string>
     <string name="list_menu_add_dates">Add dates</string>
-    <string name="list_menu_get_poll_detail">Show poll info</string>
-    <string name="list_menu_add_location">Add a new location</string>
-    <string name="detail_menu_back_to_list">Back to list of locations</string>
-    <string name="detail_menu_poll_info">Detailed poll info</string>
-    <string name="detail_menu_delete_location">Delete this location</string>
-    <string name="detail_menu_edit_location">Edit this location</string>
+    <string name="list_menu_get_poll_detail">Show poll info</string>
+    <string name="list_menu_add_location">Add a new location</string>
+    <string name="detail_menu_back_to_list">Back to list of locations</string>
+    <string name="detail_menu_poll_info">Detailed poll info</string>
+    <string name="detail_menu_delete_location">Delete this location</string>
+    <string name="detail_menu_edit_location">Edit this location</string>
     <string name="poll_detail_menu_back_to_location_info">Back to location info</string>
-    <string name="db_name">PUV</string>
-    <string name="PUVDatabase_onCreate">"
-DROP TABLE IF EXISTS jobs;
-DROP TABLE IF EXISTS employers;
-DROP TABLE IF EXISTS workers;
-DROP TABLE IF EXISTS status;
+    <string name="db_name">PUV</string>
+    <string name="PUVDatabase_onCreate">"
+DROP TABLE IF EXISTS poll;
+DROP TABLE IF EXISTS choice;
+DROP TABLE IF EXISTS datechoice;
+DROP TABLE IF EXISTS voter;
 create table poll(id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, question TEXT, private INTEGER, anonymous INTEGER, onechoice INTEGER, locations INTEGER, dates INTEGER, createdon TEXT, createdby TEXT, last_vote TEXT, total_votes INTEGER, user TEXT, email TEXT);
-create table choice(_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, choice TEXT, loc_lat INTEGER, loc_long INTEGER, address TEXT, url TEXT, votes INTEGER);
-create table datechoice(_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, datetime TEXT, dateortime INTEGER, votes INTEGER);
-create table voter(_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, choice_id INTEGER, datechoice_id INTEGER, createdby TEXT, createdon TEXT);
-insert into poll(id, key, question, private, anonymous, onechoice, locations, dates, createdon, createdby, last_vote, total_votes, user, email) values (1, 'agpwbGFjZXV2b3RlcgoLEgRQb2xsGAEM', 'Lets go for a drink next month', 0, 1, 0, \
-3, 2, '01-10-2010', 'Ed', '01-11-2010', 3, 'Ed', 'ed.crewe@bris.ac.uk');
-insert into choice(_id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (1, 'agpwbGFjZXV2b3RlcgoLEgRQb2asdfsdfads', 1, 'Cat and Wheel', '53', '0.2', 'The Arches', 'http://catandwheel.com', 3);
-insert into choice(_id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (2, 1, 'agpwbGFjZXV2b3aadgfadgfasdgf', 'Prince of Wales', '53', '0.25', '20 Gloucester Rd', 'http://pow.com', 2);
-insert into choice(_id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (3, 1, 'agpwbGFjZXV2b3Rdgfadfg', 'Robin Hood', '53', '0.3', '50 Gloucester Rd', 'http://robinhood.com', 4);
-insert into datechoice(_id, key, poll_id, datetime, dateortime, votes) values (1, 'agpwbGFjZX345drfgd', 1, '21-12-2010', 0, 3);
-insert into datechoice(_id, key, poll_id, datetime, dateortime, votes) values (2, 'agpwbGFj345dfsdgf', 1, '18-12-2010', 0, 5);
-insert into voter(_id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (1, 'agpwbGFjZXV2bsgfdfgdgfGAEM', 1, 1, 0, 'Freddy', '21-10-2010');
-insert into voter(_id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (2, 'dfgdgfdfgEgRQb2xsGAEM', 1, 2, 0, 'Jim', '21-10-2010');
-insert into voter(_id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (3, 'sdgadfgadfgV2b3RlcgoLEgRQb2xsGAEM', 1, 0, 2, 'Freddy', '21-10-2010');
-insert into voter(_id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (4, 'wqeshjdgjhV2b3RlcgoLEgRQb2xsGAEM', 1, 0, 3, 'Jim', '21-10-2010');
-"</string>
-    <string name="PUVDatabase_onUpgrade">"
-DROP TABLE IF EXISTS jobs
-DROP TABLE IF EXISTS employers
-DROP TABLE IF EXISTS workers
-DROP TABLE IF EXISTS status
-"</string>
+create table choice(id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, choice TEXT, loc_lat INTEGER, loc_long INTEGER, address TEXT, url TEXT, votes INTEGER);
+create table datechoice(id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, datetime TEXT, dateortime INTEGER, votes INTEGER);
+create table voter(id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, poll_id INTEGER, choice_id INTEGER, datechoice_id INTEGER, createdby TEXT, createdon TEXT);
+insert into poll(id, key, question, private, anonymous, onechoice, locations, dates, createdon, createdby, last_vote, total_votes, user, email) values (1, 'agpwbGFjZXV2b3RlcgoLEgRQb2xsGAEM', 'Lets go for a drink next month', 0, 1, 0, 3, 2, '01-10-2010', 'Ed', '01-11-2010', 3, 'Ed', 'ed.crewe@bris.ac.uk');
+insert into choice(id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (1, 'agpwbGFjZXV2b3RlcgoLEgRQb2asdfsdfads', 1, 'Cat and Wheel', '53', '0.2', 'The Arches', 'http://catandwheel.com', 3);
+insert into choice(id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (2, 1, 'agpwbGFjZXV2b3aadgfadgfasdgf', 'Prince of Wales', '53', '0.25', '20 Gloucester Rd', 'http://pow.com', 2);
+insert into choice(id, key, poll_id, choice, loc_lat, loc_long, address, url, votes) values (3, 1, 'agpwbGFjZXV2b3Rdgfadfg', 'Robin Hood', '53', '0.3', '50 Gloucester Rd', 'http://robinhood.com', 4);
+insert into datechoice(id, key, poll_id, datetime, dateortime, votes) values (1, 'agpwbGFjZX345drfgd', 1, '21-12-2010', 0, 3);
+insert into datechoice(id, key, poll_id, datetime, dateortime, votes) values (2, 'agpwbGFj345dfsdgf', 1, '18-12-2010', 0, 5);
+insert into voter(id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (1, 'agpwbGFjZXV2bsgfdfgdgfGAEM', 1, 1, 0, 'Freddy', '21-10-2010');
+insert into voter(id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (2, 'dfgdgfdfgEgRQb2xsGAEM', 1, 2, 0, 'Jim', '21-10-2010');
+insert into voter(id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (3, 'sdgadfgadfgV2b3RlcgoLEgRQb2xsGAEM', 1, 0, 2, 'Freddy', '21-10-2010');
+insert into voter(id, key, poll_id, choice_id, datechoice_id, createdby, createdon) values (4, 'wqeshjdgjhV2b3RlcgoLEgRQb2xsGAEM', 1, 0, 3, 'Jim', '21-10-2010');
+"</string>
+<string name="PUVDatabase_onUpgrade">"
+DROP TABLE IF EXISTS poll;
+DROP TABLE IF EXISTS choice;
+DROP TABLE IF EXISTS datechoice;
+DROP TABLE IF EXISTS voter;
+"</string>
 </resources>

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

       	public long getColDates(){return getLong(getColumnIndexOrThrow("dates"));}
      	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"));}
+     	public long getColLastVote(){return getLong(getColumnIndexOrThrow("last_vote"));}
+     	public int getColTotalVotes(){return getInt(getColumnIndexOrThrow("total_votes"));}
      	public String getColUser(){return getString(getColumnIndexOrThrow("user"));}
      	public String getColEmail(){return getString(getColumnIndexOrThrow("email"));}	
     	public String getColQuestion(){return getString(getColumnIndexOrThrow("question"));}
     public static class LocationsCursor extends SQLiteCursor{
     	/** The query for this cursor */
     	private static final String QUERY = 
-	    "select _id, key, poll_id, choice, loc_lat, loc_long, "+
+	    "select id, key, poll_id, choice, loc_lat, loc_long, "+
         "address, url, votes from choice where poll_id = ";   	
     	/** Cursor constructor */
 		private LocationsCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
 	
     public static class DatesCursor extends SQLiteCursor{
     	private static final String QUERY = 
-  	    "SELECT _id, key, poll_id, datetime, dateortime, votes "+
+  	    "SELECT id, key, poll_id, datetime, dateortime, votes "+
 	    "where poll_id = ";
 	    private DatesCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
 				String editTable, SQLiteQuery query) {
     public static class VoterCursor extends SQLiteCursor{
     	/** The query for this cursor */
     	private static final String QUERY = 
-    		"SELECT _id, key, poll_id, choice_id, datechoice_id,"+ 
+    		"SELECT id, key, poll_id, choice_id, datechoice_id,"+ 
     		"created_by, created_on"+
     		"FROM voter ";
     	/** Cursor constructor */
 		} catch (SQLException e) {
             Log.e("Error creating tables and debug data", e.toString());
         } finally {
+        	Log.e("Created database tables", "OK");
         	db.endTransaction();
         }
 	}

android/placeUvote/src/com/placeuvote/android/PollMap.java

 	 * Database cursor to access user information
 	 */
 	private LocationsCursor Locations;
-	private Long poll_id;
+	private Integer poll_id;
     /**
      * LocationsOverlay
      */
         setContentView(R.layout.map);
 
         db = new PUVDatabase(this);
-
+        poll_id = 1;
         // Get current position
         final Location myLocation = getCurrentLocation((LocationManager) getSystemService(Context.LOCATION_SERVICE));
 
 
         Drawable marker = getResources().getDrawable(R.drawable.marker_image);
         marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
-        mvMap.getOverlays().add(new PUVOverlay(marker));
+        // mvMap.getOverlays().add(new PUVOverlay(marker));
 
         mvMap.setClickable(true);
         mvMap.setEnabled(true);

android/placeUvote/src/com/placeuvote/android/PollVote.java

     private static TextView txtUser;
     private static TextView txtEmail;
     private static TextView txtQuestion;
+    private static Button btnBack;
     
     PUVDatabase db;
 
         dateLastVote = (TextView) findViewById(R.id.dateLastVote);
         numTotalVotes = (TextView) findViewById(R.id.numTotalVotes);
         txtQuestion = (TextView) findViewById(R.id.txtQuestion);
+        btnBack = (Button) findViewById(R.id.btnBack);
 
         // get the poll_id for this poll from the bundle passed by PollList
         Bundle bIn = this.getIntent().getExtras();
 		chkPrivate.setChecked(IntToBool(poll.getColPrivate()));
 		chkAnonymous.setChecked(IntToBool(poll.getColAnonymous()));
 		chkOneChoice.setChecked(IntToBool(poll.getColOneChoice()));
-		dateCreatedOn.setText("Created: " + dateFormat.format(poll.getColCreatedOn()));
-		txtCreatedBy.setText(poll.getColCreatedBy());
+		dateCreatedOn.setText("Created on: " + dateFormat.format(poll.getColCreatedOn()));
+		txtCreatedBy.setText("Created by: " + poll.getColCreatedBy());
 		dateLastVote.setText("Last vote: " + dateFormat.format(poll.getColLastVote()));
-		numTotalVotes.setText(poll.getColTotalVotes());
-        txtUser.setText(poll.getColUser());
+		numTotalVotes.setText("Total votes: " + Integer.toString(poll.getColTotalVotes()));
+        // txtUser.setText(poll.getColUser());
         txtQuestion.setText(poll.getColQuestion());
 
     }
                 return false;
         }
     }
+    
+    private final Button.OnClickListener btnBackClick = new Button.OnClickListener() 
+    {
+        public void onClick(View v) 
+        {
+        	finish();
+        }
+    };  
 }

android/placeUvote/src/com/placeuvote/android/RSSReader.java

 import com.placeuvote.android.R;
 import com.placeuvote.android.PollDetail;
 
+
 public class RSSReader extends Activity implements OnItemClickListener
 {
 
 	
 	public final String tag = "RSSReader";
 	private RSSFeed feed = null;
+	private PUVDatabase db;
 	
 	/** Called when the activity is first created. */
 
         
         // go get our feed!
         feed = getFeed(PUVFEED);
+        db = new PUVDatabase(this);
 
         // display UI
         UpdateDisplay();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.