mirror of https://github.com/tasks/tasks
Remove FilterCategory, GtasksListAdder
Filter categories were only being used as lists of filterspull/189/head
parent
17229bcb7c
commit
680142fdcd
@ -1,99 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.api;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A <code>FilterCategory</code> groups common {@link Filter}s and allows
|
|
||||||
* a user to show/hide all of its children.
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FilterCategory extends FilterListItem {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Filter}s contained by this category
|
|
||||||
*/
|
|
||||||
public Filter[] children;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for creating a new FilterCategory
|
|
||||||
* @param listingTitle
|
|
||||||
* Title of this item as displayed on the lists page, e.g. Inbox
|
|
||||||
* @param children
|
|
||||||
* filters belonging to this category
|
|
||||||
*/
|
|
||||||
public FilterCategory(String listingTitle, Filter[] children) {
|
|
||||||
this.listingTitle = listingTitle;
|
|
||||||
this.children = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for creating a new FilterCategory
|
|
||||||
*/
|
|
||||||
protected FilterCategory() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- parcelable
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
dest.writeParcelableArray(children, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parcelable creator
|
|
||||||
*/
|
|
||||||
public static final Parcelable.Creator<FilterCategory> CREATOR = new Parcelable.Creator<FilterCategory>() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FilterCategory createFromParcel(Parcel source) {
|
|
||||||
FilterCategory item = new FilterCategory();
|
|
||||||
item.readFromParcel(source);
|
|
||||||
|
|
||||||
Parcelable[] parcelableChildren = source.readParcelableArray(
|
|
||||||
FilterCategory.class.getClassLoader());
|
|
||||||
item.children = new Filter[parcelableChildren.length];
|
|
||||||
for(int i = 0; i < item.children.length; i++) {
|
|
||||||
if(parcelableChildren[i] instanceof FilterListItem) {
|
|
||||||
item.children[i] = (Filter) parcelableChildren[i];
|
|
||||||
} else {
|
|
||||||
item.children[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FilterCategory[] newArray(int size) {
|
|
||||||
return new FilterCategory[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.api;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A <code>FilterCategoryWithNewButton</code> has a button for new filter creation
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FilterCategoryWithNewButton extends FilterCategory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Intent to launch
|
|
||||||
*/
|
|
||||||
public PendingIntent intent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Label for new button
|
|
||||||
*/
|
|
||||||
public String label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for creating a new FilterCategory
|
|
||||||
* @param listingTitle
|
|
||||||
* Title of this item as displayed on the lists page, e.g. Inbox
|
|
||||||
* @param children
|
|
||||||
* filters belonging to this category
|
|
||||||
*/
|
|
||||||
public FilterCategoryWithNewButton(String listingTitle, Filter[] children) {
|
|
||||||
this.listingTitle = listingTitle;
|
|
||||||
this.children = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for creating a new FilterCategory
|
|
||||||
*/
|
|
||||||
protected FilterCategoryWithNewButton() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- parcelable
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
dest.writeParcelable(intent, 0);
|
|
||||||
dest.writeString(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parcelable creator
|
|
||||||
*/
|
|
||||||
public static final Parcelable.Creator<FilterCategoryWithNewButton> CREATOR = new Parcelable.Creator<FilterCategoryWithNewButton>() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FilterCategoryWithNewButton createFromParcel(Parcel source) {
|
|
||||||
FilterCategoryWithNewButton item = new FilterCategoryWithNewButton();
|
|
||||||
item.readFromParcel(source);
|
|
||||||
|
|
||||||
Parcelable[] parcelableChildren = source.readParcelableArray(
|
|
||||||
FilterCategoryWithNewButton.class.getClassLoader());
|
|
||||||
item.children = new Filter[parcelableChildren.length];
|
|
||||||
for(int i = 0; i < item.children.length; i++) {
|
|
||||||
if(parcelableChildren[i] instanceof FilterListItem) {
|
|
||||||
item.children[i] = (Filter) parcelableChildren[i];
|
|
||||||
} else {
|
|
||||||
item.children[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item.intent = source.readParcelable(PendingIntent.class.getClassLoader());
|
|
||||||
item.label = source.readString();
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FilterCategoryWithNewButton[] newArray(int size) {
|
|
||||||
return new FilterCategoryWithNewButton[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.gtasks;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
import com.todoroo.andlib.utility.DialogUtilities;
|
|
||||||
import com.todoroo.astrid.api.FilterWithCustomIntent;
|
|
||||||
import com.todoroo.astrid.data.StoreObject;
|
|
||||||
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
|
|
||||||
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.tasks.R;
|
|
||||||
import org.tasks.injection.InjectingActivity;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
public class GtasksListAdder extends InjectingActivity {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GtasksListAdder.class);
|
|
||||||
|
|
||||||
@Inject GtasksPreferenceService gtasksPreferenceService;
|
|
||||||
@Inject GtasksListService gtasksListService;
|
|
||||||
@Inject GtasksTokenValidator gtasksTokenValidator;
|
|
||||||
@Inject GtasksMetadata gtasksMetadata;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
showNewListDialog(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNewListDialog(final Activity activity) {
|
|
||||||
FrameLayout frame = new FrameLayout(activity);
|
|
||||||
final EditText editText = new EditText(activity);
|
|
||||||
frame.addView(editText);
|
|
||||||
frame.setPadding(10, 0, 10, 0);
|
|
||||||
|
|
||||||
DialogInterface.OnClickListener onClick = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (gtasksPreferenceService.isLoggedIn() && ! gtasksPreferenceService.isOngoing()) {
|
|
||||||
final ProgressDialog pd = DialogUtilities.progressDialog(GtasksListAdder.this,
|
|
||||||
GtasksListAdder.this.getString(R.string.gtasks_FEx_creating_list));
|
|
||||||
pd.show();
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
String token = gtasksPreferenceService.getToken();
|
|
||||||
try {
|
|
||||||
token = gtasksTokenValidator.validateAuthToken(activity, token);
|
|
||||||
GtasksInvoker service = new GtasksInvoker(gtasksTokenValidator, token);
|
|
||||||
String title = editText.getText().toString();
|
|
||||||
if (TextUtils.isEmpty(title)) //Don't create a list without a title
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StoreObject newList = gtasksListService.addNewList(service.createGtaskList(title));
|
|
||||||
if (newList != null) {
|
|
||||||
FilterWithCustomIntent listFilter = (FilterWithCustomIntent) GtasksFilterExposer.filterFromList(gtasksMetadata, activity, newList);
|
|
||||||
listFilter.start(activity, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
DialogUtilities.okDialog(activity, activity.getString(R.string.gtasks_FEx_create_list_error), null);
|
|
||||||
} finally {
|
|
||||||
pd.dismiss();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogInterface.OnClickListener onCancel = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogUtilities.viewDialog(activity,
|
|
||||||
activity.getString(R.string.gtasks_FEx_create_list_dialog),
|
|
||||||
frame, onClick, onCancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Loading…
Reference in New Issue