Skip to content

Commit

Permalink
- Update build tools version.
Browse files Browse the repository at this point in the history
- Ignoring keystore files - THESE SHOULD NOT BE CHECKED IN
  They will however need to be present in the keys folder
  for the release build to work.
- Extracted Open311 credentials as resources. These should be
  defined in an xml file the IS NOT CHECKED IN
- Set max android version to 18.
- Added basic auth to feedback request.
- Added refresh on incident resolution and creation.
  • Loading branch information
justinberry committed Oct 26, 2013
1 parent 5df33b0 commit 8e9b55f
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 135 deletions.
6 changes: 3 additions & 3 deletions libraries/google-play-services_lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath 'com.android.tools.build:gradle:0.6.3'
}
}
apply plugin: 'android-library'

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
compileSdkVersion 18
buildToolsVersion "18.1.1"

sourceSets {
main {
Expand Down
1 change: 1 addition & 0 deletions resilience-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
res/values/secret.xml
**/*.keystore
9 changes: 4 additions & 5 deletions resilience-app/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.com.dius.resilience"
android:versionCode="1"
android:versionName="1.0-SNAPSHOT">
android:versionCode="2"
android:versionName="0.1">

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17"/>
android:targetSdkVersion="18"/>

<uses-feature
android:name="android.hardware.camera"
Expand Down Expand Up @@ -43,7 +43,6 @@
</intent-filter>
</activity>

<activity android:name=".ui.activity.ViewIncidentActivity"/>
<activity android:name=".ui.activity.CreateServiceRequestActivity"/>
<activity android:name=".ui.activity.ServiceRequestListActivity"/>
<activity android:name=".ui.activity.MapViewActivity"/>
Expand All @@ -56,7 +55,7 @@

<!-- TODO - extract from properties file -->
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDTpNpP7fh20uISO8MI3opvmDxQTbQlhp0" />
android:value="" />

</application>

Expand Down
29 changes: 25 additions & 4 deletions resilience-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath 'com.android.tools.build:gradle:0.6.3'
}
}
apply plugin: 'android'
Expand All @@ -16,10 +16,31 @@ dependencies {
}

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
compileSdkVersion 18
buildToolsVersion "18.1.1"

sourceSets {
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
packageName "au.com.dius.resilience"
}

signingConfigs {
release {
storeFile file("keys/release.keystore")
storePassword ""
keyAlias "resilience"
keyPassword ""
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion resilience-app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="uploading_photo">Compressing and uploading photo&#8230;</string>
<string name="uploading_issue">Creating issue&#8230;</string>
<string name="upload_complete">Complete.</string>
<string name="upload_failed">Upload failed. Please try again in a few minutes.</string>
<string name="upload_failed">Upload failed. Tap to try again.</string>
<string name="reporting">Reporting %s</string>

<!-- View/create incident -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.com.dius.resilience;

import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import au.com.dius.resilience.persistence.repository.impl.PreferenceAdapter;
Expand All @@ -18,8 +19,10 @@ public void onCreate() {
}

private void initialiseOpen311() {
Open311.setBaseUrl(getApplicationContext().getString(R.string.open_311_base_url));
Open311.setBasicAuth("android", "yyy");
Context applicationContext = getApplicationContext();
Open311.setBaseUrl(applicationContext.getString(R.string.open_311_base_url));
Open311.setBasicAuth(applicationContext.getString(R.string.open_311_username)
, applicationContext.getString(R.string.open_311_password));
}

private void setDefaultPreferences() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import au.com.dius.resilience.model.FeedbackResult;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
Expand Down Expand Up @@ -46,21 +49,19 @@ protected FeedbackResult doInBackground(Feedback... params) {
FeedbackResult result = null;

for (int i = 0; i < params.length; i++) {

result = sendFeedback(params[i]);

}

return result;
}

private FeedbackResult sendFeedback(Feedback f) {
JSONObject json = null;
HttpParams httpParams = null;
HttpClient client = null;
StringBuilder address = null;
HttpPost request = null;
HttpResponse response = null;
JSONObject json;
HttpParams httpParams;
HttpClient client;
StringBuilder address;
HttpPost request;
HttpResponse response;

// Create JSON object
try {
Expand All @@ -79,6 +80,8 @@ private FeedbackResult sendFeedback(Feedback f) {
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
client = new DefaultHttpClient(httpParams);

addAuthentication(client);

// Create URL
address = new StringBuilder(activity.getString(R.string.open_311_base_url));
address.append("/");
Expand Down Expand Up @@ -110,6 +113,12 @@ private FeedbackResult sendFeedback(Feedback f) {
return new FeedbackResult(status.getStatusCode() == FEEDBACK_SUCCESSFUL_STATUS, null);
}

private void addAuthentication(HttpClient client) {
Credentials credentials = new UsernamePasswordCredentials(activity.getString(R.string.open_311_username),
activity.getString(R.string.open_311_password));
((DefaultHttpClient)client).getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
}

@Override
protected void onPostExecute(FeedbackResult result) {
callback.onTaskDone(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Intent;

import java.io.File;

import au.com.dius.resilience.R;
import au.com.dius.resilience.intent.Extras;
import au.com.dius.resilience.intent.Intents;
import au.com.dius.resilience.persistence.repository.impl.CloudinaryRepository;
import au.com.dius.resilience.util.ImageCompressor;
import au.com.dius.resilience.util.Logger;
import au.com.justinb.open311.GenericRequestAdapter;
import au.com.justinb.open311.model.ServiceRequest;

import java.io.File;

public class CreateIncidentService extends IntentService {

private static final String CREATE_INCIDENT_SERVICE = "CreateIncidentService";
Expand All @@ -36,12 +38,12 @@ protected void onHandleIntent(Intent intent) {

String photoUri = intent.getStringExtra(Extras.PHOTO_LOCAL_URI);
ServiceRequest.Builder serviceRequestBuilder =
(ServiceRequest.Builder) intent.getSerializableExtra(Extras.SERVICE_REQUEST_BUILDER);
(ServiceRequest.Builder) intent.getSerializableExtra(Extras.SERVICE_REQUEST_BUILDER);

ServiceRequest serviceRequest = serviceRequestBuilder.createServiceRequest();

ProgressNotifier progressNotifier = new ProgressNotifier(this,
getString(R.string.reporting, serviceRequest.getServiceName()));
getString(R.string.reporting, serviceRequest.getServiceName()));

try {

Expand All @@ -55,14 +57,20 @@ protected void onHandleIntent(Intent intent) {

requestAdapter.create(serviceRequestBuilder.createServiceRequest());

Intent refreshIntent = new Intent(Intents.RESILIENCE_INCIDENT_CREATED);
sendBroadcast(refreshIntent);

progressNotifier.setText(getString(R.string.upload_complete));
progressNotifier.setProgress(DONE);

} catch (Throwable e) {
progressNotifier.setFailureAction(PendingIntent.getService(this, 0, intent, 0));
progressNotifier.setText(getString(R.string.upload_failed));
progressNotifier.setProgress(DONE);
Logger.e(this, "Error while uploading incident: ", e, e.getCause().getMessage());
Logger.e(this, "Error while uploading incident: ", e);
if (e != null && e.getCause() != null) {
Logger.e(this, "Cause: ", e.getCause().getMessage());
}
}
}
}
Loading

0 comments on commit 8e9b55f

Please sign in to comment.