package com.github.mobile.android.issue;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;

import com.github.mobile.android.ConfirmDialogFragment;
import com.github.mobile.android.DialogFragmentActivity;
import com.github.mobile.android.R.layout;
import com.github.mobile.android.R.string;
import com.github.mobile.android.RequestFuture;
import com.github.mobile.android.persistence.AccountDataManager;
import com.github.mobile.android.util.GitHubIntents.Builder;
import com.google.inject.Inject;

/**
 * Activity to browse a list of bookmarked {@link IssueFilter} items
 */
public class FilterBrowseActivity extends DialogFragmentActivity implements OnItemLongClickListener {

    /**
     * Create intent to browse issue filters
     *
     * @return intent
     */
    public static Intent createIntent() {
        return new Builder("repo.issues.filters.VIEW").toIntent();
    }

    private static final String ARG_FILTER = "filter";

    private static final int REQUEST_DELETE = 1;

    @Inject
    private AccountDataManager cache;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(string.saved_filters_title);
        setContentView(layout.issue_filter_list);

        FilterListFragment filterFragment = (FilterListFragment) getSupportFragmentManager().findFragmentById(
                android.R.id.list);
        filterFragment.getListView().setOnItemLongClickListener(this);
    }

    public void onDialogResult(int requestCode, int resultCode, Bundle arguments) {
        if (requestCode == REQUEST_DELETE && resultCode == RESULT_OK) {
            IssueFilter filter = (IssueFilter) arguments.getSerializable(ARG_FILTER);
            cache.removeIssueFilter(filter, new RequestFuture<IssueFilter>() {

                public void success(IssueFilter response) {
                    ((FilterListFragment) getSupportFragmentManager().findFragmentById(android.R.id.list)).refresh();
                }
            });
            return;
        }
        super.onDialogResult(requestCode, resultCode, arguments);
    }

    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        IssueFilter filter = (IssueFilter) parent.getItemAtPosition(position);
        Bundle args = new Bundle();
        args.putSerializable(ARG_FILTER, filter);
        ConfirmDialogFragment.show(this, REQUEST_DELETE, null,
                "Are you sure you want to remove this saved issue filter?", args);
        return true;
    }
}

@@ -35,16 +35,141 @@
 issue;%0A%0A
+import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;%0Aimport static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;%0A
 import a
@@ -187,24 +187,24 @@
 ent.Intent;%0A
-
 import andro
@@ -338,16 +338,60 @@
 tener;%0A%0A
+import com.actionbarsherlock.view.MenuItem;%0A
 import c
@@ -495,16 +495,63 @@
 tivity;%0A
+import com.github.mobile.android.HomeActivity;%0A
 import c
@@ -1589,16 +1589,79 @@
 r_list);
+%0A        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 %0A%0A      
@@ -2435,32 +2435,32 @@
 turn;%0A        %7D%0A
-
         super.on
@@ -2508,32 +2508,453 @@
 uments);%0A    %7D%0A%0A
+    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A        case android.R.id.home:%0A            Intent intent = new Intent(this, HomeActivity.class);%0A            intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP %7C FLAG_ACTIVITY_SINGLE_TOP);%0A            startActivity(intent);%0A            return true;%0A        default:%0A            return super.onOptionsItemSelected(item);%0A        %7D%0A    %7D%0A%0A
     public boole

Add home link to FilterBrowseActivity