Upgrade to api level 6 and send creation date when saving task

pull/14/head
Sam Bosley 13 years ago
parent f2baeb259c
commit f6d3df10a3

@ -269,9 +269,15 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
body.setOrientation(LinearLayout.VERTICAL);
body.setPadding(10, 0, 10, 0);
final EditText name = addEditField(body,
R.string.actfm_ALA_name_label);
name.setInputType(InputType.TYPE_CLASS_TEXT |
final EditText firstNameField = addEditField(body,
R.string.actfm_ALA_firstname_label);
firstNameField.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PERSON_NAME |
InputType.TYPE_TEXT_FLAG_CAP_WORDS);
final EditText lastNameField = addEditField(body,
R.string.actfm_ALA_lastname_label);
lastNameField.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PERSON_NAME |
InputType.TYPE_TEXT_FLAG_CAP_WORDS);
@ -282,7 +288,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
@Override
public void onClick(View v) {
isNew.set(!isNew.get());
int nameIndex = body.indexOfChild(name);
int nameIndex = body.indexOfChild(lastNameField);
int visibility = isNew.get() ? View.VISIBLE : View.GONE;
int passwordVisibility = isNew.get() ? View.GONE : View.VISIBLE;
toggleNew.setText(isNew.get() ? R.string.actfm_ALA_pw_returning
@ -290,6 +296,8 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
dialog.get().setTitle(
isNew.get() ? R.string.actfm_ALA_signup_title
: R.string.actfm_ALA_login_title);
body.getChildAt(nameIndex - 3).setVisibility(visibility);
body.getChildAt(nameIndex - 2).setVisibility(visibility);
body.getChildAt(nameIndex - 1).setVisibility(visibility);
body.getChildAt(nameIndex).setVisibility(visibility);
@ -331,11 +339,14 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dlg, int which) {
String nameString = isNew.get() ? name.getText().toString()
String firstName = isNew.get() ? firstNameField.getText().toString()
: null;
AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, name, email, password);
String lastName = isNew.get() ? lastNameField.getText().toString()
: null;
AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, firstNameField, lastNameField, email, password);
authenticate(email.getText().toString(),
nameString, ActFmInvoker.PROVIDER_PASSWORD,
firstName, lastName, ActFmInvoker.PROVIDER_PASSWORD,
password.getText().toString());
if (isNew.get())
@ -346,7 +357,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dlg, int which) {
AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, name, email, password);
AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, firstNameField, lastNameField, email, password);
}
}).show());
@ -427,10 +438,11 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
JSONObject json;
try {
json = Util.parseJson(response);
String name = json.getString("name"); //$NON-NLS-1$
String firstName = json.getString("first_name"); //$NON-NLS-1$
String lastName = json.getString("last_name");
String email = json.getString("email"); //$NON-NLS-1$
authenticate(email, name, ActFmInvoker.PROVIDER_FACEBOOK,
authenticate(email, firstName, lastName, ActFmInvoker.PROVIDER_FACEBOOK,
facebook.getAccessToken());
StatisticsService.reportEvent(StatisticsConstants.ACTFM_LOGIN_FB);
} catch (FacebookError e) {
@ -467,7 +479,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
// --- utilities
@SuppressWarnings("nls")
public void authenticate(final String email, final String name, final String provider,
public void authenticate(final String email, final String firstName, final String lastName, final String provider,
final String secret) {
if (progressDialog == null)
progressDialog = DialogUtilities.progressDialog(this,
@ -477,7 +489,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
@Override
public void run() {
try {
final JSONObject result = actFmInvoker.authenticate(email, name,
final JSONObject result = actFmInvoker.authenticate(email, firstName, lastName,
provider, secret);
final String token = actFmInvoker.getToken();
@ -591,7 +603,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
} else if (requestCode == REQUEST_CODE_GOOGLE) {
String email= data.getStringExtra(ActFmGoogleAuthActivity.RESULT_EMAIL);
String token = data.getStringExtra(ActFmGoogleAuthActivity.RESULT_TOKEN);
authenticate(email, email, "google", token);
authenticate(email, email, "", "google", token);
}
}

@ -296,15 +296,26 @@ public final class ActFmSyncService {
* Synchronize with server when data changes
*/
public void pushTaskOnSave(Task task, ContentValues values) {
Task taskForRemote = taskService.fetchById(task.getId(), Task.REMOTE_ID, Task.CREATION_DATE);
long remoteId;
if(task.containsValue(Task.REMOTE_ID)) {
remoteId = task.getValue(Task.REMOTE_ID);
} else {
Task taskForRemote = taskService.fetchById(task.getId(), Task.REMOTE_ID);
if(taskForRemote == null)
return;
remoteId = taskForRemote.getValue(Task.REMOTE_ID);
}
long creationDate;
if (task.containsValue(Task.CREATION_DATE)) {
creationDate = task.getValue(Task.CREATION_DATE);
} else {
if (taskForRemote == null)
return;
creationDate = taskForRemote.getValue(Task.CREATION_DATE);
}
boolean newlyCreated = remoteId == 0;
ArrayList<Object> params = new ArrayList<Object>();
@ -402,6 +413,8 @@ public final class ActFmSyncService {
if(params.size() == 0 || !checkForToken())
return;
params.add("created_at"); params.add(creationDate);
if(!newlyCreated) {
params.add("id"); params.add(remoteId);
} else if(!values.containsKey(Task.TITLE.name)) {

@ -221,6 +221,12 @@
<!-- share login: Name -->
<string name="actfm_ALA_name_label">Name</string>
<!-- share login: Name -->
<string name="actfm_ALA_firstname_label">First Name</string>
<!-- share login: Name -->
<string name="actfm_ALA_lastname_label">Last Name</string>
<!-- share login: Email -->
<string name="actfm_ALA_email_label">Email</string>

Loading…
Cancel
Save