Better feedback when trying to share a task when not logged in

pull/14/head
Sam Bosley 14 years ago
parent ebf290e6a5
commit 854b6c6b33

@ -15,6 +15,7 @@ import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.text.TextUtils;
@ -103,6 +104,8 @@ public class EditPeopleControlSet extends PopupControlSet {
private final EditText assignedCustom;
private final View assignedClear;
private final ArrayList<AssignedToUser> listValues = new ArrayList<AssignedToUser>();
private String saveToast = null;
@ -144,6 +147,7 @@ public class EditPeopleControlSet extends PopupControlSet {
assignedList = (ListView) getView().findViewById(R.id.assigned_list);
assignedList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
assignedList.setItemsCanFocus(false);
assignedClear = getView().findViewById(R.id.assigned_clear);
assignedDisplay = (TextView) getDisplayView().findViewById(R.id.assigned_display);
sharedWithContainer = (PeopleContainer) getSharedWithView().findViewById(R.id.share_container);
@ -301,9 +305,11 @@ public class EditPeopleControlSet extends PopupControlSet {
myself.put("id", 0L);
sharedPeople.add(0, myself);
JSONObject unassigned = new JSONObject();
unassigned.put("id", -1L);
sharedPeople.add(1, unassigned);
if (actFmPreferenceService.isLoggedIn()) {
JSONObject unassigned = new JSONObject();
unassigned.put("id", -1L);
sharedPeople.add(1, unassigned);
}
// de-duplicate by user id and/or email
listValues.clear();
@ -407,8 +413,11 @@ public class EditPeopleControlSet extends PopupControlSet {
}
}
private void assignToMe() {
assignedClear.performClick();
}
private void setUpListeners() {
final View assignedClear = getView().findViewById(R.id.assigned_clear);
assignedList.setOnItemClickListener(new OnItemClickListener() {
@Override
@ -521,8 +530,25 @@ public class EditPeopleControlSet extends PopupControlSet {
JSONObject sharedWith = parseSharedWithAndTags();
dirty = dirty || sharedWith.has("p");
if(dirty && !actFmPreferenceService.isLoggedIn()) {
activity.startActivityForResult(new Intent(activity, ActFmLoginActivity.class),
loginRequestCode);
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
activity.startActivityForResult(new Intent(activity, ActFmLoginActivity.class),
loginRequestCode);
}
};
DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
makePrivateTask();
AssignedToUser me = (AssignedToUser) assignedList.getAdapter().getItem(0);
task.setValue(Task.USER_ID, me.user.optLong("id", -2));
task.setValue(Task.USER, me.user.toString());
}
};
DialogUtilities.okCancelCustomDialog(activity, activity.getString(R.string.actfm_EPA_login_button), activity.getString(R.string.actfm_EPA_login_to_share), R.string.actfm_EPA_login_button, R.string.actfm_EPA_dont_share_button, okListener, cancelListener);
return false;
}
@ -551,6 +577,13 @@ public class EditPeopleControlSet extends PopupControlSet {
return false;
}
private void makePrivateTask() {
assignToMe();
sharedWithContainer.removeAllViews();
sharedWithContainer.addPerson("");
refreshDisplayView();
}
private void showSaveToast() {
int length = saveToast.indexOf('\n') > -1 ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
Toast.makeText(activity, saveToast, length).show();
@ -742,6 +775,8 @@ public class EditPeopleControlSet extends PopupControlSet {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == loginRequestCode && resultCode == Activity.RESULT_OK)
saveSharingSettings(saveToast);
else if (requestCode == loginRequestCode)
makePrivateTask();
}
@Override

@ -143,6 +143,13 @@
<!-- task sharing dialog: tag not found (%s => tag) -->
<string name="actfm_EPA_invalid_tag">List Not Found: %s</string>
<!-- task sharing login prompt -->
<string name="actfm_EPA_login_to_share">You need to be logged in to Astrid.com to share tasks! Please log in or make this a private task.</string>
<string name="actfm_EPA_login_button">Log in</string>
<string name="actfm_EPA_dont_share_button">Make private</string>
<!-- ========================================= sharing login activity == -->

@ -28,6 +28,7 @@ import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.widget.Toast;
import com.crittercism.app.Crittercism;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
@ -341,6 +342,20 @@ public class EditPreferences extends TodorooPreferenceActivity {
return true;
}
});
findPreference(getString(R.string.p_statistics)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Boolean value = (Boolean) newValue;
if (!value.booleanValue()) {
//Crittercism.shutDown();
} else {
Crittercism.init(getApplicationContext(), Constants.CRITTERCISM_APP_ID,
Constants.CRITTERCISM_OATH_KEY, Constants.CRITTERCISM_SECRET);
}
return true;
}
});
}
private void onVoiceReminderStatusChanged(final Preference preference, boolean newValue) {

@ -111,8 +111,10 @@ public class StartupService {
// sets up context manager
ContextManager.setContext(context);
Crittercism.init(context.getApplicationContext(), Constants.CRITTERCISM_APP_ID,
Constants.CRITTERCISM_OATH_KEY, Constants.CRITTERCISM_SECRET);
if (!StatisticsService.dontCollectStatistics()) {
Crittercism.init(context.getApplicationContext(), Constants.CRITTERCISM_APP_ID,
Constants.CRITTERCISM_OATH_KEY, Constants.CRITTERCISM_SECRET);
}
// show notification if reminders are silenced
if(context instanceof Activity) {

@ -106,7 +106,7 @@ public class StatisticsService {
}
}
private static boolean dontCollectStatistics() {
public static boolean dontCollectStatistics() {
return !Preferences.getBoolean(R.string.p_statistics, true);
}

Loading…
Cancel
Save