Remove CommentsFragment

pull/189/head
Alex Baker 11 years ago
parent 6124039d9d
commit d475359595

@ -1,278 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.actfm;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback;
import com.todoroo.astrid.actfm.ActFmCameraModule.ClearImageCallback;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.adapter.UpdateAdapter;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.UserActivity;
import org.json.JSONObject;
import org.tasks.R;
import org.tasks.injection.InjectingListFragment;
import javax.inject.Inject;
public abstract class CommentsFragment extends InjectingListFragment {
protected UpdateAdapter updateAdapter;
protected EditText addCommentField;
protected ViewGroup listHeader;
protected Button footerView = null;
protected ImageButton pictureButton;
protected Bitmap picture = null;
public static final String TAG_UPDATES_FRAGMENT = "tagupdates_fragment"; //$NON-NLS-1$
protected static final int MENU_REFRESH_ID = Menu.FIRST;
@Inject UserActivityDao userActivityDao;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
return inflater.inflate(getLayout(), container, false);
}
protected abstract int getLayout();
protected abstract void loadModelFromIntent(Intent intent);
protected abstract boolean hasModel();
protected abstract Cursor getCursor();
protected abstract void addHeaderToListView(ListView listView);
protected abstract UserActivity createUpdate();
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
loadModelFromIntent(getActivity().getIntent());
OnTouchListener onTouch = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.requestFocusFromTouch();
return false;
}
};
if (!hasModel()) {
getView().findViewById(R.id.updatesFooter).setVisibility(View.GONE);
}
addCommentField = (EditText) getView().findViewById(R.id.commentField);
addCommentField.setOnTouchListener(onTouch);
setUpUpdateList();
}
protected void setUpUpdateList() {
final ImageButton commentButton = (ImageButton) getView().findViewById(R.id.commentButton);
addCommentField = (EditText) getView().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.setVisibility(TextUtils.isEmpty(addCommentField.getText()) ? View.GONE : View.VISIBLE);
commentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addComment();
}
});
final ClearImageCallback clearImage = new ClearImageCallback() {
@Override
public void clearImage() {
picture = null;
resetPictureButton();
}
};
pictureButton = (ImageButton) getView().findViewById(R.id.picture);
pictureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (picture != null) {
ActFmCameraModule.showPictureLauncher(CommentsFragment.this, clearImage);
} else {
ActFmCameraModule.showPictureLauncher(CommentsFragment.this, null);
}
}
});
refreshUpdatesList();
}
protected void resetPictureButton() {
TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.ic_action_camera, typedValue, true);
pictureButton.setImageResource(typedValue.resourceId);
}
protected void refreshUpdatesList() {
Activity activity = getActivity();
View view = getView();
if (activity == null || view == null) {
return;
}
Cursor cursor;
ListView listView = ((ListView) view.findViewById(android.R.id.list));
if(updateAdapter == null) {
cursor = getCursor();
activity.startManagingCursor(cursor);
updateAdapter = new UpdateAdapter(this, R.layout.update_adapter_row, cursor);
addHeaderToListView(listView);
addFooterToListView(listView);
listView.setAdapter(updateAdapter);
} else {
cursor = updateAdapter.getCursor();
cursor.requery();
activity.startManagingCursor(cursor);
if (footerView != null) {
listView.removeFooterView(footerView);
footerView = null;
}
}
listView.setVisibility(View.VISIBLE);
}
private void addFooterToListView(ListView listView) {
if (footerView != null) {
listView.removeFooterView(footerView);
}
footerView = null;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(menu.size() > 0) {
return;
}
MenuItem item;
boolean showCommentsRefresh = false;
if (showCommentsRefresh) {
Activity activity = getActivity();
if (activity instanceof TaskListActivity) {
TaskListActivity tla = (TaskListActivity) activity;
showCommentsRefresh = tla.getTaskEditFragment() == null;
}
}
if(showCommentsRefresh) {
item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE,
R.string.ENA_refresh_comments);
item.setIcon(R.drawable.icn_menu_refresh_dark);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle my own menus
switch (item.getItemId()) {
case MENU_REFRESH_ID: {
return true;
}
default: return false;
}
}
protected void addComment() {
UserActivity update = createUpdate();
if (picture != null) {
JSONObject pictureJson = RemoteModel.PictureHelper.savePictureJson(getActivity(), picture);
if (pictureJson != null) {
update.setPicture(pictureJson.toString());
}
}
userActivityDao.createNew(update);
addCommentField.setText(""); //$NON-NLS-1$
picture = null;
resetPictureButton();
refreshUpdatesList();
}
@Override
public 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(getActivity(), requestCode, resultCode, data, callback)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
}

