Skip to content

Commit

Permalink
Displaying closed issues in milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
Motoaleks committed Dec 21, 2017
1 parent 2fe6404 commit 6e2c675
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.github.mobile.Intents;
import com.github.mobile.R;
import com.github.mobile.core.issue.IssueFilter;
import com.github.mobile.ui.DialogFragmentActivity;
import com.github.mobile.ui.issue.IssuesFragment;
import com.github.mobile.ui.repo.RepositoryViewActivity;

import org.eclipse.egit.github.core.Milestone;
Expand All @@ -18,6 +26,7 @@

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static com.github.mobile.Intents.EXTRA_ISSUE_FILTER;
import static com.github.mobile.Intents.EXTRA_MILESTONE;
import static com.github.mobile.Intents.EXTRA_REPOSITORY;
import static com.github.mobile.RequestCodes.MILESTONE_VIEW;
Expand All @@ -41,6 +50,7 @@ public static Intent createIntent(Repository repository, Milestone milestone, in

private Repository repository;
private Milestone milestone;
private ToggleButton closedIssues;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -55,6 +65,36 @@ protected void onCreate(Bundle savedInstanceState) {
actionBar.setTitle(milestone.getTitle());
actionBar.setSubtitle(R.string.milestone);
actionBar.setDisplayHomeAsUpEnabled(true);

MilestoneFragment milestoneFragment = new MilestoneFragment();
IssuesFragment issuesFragment = new IssuesFragment();

IssueFilter filter = new IssueFilter(repository);
filter.setMilestone(milestone);
filter.setOpen(true);
getIntent().putExtra(EXTRA_ISSUE_FILTER, filter);

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

transaction.add(R.id.ms_description, milestoneFragment);
transaction.add(R.id.ms_issues, issuesFragment);

transaction.commit();

closedIssues = (ToggleButton) finder.find(R.id.tb_closed_issues);
closedIssues.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
IssueFilter filter = new IssueFilter(repository);
filter.setMilestone(milestone);
filter.setOpen(!b);
getIntent().putExtra(EXTRA_ISSUE_FILTER, filter);
IssuesFragment issuesFragment = new IssuesFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.ms_issues, issuesFragment);
transaction.commit();
}
});
}

@Override
Expand Down
29 changes: 25 additions & 4 deletions app/src/main/res/layout/milestone_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand All @@ -8,10 +9,30 @@
android:id="@+id/toolbar"
style="@style/Toolbar" />

<fragment
android:id="@android:id/list"
class="com.github.mobile.ui.milestone.MilestoneFragment"
<FrameLayout
android:id="@+id/ms_description"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content">

</FrameLayout>

<ToggleButton
android:id="@+id/tb_closed_issues"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/issues_display_closed"
android:textAlignment="viewStart"
android:textAppearance="@style/TextAppearance.Design.Hint"
android:textOff="@string/issues_display_closed"
android:textOn="@string/issues_display_opened"
android:textSize="14sp" />


<FrameLayout
android:id="@+id/ms_issues"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,5 +356,7 @@
<string name="ms_date_month">month</string>
<string name="ms_choose_date">Choose date</string>
<string name="ms_percent_completed">% completed</string>
<string name="issues_display_closed">Display closed</string>
<string name="issues_display_opened">Display opened</string>

</resources>

0 comments on commit 6e2c675

Please sign in to comment.