Comment pictures show up in taskeditactivity now YAAA

pull/14/head
Andrew Shaw 13 years ago
parent ed10a08cbe
commit 89aa3a00c9

@ -14,6 +14,7 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.widget.ArrayAdapter;
import com.timsu.astrid.R;
@ -70,6 +71,47 @@ public class ActFmCameraModule {
.show().setOwnerActivity(activity);
}
public static void showPictureLauncher(final Fragment fragment, final ClearImageCallback clearImageOption) {
ArrayList<String> options = new ArrayList<String>();
options.add(fragment.getString(R.string.actfm_picture_camera));
options.add(fragment.getString(R.string.actfm_picture_gallery));
if (clearImageOption != null) {
options.add(fragment.getString(R.string.actfm_picture_clear));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(fragment.getActivity(),
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(fragment.getActivity());
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (lastTempFile != null) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile));
}
fragment.startActivityForResult(intent, REQUEST_CODE_CAMERA);
} else if (which == 1) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
fragment.startActivityForResult(Intent.createChooser(intent,
fragment.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(fragment.getActivity())
.setAdapter(adapter, listener)
.show().setOwnerActivity(fragment.getActivity());
}
@SuppressWarnings("nls")
private static File getTempFile(Activity activity) {
try {

@ -15,6 +15,7 @@ import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -84,6 +85,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
private int commentItems = 10;
private ImageButton pictureButton;
private Bitmap picture = null;
private final Fragment fragment;
private final List<UpdatesChangedListener> listeners = new LinkedList<UpdatesChangedListener>();
@ -92,8 +94,11 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
public void commentAdded();
}
public EditNoteActivity(Activity activity, View parent, long t) {
super(activity);
public EditNoteActivity(Fragment fragment, View parent, long t) {
super(fragment.getActivity());
Log.d("EditnoteActivity", "Contructor being called");
this.fragment = fragment;
DependencyInjectionService.getInstance().inject(this);
setOrientation(VERTICAL);
@ -191,6 +196,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
final ClearImageCallback clearImage = new ClearImageCallback() {
@Override
public void clearImage() {
Log.e("Errrr EditNOtes activity", "Picture clear image called");
picture = null;
pictureButton.setImageResource(R.drawable.camera_button);
}
@ -200,9 +206,9 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
@Override
public void onClick(View v) {
if (picture != null)
ActFmCameraModule.showPictureLauncher((Activity)getContext(), clearImage);
ActFmCameraModule.showPictureLauncher(fragment, clearImage);
else
ActFmCameraModule.showPictureLauncher((Activity)getContext(), null);
ActFmCameraModule.showPictureLauncher(fragment, null);
}
});
if(!TextUtils.isEmpty(task.getValue(Task.NOTES))) {
@ -217,6 +223,10 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
// loadingText = (TextView) findViewById(R.id.loading);
loadingText = new TextView(getContext());
for (UpdatesChangedListener l : listeners) {
l.updatesChanged();
}
}
private void setUpListAdapter() {
@ -334,6 +344,16 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
DateUtils.FORMAT_ABBREV_RELATIVE);
date.setText(dateString);
}
// picture
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
if(TextUtils.isEmpty(item.commentPicture))
commentPictureView.setVisibility(View.GONE);
else {
commentPictureView.setVisibility(View.VISIBLE);
commentPictureView.setUrl(item.commentPicture);
}
}
}
public void refreshData(boolean manual, SyncResultCallback existingCallback) {
@ -390,10 +410,11 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
update.setValue(Update.TASK, task.getValue(Task.REMOTE_ID));
update.setValue(Update.CREATION_DATE, DateUtilities.now());
Log.d("Add comment", "The picture is: " + picture);
if (picture != null) {
update.setValue(Update.PICTURE, Update.PICTURE_LOADING);
}
Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
updateDao.createNew(update);
final long updateId = update.getId();
@ -402,6 +423,8 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
@Override
public void run() {
actFmSyncService.pushUpdate(updateId, tempPicture);
Log.d("Run thread", "The picture is: " + picture);
}
}.start();
commentField.setText(""); //$NON-NLS-1$
@ -424,14 +447,16 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
private final String picture;
private final String title;
private final String body;
private final String commentPicture;
private final long createdAt;
public NoteOrUpdate(String picture, String title, String body,
public NoteOrUpdate(String picture, String title, String body, String commentPicture,
long createdAt) {
super();
this.picture = picture;
this.title = title;
this.body = body;
this.commentPicture = commentPicture;
this.createdAt = createdAt;
}
@ -442,6 +467,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL),
m.getValue(NoteMetadata.TITLE),
m.getValue(NoteMetadata.BODY),
m.getValue(NoteMetadata.COMMENTPICTURE),
m.getValue(Metadata.CREATION_DATE));
}
@ -455,10 +481,12 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
description = message;
else if(!TextUtils.isEmpty(message))
description += " " + message;
String commentPicture = u.getValue(Update.PICTURE);
return new NoteOrUpdate(user.optString("picture"),
user.optString("name", ""),
description,
commentPicture,
u.getValue(Update.CREATION_DATE));
}
@ -504,6 +532,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
public void handleCameraResult(Bitmap bitmap) {
picture = bitmap;
pictureButton.setImageBitmap(picture);
Log.d("Picture", "Picture = " + picture);
}
};

@ -23,10 +23,14 @@ public class NoteMetadata {
/** note thumbnail URL */
public static final StringProperty THUMBNAIL = Metadata.VALUE3;
/** note external id (use for your own purposes) */
public static final StringProperty COMMENTPICTURE = Metadata.VALUE6;
/** note external provider (use for your own purposes) */
public static final StringProperty EXT_PROVIDER = Metadata.VALUE4;
/** note external id (use for your own purposes) */
public static final StringProperty EXT_ID = Metadata.VALUE5;
}

@ -47,6 +47,17 @@
android:paddingLeft="50dip"
android:textSize="14sp" />
<!-- picture -->
<greendroid.widget.AsyncImageView android:id="@+id/comment_picture"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_below="@id/description"
android:paddingTop="5dip"
astrid:defaultSrc="@drawable/icn_default_person_image"
android:scaleType="fitCenter"
android:visibility="gone" />
<!-- activity date -->
<TextView android:id="@+id/date"
android:layout_width="75dip"

@ -370,26 +370,24 @@ public final class TaskEditActivity extends Fragment implements
long idParam = getActivity().getIntent().getLongExtra(TOKEN_ID,
-1L);
if (remoteId > 0 && idParam > -1L) {
// if (editNotes == null) {
editNotes = new EditNoteActivity(getActivity(), getView(),
if (editNotes == null) {
editNotes = new EditNoteActivity(this, getView(),
idParam);
editNotes.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
editNotes.addListener(this);
if (timerAction != null) {
timerAction.addListener(editNotes);
}
else {
Log.d("Did not add timerAction", "did not add timer action");
}
// }
// else {
// editNotes.loadViewForTaskID(idParam);
// }
}
else {
editNotes.loadViewForTaskID(idParam);
}
if (mAdapter == null) {
mAdapter = new TaskEditViewPager(getActivity());
mAdapter.parent = this;
editNotes = new EditNoteActivity(getActivity(), getView(),
editNotes = new EditNoteActivity(this, getView(),
idParam);
editNotes.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
@ -1087,6 +1085,7 @@ public final class TaskEditActivity extends Fragment implements
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("Activity !!!", "Called on camera for request code: " + requestCode + "EditNOtes: " + editNotes.toString());
if (editNotes.activityResult(requestCode, resultCode, data)) {
return;
}

Loading…
Cancel
Save