@ -1,83 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.actfm;
import android.content.Intent;
import android.database.Cursor;
import android.view.ViewGroup;
import android.widget.ListView;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.utility.AstridPreferences;
import org.tasks.R;
import javax.inject.Inject;
public class TagCommentsFragment extends CommentsFragment {
private TagData tagData;
@Inject TagDataService tagDataService;
public TagCommentsFragment() {
super();
}
public TagCommentsFragment(TagData tagData) {
this();
this.tagData = tagData;
}
@Override
protected int getLayout() {
return R.layout.tag_updates_fragment;
}
@Override
protected void loadModelFromIntent(Intent intent) {
if (tagData == null) {
long id = intent.getLongExtra(TagViewFragment.EXTRA_TAG_DATA, 0);
if (id > 0) {
tagData = tagDataService.fetchById(id, TagData.PROPERTIES);
}
}
}
@Override
protected boolean hasModel() {
return tagData != null;
}
@Override
protected Cursor getCursor() {
return tagDataService.getActivityForTagData(tagData);
}
@Override
protected void addHeaderToListView(ListView listView) {
if (AstridPreferences.useTabletLayout(getActivity()) && tagData != null) {
listHeader = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.tag_updates_header, listView, false);
listView.addHeaderView(listHeader);
}
}
@Override
protected UserActivity createUpdate() {
UserActivity userActivity = new UserActivity();
userActivity.setMessage(addCommentField.getText().toString());
userActivity.setAction(UserActivity.ACTION_TAG_COMMENT);
userActivity.setUserUUID(Task.USER_ID_SELF);
userActivity.setTargetId(tagData.getUuid());
userActivity.setTargetName(tagData.getName());
userActivity.setCreatedAt(DateUtilities.now());
return userActivity;
}
}

