mirror of https://github.com/tasks/tasks
Task rabbit views
parent
2d26d46b6e
commit
99a8a73638
@ -0,0 +1,620 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.maps.GeoPoint;
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.andlib.service.RestClient;
|
||||
import com.todoroo.andlib.utility.Preferences;
|
||||
import com.todoroo.astrid.actfm.EditPeopleControlSet.AssignedChangedListener;
|
||||
import com.todoroo.astrid.actfm.OAuthLoginActivity;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.helper.TaskEditControlSet;
|
||||
import com.todoroo.astrid.service.StatisticsConstants;
|
||||
import com.todoroo.astrid.service.StatisticsService;
|
||||
import com.todoroo.astrid.ui.PopupControlSet;
|
||||
|
||||
public class TaskRabbitControlSet extends PopupControlSet implements AssignedChangedListener, LocationListener {
|
||||
|
||||
|
||||
public interface TaskRabbitSetListener {
|
||||
public void readFromModel(JSONObject json, String key);
|
||||
public void saveToJSON(JSONObject json, String key) throws JSONException;
|
||||
public void writeToJSON(JSONObject json, String key) throws JSONException;
|
||||
}
|
||||
|
||||
/** task model */
|
||||
Task model = null;
|
||||
|
||||
@Autowired
|
||||
private RestClient restClient;
|
||||
|
||||
|
||||
GeoPoint[] supportedLocations =
|
||||
{
|
||||
new GeoPoint(42358430, -71059770),
|
||||
new GeoPoint(37739230, -122439880),
|
||||
new GeoPoint(40714350, -74005970),
|
||||
new GeoPoint(41878110, -8762980),
|
||||
new GeoPoint(34052230, -118243680),
|
||||
new GeoPoint(33717470, -117831140)};
|
||||
|
||||
/** true if editing started with a new task */
|
||||
boolean isNewTask = false;
|
||||
private EditText taskDescription;
|
||||
private Button taskButton;
|
||||
private LinearLayout taskControls;
|
||||
private Location currentLocation;
|
||||
private final Fragment fragment;
|
||||
private final List<TaskRabbitSetListener> controls = Collections.synchronizedList(new ArrayList<TaskRabbitSetListener>());
|
||||
|
||||
private Spinner spinnerMode;
|
||||
|
||||
public static final int REQUEST_CODE_TASK_RABBIT_OAUTH = 5;
|
||||
/** Act.fm current user name */
|
||||
|
||||
public static final String TASK_RABBIT_TOKEN = "task_rabbit_token"; //$NON-NLS-1$
|
||||
//public static final String TASK_RABBIT_URL = "http://www.taskrabbit.com"; //$NON-NLS-1$
|
||||
public static final String TASK_RABBIT_URL = "http://rs-astrid-api.taskrabbit.com"; //$NON-NLS-1$
|
||||
public static final String TASK_RABBIT_CLIENT_ID = "fDTmGeR0uNCvoxopNyqsRWae8xOvbOBqC7jmHaxv"; //$NON-NLS-1$
|
||||
public static final String TASK_RABBIT_CLIENT_APPLICATION_ID = "XBpKshU8utH5eaNmhky9N8aAId5rSLTh04Hi60Co"; //$NON-NLS-1$
|
||||
|
||||
public static final String CITY_NAME = "task_rabbit_city_name"; //$NON-NLS-1$
|
||||
private TaskRabbitTaskContainer taskRabbitTask;
|
||||
|
||||
|
||||
|
||||
public TaskRabbitControlSet(Fragment fragment, int viewLayout, int displayViewLayout) {
|
||||
super(fragment.getActivity(), viewLayout, displayViewLayout, 0);
|
||||
this.fragment = fragment;
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
loadLocation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void refreshDisplayView() {
|
||||
JSONObject remoteData = taskRabbitTask.getRemoteTaskData();
|
||||
if (remoteData != null)
|
||||
updateDisplay(remoteData);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
model = task;
|
||||
taskRabbitTask = TaskRabbitDataService.getInstance().getContainerForTask(model);
|
||||
updateTaskRow(taskRabbitTask);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OnClickListener getDisplayClickListener() {
|
||||
return new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setUpUIComponents();
|
||||
dialog.show();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
// TaskRabbitDataService.getInstance().saveTaskAndMetadata(taskRabbitTask);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void updateTaskRow(TaskRabbitTaskContainer container) {
|
||||
displayText.setText("Task Rabbit Status");
|
||||
JSONObject remoteData = container.getRemoteTaskData();
|
||||
if (remoteData != null) {
|
||||
updateDisplay(remoteData);
|
||||
updateStatus(remoteData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setUpControls() {
|
||||
TypedArray arrays = activity.getResources().obtainTypedArray(R.array.tr_default_set);
|
||||
TypedArray arrayType = activity.getResources().obtainTypedArray(R.array.tr_default_array);
|
||||
for (int i = 0; i < arrays.length(); i++) {
|
||||
|
||||
|
||||
int titleID = arrays.getResourceId(i, -1);
|
||||
int arrayID = arrayType.getResourceId(i, -1);
|
||||
if (arrayID == R.string.tr_location) {
|
||||
TaskRabbitLocationControlSet set = new TaskRabbitLocationControlSet(fragment, R.layout.task_rabbit_row, titleID, i, spinnerMode.getSelectedItemPosition());
|
||||
controls.add(set);
|
||||
}
|
||||
else if(arrayID == R.string.tr_deadline) {
|
||||
|
||||
TaskRabbitDeadlineControlSet deadlineControl = new TaskRabbitDeadlineControlSet(
|
||||
activity, R.layout.control_set_deadline,
|
||||
R.layout.task_rabbit_row);
|
||||
controls.add(deadlineControl);
|
||||
}
|
||||
else if(arrayID == R.string.tr_name) {
|
||||
TaskRabbitNameControlSet nameControlSet = new TaskRabbitNameControlSet(activity,
|
||||
R.layout.control_set_notes, R.layout.control_set_notes_display, titleID, i);
|
||||
controls.add(nameControlSet);
|
||||
}
|
||||
else {
|
||||
TaskRabbitSpinnerControlSet set = new TaskRabbitSpinnerControlSet(fragment, R.layout.task_rabbit_spinner, titleID, i, spinnerMode.getSelectedItemPosition());
|
||||
controls.add(set);
|
||||
}
|
||||
}
|
||||
if(taskDescription.getText().length() == 0){
|
||||
taskDescription.setText(model.getValue(Task.TITLE) + model.getValue(Task.NOTES));
|
||||
}
|
||||
populateFields(taskRabbitTask);
|
||||
}
|
||||
private void displayViewsForMode(int mode) {
|
||||
|
||||
for (int i = 0; i < taskControls.getChildCount(); i++){
|
||||
ViewGroup row = (ViewGroup)taskControls.getChildAt(i);
|
||||
row.removeAllViews();
|
||||
}
|
||||
taskControls.removeAllViews();
|
||||
|
||||
LinearLayout row = null;
|
||||
|
||||
int[] presetValues = getPresetValues(mode);
|
||||
String[] keys = activity.getResources().getStringArray(R.array.tr_default_set_key);
|
||||
for (int i = 1; i < controls.size(); i++) {
|
||||
if (presetValues[i] == -1) continue;
|
||||
if (row == null || row.getChildCount() == 2) {
|
||||
row = new LinearLayout(activity);
|
||||
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 100));
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
taskControls.addView(row);
|
||||
}
|
||||
TaskRabbitSetListener set = controls.get(i);
|
||||
row.addView(((TaskEditControlSet)set).getDisplayView(), new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
|
||||
JSONObject parameters = new JSONObject();
|
||||
try {
|
||||
parameters.put(keys[i], (presetValues[i]));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
((TaskRabbitSetListener) set).readFromModel(parameters, keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Initialize UI components */
|
||||
private void setUpUIComponents() {
|
||||
if (taskDescription == null){
|
||||
taskDescription = (EditText) getView().findViewById(R.id.task_description);
|
||||
|
||||
taskControls = (LinearLayout)getView().findViewById(R.id.task_controls);
|
||||
|
||||
taskButton = (Button) getView().findViewById(R.id.task_button);
|
||||
taskButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
submitTaskRabbit();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
spinnerMode = (Spinner) getView().findViewById(R.id.task_type);
|
||||
String[] listTypes = activity.getResources().getStringArray(
|
||||
R.array.tr_preset_types);
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
||||
activity, android.R.layout.simple_spinner_item, listTypes);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
spinnerMode.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
spinnerMode.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
displayViewsForMode(spinnerMode.getSelectedItemPosition());
|
||||
}
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setUpControls();
|
||||
}
|
||||
}
|
||||
|
||||
private void populateFields(TaskRabbitTaskContainer container) {
|
||||
if (container == null) {
|
||||
return;
|
||||
}
|
||||
JSONObject jsonData = container.getLocalTaskData();
|
||||
synchronized (controls) {
|
||||
if(jsonData != null) {
|
||||
String[] keys = activity.getResources().getStringArray(R.array.tr_default_set_key);
|
||||
spinnerMode.setSelection(jsonData.optInt(keys[0]));
|
||||
for (int i = 1; i < controls.size(); i++) {
|
||||
TaskRabbitSetListener set = (TaskRabbitSetListener) controls.get(i);
|
||||
set.readFromModel(jsonData, keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject localParamsToJSON () throws JSONException {
|
||||
|
||||
JSONObject parameters = new JSONObject();
|
||||
|
||||
int[] presetValues = getPresetValues(spinnerMode.getSelectedItemPosition());
|
||||
String[] keys = activity.getResources().getStringArray(R.array.tr_default_set_key);
|
||||
|
||||
parameters.put(activity.getString(R.string.tr_set_key_type), spinnerMode.getSelectedItem().toString());
|
||||
parameters.put(activity.getString(R.string.tr_set_key_description), taskDescription.getText().toString());
|
||||
for (int i = 1; i < controls.size(); i++) {
|
||||
if (presetValues[i] == -1) continue;
|
||||
TaskRabbitSetListener set = controls.get(i);
|
||||
set.writeToJSON(parameters, keys[i]);
|
||||
}
|
||||
if (parameters.optJSONArray("other_locations_attributes") == null) {
|
||||
parameters.put(activity.getString(R.string.tr_attr_city_id), Preferences.getInt("task_rabbit_city_id", 1));
|
||||
parameters.put(activity.getString(R.string.tr_attr_city_lat), true);
|
||||
}
|
||||
|
||||
Log.d("localParamsToJSON", parameters.toString());
|
||||
return new JSONObject().put("task", parameters);
|
||||
}
|
||||
|
||||
|
||||
private int[] getPresetValues(int mode) {
|
||||
TypedArray arrays = activity.getResources().obtainTypedArray(R.array.tr_default_type_array);
|
||||
int[] presetValues = activity.getResources().getIntArray(arrays.getResourceId(mode, -1));
|
||||
return presetValues;
|
||||
}
|
||||
|
||||
|
||||
private String serializeToJSON () throws JSONException {
|
||||
|
||||
JSONObject parameters = new JSONObject();
|
||||
String[] keys = activity.getResources().getStringArray(R.array.tr_default_set_key);
|
||||
for (int i = 1; i < controls.size(); i++) {
|
||||
TaskRabbitSetListener set = controls.get(i);
|
||||
set.saveToJSON(parameters, keys[i]);
|
||||
}
|
||||
parameters.put(activity.getString(R.string.tr_set_key_type), spinnerMode.getSelectedItemPosition());
|
||||
parameters.put(activity.getString(R.string.tr_set_key_description), taskDescription.getText().toString());
|
||||
return parameters.toString();
|
||||
}
|
||||
private HttpEntity getTaskBody() {
|
||||
|
||||
try {
|
||||
return new StringEntity(localParamsToJSON().toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private final Handler handler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case -1:
|
||||
|
||||
if(dialog.isShowing()) {
|
||||
AlertDialog.Builder adb = new AlertDialog.Builder(activity);
|
||||
adb.setTitle("Error posting task");
|
||||
adb.setMessage("Please try again");
|
||||
adb.setPositiveButton("Close",null);
|
||||
adb.show();
|
||||
}
|
||||
break;
|
||||
case 0: break;
|
||||
case 1:
|
||||
showSuccessToast();
|
||||
TaskRabbitDataService.getInstance().saveTaskAndMetadata(taskRabbitTask);
|
||||
updateDisplay(taskRabbitTask.getRemoteTaskData());
|
||||
dialog.dismiss();
|
||||
break;
|
||||
case 2:
|
||||
TaskRabbitDataService.getInstance().saveTaskAndMetadata(taskRabbitTask);
|
||||
updateDisplay(taskRabbitTask.getRemoteTaskData());
|
||||
dialog.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected void submitTaskRabbit(){
|
||||
|
||||
if(!Preferences.isSet(TASK_RABBIT_TOKEN)){
|
||||
loginTaskRabbit();
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
String urlCall = "tasks/";
|
||||
Log.d("Tasks url:", taskRabbitURL(urlCall));
|
||||
Header authorization = new BasicHeader("Authorization", "OAuth " + Preferences.getStringValue(TASK_RABBIT_TOKEN)); //$NON-NLS-1$
|
||||
Header contentType = new BasicHeader("Content-Type", //$NON-NLS-1$
|
||||
"application/json"); //$NON-NLS-1$
|
||||
String response = restClient.post(taskRabbitURL(urlCall), getTaskBody(), contentType, authorization);
|
||||
Log.d("Task rabbit response", response);
|
||||
JSONObject taskResponse = new JSONObject(response);
|
||||
if(taskResponse.has("id")){
|
||||
taskRabbitTask.setRemoteTaskData(response);
|
||||
taskRabbitTask.setTaskID(taskResponse.optString("id"));
|
||||
Message successMessage = new Message();
|
||||
successMessage.what = 1;
|
||||
handler.sendMessage(successMessage);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Message failureMessage = new Message();
|
||||
failureMessage.what = -1;
|
||||
handler.sendMessage(failureMessage);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
try {
|
||||
taskRabbitTask.setLocalTaskData(serializeToJSON().toString());
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//submit!
|
||||
}
|
||||
|
||||
/**
|
||||
* Show toast for task edit canceling
|
||||
*/
|
||||
private void showSuccessToast() {
|
||||
Toast.makeText(activity, "Task posted to Task Rabbit successfully!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
protected void loginTaskRabbit() {
|
||||
Intent intent = new Intent(activity,
|
||||
OAuthLoginActivity.class);
|
||||
try {
|
||||
String url = TASK_RABBIT_URL + "/api/authorize?client_id=" + TASK_RABBIT_CLIENT_ID;
|
||||
intent.putExtra(OAuthLoginActivity.URL_TOKEN, url);
|
||||
fragment.startActivityForResult(intent, REQUEST_CODE_TASK_RABBIT_OAUTH);
|
||||
StatisticsService.reportEvent(StatisticsConstants.ACTFM_LOGIN_GL_START);
|
||||
} catch (Exception e) {
|
||||
// handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void loadLocation() {
|
||||
LocationManager locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
|
||||
currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
|
||||
updateControlSetLocation(currentLocation);
|
||||
}
|
||||
|
||||
protected void saveUserInfo(String response) throws Exception {
|
||||
JSONObject userObject = new JSONObject(response);
|
||||
JSONObject cityObject = userObject.getJSONObject("city");
|
||||
if (cityObject.has("name")){
|
||||
Preferences.setString("task_rabbit_city_name", cityObject.getString("name"));
|
||||
}
|
||||
if (cityObject.has("id")){
|
||||
Preferences.setInt("task_rabbit_city_id", cityObject.getInt("id"));
|
||||
}
|
||||
if (cityObject.has("lat")){
|
||||
// currentLocation.setLatitude(cityObject.getDouble("lat"));
|
||||
Preferences.setString("task_rabbit_city_lat", String.valueOf(cityObject.getDouble("lat")));
|
||||
}
|
||||
if (cityObject.has("lng")){
|
||||
// currentLocation.setLongitude(cityObject.getDouble("lng"));
|
||||
Preferences.setString("task_rabbit_city_lng", String.valueOf(cityObject.getDouble("lng")));
|
||||
}
|
||||
}
|
||||
|
||||
private String taskRabbitURL(String method) {
|
||||
return TASK_RABBIT_URL + "/api/v1/"+ method;
|
||||
|
||||
}
|
||||
|
||||
/** Fire task rabbit if assigned **/
|
||||
@Override
|
||||
public void assignedChanged(String name, JSONObject json) {
|
||||
// TODO Auto-generated method stub
|
||||
if (name.equals(activity.getString(R.string.actfm_EPA_task_rabbit))) {
|
||||
setUpUIComponents();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean activityResult (int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_TASK_RABBIT_OAUTH && resultCode == Activity.RESULT_OK){
|
||||
String result = data.getStringExtra(OAuthLoginActivity.DATA_RESPONSE);
|
||||
if(result.contains("access_token=")) {
|
||||
try {
|
||||
result = result.substring(result.indexOf("access_token=")+"access_token=".length());
|
||||
Preferences.setString(TASK_RABBIT_TOKEN, result);
|
||||
String response = restClient.get(taskRabbitURL("account"));
|
||||
Log.d("Task rabbit response", response);
|
||||
saveUserInfo(response);
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (TaskRabbitSetListener set : controls) {
|
||||
if (set.getClass().equals(TaskRabbitLocationControlSet.class)) {
|
||||
if (((TaskRabbitLocationControlSet) set).activityResult(requestCode, resultCode, data)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see android.location.LocationListener#onLocationChanged(android.location.Location)
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
|
||||
currentLocation = location;
|
||||
updateControlSetLocation(currentLocation);
|
||||
|
||||
}
|
||||
public void updateControlSetLocation (Location location) {
|
||||
for (TaskRabbitSetListener controlSet : controls) {
|
||||
if (TaskRabbitLocationControlSet.class.isAssignableFrom(controlSet.getClass())) {
|
||||
((TaskRabbitLocationControlSet) controlSet).updateCurrentLocation(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
public void updateDisplay(JSONObject json) {
|
||||
if (json != null && json.has("state_label")) {
|
||||
String status = json.optString(activity.getString(R.string.tr_attr_state_label));
|
||||
TextView statusText = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
|
||||
statusText.setText(status);
|
||||
getDisplayView().setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
getDisplayView().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void updateStatus(JSONObject json){
|
||||
|
||||
final int taskID = json.optInt("id"); //$NON-NLS-1$
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
Log.d("Tasks url:", taskRabbitURL("tasks/" + taskID));
|
||||
String response = restClient.get(taskRabbitURL("tasks/" + taskID));
|
||||
Log.d("Task rabbit response", response);
|
||||
JSONObject taskResponse = new JSONObject(response);
|
||||
if(taskResponse.has("id")){
|
||||
taskRabbitTask.setRemoteTaskData(response);
|
||||
taskRabbitTask.setTaskID(taskResponse.optString("id"));
|
||||
Message successMessage = new Message();
|
||||
successMessage.what = 2;
|
||||
handler.sendMessage(successMessage);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Message failureMessage = new Message();
|
||||
failureMessage.what = 0;
|
||||
handler.sendMessage(failureMessage);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
//submit!
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return !TextUtils.isEmpty(Preferences.getStringValue(TASK_RABBIT_TOKEN));
|
||||
}
|
||||
@Override
|
||||
public boolean shouldShowTaskRabbit() {
|
||||
//if (isLoggedIn()) return true;
|
||||
if(!Locale.getDefault().getCountry().equals("US") ) return false; //$NON-NLS-1$
|
||||
for (GeoPoint point : supportedLocations){
|
||||
Location city = new Location(""); //$NON-NLS-1$
|
||||
city.setLatitude(point.getLatitudeE6()/1E6);
|
||||
city.setLongitude(point.getLongitudeE6()/1E6);
|
||||
float distance = currentLocation.distanceTo(city);
|
||||
if (distance < 400000) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
/**
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.todoroo.andlib.data.Property;
|
||||
import com.todoroo.andlib.data.TodorooCursor;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.andlib.sql.Criterion;
|
||||
import com.todoroo.andlib.sql.Join;
|
||||
import com.todoroo.andlib.sql.Query;
|
||||
import com.todoroo.astrid.core.PluginServices;
|
||||
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
||||
import com.todoroo.astrid.dao.StoreObjectDao;
|
||||
import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria;
|
||||
import com.todoroo.astrid.dao.TaskDao;
|
||||
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
import com.todoroo.astrid.data.StoreObject;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.notes.NoteMetadata;
|
||||
import com.todoroo.astrid.producteev.ProducteevUtilities;
|
||||
import com.todoroo.astrid.producteev.sync.ProducteevDashboard;
|
||||
import com.todoroo.astrid.service.MetadataService;
|
||||
import com.todoroo.astrid.tags.TagService;
|
||||
|
||||
public final class TaskRabbitDataService {
|
||||
|
||||
// --- constants
|
||||
|
||||
/** Utility for joining tasks with metadata */
|
||||
public static final Join METADATA_JOIN = Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK));
|
||||
|
||||
/** NoteMetadata provider string */
|
||||
public static final String NOTE_PROVIDER = "taskrabbit"; //$NON-NLS-1$
|
||||
|
||||
// --- singleton
|
||||
|
||||
private static TaskRabbitDataService instance = null;
|
||||
|
||||
public static synchronized TaskRabbitDataService getInstance() {
|
||||
if(instance == null)
|
||||
instance = new TaskRabbitDataService(ContextManager.getContext());
|
||||
return instance;
|
||||
}
|
||||
|
||||
// --- instance variables
|
||||
|
||||
protected final Context context;
|
||||
|
||||
@Autowired
|
||||
private TaskDao taskDao;
|
||||
|
||||
@Autowired
|
||||
private MetadataService metadataService;
|
||||
|
||||
@Autowired
|
||||
private StoreObjectDao storeObjectDao;
|
||||
|
||||
private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE;
|
||||
|
||||
static final Random random = new Random();
|
||||
|
||||
private TaskRabbitDataService(Context context) {
|
||||
this.context = context;
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
}
|
||||
|
||||
// --- task and metadata methods
|
||||
|
||||
/**
|
||||
* Clears metadata information. Used when user logs out of service
|
||||
*/
|
||||
public void clearMetadata() {
|
||||
PluginServices.getTaskService().clearDetails(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).
|
||||
where(MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY))));
|
||||
metadataService.deleteWhere(Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY));
|
||||
storeObjectDao.deleteWhere(StoreObject.TYPE.eq(ProducteevDashboard.TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tasks that were created since last sync
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public TodorooCursor<Task> getLocallyCreated(Property<?>[] properties) {
|
||||
return
|
||||
taskDao.query(Query.select(properties).join(TaskRabbitDataService.METADATA_JOIN).where(
|
||||
Criterion.and(
|
||||
Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).
|
||||
where(Criterion.and(MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY), TaskRabbitMetadata.ID.gt(0))))),
|
||||
TaskCriteria.isActive())).
|
||||
groupBy(Task.ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tasks that were modified since last sync
|
||||
* @param properties
|
||||
* @return null if never sync'd
|
||||
*/
|
||||
public TodorooCursor<Task> getLocallyUpdated(Property<?>[] properties) {
|
||||
long lastSyncDate = preferences.getLastSyncDate();
|
||||
if(lastSyncDate == 0)
|
||||
return taskDao.query(Query.select(Task.ID).where(Criterion.none));
|
||||
return
|
||||
taskDao.query(Query.select(properties).join(TaskRabbitDataService.METADATA_JOIN).where(
|
||||
Criterion.and(
|
||||
MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY),
|
||||
TaskRabbitMetadata.ID.gt(0),
|
||||
Task.MODIFICATION_DATE.gt(lastSyncDate))).
|
||||
groupBy(Task.ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for a local task with same remote id, updates this task's id
|
||||
* @param remoteTask
|
||||
* @return true if found local match
|
||||
*/
|
||||
public boolean findLocalMatch(TaskRabbitTaskContainer remoteTask) {
|
||||
if(remoteTask.task.getId() != Task.NO_ID)
|
||||
return true;
|
||||
TodorooCursor<Task> cursor = taskDao.query(Query.select(Task.ID).
|
||||
join(TaskRabbitDataService.METADATA_JOIN).where(Criterion.and(MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY),
|
||||
TaskRabbitMetadata.ID.eq(remoteTask.trTask.getValue(TaskRabbitMetadata.ID)))));
|
||||
try {
|
||||
if(cursor.getCount() == 0)
|
||||
return false;
|
||||
cursor.moveToFirst();
|
||||
remoteTask.task.setId(cursor.get(Task.ID));
|
||||
return true;
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a task and its metadata
|
||||
* @param task
|
||||
*/
|
||||
public void saveTaskAndMetadata(TaskRabbitTaskContainer task) {
|
||||
taskDao.save(task.task);
|
||||
|
||||
task.metadata.add(task.trTask);
|
||||
// note we don't include note metadata, since we only receive deltas
|
||||
metadataService.synchronizeMetadata(task.task.getId(), task.metadata,
|
||||
Criterion.or(MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY),
|
||||
MetadataCriteria.withKey(TagService.KEY)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a task and its metadata
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
public TaskRabbitTaskContainer readTaskAndMetadata(TodorooCursor<Task> taskCursor) {
|
||||
Task task = new Task(taskCursor);
|
||||
|
||||
// read tags, notes, etc
|
||||
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
|
||||
TodorooCursor<Metadata> metadataCursor = metadataService.query(Query.select(Metadata.PROPERTIES).
|
||||
where(Criterion.and(MetadataCriteria.byTask(task.getId()),
|
||||
Criterion.or(MetadataCriteria.withKey(TagService.KEY),
|
||||
MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY),
|
||||
MetadataCriteria.withKey(NoteMetadata.METADATA_KEY)))));
|
||||
try {
|
||||
for(metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) {
|
||||
metadata.add(new Metadata(metadataCursor));
|
||||
}
|
||||
} finally {
|
||||
metadataCursor.close();
|
||||
}
|
||||
|
||||
return new TaskRabbitTaskContainer(task, metadata.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a task and its metadata
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
public TaskRabbitTaskContainer getContainerForTask(Task task) {
|
||||
// read tags, notes, etc
|
||||
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
|
||||
TodorooCursor<Metadata> metadataCursor = metadataService.query(Query.select(Metadata.PROPERTIES).
|
||||
where(Criterion.and(MetadataCriteria.byTask(task.getId()),
|
||||
Criterion.or(MetadataCriteria.withKey(TagService.KEY),
|
||||
MetadataCriteria.withKey(TaskRabbitMetadata.METADATA_KEY),
|
||||
MetadataCriteria.withKey(NoteMetadata.METADATA_KEY)))));
|
||||
try {
|
||||
for(metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) {
|
||||
metadata.add(new Metadata(metadataCursor));
|
||||
}
|
||||
} finally {
|
||||
metadataCursor.close();
|
||||
}
|
||||
|
||||
if (metadata.size() == 0) return new TaskRabbitTaskContainer(task);
|
||||
return new TaskRabbitTaskContainer(task, metadata.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads metadata out of a task
|
||||
* @return null if no metadata found
|
||||
*/
|
||||
public Metadata getTaskMetadata(long taskId) {
|
||||
TodorooCursor<Metadata> cursor = metadataService.query(Query.select(
|
||||
Metadata.PROPERTIES).where(
|
||||
MetadataCriteria.byTaskAndwithKey(taskId, TaskRabbitMetadata.METADATA_KEY)));
|
||||
try {
|
||||
if(cursor.getCount() == 0)
|
||||
return null;
|
||||
cursor.moveToFirst();
|
||||
return new Metadata(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads task notes out of a task
|
||||
*/
|
||||
public TodorooCursor<Metadata> getTaskNotesCursor(long taskId) {
|
||||
TodorooCursor<Metadata> cursor = metadataService.query(Query.select(Metadata.PROPERTIES).
|
||||
where(MetadataCriteria.byTaskAndwithKey(taskId, NoteMetadata.METADATA_KEY)));
|
||||
return cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads store objects.
|
||||
*/
|
||||
public StoreObject[] readStoreObjects(String type) {
|
||||
StoreObject[] ret;
|
||||
TodorooCursor<StoreObject> cursor = storeObjectDao.query(Query.select(StoreObject.PROPERTIES).
|
||||
where(StoreObjectCriteria.byType(type)));
|
||||
try {
|
||||
ret = new StoreObject[cursor.getCount()];
|
||||
for(int i = 0; i < ret.length; i++) {
|
||||
cursor.moveToNext();
|
||||
StoreObject dashboard = new StoreObject(cursor);
|
||||
ret[i] = dashboard;
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
import com.todoroo.andlib.utility.DialogUtilities;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet.TaskRabbitSetListener;
|
||||
import com.todoroo.astrid.ui.DateAndTimePicker;
|
||||
import com.todoroo.astrid.ui.PopupControlSet;
|
||||
|
||||
public class TaskRabbitDeadlineControlSet extends PopupControlSet implements TaskRabbitSetListener{
|
||||
|
||||
private final DateAndTimePicker dateAndTimePicker;
|
||||
|
||||
public TaskRabbitDeadlineControlSet(Activity activity, int viewLayout, int displayViewLayout) {
|
||||
super(activity, viewLayout, displayViewLayout, 0);
|
||||
|
||||
dateAndTimePicker = (DateAndTimePicker) getView().findViewById(R.id.date_and_time);
|
||||
this.displayText.setText(activity.getString(R.string.TEA_when_header_label));
|
||||
|
||||
Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null);
|
||||
okButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onOkClick();
|
||||
DialogUtilities.dismissDialog(TaskRabbitDeadlineControlSet.this.activity, TaskRabbitDeadlineControlSet.this.dialog);
|
||||
}
|
||||
});
|
||||
LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body);
|
||||
body.addView(okButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshDisplayView() {
|
||||
TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
|
||||
String toDisplay = dateAndTimePicker.getDisplayString(activity);
|
||||
dateDisplay.setText(toDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
long dueDate = task.getValue(Task.DUE_DATE);
|
||||
dateAndTimePicker.initializeWithDate(dueDate);
|
||||
refreshDisplayView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromModel(JSONObject json, String key) {
|
||||
long dateValue = json.optLong(key);
|
||||
Date currentDate = null;
|
||||
if (dateValue < 24) {
|
||||
currentDate = new Date();
|
||||
currentDate.setHours((int)dateValue);
|
||||
currentDate.setMinutes(0);
|
||||
currentDate.setSeconds(0);
|
||||
}
|
||||
else {
|
||||
currentDate = new Date(dateValue);
|
||||
}
|
||||
|
||||
dateAndTimePicker.initializeWithDate(DateUtilities.dateToUnixtime(currentDate)+ DateUtilities.ONE_DAY);
|
||||
refreshDisplayView();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveToJSON(JSONObject json, String key) throws JSONException {
|
||||
json.put(key, dateAndTimePicker.constructDueDate());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToJSON(JSONObject json, String key) throws JSONException {
|
||||
long dueDate = dateAndTimePicker.constructDueDate();
|
||||
json.put(key, dueDate);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.helper.TaskEditControlSet;
|
||||
import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet.TaskRabbitSetListener;
|
||||
|
||||
public class TaskRabbitLocationControlSet extends TaskEditControlSet implements TaskRabbitSetListener {
|
||||
|
||||
private final int setID;
|
||||
private final int type;
|
||||
private final TextView displayText;
|
||||
private final TextView displayEdit;
|
||||
private final Fragment fragment;
|
||||
private Location location;
|
||||
private String locationName;
|
||||
|
||||
public int REQUEST_CODE_TASK_RABBIT_LOCATION = 6;
|
||||
|
||||
public TaskRabbitLocationControlSet(final Fragment fragment , int viewLayout, int title, int setID, int type) {
|
||||
super(fragment.getActivity(), viewLayout);
|
||||
this.setID = setID;
|
||||
this.type = type;
|
||||
this.fragment = fragment;
|
||||
// DependencyInjectionService.getInstance().inject(this);
|
||||
REQUEST_CODE_TASK_RABBIT_LOCATION += setID;
|
||||
|
||||
displayText = (TextView) getDisplayView().findViewById(R.id.display_row_title);
|
||||
displayText.setText(getActivity().getString(title));
|
||||
|
||||
displayEdit = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
|
||||
displayEdit.setText(getLocationText());
|
||||
|
||||
this.getView().setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent mapIntent = new Intent(getActivity(), TaskRabbitMapActivity.class);
|
||||
fragment.startActivityForResult(mapIntent, REQUEST_CODE_TASK_RABBIT_LOCATION);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private Activity getActivity() {
|
||||
return fragment.getActivity();
|
||||
}
|
||||
|
||||
|
||||
private void parseTaskLocation(JSONObject json) {
|
||||
|
||||
if (json == null) return;
|
||||
if (json.has("name"))
|
||||
locationName = json.optString("name");
|
||||
if(json.has("lng")) {
|
||||
location = new Location("");
|
||||
location.setLatitude(json.optInt("lng"));
|
||||
location.setLatitude(json.optInt("lat"));
|
||||
}
|
||||
}
|
||||
|
||||
public String getLocationText () {
|
||||
if (!TextUtils.isEmpty(locationName) && location != null)
|
||||
return String.format("%S (%d : %d)", locationName, location.getLongitude(), location.getLatitude());
|
||||
|
||||
return "Current location";
|
||||
}
|
||||
public boolean activityResult (int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_TASK_RABBIT_LOCATION && resultCode == Activity.RESULT_OK) {
|
||||
|
||||
int lng = data.getIntExtra("lng", 0);
|
||||
int lat = data.getIntExtra("lat", 0);
|
||||
locationName = data.getStringExtra("name");
|
||||
location = new Location("");
|
||||
location.setLatitude(locationToDouble(lat));
|
||||
location.setLongitude(locationToDouble(lng));
|
||||
displayEdit.setText(getLocationText());
|
||||
|
||||
Log.d("TASK RABBIT CONTROL SET FOUND CODE", "THE LAT IS: " + lat + " LNG IS: " + lng);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static double locationToDouble(int location) {
|
||||
return (location+ 0.0) / 1e6;
|
||||
}
|
||||
public static int locationToInt(double location) {
|
||||
return (int)(location * 1e6);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void getAddressFromLocation(Location location){
|
||||
try {
|
||||
Geocoder geocoder = new Geocoder(fragment.getActivity(), Locale.getDefault());
|
||||
// Acquire a reference to the system Location Manager
|
||||
List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
|
||||
if (addresses != null){
|
||||
for (Address address : addresses){
|
||||
updateAddress(address);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("Location error", e.toString());
|
||||
}
|
||||
}
|
||||
private void updateAddress(Address address){
|
||||
if(address.getLocality() != null && address.getPostalCode() != null){
|
||||
locationName = (address.getLocality() + ", " + address.getPostalCode());
|
||||
// currentAddress = address;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromModel(JSONObject json, String key) {
|
||||
parseTaskLocation(json.optJSONObject(key));
|
||||
displayEdit.setText(getLocationText());
|
||||
}
|
||||
|
||||
public void updateCurrentLocation(Location currentLocation) {
|
||||
if (location != null) {
|
||||
location = currentLocation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToJSON(JSONObject json, String key) throws JSONException {
|
||||
json.put(key, getTaskLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToJSON(JSONObject json, String key) throws JSONException {
|
||||
JSONArray locations = json.optJSONArray("other_locations_attributes");
|
||||
if (locations == null) {
|
||||
locations = new JSONArray();
|
||||
}
|
||||
locations.put(getTaskLocation());
|
||||
json.put("other_locations_attributes", locations);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private JSONObject getTaskLocation() {
|
||||
|
||||
try {
|
||||
JSONObject locationObject = new JSONObject();
|
||||
if(!TextUtils.isEmpty(locationName)){
|
||||
locationObject.put("name", locationName);
|
||||
}
|
||||
else {
|
||||
locationObject.put("name", displayText.getText().toString());
|
||||
}
|
||||
if(location != null) {
|
||||
locationObject.put("lng", location.getLongitude());
|
||||
locationObject.put("lat", location.getLatitude());
|
||||
}
|
||||
else {
|
||||
locationObject.put("address", "300 Beale");
|
||||
locationObject.put("city", "San Francisco");
|
||||
locationObject.put("state", "CA");
|
||||
locationObject.put("zip", "94158");
|
||||
}
|
||||
return locationObject;
|
||||
}
|
||||
catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//don't need these
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
}
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.android.maps.GeoPoint;
|
||||
import com.google.android.maps.MapActivity;
|
||||
import com.google.android.maps.MapController;
|
||||
import com.google.android.maps.MapView;
|
||||
import com.google.android.maps.Overlay;
|
||||
import com.google.android.maps.OverlayItem;
|
||||
import com.timsu.astrid.R;
|
||||
|
||||
|
||||
public class TaskRabbitMapActivity extends MapActivity implements LocationListener {
|
||||
|
||||
private MapView mapView;
|
||||
private MapController mapController;
|
||||
public Location location;
|
||||
private EditText searchText;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.task_rabbit_map_activity);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.map_view);
|
||||
mapView.setBuiltInZoomControls(true);
|
||||
|
||||
|
||||
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
||||
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
|
||||
|
||||
List<Overlay> mapOverlays = mapView.getOverlays();
|
||||
|
||||
Drawable drawable = this.getResources().getDrawable(R.drawable.icon_locale);
|
||||
TaskRabbitMapOverlayItem itemizedoverlay = new TaskRabbitMapOverlayItem(drawable, this);
|
||||
GeoPoint point = null;
|
||||
if(lastKnownLocation != null) {
|
||||
|
||||
point = new GeoPoint((int)(lastKnownLocation.getLatitude()*1E6),(int)(lastKnownLocation.getLongitude()*1E6));
|
||||
}
|
||||
else {
|
||||
point = new GeoPoint(19240000,-99120000);
|
||||
}
|
||||
|
||||
OverlayItem overlayitem = new OverlayItem(point, "Set this location", "For the rabbits!");
|
||||
itemizedoverlay.addOverlay(overlayitem);
|
||||
mapOverlays.add(itemizedoverlay);
|
||||
|
||||
|
||||
|
||||
|
||||
mapController = mapView.getController();
|
||||
mapController.animateTo(point);
|
||||
mapController.setZoom(17);
|
||||
mapView.invalidate();
|
||||
|
||||
searchText=(EditText)findViewById(R.id.search_text);
|
||||
|
||||
Button searchButton=(Button)findViewById(R.id.search_button);
|
||||
searchButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
searchLocation();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private final Handler handler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
|
||||
mapView.invalidate();
|
||||
// What to do when ready, example:
|
||||
break;
|
||||
case -1:
|
||||
|
||||
AlertDialog.Builder adb = new AlertDialog.Builder(TaskRabbitMapActivity.this);
|
||||
adb.setTitle("Google Map");
|
||||
adb.setMessage("Please Provide the Proper Place");
|
||||
adb.setPositiveButton("Close",null);
|
||||
adb.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void searchLocation() {
|
||||
|
||||
Thread thread = new Thread(){
|
||||
@Override
|
||||
public void run (){
|
||||
|
||||
List<Address> addresses = null;
|
||||
try {
|
||||
|
||||
Geocoder geoCoder = new Geocoder(TaskRabbitMapActivity.this, Locale.getDefault());
|
||||
addresses = geoCoder.getFromLocationName(searchText.getText().toString(),5);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(addresses != null && addresses.size() > 0)
|
||||
{
|
||||
GeoPoint q = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6),
|
||||
(int) (addresses.get(0).getLongitude() * 1E6));
|
||||
|
||||
Drawable drawable = TaskRabbitMapActivity.this.getResources().getDrawable(R.drawable.icon_locale);
|
||||
TaskRabbitMapOverlayItem itemizedoverlay = new TaskRabbitMapOverlayItem(drawable, TaskRabbitMapActivity.this);
|
||||
mapController.animateTo(q);
|
||||
mapController.setZoom(12);
|
||||
|
||||
OverlayItem overlayitem = new OverlayItem(q, "Set this location", "For the rabbits!");
|
||||
|
||||
itemizedoverlay.addOverlay(overlayitem);
|
||||
List<Overlay> mapOverlays = mapView.getOverlays();
|
||||
mapOverlays.clear();
|
||||
mapOverlays.add(itemizedoverlay);
|
||||
|
||||
Message successMessage = new Message();
|
||||
successMessage.what = 1;
|
||||
handler.sendMessage(successMessage);
|
||||
// searchText.setText("");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Message failureMessage = new Message();
|
||||
failureMessage.what = -1;
|
||||
handler.sendMessage(failureMessage);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
thread.start();
|
||||
|
||||
}
|
||||
@Override
|
||||
protected boolean isRouteDisplayed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateLocationOverlay() {
|
||||
if (location == null) { return; };
|
||||
List<Overlay> mapOverlays = mapView.getOverlays();
|
||||
Drawable drawable = this.getResources().getDrawable(R.drawable.gl_alarm);
|
||||
TaskRabbitMapOverlayItem myItemizedOverlay = new TaskRabbitMapOverlayItem(drawable);
|
||||
GeoPoint point = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6));
|
||||
|
||||
OverlayItem overlayitem = new OverlayItem(point, "Astrid!!", "WOrks!");
|
||||
myItemizedOverlay.addOverlay(overlayitem);
|
||||
mapOverlays.add(myItemizedOverlay);
|
||||
}
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// TODO Auto-generated method stub
|
||||
if (location != null) {
|
||||
double lat = location.getLatitude();
|
||||
double lng = location.getLongitude();
|
||||
this.location = location;
|
||||
GeoPoint p = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
|
||||
mapController.animateTo(p);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,183 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.google.android.maps.ItemizedOverlay;
|
||||
import com.google.android.maps.OverlayItem;
|
||||
import com.timsu.astrid.R;
|
||||
|
||||
public class TaskRabbitMapOverlayItem extends ItemizedOverlay {
|
||||
private final ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
|
||||
|
||||
private Drawable defaultMarker;
|
||||
private Activity mActivity;
|
||||
private OverlayItem inDrag;
|
||||
private int xDragImageOffset=0;
|
||||
private int yDragImageOffset=0;
|
||||
private final int xDragTouchOffset=0;
|
||||
private final int yDragTouchOffset=0;
|
||||
private ImageView dragImage=null;
|
||||
private OverlayItem selectedItem=null;
|
||||
private final int didTap = -1;
|
||||
private final Point tapPoint = null;
|
||||
public TaskRabbitMapOverlayItem(Drawable defaultMarker) {
|
||||
super(boundCenterBottom(defaultMarker));
|
||||
}
|
||||
|
||||
public TaskRabbitMapOverlayItem(Drawable defaultMarker, Activity activity) {
|
||||
super(boundCenterBottom(defaultMarker));
|
||||
this.defaultMarker = defaultMarker;
|
||||
mActivity = activity;
|
||||
|
||||
getDragImage();
|
||||
}
|
||||
|
||||
public ImageView getDragImage() {
|
||||
if (dragImage == null) {
|
||||
|
||||
dragImage= new ImageView(mActivity);
|
||||
|
||||
dragImage.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.icon_locale));
|
||||
//dragImage.setImageDrawable(R.drawable.gl_alarm);
|
||||
dragImage.setLayoutParams(new RelativeLayout.LayoutParams(50, 50));
|
||||
|
||||
|
||||
xDragImageOffset=dragImage.getDrawable().getIntrinsicWidth()/2;
|
||||
yDragImageOffset=dragImage.getDrawable().getIntrinsicHeight();
|
||||
}
|
||||
return dragImage;
|
||||
}
|
||||
|
||||
public void addOverlay(OverlayItem overlay) {
|
||||
mOverlays.add(overlay);
|
||||
populate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OverlayItem createItem(int i) {
|
||||
return mOverlays.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mOverlays.size();
|
||||
}
|
||||
@Override
|
||||
protected boolean onTap(int index) {
|
||||
if (index >= mOverlays.size()) {
|
||||
return false;
|
||||
}
|
||||
selectedItem = mOverlays.get(index);
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(mActivity);
|
||||
dialog.setTitle("Set this as your location?");
|
||||
dialog.setMessage(selectedItem.getSnippet());
|
||||
dialog.setIcon(
|
||||
android.R.drawable.ic_dialog_alert).setPositiveButton(
|
||||
android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
Intent data = new Intent();
|
||||
data.putExtra("lat",selectedItem.getPoint().getLatitudeE6());
|
||||
data.putExtra("lng",selectedItem.getPoint().getLongitudeE6());
|
||||
mActivity.setResult(Activity.RESULT_OK, data);
|
||||
mActivity.finish();
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel, null);
|
||||
dialog.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
|
||||
final int action=event.getAction();
|
||||
final int x=(int)event.getX();
|
||||
final int y=(int)event.getY();
|
||||
boolean result=false;
|
||||
|
||||
if (action==MotionEvent.ACTION_DOWN) {
|
||||
|
||||
for (int i = 0; i < mOverlays.size(); i++) {
|
||||
OverlayItem item = mOverlays.get(i);
|
||||
Point p= new Point(0,0);
|
||||
|
||||
mapView.getProjection().toPixels(item.getPoint(), p);
|
||||
|
||||
if (hitTest(item, defaultMarker, x-p.x, y-p.y)) {
|
||||
didTap = i;
|
||||
tapPoint = new Point((int) event.getX(), (int) event.getY());
|
||||
|
||||
result=true;
|
||||
inDrag=item;
|
||||
mOverlays.remove(inDrag);
|
||||
populate();
|
||||
|
||||
xDragTouchOffset=0;
|
||||
yDragTouchOffset=0;
|
||||
|
||||
setDragImagePosition(p.x, p.y);
|
||||
// dragImage.setVisibility(View.VISIBLE);
|
||||
|
||||
xDragTouchOffset=x-p.x;
|
||||
yDragTouchOffset=y-p.y;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action==MotionEvent.ACTION_MOVE && inDrag!=null) {
|
||||
setDragImagePosition(x, y);
|
||||
if (tapPoint != null && Math.abs(tapPoint.x - event.getX()) > 10 && Math.abs(tapPoint.x - event.getX()) > 10) {
|
||||
didTap = -1;
|
||||
}
|
||||
result=true;
|
||||
}
|
||||
else if (action==MotionEvent.ACTION_UP && inDrag!=null) {
|
||||
// dragImage.setVisibility(View.GONE);
|
||||
if (didTap != -1) {
|
||||
this.onTap(didTap);
|
||||
didTap = -1;
|
||||
return true;
|
||||
}
|
||||
GeoPoint pt=mapView.getProjection().fromPixels(x-xDragTouchOffset,
|
||||
y-yDragTouchOffset);
|
||||
OverlayItem toDrop=new OverlayItem(pt, inDrag.getTitle(),
|
||||
inDrag.getSnippet());
|
||||
|
||||
mOverlays.add(toDrop);
|
||||
populate();
|
||||
|
||||
inDrag=null;
|
||||
result=true;
|
||||
}
|
||||
|
||||
return(result || super.onTouchEvent(event, mapView));
|
||||
}
|
||||
|
||||
private void setDragImagePosition(int x, int y) {
|
||||
getDragImage();
|
||||
RelativeLayout.LayoutParams lp=
|
||||
(RelativeLayout.LayoutParams)dragImage.getLayoutParams();
|
||||
|
||||
if (lp != null) {
|
||||
lp.setMargins(x-xDragImageOffset-xDragTouchOffset,
|
||||
y-yDragImageOffset-yDragTouchOffset, 0, 0);
|
||||
}
|
||||
dragImage.setLayoutParams(lp);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import com.todoroo.andlib.data.AbstractModel;
|
||||
import com.todoroo.andlib.data.Property.StringProperty;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
|
||||
/**
|
||||
* Metadata entries for a GTasks Task
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class TaskRabbitMetadata {
|
||||
|
||||
static final int VALUE_UNSET = -1;
|
||||
|
||||
/** metadata key */
|
||||
public static final String METADATA_KEY = "taskrabbit"; //$NON-NLS-1$
|
||||
|
||||
/** task id in taskrabbit */
|
||||
public static final StringProperty ID = new StringProperty(Metadata.TABLE,
|
||||
Metadata.VALUE1.name);
|
||||
|
||||
public static final StringProperty DATA_LOCAL = new StringProperty(Metadata.TABLE,
|
||||
Metadata.VALUE2.name);
|
||||
|
||||
public static final StringProperty DATA_REMOTE = new StringProperty(Metadata.TABLE,
|
||||
Metadata.VALUE3.name);
|
||||
|
||||
/**
|
||||
* Creates default GTasks metadata item
|
||||
* @param taskId if > 0, will set metadata task field
|
||||
* @return
|
||||
*/
|
||||
public static Metadata createEmptyMetadata(long taskId) {
|
||||
Metadata metadata = new Metadata();
|
||||
metadata.setValue(Metadata.KEY, TaskRabbitMetadata.METADATA_KEY);
|
||||
metadata.setValue(ID, ""); //$NON-NLS-1$
|
||||
metadata.setValue(DATA_LOCAL, ""); //$NON-NLS-1$
|
||||
metadata.setValue(DATA_REMOTE, ""); //$NON-NLS-1$
|
||||
if(taskId > AbstractModel.NO_ID)
|
||||
metadata.setValue(Metadata.TASK, taskId);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet.TaskRabbitSetListener;
|
||||
import com.todoroo.astrid.ui.EditNotesControlSet;
|
||||
|
||||
public class TaskRabbitNameControlSet extends EditNotesControlSet implements TaskRabbitSetListener{
|
||||
|
||||
public TaskRabbitNameControlSet(Activity activity, int viewLayout,
|
||||
int displayViewLayout, int titleID, int i) {
|
||||
super(activity, viewLayout, displayViewLayout);
|
||||
displayText.setText("Restaurant name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromModel(JSONObject json, String key) {
|
||||
|
||||
editText.setTextKeepState(json.optString(key, ""));
|
||||
notesPreview.setText(json.optString(key, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToJSON(JSONObject json, String key) throws JSONException {
|
||||
json.put(key, editText.getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToJSON(JSONObject json, String key) throws JSONException {
|
||||
json.put(key, editText.getText().toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.ui.PopupControlSet;
|
||||
|
||||
public class TaskRabbitRow extends PopupControlSet{
|
||||
|
||||
private final int setID;
|
||||
private final int type;
|
||||
private final TextView body;
|
||||
|
||||
public TaskRabbitRow(Activity activity, int viewLayout, int displayViewLayout, int setID, int type, final String title) {
|
||||
super(activity, viewLayout, displayViewLayout, title);
|
||||
this.setID = setID;
|
||||
this.type = type;
|
||||
body = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setBody(String desc) {
|
||||
body.setText(desc);
|
||||
}
|
||||
|
||||
public void showPopupForRow() {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
protected void refreshDisplayView() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public boolean populateFromTask (TaskRabbitTaskContainer task) {
|
||||
|
||||
if (task != null) {
|
||||
String[] types = activity.getResources().getStringArray(R.array.tr_default_set_key);
|
||||
|
||||
JSONObject trJSON = task.getLocalTaskData();
|
||||
try {
|
||||
trJSON.getString(types[setID]);
|
||||
body.setText(trJSON.getString(types[setID]));
|
||||
return true;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
public void readFromTask(TaskRabbitTaskContainer task) {
|
||||
if (!populateFromTask(task)) {
|
||||
return;
|
||||
}
|
||||
body.setText("Whats up dowg");
|
||||
|
||||
}
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
return body.getText().toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.helper.TaskEditControlSet;
|
||||
import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet.TaskRabbitSetListener;
|
||||
|
||||
public class TaskRabbitSpinnerControlSet extends TaskEditControlSet implements TaskRabbitSetListener{
|
||||
|
||||
private final Spinner spinner;
|
||||
private final int setID;
|
||||
private final int type;
|
||||
private final int titleID;
|
||||
private final TextView displayText;
|
||||
private final Fragment fragment;
|
||||
private final ArrayAdapter adapter;
|
||||
|
||||
public TaskRabbitSpinnerControlSet(final Fragment fragment, int viewLayout, int title, int setID, int type) {
|
||||
super(fragment.getActivity(), viewLayout);
|
||||
this.setID = setID;
|
||||
this.type = type;
|
||||
this.fragment = fragment;
|
||||
this.titleID = title;
|
||||
// DependencyInjectionService.getInstance().inject(this);
|
||||
|
||||
spinner = (Spinner)getView().findViewById(R.id.display_row_edit);
|
||||
spinner.setPrompt(getActivity().getString(title));
|
||||
|
||||
displayText = (TextView) getDisplayView().findViewById(R.id.display_row_title);
|
||||
displayText.setText(title);
|
||||
|
||||
|
||||
|
||||
String[] listTypes;
|
||||
if (title == R.string.tr_set_named_price){
|
||||
listTypes = getStringDefaultArray(type, R.array.tr_default_price_type_array);
|
||||
}
|
||||
else {
|
||||
listTypes = getStringDefaultArray(setID, R.array.tr_default_array);
|
||||
}
|
||||
|
||||
|
||||
adapter = new ArrayAdapter<String>(
|
||||
getActivity(), android.R.layout.simple_spinner_item, listTypes);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setSelection(0); // plus 1 for the no selection item
|
||||
}
|
||||
});
|
||||
}
|
||||
public String[] getStringDefaultArray(int position, int arrayType) {
|
||||
TypedArray arrays = getActivity().getResources().obtainTypedArray(arrayType);
|
||||
int arrayID = arrays.getResourceId(position, -1);
|
||||
return getActivity().getResources().getStringArray(arrayID);
|
||||
}
|
||||
|
||||
private Activity getActivity() {
|
||||
return fragment.getActivity();
|
||||
}
|
||||
|
||||
public int selectedPosition() {
|
||||
return spinner.getSelectedItemPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromModel(JSONObject json, String key) {
|
||||
int intValue = json.optInt(key);
|
||||
if (intValue < spinner.getCount())
|
||||
spinner.setSelection(intValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToJSON(JSONObject json, String key) throws JSONException {
|
||||
json.put(key, spinner.getSelectedItemPosition());
|
||||
|
||||
}
|
||||
|
||||
public int parseToDollars (String conversion){
|
||||
int index = conversion.lastIndexOf('$');
|
||||
String cents = conversion.substring(index+1);
|
||||
if(TextUtils.isEmpty(cents)) return 0;
|
||||
Log.d("PARSING TO CHANGE", cents);
|
||||
return Integer.parseInt(cents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToJSON(JSONObject json, String key) throws JSONException {
|
||||
|
||||
if(spinner.getSelectedItem() != null){
|
||||
String spinnerString = spinner.getSelectedItem().toString();
|
||||
if (titleID == R.string.tr_set_cost_in_cents || titleID == R.string.tr_set_named_price) {
|
||||
int cents = parseToDollars(spinnerString) *100;
|
||||
json.put(key, cents);
|
||||
}
|
||||
else if (key.contains("description")) {
|
||||
String description = json.optString("description", "");
|
||||
description += String.format("\n%S %S", key, spinner.getSelectedItem().toString()); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
json.put(key, spinnerString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.todoroo.astrid.taskrabbit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.todoroo.andlib.data.Property.StringProperty;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.sync.SyncContainer;
|
||||
|
||||
/**
|
||||
* RTM Task Container
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class TaskRabbitTaskContainer extends SyncContainer {
|
||||
|
||||
public Metadata trTask;
|
||||
|
||||
public TaskRabbitTaskContainer(Task task, Metadata trTask) {
|
||||
this.task = task;
|
||||
this.trTask = trTask;
|
||||
if(this.trTask == null) {
|
||||
this.trTask = TaskRabbitMetadata.createEmptyMetadata(task.getId());
|
||||
}
|
||||
this.metadata = new ArrayList<Metadata>();
|
||||
}
|
||||
|
||||
public TaskRabbitTaskContainer(Task task) {
|
||||
this(task, null);
|
||||
}
|
||||
|
||||
public JSONObject getLocalTaskData() {
|
||||
return getJSONData(TaskRabbitMetadata.DATA_LOCAL);
|
||||
}
|
||||
public JSONObject getRemoteTaskData() {
|
||||
return getJSONData(TaskRabbitMetadata.DATA_REMOTE);
|
||||
}
|
||||
|
||||
public String getTaskID() {
|
||||
return trTask.getValue(TaskRabbitMetadata.ID);
|
||||
}
|
||||
private JSONObject getJSONData(StringProperty key) {
|
||||
String jsonString = trTask.getValue(key);
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
try {
|
||||
return new JSONObject(jsonString);
|
||||
} catch (Exception e) {
|
||||
Log.e("Task Rabbit task container", //$NON-NLS-1$
|
||||
e.toString());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void setTaskID(String taskID) {
|
||||
trTask.setValue(TaskRabbitMetadata.ID, taskID);
|
||||
}
|
||||
public void setLocalTaskData(String taskData) {
|
||||
trTask.setValue(TaskRabbitMetadata.DATA_LOCAL, taskData);
|
||||
}
|
||||
public void setRemoteTaskData(String taskData) {
|
||||
trTask.setValue(TaskRabbitMetadata.DATA_REMOTE, taskData);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 278 KiB |
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||
android:id="@+id/edit_scroll"
|
||||
style="@style/Content_EditScroll"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/task_rabbit_parent"
|
||||
style="@style/Content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.GEN_EditLabel.DLG_EditLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/TEA_reminder_alarm_label" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/task_type"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/task_controls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/task_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dip"
|
||||
android:hint="Description" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/task_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Send Task!" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.maps.MapView
|
||||
android:id="@+id/map_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="9"
|
||||
android:apiKey="0J-miH1uUbgW2wG77C9qZiqvpBW8FEnoRnn7qBw"
|
||||
android:clickable="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="46 Watertree Ct. The Woodlands TX 77380"
|
||||
android:layout_weight="3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/search_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Search"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/display_row_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/display_row_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Friend" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/display_row_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello" />
|
||||
|
||||
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/display_row_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:spinnerMode="dropdown"
|
||||
android:background="#00000000" >
|
||||
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,373 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains preference keys and preference list values.
|
||||
These should not be translated
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- ============================================================ MILK == -->
|
||||
|
||||
<string-array name="tr_preset_types">
|
||||
<item>@string/tr_type_virtual</item>
|
||||
<item>@string/tr_type_food_delivery</item>
|
||||
<item>@string/tr_type_cleaning</item>
|
||||
<item>@string/tr_type_donations</item>
|
||||
<item>@string/tr_type_delivery</item>
|
||||
<item>@string/tr_type_handyman</item>
|
||||
<item>@string/tr_type_shopping</item>
|
||||
<item>@string/tr_type_something_else</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Preference Key (do not translate) -->
|
||||
<string name="tr_type_virtual">Virtual task</string>
|
||||
<string name="tr_type_food_delivery">Food Delivery</string>
|
||||
<string name="tr_type_cleaning">Cleaning</string>
|
||||
<string name="tr_type_donations">Donations</string>
|
||||
<string name="tr_type_delivery">Delivery</string>
|
||||
<string name="tr_type_handyman">Handyman</string>
|
||||
<string name="tr_type_shopping">Shopping</string>
|
||||
<string name="tr_type_something_else">Something else</string>
|
||||
|
||||
|
||||
<array name="tr_default_type_array">
|
||||
<item>@array/tr_default_type_virtual</item>
|
||||
<item>@array/tr_default_type_food_delivery</item>
|
||||
<item>@array/tr_default_type_cleaning</item>
|
||||
<item>@array/tr_default_type_donations</item>
|
||||
<item>@array/tr_default_type_delivery</item>
|
||||
<item>@array/tr_default_type_handyman</item>
|
||||
<item>@array/tr_default_type_shopping</item>
|
||||
</array>
|
||||
|
||||
<array name="tr_default_type_virtual">
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>4</item>
|
||||
<item>1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>25</item>
|
||||
</array>
|
||||
<array name="tr_default_type_food_delivery">
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>20</item>
|
||||
</array>
|
||||
<array name="tr_default_type_cleaning">
|
||||
<item>2</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>10</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>25</item>
|
||||
</array>
|
||||
<array name="tr_default_type_donations">
|
||||
<item>3</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>25</item>
|
||||
</array>
|
||||
<array name="tr_default_type_delivery">
|
||||
<item>4</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>25</item>
|
||||
</array>
|
||||
<array name="tr_default_type_handyman">
|
||||
<item>5</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>2</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>-1</item>
|
||||
<item>1</item>
|
||||
<item>50</item>
|
||||
</array>
|
||||
<array name="tr_default_type_shopping">
|
||||
<item>6</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>0</item>
|
||||
<item>2</item>
|
||||
<item>20</item>
|
||||
</array>
|
||||
|
||||
<array name="tr_default_type_something_else">
|
||||
<item>7</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>0</item>
|
||||
<item>2</item>
|
||||
<item>20</item>
|
||||
</array>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Preference Key (do not translate) -->
|
||||
<string name="tr_attr_name">name</string>
|
||||
<string name="tr_attr_id">id</string>
|
||||
|
||||
<!-- Preference Key (do not translate) -->
|
||||
<string name="tr_attr_state">state</string>
|
||||
<string name="tr_attr_state_label">state_label</string>
|
||||
|
||||
<!-- Preference Key (do not translate) -->
|
||||
<string name="tr_attr_city">city</string>
|
||||
<string name="tr_attr_city_id">city_id</string>
|
||||
<string name="tr_attr_city_name">name</string>
|
||||
<string name="tr_attr_city_lng">lng</string>
|
||||
<string name="tr_attr_city_lat">lat</string>
|
||||
<string name="tr_attr_city_virtual">virtual</string>
|
||||
|
||||
|
||||
|
||||
<string-array name="tr_default_set">
|
||||
<item>@string/tr_set_type</item>
|
||||
<item>@string/tr_set_name</item>
|
||||
<item>@string/tr_set_location</item>
|
||||
<item>@string/tr_set_skill_required</item>
|
||||
<item>@string/tr_set_duration</item>
|
||||
<item>@string/tr_set_supplies</item>
|
||||
<item>@string/tr_set_deadline</item>
|
||||
<item>@string/tr_set_drop_off</item>
|
||||
<item>@string/tr_set_cost_in_cents</item>
|
||||
<item>@string/tr_set_named_price</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Control set title (do not translate) -->
|
||||
<string name="tr_set_type">Type</string>
|
||||
<string name="tr_set_name">Name</string>
|
||||
<string name="tr_set_location">Location</string>
|
||||
<string name="tr_set_skill_required">Skill Required</string>
|
||||
<string name="tr_set_duration">Duration</string>
|
||||
<string name="tr_set_supplies">Supplies</string>
|
||||
<string name="tr_set_deadline">Deadline</string>
|
||||
<string name="tr_set_drop_off">Dropoff</string>
|
||||
<string name="tr_set_cost_in_cents">Expenses</string>
|
||||
<string name="tr_set_named_price">I will Pay</string>
|
||||
|
||||
|
||||
<string-array name="tr_default_set_key">
|
||||
<item>@string/tr_set_key_type</item>
|
||||
<item>@string/tr_set_key_name</item>
|
||||
<item>@string/tr_set_key_location</item>
|
||||
<item>@string/tr_set_key_skill_required</item>
|
||||
<item>@string/tr_set_key_duration</item>
|
||||
<item>@string/tr_set_key_supplies</item>
|
||||
<item>@string/tr_set_key_deadline</item>
|
||||
<item>@string/tr_set_key_drop_off</item>
|
||||
<item>@string/tr_set_key_cost_in_cents</item>
|
||||
<item>@string/tr_set_key_named_price</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Control set key for json (do not translate) -->
|
||||
<string name="tr_set_key_type">name</string>
|
||||
<string name="tr_set_key_name">name:specific</string>
|
||||
<string name="tr_set_key_location">location</string>
|
||||
<string name="tr_set_key_skill_required">description:skill_required</string>
|
||||
<string name="tr_set_key_duration">description:duration</string>
|
||||
<string name="tr_set_key_supplies">description:supplies</string>
|
||||
<string name="tr_set_key_deadline">complete_by_time</string>
|
||||
<string name="tr_set_key_drop_off">location</string>
|
||||
<string name="tr_set_key_cost_in_cents">cost_in_cents</string>
|
||||
<string name="tr_set_key_named_price">named_price</string>
|
||||
<string name="tr_set_key_description">description</string>
|
||||
|
||||
|
||||
<array name="tr_default_array">
|
||||
<item>@array/tr_empty_string_array</item>
|
||||
<item>@array/tr_empty_string_array</item>
|
||||
<item>@string/tr_location</item>
|
||||
<item>@array/tr_default_skill</item>
|
||||
<item>@array/tr_default_duration</item>
|
||||
<item>@array/tr_default_supplies</item>
|
||||
<item>@string/tr_deadline</item>
|
||||
<item>@string/tr_location</item>
|
||||
<item>@array/tr_default_cost_in_cents</item>
|
||||
<item>@array/tr_default_named_price</item>
|
||||
</array>
|
||||
|
||||
|
||||
<!-- Default options -->
|
||||
|
||||
|
||||
<string-array name="tr_default_skill">
|
||||
<item>@string/tr_default_skill_research</item>
|
||||
<item>@string/tr_default_skill_phone_calls</item>
|
||||
<item>@string/tr_default_skill_event_planning</item>
|
||||
<item>@string/tr_default_skill_usability_testing</item>
|
||||
<item>@string/tr_default_skill_craigslist</item>
|
||||
<item>@string/tr_default_skill_help</item>
|
||||
<item>@string/tr_default_skill_ebay_help</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Skills Needed -->
|
||||
<string name="tr_default_skill_research">Research</string>
|
||||
<string name="tr_default_skill_phone_calls">Phone Calls</string>
|
||||
<string name="tr_default_skill_event_planning">Event Planning</string>
|
||||
<string name="tr_default_skill_usability_testing">Usability Testing</string>
|
||||
<string name="tr_default_skill_craigslist">Craigslist</string>
|
||||
<string name="tr_default_skill_help">Help</string>
|
||||
<string name="tr_default_skill_ebay_help">eBay Help</string>
|
||||
<string name="tr_default_skill_carpentry">Carpentry</string>
|
||||
<string name="tr_default_skill_assembly_repair">Assembly and Repair</string>
|
||||
<string name="tr_default_skill_plumbing">Plumbing</string>
|
||||
<string name="tr_default_skill_ikea_assembly">IKEA assembly</string>
|
||||
<string name="tr_default_skill_heavy_lifting">Heavy lifting</string>
|
||||
|
||||
|
||||
<string-array name="tr_default_supplies">
|
||||
<item>@string/tr_default_supplies_provided</item>
|
||||
<item>@string/tr_default_supplies_not_provided</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Supplies provided -->
|
||||
<string name="tr_default_supplies_provided">Supplies will be provided</string>
|
||||
<string name="tr_default_supplies_not_provided">Supplies will NOT be provided</string>
|
||||
|
||||
|
||||
<string-array name="tr_default_cost_in_cents">
|
||||
<item>@string/tr_default_cost_in_cents_0</item>
|
||||
<item>@string/tr_default_cost_in_cents_25</item>
|
||||
<item>@string/tr_default_cost_in_cents_50</item>
|
||||
<item>@string/tr_default_cost_in_cents_100</item>
|
||||
<item>@string/tr_default_cost_in_cents_101</item>
|
||||
</string-array>
|
||||
|
||||
<!-- cost_in_cents -->
|
||||
<string name="tr_default_cost_in_cents_0">$0</string>
|
||||
<string name="tr_default_cost_in_cents_25">Less than $25</string>
|
||||
<string name="tr_default_cost_in_cents_50">Less than $50</string>
|
||||
<string name="tr_default_cost_in_cents_100">Less than $100</string>
|
||||
<string name="tr_default_cost_in_cents_101">More than $100</string>
|
||||
|
||||
|
||||
<string-array name="tr_default_named_price">
|
||||
<item>@string/tr_default_named_price_10</item>
|
||||
<item>@string/tr_default_named_price_20</item>
|
||||
<item>@string/tr_default_named_price_30</item>
|
||||
<item>@string/tr_default_named_price_40</item>
|
||||
</string-array>
|
||||
<!-- named_price -->
|
||||
<string name="tr_default_named_price_10">$10</string>
|
||||
<string name="tr_default_named_price_20">$20</string>
|
||||
<string name="tr_default_named_price_30">$30</string>
|
||||
<string name="tr_default_named_price_40">$40</string>
|
||||
<string name="tr_default_named_price_50">$50</string>
|
||||
<string name="tr_default_named_price_60">$60</string>
|
||||
<string name="tr_default_named_price_70">$70</string>
|
||||
|
||||
|
||||
<string-array name="tr_default_duration">
|
||||
<item>@string/tr_default_duration_0</item>
|
||||
<item>@string/tr_default_duration_1</item>
|
||||
<item>@string/tr_default_duration_3</item>
|
||||
<item>@string/tr_default_duration_6</item>
|
||||
<item>@string/tr_default_duration_10</item>
|
||||
</string-array>
|
||||
<!-- Duration -->
|
||||
<string name="tr_default_duration_0">Less than 1 hour</string>
|
||||
<string name="tr_default_duration_1">1 - 3 hours</string>
|
||||
<string name="tr_default_duration_3">3 - 6 hours</string>
|
||||
<string name="tr_default_duration_6">More than 6 hours</string>
|
||||
<string name="tr_default_duration_10">I do not know</string>
|
||||
|
||||
|
||||
<string-array name="tr_empty_string_array"></string-array>
|
||||
<string name="tr_location">tr_location</string>
|
||||
<string name="tr_deadline">tr_deadline</string>
|
||||
<string name="tr_name">tr_name</string>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<array name="tr_default_price_type_array">
|
||||
<item>@array/tr_type_default_price_virtual</item>
|
||||
<item>@array/tr_type_default_price_food_delivery</item>
|
||||
<item>@array/tr_type_default_price_cleaning</item>
|
||||
<item>@array/tr_type_default_price_food_delivery</item>
|
||||
<item>@array/tr_type_default_price_food_delivery</item>
|
||||
<item>@array/tr_type_default_price_handyman</item>
|
||||
<item>@array/tr_type_default_price_food_delivery</item>
|
||||
<item>@array/tr_type_default_price_food_delivery</item>
|
||||
</array>
|
||||
|
||||
<string-array name="tr_type_default_price_virtual">
|
||||
<item>$15</item>
|
||||
<item>$20</item>
|
||||
<item>$25</item>
|
||||
<item>$30</item>
|
||||
<item>$35</item>
|
||||
<item>$45</item>
|
||||
<item>$55</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="tr_type_default_price_food_delivery">
|
||||
<item>$10</item>
|
||||
<item>$15</item>
|
||||
<item>$20</item>
|
||||
<item>$25</item>
|
||||
<item>$30</item>
|
||||
<item>$40</item>
|
||||
<item>$50</item>
|
||||
</string-array>
|
||||
<string-array name="tr_type_default_price_cleaning">
|
||||
<item>$40</item>
|
||||
<item>$50</item>
|
||||
<item>$60</item>
|
||||
<item>$70</item>
|
||||
<item>$80</item>
|
||||
<item>$90</item>
|
||||
<item>$100</item>
|
||||
</string-array>
|
||||
<string-array name="tr_type_default_price_handyman">
|
||||
<item>$20</item>
|
||||
<item>$30</item>
|
||||
<item>$40</item>
|
||||
<item>$45</item>
|
||||
<item>$50</item>
|
||||
<item>$70</item>
|
||||
<item>$95</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Android-ViewPagerIndicator-Example</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
Loading…
Reference in New Issue