Merge remote-tracking branch 'sbosley/110922_sb_list_view_iosify'
@ -0,0 +1,144 @@
|
||||
package com.todoroo.astrid.actfm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
|
||||
public class ActFmCameraModule {
|
||||
|
||||
protected static final int REQUEST_CODE_CAMERA = 1;
|
||||
protected static final int REQUEST_CODE_PICTURE = 2;
|
||||
|
||||
private static File lastTempFile = null;
|
||||
|
||||
public interface ClearImageCallback {
|
||||
public void clearImage();
|
||||
}
|
||||
|
||||
public static void showPictureLauncher(final Activity activity, final ClearImageCallback clearImageOption) {
|
||||
ArrayList<String> options = new ArrayList<String>();
|
||||
options.add(activity.getString(R.string.actfm_picture_camera));
|
||||
options.add(activity.getString(R.string.actfm_picture_gallery));
|
||||
|
||||
if (clearImageOption != null) {
|
||||
options.add(activity.getString(R.string.actfm_picture_clear));
|
||||
}
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity,
|
||||
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
|
||||
|
||||
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public void onClick(DialogInterface d, int which) {
|
||||
if(which == 0) {
|
||||
lastTempFile = getTempFile(activity);
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if (lastTempFile != null) {
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile));
|
||||
}
|
||||
activity.startActivityForResult(intent, REQUEST_CODE_CAMERA);
|
||||
} else if (which == 1) {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("image/*");
|
||||
activity.startActivityForResult(Intent.createChooser(intent,
|
||||
activity.getString(R.string.actfm_TVA_tag_picture)), REQUEST_CODE_PICTURE);
|
||||
} else {
|
||||
if (clearImageOption != null)
|
||||
clearImageOption.clearImage();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// show a menu of available options
|
||||
new AlertDialog.Builder(activity)
|
||||
.setAdapter(adapter, listener)
|
||||
.show().setOwnerActivity(activity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
private static File getTempFile(Activity activity) {
|
||||
try {
|
||||
String storageState = Environment.getExternalStorageState();
|
||||
if(storageState.equals(Environment.MEDIA_MOUNTED)) {
|
||||
String path = Environment.getExternalStorageDirectory().getName() + File.separatorChar + "Android/data/" + activity.getPackageName() + "/files/";
|
||||
File photoFile = File.createTempFile("comment_pic_" + DateUtilities.now(), ".jpg", new File(path));
|
||||
return photoFile;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface CameraResultCallback {
|
||||
public void handleCameraResult(Bitmap bitmap);
|
||||
}
|
||||
|
||||
private static Bitmap bitmapFromUri(Activity activity, Uri uri) {
|
||||
String[] projection = { MediaStore.Images.Media.DATA };
|
||||
Cursor cursor = activity.managedQuery(uri, projection, null, null, null);
|
||||
String path;
|
||||
|
||||
if(cursor != null) {
|
||||
try {
|
||||
int column_index = cursor
|
||||
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
path = cursor.getString(column_index);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
} else {
|
||||
path = uri.getPath();
|
||||
}
|
||||
|
||||
return BitmapFactory.decodeFile(path);
|
||||
}
|
||||
|
||||
public static boolean activityResult(Activity activity, int requestCode, int resultCode, Intent data,
|
||||
CameraResultCallback cameraResult) {
|
||||
if(requestCode == ActFmCameraModule.REQUEST_CODE_CAMERA && resultCode == Activity.RESULT_OK) {
|
||||
Bitmap bitmap;
|
||||
if (data == null) { // large from camera
|
||||
if (lastTempFile != null) {
|
||||
bitmap = bitmapFromUri(activity, Uri.fromFile(lastTempFile));
|
||||
lastTempFile.deleteOnExit();
|
||||
lastTempFile = null;
|
||||
}
|
||||
else
|
||||
bitmap = null;
|
||||
} else
|
||||
bitmap = data.getParcelableExtra("data"); //$NON-NLS-1$
|
||||
if(bitmap != null) {
|
||||
activity.setResult(Activity.RESULT_OK);
|
||||
cameraResult.handleCameraResult(bitmap);
|
||||
}
|
||||
return true;
|
||||
} else if(requestCode == ActFmCameraModule.REQUEST_CODE_PICTURE && resultCode == Activity.RESULT_OK) {
|
||||
Uri uri = data.getData();
|
||||
Bitmap bitmap = bitmapFromUri(activity, uri);
|
||||
if(bitmap != null) {
|
||||
activity.setResult(Activity.RESULT_OK);
|
||||
cameraResult.handleCameraResult(bitmap);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,295 @@
|
||||
package com.todoroo.astrid.actfm;
|
||||
|
||||
import greendroid.widget.AsyncImageView;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.andlib.utility.AndroidUtilities;
|
||||
import com.todoroo.andlib.utility.DialogUtilities;
|
||||
import com.todoroo.andlib.utility.Preferences;
|
||||
import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
||||
import com.todoroo.astrid.data.TagData;
|
||||
import com.todoroo.astrid.service.StatisticsConstants;
|
||||
import com.todoroo.astrid.service.StatisticsService;
|
||||
import com.todoroo.astrid.service.TagDataService;
|
||||
import com.todoroo.astrid.service.ThemeService;
|
||||
import com.todoroo.astrid.tags.TagFilterExposer;
|
||||
import com.todoroo.astrid.tags.TagService;
|
||||
import com.todoroo.astrid.ui.PeopleContainer;
|
||||
import com.todoroo.astrid.utility.Flags;
|
||||
import com.todoroo.astrid.welcome.HelpInfoPopover;
|
||||
|
||||
public class TagSettingsActivity extends Activity {
|
||||
|
||||
protected static final int REQUEST_ACTFM_LOGIN = 3;
|
||||
|
||||
private static final String MEMBERS_IN_PROGRESS = "members"; //$NON-NLS-1$
|
||||
|
||||
private TagData tagData;
|
||||
|
||||
@Autowired TagDataService tagDataService;
|
||||
|
||||
@Autowired ActFmSyncService actFmSyncService;
|
||||
|
||||
@Autowired ActFmPreferenceService actFmPreferenceService;
|
||||
|
||||
private PeopleContainer tagMembers;
|
||||
private AsyncImageView picture;
|
||||
private EditText tagName;
|
||||
private CheckBox isSilent;
|
||||
|
||||
boolean isNewTag = false;
|
||||
|
||||
public TagSettingsActivity() {
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeService.applyTheme(this);
|
||||
setContentView(R.layout.tag_settings_activity);
|
||||
tagData = getIntent().getParcelableExtra(TagViewActivity.EXTRA_TAG_DATA);
|
||||
if (tagData == null) {
|
||||
isNewTag = true;
|
||||
tagData = new TagData();
|
||||
}
|
||||
setUpSettingsPage();
|
||||
|
||||
if(savedInstanceState != null && savedInstanceState.containsKey(MEMBERS_IN_PROGRESS)) {
|
||||
final String members = savedInstanceState.getString(MEMBERS_IN_PROGRESS);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.sleepDeep(500);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateMembers(members);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
showCollaboratorsPopover();
|
||||
}
|
||||
|
||||
private void showCollaboratorsPopover() {
|
||||
if (!Preferences.getBoolean(R.string.p_showed_collaborators_help, false)) {
|
||||
View members = findViewById(R.id.members_container);
|
||||
HelpInfoPopover.showPopover(this, members, R.string.help_popover_collaborators);
|
||||
Preferences.setBoolean(R.string.p_showed_collaborators_help, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUpSettingsPage() {
|
||||
tagMembers = (PeopleContainer) findViewById(R.id.members_container);
|
||||
tagName = (EditText) findViewById(R.id.tag_name);
|
||||
picture = (AsyncImageView) findViewById(R.id.picture);
|
||||
isSilent = (CheckBox) findViewById(R.id.tag_silenced);
|
||||
|
||||
if(actFmPreferenceService.isLoggedIn()) {
|
||||
picture.setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.listSettingsMore).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
picture.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
ActFmCameraModule.showPictureLauncher(TagSettingsActivity.this, null);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.saveMembers).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
|
||||
refreshSettingsPage();
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
setResult(RESULT_OK);
|
||||
String oldName = tagData.getValue(TagData.NAME);
|
||||
String newName = tagName.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(newName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean nameChanged = !oldName.equals(newName);
|
||||
TagService service = TagService.getInstance();
|
||||
if (nameChanged) {
|
||||
if (oldName.equalsIgnoreCase(newName)) { // Change the capitalization of a list manually
|
||||
tagData.setValue(TagData.NAME, newName);
|
||||
service.renameCaseSensitive(oldName, newName);
|
||||
tagData.setFlag(TagData.FLAGS, TagData.FLAG_EMERGENT, false);
|
||||
} else { // Rename list--check for existing name
|
||||
newName = service.getTagWithCase(newName);
|
||||
tagName.setText(newName);
|
||||
if (!newName.equals(oldName)) {
|
||||
tagData.setValue(TagData.NAME, newName);
|
||||
service.rename(oldName, newName);
|
||||
tagData.setFlag(TagData.FLAGS, TagData.FLAG_EMERGENT, false);
|
||||
} else {
|
||||
nameChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(newName.length() > 0 && oldName.length() == 0) {
|
||||
tagDataService.save(tagData);
|
||||
//setUpNewTag(newName);
|
||||
}
|
||||
|
||||
JSONArray members = tagMembers.toJSONArray();
|
||||
if(members.length() > 0 && !actFmPreferenceService.isLoggedIn()) {
|
||||
startActivityForResult(new Intent(this, ActFmLoginActivity.class),
|
||||
REQUEST_ACTFM_LOGIN);
|
||||
return;
|
||||
}
|
||||
|
||||
int oldMemberCount = tagData.getValue(TagData.MEMBER_COUNT);
|
||||
if (members.length() > oldMemberCount) {
|
||||
StatisticsService.reportEvent(StatisticsConstants.ACTFM_LIST_SHARED);
|
||||
}
|
||||
tagData.setValue(TagData.MEMBERS, members.toString());
|
||||
tagData.setValue(TagData.MEMBER_COUNT, members.length());
|
||||
tagData.setFlag(TagData.FLAGS, TagData.FLAG_SILENT, isSilent.isChecked());
|
||||
|
||||
if(actFmPreferenceService.isLoggedIn())
|
||||
Flags.set(Flags.TOAST_ON_SAVE);
|
||||
else
|
||||
Toast.makeText(this, R.string.tag_list_saved, Toast.LENGTH_LONG).show();
|
||||
|
||||
tagDataService.save(tagData);
|
||||
|
||||
if (isNewTag) {
|
||||
Intent intent = new Intent(this, TagViewActivity.class);
|
||||
intent.putExtra(TagViewActivity.EXTRA_TAG_NAME, newName);
|
||||
intent.putExtra(TagViewActivity.TOKEN_FILTER, TagFilterExposer.filterFromTagData(this, tagData));
|
||||
finish();
|
||||
startActivity(intent);
|
||||
return;
|
||||
}
|
||||
|
||||
refreshSettingsPage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
private void refreshSettingsPage() {
|
||||
tagName.setText(tagData.getValue(TagData.NAME));
|
||||
if (isNewTag) {
|
||||
((TextView)findViewById(R.id.listLabel)).setText(getString(R.string.tag_new_list));
|
||||
} else {
|
||||
((TextView) findViewById(R.id.listLabel)).setText(this.getString(R.string.tag_settings_title, tagData.getValue(TagData.NAME)));
|
||||
}
|
||||
picture.setUrl(tagData.getValue(TagData.PICTURE));
|
||||
setTitle(tagData.getValue(TagData.NAME));
|
||||
|
||||
TextView ownerLabel = (TextView) findViewById(R.id.tag_owner);
|
||||
try {
|
||||
if(tagData.getFlag(TagData.FLAGS, TagData.FLAG_EMERGENT)) {
|
||||
ownerLabel.setText(String.format("<%s>", getString(R.string.actfm_TVA_tag_owner_none)));
|
||||
} else if(tagData.getValue(TagData.USER_ID) == 0) {
|
||||
ownerLabel.setText(Preferences.getStringValue(ActFmPreferenceService.PREF_NAME));
|
||||
} else {
|
||||
JSONObject owner = new JSONObject(tagData.getValue(TagData.USER));
|
||||
ownerLabel.setText(owner.getString("name"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("tag-view-activity", "json error refresh owner", e);
|
||||
ownerLabel.setText("<error>");
|
||||
System.err.println(tagData.getValue(TagData.USER));
|
||||
}
|
||||
|
||||
String peopleJson = tagData.getValue(TagData.MEMBERS);
|
||||
updateMembers(peopleJson);
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
private void updateMembers(String peopleJson) {
|
||||
tagMembers.removeAllViews();
|
||||
if(!TextUtils.isEmpty(peopleJson)) {
|
||||
try {
|
||||
JSONArray people = new JSONArray(peopleJson);
|
||||
tagMembers.fromJSONArray(people);
|
||||
} catch (JSONException e) {
|
||||
System.err.println(peopleJson);
|
||||
Log.e("tag-view-activity", "json error refresh members", e);
|
||||
}
|
||||
}
|
||||
|
||||
tagMembers.addPerson(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void uploadTagPicture(final Bitmap bitmap) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String url = actFmSyncService.setTagPicture(tagData.getValue(TagData.REMOTE_ID), bitmap);
|
||||
tagData.setValue(TagData.PICTURE, url);
|
||||
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
||||
tagDataService.save(tagData);
|
||||
} catch (IOException e) {
|
||||
DialogUtilities.okDialog(TagSettingsActivity.this, e.toString(), null);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if(tagMembers.getChildCount() > 1) {
|
||||
JSONArray members = tagMembers.toJSONArray();
|
||||
outState.putString(MEMBERS_IN_PROGRESS, members.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
CameraResultCallback callback = new CameraResultCallback() {
|
||||
@Override
|
||||
public void handleCameraResult(Bitmap bitmap) {
|
||||
picture.setImageBitmap(bitmap);
|
||||
uploadTagPicture(bitmap);
|
||||
}
|
||||
};
|
||||
if (ActFmCameraModule.activityResult(this, requestCode, resultCode, data, callback)) {
|
||||
// Handled
|
||||
} else if(requestCode == REQUEST_ACTFM_LOGIN && resultCode == Activity.RESULT_OK) {
|
||||
saveSettings();
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,272 @@
|
||||
package com.todoroo.astrid.actfm;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.data.TodorooCursor;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
import com.todoroo.andlib.utility.DialogUtilities;
|
||||
import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback;
|
||||
import com.todoroo.astrid.actfm.ActFmCameraModule.ClearImageCallback;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
||||
import com.todoroo.astrid.adapter.UpdateAdapter;
|
||||
import com.todoroo.astrid.dao.UpdateDao;
|
||||
import com.todoroo.astrid.data.TagData;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.data.Update;
|
||||
import com.todoroo.astrid.service.StatisticsConstants;
|
||||
import com.todoroo.astrid.service.StatisticsService;
|
||||
import com.todoroo.astrid.service.TagDataService;
|
||||
import com.todoroo.astrid.service.ThemeService;
|
||||
import com.todoroo.astrid.utility.Flags;
|
||||
|
||||
public class TagUpdatesActivity extends ListActivity {
|
||||
|
||||
private TagData tagData;
|
||||
private UpdateAdapter updateAdapter;
|
||||
private EditText addCommentField;
|
||||
|
||||
private ImageButton pictureButton;
|
||||
|
||||
private Bitmap picture = null;
|
||||
|
||||
private static final int MENU_REFRESH_ID = Menu.FIRST;
|
||||
|
||||
@Autowired ActFmPreferenceService actFmPreferenceService;
|
||||
@Autowired TagDataService tagDataService;
|
||||
@Autowired UpdateDao updateDao;
|
||||
@Autowired ActFmSyncService actFmSyncService;
|
||||
|
||||
public TagUpdatesActivity() {
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeService.applyTheme(this);
|
||||
setContentView(R.layout.tag_updates_activity);
|
||||
tagData = getIntent().getParcelableExtra(TagViewActivity.EXTRA_TAG_DATA);
|
||||
|
||||
OnTouchListener onTouch = new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
v.requestFocusFromTouch();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
addCommentField = (EditText) findViewById(R.id.commentField);
|
||||
addCommentField.setOnTouchListener(onTouch);
|
||||
|
||||
setUpUpdateList();
|
||||
}
|
||||
|
||||
protected void setUpUpdateList() {
|
||||
((TextView) findViewById(R.id.listLabel)).setText(this.getString(R.string.tag_updates_title, tagData.getValue(TagData.NAME)));
|
||||
final ImageButton commentButton = (ImageButton) findViewById(R.id.commentButton);
|
||||
addCommentField = (EditText) findViewById(R.id.commentField);
|
||||
addCommentField.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
|
||||
if(actionId == EditorInfo.IME_NULL && addCommentField.getText().length() > 0) {
|
||||
addComment();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
addCommentField.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
commentButton.setVisibility((s.length() > 0) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
//
|
||||
}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//
|
||||
}
|
||||
});
|
||||
commentButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addComment();
|
||||
}
|
||||
});
|
||||
|
||||
final ClearImageCallback clearImage = new ClearImageCallback() {
|
||||
@Override
|
||||
public void clearImage() {
|
||||
picture = null;
|
||||
pictureButton.setImageResource(R.drawable.icn_camera);
|
||||
}
|
||||
};
|
||||
pictureButton = (ImageButton) findViewById(R.id.picture);
|
||||
pictureButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (picture != null)
|
||||
ActFmCameraModule.showPictureLauncher(TagUpdatesActivity.this, clearImage);
|
||||
else
|
||||
ActFmCameraModule.showPictureLauncher(TagUpdatesActivity.this, null);
|
||||
}
|
||||
});
|
||||
|
||||
refreshUpdatesList();
|
||||
}
|
||||
|
||||
private void refreshUpdatesList() {
|
||||
|
||||
if(!actFmPreferenceService.isLoggedIn() || tagData.getValue(Task.REMOTE_ID) <= 0)
|
||||
return;
|
||||
|
||||
if(updateAdapter == null) {
|
||||
TodorooCursor<Update> currentCursor = tagDataService.getUpdates(tagData);
|
||||
startManagingCursor(currentCursor);
|
||||
|
||||
updateAdapter = new UpdateAdapter(this, R.layout.update_adapter_row,
|
||||
currentCursor, false, null);
|
||||
((ListView)findViewById(android.R.id.list)).setAdapter(updateAdapter);
|
||||
} else {
|
||||
Cursor cursor = updateAdapter.getCursor();
|
||||
cursor.requery();
|
||||
startManagingCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
if(menu.size() > 0)
|
||||
return true;
|
||||
|
||||
MenuItem item;
|
||||
if(actFmPreferenceService.isLoggedIn()) {
|
||||
item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE,
|
||||
R.string.ENA_refresh_comments);
|
||||
item.setIcon(R.drawable.ic_menu_refresh);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
// handle my own menus
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case MENU_REFRESH_ID: {
|
||||
|
||||
final ProgressDialog progressDialog = DialogUtilities.progressDialog(this, getString(R.string.DLG_please_wait));
|
||||
actFmSyncService.fetchUpdatesForTag(tagData, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshUpdatesList();
|
||||
DialogUtilities.dismissDialog(TagUpdatesActivity.this, progressDialog);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
private void addComment() {
|
||||
if(tagData.getValue(TagData.REMOTE_ID) == 0L)
|
||||
return;
|
||||
|
||||
Update update = new Update();
|
||||
update.setValue(Update.MESSAGE, addCommentField.getText().toString());
|
||||
update.setValue(Update.ACTION_CODE, "tag_comment");
|
||||
update.setValue(Update.USER_ID, 0L);
|
||||
update.setValue(Update.TAGS, "," + tagData.getValue(TagData.REMOTE_ID) + ",");
|
||||
update.setValue(Update.CREATION_DATE, DateUtilities.now());
|
||||
if (picture != null) {
|
||||
update.setValue(Update.PICTURE, Update.PICTURE_LOADING);
|
||||
}
|
||||
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
||||
updateDao.createNew(update);
|
||||
|
||||
final long updateId = update.getId();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
actFmSyncService.pushUpdate(updateId, picture);
|
||||
}
|
||||
}.start();
|
||||
addCommentField.setText(""); //$NON-NLS-1$
|
||||
pictureButton.setImageResource(R.drawable.icn_camera);
|
||||
refreshUpdatesList();
|
||||
|
||||
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TAG_COMMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
CameraResultCallback callback = new CameraResultCallback() {
|
||||
@Override
|
||||
public void handleCameraResult(Bitmap bitmap) {
|
||||
picture = bitmap;
|
||||
pictureButton.setImageBitmap(picture);
|
||||
}
|
||||
};
|
||||
|
||||
if (ActFmCameraModule.activityResult(this, requestCode, resultCode, data, callback)) {
|
||||
//Handled
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
StatisticsService.sessionStop(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
StatisticsService.sessionStart(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatisticsService.sessionPause();
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 2.8 KiB |
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="false"
|
||||
android:drawable="@drawable/header_background"/>
|
||||
<item android:state_pressed="true" android:state_enabled="true"
|
||||
android:drawable="@drawable/header_background_pressed"/>
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="true" android:drawable="@drawable/header_background_pressed"/>
|
||||
|
||||
</selector>
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="false"
|
||||
android:drawable="@drawable/header_background_white"/>
|
||||
<item android:state_pressed="true" android:state_enabled="true"
|
||||
android:drawable="@drawable/header_background_pressed"/>
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="true" android:drawable="@drawable/header_background_pressed"/>
|
||||
|
||||
</selector>
|
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 693 B |
After Width: | Height: | Size: 655 B |
After Width: | Height: | Size: 430 B |
After Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 48 KiB |
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="false" android:drawable="@drawable/icn_arrow" />
|
||||
<item android:state_pressed="true" android:state_enabled="true"
|
||||
android:drawable="@drawable/icn_arrow_over" />
|
||||
<item android:state_pressed="false" android:state_enabled="true"
|
||||
android:state_focused="true" android:drawable="@drawable/icn_arrow_over" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- settings tab -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||
android:id="@+id/settings"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
style="@style/Content">
|
||||
|
||||
<LinearLayout
|
||||
style="@style/Header"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="43dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- List Label -->
|
||||
<TextView android:id="@+id/listLabel"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="start"
|
||||
style="@style/TextAppearance.TLA_Header"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="100">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="10dip">
|
||||
|
||||
<greendroid.widget.AsyncImageView
|
||||
android:id="@+id/picture"
|
||||
android:layout_width="80dip"
|
||||
android:layout_height="80dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:paddingRight="10dip"
|
||||
android:visibility="gone"
|
||||
astrid:defaultSrc="@android:drawable/ic_menu_gallery" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tag_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/picture"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="10dip"
|
||||
style="@style/TextAppearance.GEN_EditLabel"
|
||||
android:text="@string/actfm_TVA_tag_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/picture"
|
||||
android:layout_below="@id/tag_label"
|
||||
android:layout_marginTop="10dip" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="@android:drawable/divider_horizontal_dark" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingBottom="5dip"
|
||||
style="@style/TextAppearance.GEN_EditLabel"
|
||||
android:text="@string/actfm_TVA_members_label" />
|
||||
|
||||
<com.todoroo.astrid.ui.PeopleContainer
|
||||
android:id="@+id/members_container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
<LinearLayout
|
||||
android:id="@+id/listSettingsMore"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dip"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="@android:drawable/divider_horizontal_dark" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dip"
|
||||
style="@style/TextAppearance.GEN_EditLabel"
|
||||
android:text="@string/actfm_TVA_tag_owner_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tag_owner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dip"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_silenced"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dip"
|
||||
android:paddingLeft="45dip"
|
||||
style="@style/TextAppearance"
|
||||
android:text="@string/actfm_TVA_silence_label" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/membersFooter"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="10dip"
|
||||
android:padding="5dip"
|
||||
android:background="@drawable/footer_background"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/saveMembers"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/tango_save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
style="@style/Content">
|
||||
|
||||
<LinearLayout
|
||||
style="@style/Header"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="43dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- List Label -->
|
||||
<TextView android:id="@+id/listLabel"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="start"
|
||||
style="@style/TextAppearance.TLA_Header"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100"/>
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
<LinearLayout
|
||||
android:id="@+id/updatesFooter"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="47dip"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/footer_background"
|
||||
android:padding="3dip"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- Voice Add Button -->
|
||||
<ImageButton android:id="@+id/picture"
|
||||
android:layout_width="39dip"
|
||||
android:layout_height="39dip"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginRight="3dip"
|
||||
android:paddingLeft="7dip"
|
||||
android:paddingRight="7dip"
|
||||
android:paddingBottom="2dip"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/footer_button"
|
||||
android:src="@drawable/icn_camera"
|
||||
android:scaleType="fitCenter"/>
|
||||
|
||||
<!-- Quick Add Task -->
|
||||
<EditText android:id="@+id/commentField"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="3dip"
|
||||
android:layout_weight="100"
|
||||
android:background="@drawable/footer_edittext"
|
||||
android:hint="@string/TVA_add_comment"
|
||||
android:textSize="16sp"
|
||||
android:autoText="true"
|
||||
android:capitalize="sentences"/>
|
||||
|
||||
<!-- Extended Add Button -->
|
||||
<ImageButton android:id="@+id/commentButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="39dip"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginRight="3dip"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/footer_button"
|
||||
android:src="@drawable/ic_footer_add"
|
||||
android:scaleType="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="100">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="43dip"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/asMembersHeaderBackground">
|
||||
<HorizontalScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="43dip"
|
||||
android:layout_weight="15"
|
||||
android:scrollbars="none">
|
||||
<LinearLayout
|
||||
android:id="@+id/shared_with"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent">
|
||||
<TextView
|
||||
android:id="@+id/no_members"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="10dip"
|
||||
style="@style/TextAppearance"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/actfm_TVA_no_members_alert"/>
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
<ImageView
|
||||
android:id="@+id/members_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="85"
|
||||
android:padding="7dip"
|
||||
android:src="?attr/asMembersHeaderArrow"
|
||||
android:scaleType="fitCenter"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/filter_assigned"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:paddingTop="3dip"
|
||||
android:paddingBottom="3dip"
|
||||
style="@style/TextAppearance"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- List body goes here -->
|
||||
|
||||
</LinearLayout>
|