Use debug/release api keys with google maps (for taskrabbit), fixed some task rabbit copy

pull/14/head
Sam Bosley 13 years ago
parent 52fbe3b63b
commit 9247845670

@ -127,6 +127,10 @@
match="TASK_RABBIT_URL = .*"
replace="TASK_RABBIT_URL = "${apikey.taskrabbit.url}";" />
<replaceregexp file="${source.dir}/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java"
match="MAPS_API_KEY = .*"
replace="MAPS_API_KEY = &quot;${apikey.maps}&quot;;" />
<replaceregexp file="${source.dir}/com/todoroo/astrid/gtasks/api/GtasksInvoker.java"
match="API_KEY = .*"
replace="API_KEY = &quot;${apikey.gtasks}&quot;;" />

@ -158,6 +158,8 @@ public class TaskRabbitActivity extends FragmentActivity {
private TaskRabbitTaskContainer taskRabbitTask;
private boolean showingNoGPSAlertMessage = false;
public TaskRabbitActivity() {
DependencyInjectionService.getInstance().inject(this);
}
@ -217,7 +219,8 @@ public class TaskRabbitActivity extends FragmentActivity {
didReportStatistics = true;
}
populateFields();
showIntroDialog();
if (!showingNoGPSAlertMessage)
showIntroDialog();
}
@Override
@ -689,7 +692,7 @@ public class TaskRabbitActivity extends FragmentActivity {
Intent intent = new Intent(this,
OAuthLoginActivity.class);
try {
String url = TASK_RABBIT_URL + "/api/authorize?client_id=" + TASK_RABBIT_CLIENT_ID; //$NON-NLS-1$
String url = String.format(TASK_RABBIT_URL + "/api/authorize?client_id=%s&client_application=%s", TASK_RABBIT_CLIENT_ID, TASK_RABBIT_CLIENT_APPLICATION_ID); //$NON-NLS-1$
intent.putExtra(OAuthLoginActivity.URL_TOKEN, url);
this.startActivityForResult(intent, REQUEST_CODE_TASK_RABBIT_OAUTH);
StatisticsService.reportEvent(StatisticsConstants.TASK_RABBIT_LOGIN);
@ -697,11 +700,13 @@ public class TaskRabbitActivity extends FragmentActivity {
e.printStackTrace();
}
}
private void loadLocation() {
if (locationManager == null) {
locationManager = new TaskRabbitLocationManager(this);
if ( !locationManager.isLocationUpdatesEnabled()) {
if (!locationManager.isLocationUpdatesEnabled()) {
buildAlertMessageNoGps();
showingNoGPSAlertMessage = true;
}
}
currentLocation = locationManager.getLastKnownLocation();
@ -730,11 +735,14 @@ public class TaskRabbitActivity extends FragmentActivity {
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_CODE_ENABLE_GPS);
showingNoGPSAlertMessage = false;
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
dialog.cancel();
showingNoGPSAlertMessage = false;
showIntroDialog();
}
});
final AlertDialog alert = builder.create();
@ -777,7 +785,7 @@ public class TaskRabbitActivity extends FragmentActivity {
result = result.substring(result.indexOf(key)+key.length());
Preferences.setString(TASK_RABBIT_TOKEN, result);
String url = String.format("%s?oauth_token=%s&client_application=",taskRabbitURL("account"), Preferences.getStringValue(TASK_RABBIT_TOKEN), TASK_RABBIT_CLIENT_APPLICATION_ID);
String url = String.format("%s?oauth_token=%s&client_application=%s",taskRabbitURL("account"), Preferences.getStringValue(TASK_RABBIT_TOKEN), TASK_RABBIT_CLIENT_APPLICATION_ID);
String response = restClient.get(url);
saveUserInfo(response);//;
@ -789,7 +797,6 @@ public class TaskRabbitActivity extends FragmentActivity {
}
}
else if (requestCode == REQUEST_CODE_ENABLE_GPS) {
loadLocation();
}

@ -19,8 +19,10 @@ import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
@ -43,6 +45,9 @@ public class TaskRabbitMapActivity extends MapActivity implements LocationListen
private static final int LOCATION_SEARCH_SUCCESS = 1;
private static final int LOCATION_SEARCH_FAIL = -1;
// Production value
private static final String MAPS_API_KEY = "0J-miH1uUbgVV5xsNNmvSIzb4DIENVCMERxB7gw"; //$NON-NLS-1$
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
@ -50,9 +55,14 @@ public class TaskRabbitMapActivity extends MapActivity implements LocationListen
super.onCreate(savedInstanceState);
setContentView(R.layout.task_rabbit_map_activity);
mapView = (MapView) findViewById(R.id.map_view);
mapView = new MapView(this, MAPS_API_KEY);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 12.0f);
((LinearLayout) findViewById(R.id.task_rabbit_map_parent)).addView(mapView, 0, lp);
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

@ -1,18 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/task_rabbit_map_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
style="@style/Content_EditScroll" >
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="12"
android:apiKey="0J-miH1uUbgW2wG77C9qZiqvpBW8FEnoRnn7qBw"
android:clickable="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"

@ -407,7 +407,7 @@
<string name="tr_alert_title_fail">Error posting task</string>
<string name="tr_alert_message_fail">Please try again</string>
<string name="tr_alert_button_close">Close</string>
<string name="tr_alert_gps_title">GPS needs to be enabled in order to add location based tasks. Do you want to enable it?</string>
<string name="tr_alert_gps_title">Wireless Network Location Provider needs to be enabled in order to add location based tasks. Do you want to enable it?</string>
<string name="tr_alert_gps_yes">Yes</string>
<string name="tr_alert_gps_no">No</string>

Loading…
Cancel
Save