Remove task action icon

pull/757/head
Alex Baker 6 years ago
parent c00344c56b
commit 3fbf0be594

@ -1,29 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* <p>See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.api;
import android.app.PendingIntent;
/**
* Represents an intent that can be called on a task
*
* @author Tim Su <tim@todoroo.com>
*/
public class TaskAction {
/** Intent to call when invoking this operation */
public PendingIntent intent;
/** Quick action icon */
public int icon;
/** Create an EditOperation object */
public TaskAction(PendingIntent intent, int icon) {
super();
this.intent = intent;
this.icon = icon;
}
}

@ -1,112 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* <p>See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.core;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.Spannable;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.util.AndroidRuntimeException;
import com.todoroo.astrid.api.TaskAction;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.files.FilesAction;
import com.todoroo.astrid.notes.NotesAction;
import java.util.List;
import org.tasks.R;
import timber.log.Timber;
/**
* Exposes {@link TaskAction} for phone numbers, emails, urls, etc
*
* @author Tim Su <tim@todoroo.com>
*/
public class LinkActionExposer {
public static TaskAction getActionsForTask(Context context, Task task, boolean hasAttachments) {
if (task == null) {
return null;
}
boolean hasNotes = task.hasNotes();
Spannable titleSpan = Spannable.Factory.getInstance().newSpannable(task.getTitle());
try {
Linkify.addLinks(titleSpan, Linkify.ALL);
} catch (AndroidRuntimeException e) {
// This can happen if WebView is missing
Timber.w(e);
return null;
}
URLSpan[] urlSpans = titleSpan.getSpans(0, titleSpan.length(), URLSpan.class);
if (urlSpans.length == 0 && !hasNotes && !hasAttachments) {
return null;
}
PackageManager pm = context.getPackageManager();
for (URLSpan urlSpan : urlSpans) {
String url = urlSpan.getURL();
int start = titleSpan.getSpanStart(urlSpan);
int end = titleSpan.getSpanEnd(urlSpan);
String text = titleSpan.subSequence(start, end).toString();
TaskAction taskAction = createLinkAction(context, task.getId(), url, text, pm);
if (taskAction != null) {
return taskAction;
}
}
if (hasAttachments) {
return new FilesAction(R.drawable.ic_attachment_24dp);
}
if (hasNotes) {
return new NotesAction(R.drawable.ic_event_note_24dp);
}
return null;
}
private static TaskAction createLinkAction(
Context context, long id, String url, String text, PackageManager pm) {
Intent itemIntent = new Intent(Intent.ACTION_VIEW);
itemIntent.setData(Uri.parse(url));
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(itemIntent, 0);
Intent actionIntent;
// if options > 1, display open with...
if (resolveInfoList.size() > 1) {
actionIntent = Intent.createChooser(itemIntent, text);
}
// else show app that gets opened
else if (resolveInfoList.size() == 1) {
actionIntent = itemIntent;
}
// no intents -> no item
else {
return null;
}
int icon;
if (url.startsWith("mailto")) {
icon = R.drawable.ic_email_black_24dp;
} else if (url.startsWith("tel")) {
icon = R.drawable.ic_phone_white_24dp;
} else {
icon = R.drawable.ic_public_black_24dp;
}
return new TaskAction(PendingIntent.getActivity(context, (int) id, actionIntent, 0), icon);
}
}

@ -1,15 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* <p>See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.files;
import com.todoroo.astrid.api.TaskAction;
public class FilesAction extends TaskAction {
public FilesAction(int icon) {
super(null, icon);
}
}