@ -21,8 +21,6 @@ import android.widget.Toast;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.CommentsFragment;
import com.todoroo.astrid.actfm.TagCommentsFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
@ -84,11 +82,6 @@ public class AstridActivity extends InjectingActionBarActivity
.findFragmentByTag(TaskEditFragment.TAG_TASKEDIT_FRAGMENT);
}
public CommentsFragment getTagUpdatesFragment() {
return (CommentsFragment) getSupportFragmentManager()
.findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT);
}
@Inject TaskService taskService;
@Inject StartupService startupService;
@Inject GCalHelper gcalHelper;
@ -171,12 +164,6 @@ public class AstridActivity extends InjectingActionBarActivity
if (fragmentLayout == LAYOUT_DOUBLE) {
findViewById(R.id.taskedit_fragment_container).setVisibility(View.VISIBLE);
}
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
TagCommentsFragment updates = new TagCommentsFragment(tagData);
transaction.replace(R.id.taskedit_fragment_container, updates, CommentsFragment.TAG_UPDATES_FRAGMENT);
transaction.commit();
}
public void setupTasklistFragmentWithFilter(Filter filter, Bundle extras) {

@ -25,7 +25,6 @@ import android.widget.FrameLayout;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.actfm.CommentsFragment;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.api.AstridApiConstants;
@ -288,11 +287,6 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
if (fragmentLayout != LAYOUT_SINGLE) {
getIntent().putExtra(OPEN_TASK, taskId);
}
CommentsFragment tuf = getTagUpdatesFragment();
if (tuf != null) {
tuf.getView().setVisibility(View.INVISIBLE);
}
super.onTaskListItemClicked(taskId);
}
@ -328,11 +322,6 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
if(taskeditFragmentContainer != null && taskeditFragmentContainer.getVisibility() == View.VISIBLE) {
Flags.set(Flags.TLA_DISMISSED_FROM_TASK_EDIT);
onPostResume();
CommentsFragment tuf = getTagUpdatesFragment();
if (tuf != null) {
tuf.getView().setVisibility(View.VISIBLE);
}
}
int drawerState = menuDrawer.getDrawerState();
if(drawerState == MenuDrawer.STATE_OPEN || drawerState == MenuDrawer.STATE_OPENING) {

@ -3,7 +3,6 @@ package org.tasks.injection;
import android.app.Activity;
import android.content.Context;
import com.todoroo.astrid.actfm.TagCommentsFragment;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.activity.FilterListFragment;
import com.todoroo.astrid.activity.TaskEditFragment;
@ -33,7 +32,6 @@ import static org.tasks.injection.ActivityModule.ForActivity;
SubtasksTagListFragment.class,
TagViewFragment.class,
TaskEditFragment.class,
TagCommentsFragment.class,
FilterListFragment.class,
QuickAddBar.class,
TimerFilterExposer.class,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.todoroo.astrid.ui.ErrorCatchingListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="100"
style="@style/ListView"
android:divider="@android:color/transparent"/>
<ProgressBar
android:id="@+id/comments_progressBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:visibility="gone" />
<!-- Footer -->
<LinearLayout
android:id="@+id/updatesFooter"
style="@style/Content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:minHeight="50dip"
android:orientation="horizontal"
android:background="?attr/asAbBackgroundColor"
android:padding="3dip"
android:paddingBottom="0dip" >
<!-- 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:layout_weight="1"
android:background="@android:color/transparent"
android:paddingBottom="2dip"
android:scaleType="centerInside"
android:src="?attr/ic_action_camera" />
<!-- Quick Add Task -->
<EditText
android:id="@+id/commentField"
android:layout_width="wrap_content"
android:layout_height="39dip"
android:layout_marginBottom="2dip"
android:layout_marginTop="2dip"
android:layout_marginLeft="1dip"
android:layout_marginRight="8dip"
android:layout_weight="100"
android:autoText="true"
android:background="?attr/asEditTextBackground"
android:capitalize="sentences"
android:hint="@string/TVA_add_comment"
android:paddingLeft="10dip"
android:textColor="?attr/asTextColor"
android:textSize="16sp" />
<!-- Extended Add Button -->
<ImageButton
android:id="@+id/commentButton"
android:layout_width="39dip"
android:layout_height="39dip"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="?attr/ic_action_new"
android:scaleType="center" />
</LinearLayout>
</LinearLayout>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>

@ -1,6 +1,6 @@
#!/bin/bash
for DIR in $(ls -d **/src/main/res/drawable*); do
for file in $(ls -l ${DIR} | awk '{ print $9}' | sed 's/\..\+//g'); do
for file in $(ls -l ${DIR} | /usr/bin/awk '{ print $9}' | /usr/bin/sed 's/\..\+//g'); do
if [ ! -f ${DIR}/${file} ]; then
echo "ignoring ${file}"
continue

@ -1,7 +1,8 @@
#!/bin/bash
for DIR in $(ls -d **/src/main/res/layout*); do
for file in $(ls -l ${DIR} | awk '{ print $9}' | sed 's/\..\+//g'); do
for file in $(ls -l ${DIR} | /usr/bin/awk '{ print $9}' | /usr/bin/sed 's/\..\+//g'); do
if [ ! -f ${DIR}/${file} ]; then
echo -e "ignored ${DIR}/${file}"
continue
fi;
filename=`basename ${file}`

Loading…
Cancel
Save