Permalink
Browse files

Merge branch 'master' of git://github.com/rheza/Google-Tasks-Client.git

I merged nearly all the the files but left out the library jars as they
should be included using Maven. I will fix this in the next commit.
  • Loading branch information...
2 parents 07f7d91 + 9026c8f commit 0ffd0461557443817f3ddbb038012021994095d3 @jaimeh committed Mar 26, 2012
View
@@ -37,3 +37,6 @@ tmp/
# CDT-specific
.cproject
+
+#ignore dsstore
+.DS_Store
View
@@ -4,20 +4,23 @@
android:versionCode="1"
android:versionName="1.0" >
- <uses-sdk android:minSdkVersion="8" />
-
+ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"></uses-sdk>
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+ <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<application
android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
+ android:label="@string/app_name"
+ android:theme="@style/Theme.Sherlock.Light"
+ uiOptions="splitActionBarWhenNarrow" >
<activity
- android:name=".GoogleTasksClientActivity"
- android:label="@string/app_name" >
+ android:name=".GoogleTasksClientActivity" android:label="Reddit Google Tasks">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name=".AddTaskActivity" android:label="Add new task"> </activity>
</application>
-
</manifest>
View
@@ -3,7 +3,6 @@ Google Tasks Client:
- The Google Tasks Client will be using OAuth, so you'll need to contact a PM for access to the API Key.
- GTC will be using the Google Tasks API to deal with the transfer of data. Go read up at: https://developers.google.com/google-apps/tasks/
-- <strike>As we haven't yet integrated Maven (in the 'Features' ticket tracker), you'll need to install the dependencies manually.</strike>
------------------
@@ -21,13 +20,14 @@ Navigate to location of google-tasks-client directory:
------------------
-Installing the dependencies manually:
+Installing the ActionBarSherlock dependencies manually:
==================
<ol>
- <li>Download <a href="http://google-api-java-client.googlecode.com/files/google-api-java-client-1.7.0-beta.zip">google-api-java-client</a></li>
- <li>Download <a href="http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/apis/google-api-services-tasks/v1-rev2-1.4.0-beta/google-api-services-tasks-v1-rev2-1.4.0-beta.zip">google-api-services-tasks</a></li>
+ <li>Download <a href="https://github.com/JakeWharton/ActionBarSherlock/zipball/4.0.0">ActionBarSherlock</a></li>
<li>Unzip</li>
- <li>In Eclipse: 'Right-click on the project > Build path > Add External Archives...'</li>
- <li>Add all of the .jar files found in the directories and their 'dependencies' subdirectories</li>
+ <li>In Eclipse: 'File > New > Create roject from existing source, Click Browse on location, choose library folder from extracted folder above, and click finish'</li>
+ <li>Right click on ActionBarSherlock > Properties, click Android tab, tick Android 4.0.3 as a Project Build Target</li>
+ <li>tick 'isLibrary' in The Library, Click Apply and OK.</li>
+ <li>Right click on Reddit Google Tasks > Properties, click Android tab, click Add... > Choose ActionBarSherlock > Click OK > Click Apply and OK</li>
<li>'Project > Clean...'</li>
-</ol>
+</ol>
View
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint>
View
17 pom.xml
@@ -11,8 +11,12 @@
<repository>
<id>google-api-services</id>
<url>http://mavenrepo.google-api-java-client.googlecode.com/hg</url>
- </repository>
- </repositories>
+ </repository>
+ <repository>
+ <id>jakewharton</id>
+ <url>http://r.jakewharton.com/maven/release/</url>
+ </repository>
+ </repositories>
<dependencyManagement>
<dependencies>
@@ -75,6 +79,7 @@
</dependency>
<!-- google-api-services-tasks -->
+
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-tasks</artifactId>
@@ -86,6 +91,14 @@
</exclusion>
</exclusions>
</dependency>
+
+ <!-- actionbarsherlock -->
+ <dependency>
+ <groupId>com.actionbarsherlock</groupId>
+ <artifactId>library</artifactId>
+ <version>4.0.0</version>
+ <type>apklib</type>
+ </dependency>
</dependencies>
</dependencyManagement>
</project>
View
@@ -9,3 +9,4 @@
# Project target.
target=Google Inc.:Google APIs:8
+android.library.reference.1=../ActionBarSherlock/library
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <EditText
+ android:id="@+id/editTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:ems="10"
+ android:hint="Task name"
+ android:inputType="text|textPersonName" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/editNote"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:ems="10"
+ android:hint="Note"
+ android:inputType="text|textPersonName" />
+
+</LinearLayout>
View
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:textColor="#000000"
+ android:text="Sample tasks"
+ android:layout_height="fill_parent"
+ android:padding="10dp"
+ android:textSize="18sp"
+ android:drawableLeft="@drawable/baseicon"
+ android:drawablePadding="10dp" >
+</TextView>
View
@@ -2,11 +2,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:orientation="vertical" >
+ android:orientation="vertical" >
- <TextView
- android:layout_width="fill_parent"
+ <ListView
+ android:id="@+id/mylist"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/hello" />
+ >
+ </ListView>
</LinearLayout>
@@ -0,0 +1,181 @@
+package com.redditandroiddevelopers.googletasksclient;
+
+
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.EditText;
+import android.widget.Toast;
+import android.preference.PreferenceManager;
+
+
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+
+
+
+
+import com.google.api.client.extensions.android2.AndroidHttp;
+import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
+import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
+import com.google.api.client.http.HttpTransport;
+import com.google.api.client.http.json.JsonHttpRequest;
+import com.google.api.client.http.json.JsonHttpRequestInitializer;
+import com.google.api.client.json.JsonFactory;
+import com.google.api.client.json.jackson.JacksonFactory;
+
+import com.google.api.services.tasks.TasksRequest;
+import com.google.api.services.tasks.model.Task;
+
+import java.io.IOException;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class AddTaskActivity extends SherlockActivity{
+
+ /** Logging level for HTTP requests/responses. */
+ private static final Level LOGGING_LEVEL = Level.OFF;
+
+ private static final String TAG = "TasksSample";
+
+ // This must be the exact string, and is a special for alias OAuth 2 scope
+ // "https://www.googleapis.com/auth/tasks"
+
+ final HttpTransport transport = AndroidHttp.newCompatibleTransport();
+
+ final JsonFactory jsonFactory = new JacksonFactory();
+
+
+
+ GoogleAccountManager accountManager;
+
+
+
+ String accountName;
+
+ GoogleCredential credential = new GoogleCredential();
+
+ com.google.api.services.tasks.Tasks service;
+ /** Called when the activity is first created. */
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+
+ SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ setContentView(R.layout.addtask);
+
+ service = com.google.api.services.tasks.Tasks.builder(transport, jsonFactory)
+ .setApplicationName("RedditGoogleTasks/1.0")
+ .setHttpRequestInitializer(credential)
+ .setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
+
+ public void initialize(JsonHttpRequest request) throws IOException {
+ TasksRequest tasksRequest = (TasksRequest) request;
+ tasksRequest.setKey(ClientCredentials.KEY);
+ }
+ })
+ .build();
+
+
+ //get the accountName and authToken from sharedPreferences settings
+ String PREF_ACCOUNT_NAME = settings.getString("accountName", null);
+ String PREF_AUTH_TOKEN = settings.getString("authToken", null);
+
+ Log.v(TAG, "PREF_ACCOUNT_NAME =" + PREF_ACCOUNT_NAME);
+ Log.v(TAG, "PREF_AUTH_TOKEN =" + PREF_AUTH_TOKEN);
+
+
+
+ accountName = PREF_ACCOUNT_NAME;
+ credential.setAccessToken(PREF_AUTH_TOKEN);
+
+ Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);
+
+ accountManager = new GoogleAccountManager(getApplicationContext());
+
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+
+ //add menu items to the action bar. look on onOptionsItemSelected to action code.
+
+ menu.add(0,0,0,"Save");
+ menu.add(0,1,0,"Cancel");
+
+
+ return true;
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+
+
+ switch(item.getItemId())
+ {
+ case 0:
+ {
+
+
+ //add task
+ new addTask().execute();
+
+
+ return true;
+ }
+ case 1:
+ {
+ Toast.makeText(this, "Search selected",
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+
+ }
+ //add task module
+ class addTask extends AsyncTask<String, Void, AddTaskActivity> {
+
+
+
+ protected AddTaskActivity doInBackground(String... urls) {
+ final EditText titleText = (EditText) findViewById(R.id.editTitle);
+ final EditText noteText = (EditText) findViewById(R.id.editNote);
+
+ Task task = new Task();
+
+ task.setTitle(titleText.getText().toString());
+ task.setNotes(noteText.getText().toString());
+
+
+
+ try {
+ Task result = service.tasks().insert("@default", task).execute();
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //close addTask Activity
+ finish();
+ return null;
+
+
+ }
+
+
+
+ }
+}
@@ -0,0 +1,14 @@
+package com.redditandroiddevelopers.googletasksclient;
+
+public class ClientCredentials {
+
+ /** Value of the "API key" shown under "Simple API Access". */
+ public static final String KEY = "AIzaSyDQQw3jm86Qpn9knnNAVlJ0IncVp5kDNJo";
+
+ public static void errorIfNotSpecified() {
+ if (KEY == null) {
+ System.err.println("Please enter your API key in " + ClientCredentials.class);
+ System.exit(1);
+ }
+ }
+ }
Oops, something went wrong.

0 comments on commit 0ffd046

Please sign in to comment.