@ -225,10 +225,6 @@ public class FilesControlSet extends TaskEditControlFragment {
}
}
public void hideAddAttachmentButton() {
addAttachment.setVisibility(View.GONE);
}
@Override
protected void inject(FragmentComponent component) {
component.inject(this);

@ -1,15 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* <p>See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.notes;
import com.todoroo.astrid.api.TaskAction;
public class NotesAction extends TaskAction {
public NotesAction(int icon) {
super(null, icon);
}
}

@ -5,38 +5,26 @@ import static com.todoroo.andlib.utility.AndroidUtilities.atLeastKitKat;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Paint;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnLongClick;
import com.google.common.collect.Lists;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.TaskAction;
import com.todoroo.astrid.core.LinkActionExposer;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.files.FilesAction;
import com.todoroo.astrid.notes.NotesAction;
import com.todoroo.astrid.ui.CheckableImageView;
import java.util.List;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.ui.CheckBoxes;
import timber.log.Timber;
class ViewHolder extends RecyclerView.ViewHolder {
@ -46,7 +34,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
private final int textColorSecondary;
private final int textColorHint;
private final TaskDao taskDao;
private final DialogBuilder dialogBuilder;
private final ViewHolderCallbacks callback;
private final DisplayMetrics metrics;
private final int background;
@ -73,9 +60,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.tag_block)
TextView tagBlock;
@BindView(R.id.taskActionIcon)
ImageView taskActionIcon;
private int indent;
private boolean selected;
private boolean moving;
@ -91,7 +75,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
int textColorSecondary,
int textColorHint,
TaskDao taskDao,
DialogBuilder dialogBuilder,
ViewHolderCallbacks callback,
DisplayMetrics metrics,
int background,
@ -105,7 +88,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
this.textColorSecondary = textColorSecondary;
this.textColorHint = textColorHint;
this.taskDao = taskDao;
this.dialogBuilder = dialogBuilder;
this.callback = callback;
this.metrics = metrics;
this.background = background;
@ -205,24 +187,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
nameView.setText(nameValue);
setupDueDateAndTags();
// Task action
TaskAction action = getTaskAction(task, task.hasFiles());
if (action != null) {
taskActionIcon.setVisibility(View.VISIBLE);
taskActionIcon.setImageResource(action.icon);
taskActionIcon.setTag(action);
} else {
taskActionIcon.setVisibility(View.GONE);
taskActionIcon.setTag(null);
}
}
private TaskAction getTaskAction(Task task, boolean hasFiles) {
if (task.isCompleted()) {
return null;
}
return LinkActionExposer.getActionsForTask(context, task, hasFiles);
}
private void setTaskAppearance() {
@ -324,50 +288,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
setTaskAppearance();
}
@OnClick(R.id.taskActionIcon)
void onTaskActionClick() {
TaskAction action = (TaskAction) taskActionIcon.getTag();
if (action instanceof NotesAction) {
showEditNotesDialog(task);
} else if (action instanceof FilesAction) {
showFilesDialog(task);
} else if (action != null) {
try {
action.intent.send();
} catch (PendingIntent.CanceledException e) {
// Oh well
Timber.e(e);
}
}
}
private void showEditNotesDialog(final Task task) {
Task t = taskDao.fetch(task.getId());
if (t == null || !t.hasNotes()) {
return;
}
SpannableString description = new SpannableString(t.getNotes());
Linkify.addLinks(description, Linkify.ALL);
AlertDialog dialog =
dialogBuilder
.newDialog()
.setMessage(description)
.setPositiveButton(android.R.string.ok, null)
.show();
View message = dialog.findViewById(android.R.id.message);
if (message != null && message instanceof TextView) {
((TextView) message).setMovementMethod(LinkMovementMethod.getInstance());
}
}
private void showFilesDialog(Task task) {
// TODO: reimplement this
// FilesControlSet filesControlSet = new FilesControlSet();
// filesControlSet.hideAddAttachmentButton();
// filesControlSet.readFromTask(task);
// filesControlSet.getView().performClick();
}
interface ViewHolderCallbacks {
void onCompletedTask(Task task, boolean newState);

@ -12,7 +12,6 @@ import android.view.ViewGroup;
import com.todoroo.astrid.dao.TaskDao;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.ForActivity;
import org.tasks.preferences.Preferences;
import org.tasks.ui.CheckBoxes;
@ -28,7 +27,6 @@ public class ViewHolderFactory {
private final boolean showFullTaskTitle;
private final int fontSize;
private final TaskDao taskDao;
private final DialogBuilder dialogBuilder;
private final DisplayMetrics metrics;
private final int background;
private final int selectedColor;
@ -40,13 +38,11 @@ public class ViewHolderFactory {
Preferences preferences,
CheckBoxes checkBoxes,
TagFormatter tagFormatter,
TaskDao taskDao,
DialogBuilder dialogBuilder) {
TaskDao taskDao) {
this.context = context;
this.checkBoxes = checkBoxes;
this.tagFormatter = tagFormatter;
this.taskDao = taskDao;
this.dialogBuilder = dialogBuilder;
textColorSecondary = getData(context, android.R.attr.textColorSecondary);
textColorHint = getData(context, android.R.attr.textColorTertiary);
textColorOverdue = getColor(context, R.color.overdue);
@ -71,7 +67,6 @@ public class ViewHolderFactory {
textColorSecondary,
textColorHint,
taskDao,
dialogBuilder,
callbacks,
metrics,
background,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 597 B

@ -1,12 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:autoMirrored="true"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp"
tools:ignore="UnusedAttribute,VectorRaster">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>

@ -1,12 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:autoMirrored="true"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp"
tools:ignore="UnusedAttribute,VectorRaster">
<path
android:fillColor="#FF000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z"/>
</vector>

@ -26,30 +26,13 @@
android:paddingRight="@dimen/keyline_second"
android:scaleType="center"/>
<ImageView
android:id="@+id/taskActionIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:paddingStart="0dp"
android:paddingEnd="@dimen/keyline_first"
android:paddingLeft="0dp"
android:paddingRight="@dimen/keyline_first"
android:alpha="?attr/alpha_secondary"
android:gravity="end|center_vertical"
android:scaleType="center"
android:tint="?attr/icon_tint"/>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/completeBox"
android:layout_toLeftOf="@id/taskActionIcon"
android:layout_toRightOf="@id/completeBox"
android:layout_toStartOf="@id/taskActionIcon"
android:paddingStart="0dp"
android:paddingEnd="@dimen/keyline_first"
android:paddingLeft="0dp"

Loading…
Cancel
Save