Skip to content

Commit

Permalink
Initial detailed milestone view
Browse files Browse the repository at this point in the history
View include:
- title
- due to date
- description
- progress
- back to milestones list button
  • Loading branch information
Motoaleks committed Dec 21, 2017
1 parent 98123ee commit 3e97b5c
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 16 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/github/mobile/RequestCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ public interface RequestCodes {
* Request to delete a comment
*/
int COMMENT_DELETE = 15;

/**
* Request to view milestone
*/
int MILESTONE_VIEW = 16;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,95 @@
package com.github.mobile.ui.milestone;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.github.mobile.R;
import com.github.mobile.ui.DialogFragment;

import org.eclipse.egit.github.core.Milestone;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import static com.github.mobile.Intents.EXTRA_MILESTONE;

/**
* Created by Александр on 20.12.2017.
*/

public class MilestoneFragment {
public class MilestoneFragment extends DialogFragment {
private Milestone milestone;

private TextView milestoneTitle;
private TextView milestoneDueTo;
private TextView milestoneDescription;
private ProgressBar milestoneProgress;
private TextView milestoneProgressPercentage;

@Override
public void onAttach(Context context) {
super.onAttach(context);

milestone = (Milestone) getSerializableExtra(EXTRA_MILESTONE);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.repo_milestone_item, null);
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

milestoneTitle = (TextView) finder.find(R.id.tv_milestone_name);
milestoneDueTo = (TextView) finder.find(R.id.tv_milestone_due_to);
milestoneDescription = (TextView) finder.find(R.id.tv_milestone_description);
milestoneProgress = (ProgressBar) finder.find(R.id.pB_milestone_completion_progress);
milestoneProgressPercentage = (TextView) finder.find(R.id.tv_milestone_progress_percentage);
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (milestone != null){
updateMilestone(milestone);
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// case R.id.m_edit:
// if (issue != null) {
// Intent intent = EditIssueActivity.createIntent(issue,
// repositoryId.getOwner(), repositoryId.getName(), user);
// startActivityForResult(intent, ISSUE_EDIT);
// }
// return true;
}
return true;
}

private void updateMilestone(final Milestone milestone){
if (!isUsable()){
return;
}

milestoneTitle.setText(milestone.getTitle());
DateFormat sdf = SimpleDateFormat.getDateInstance();
milestoneDueTo.setText(sdf.format(milestone.getDueOn()));
milestoneDescription.setText(milestone.getDescription());
int totalIssues = milestone.getClosedIssues() + milestone.getOpenIssues();
int progress = totalIssues == 0 ? 0 : milestone.getClosedIssues() * 100 / totalIssues;
milestoneProgress.setProgress(progress);
milestoneProgressPercentage.setText(String.valueOf(progress));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.mobile.ui.milestone;

import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
Expand All @@ -11,11 +12,15 @@
import com.github.mobile.ui.DialogFragmentActivity;
import com.github.mobile.ui.repo.RepositoryViewActivity;

import org.eclipse.egit.github.core.Milestone;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.User;

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_MILESTONE;
import static com.github.mobile.Intents.EXTRA_REPOSITORY;
import static com.github.mobile.RequestCodes.MILESTONE_VIEW;

/**
* Created by Александр on 20.12.2017.
Expand All @@ -28,22 +33,26 @@ public class MilestoneViewActivity extends DialogFragmentActivity {
* @param repository
* @return intent
*/
public static Intent createIntent(Repository repository, int position) {
return new Intents.Builder("repo.milestone.VIEW").repo(repository).toIntent();
public static Intent createIntent(Repository repository, Milestone milestone, int position) {
return new Intents.Builder("repo.milestone.VIEW")
.repo(repository)
.milestone(milestone).toIntent();
}

private Repository repository;
private Milestone milestone;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.repo_milestones);
setContentView(R.layout.milestone_view);

repository = getSerializableExtra(EXTRA_REPOSITORY);
milestone = getSerializableExtra(EXTRA_MILESTONE);

ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(repository.getName());
actionBar.setTitle(milestone.getTitle());
actionBar.setSubtitle(R.string.milestone);
actionBar.setDisplayHomeAsUpEnabled(true);
}
Expand All @@ -52,9 +61,7 @@ protected void onCreate(Bundle savedInstanceState) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = RepositoryViewActivity.createIntent(repository);
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
return true;
case R.id.add_ms_menu_item:
//creating new milestone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
package com.github.mobile.ui.repo;

import static com.github.mobile.Intents.EXTRA_MILESTONE;
import static com.github.mobile.Intents.EXTRA_REPOSITORY;
import static com.github.mobile.Intents.EXTRA_REPOSITORY_NAME;
import static com.github.mobile.Intents.EXTRA_REPOSITORY_OWNER;
import static com.github.mobile.Intents.EXTRA_USER;
import static com.github.mobile.RequestCodes.MILESTONE_VIEW;

import android.content.Context;
import android.os.Bundle;
Expand All @@ -35,13 +40,16 @@

import org.eclipse.egit.github.core.Milestone;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.RepositoryIssue;
import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.service.MilestoneService;

/**
* Fragment to display a list of milestones for a specific repository
*/
public class RepositoryMilestonesFragment extends ItemListFragment<Milestone> {
public static final String MILESTONES_STATE_ALL="all";
public static final String MILESTONES_STATE_ALL = "all";

/**
* Milestone service
Expand Down Expand Up @@ -84,10 +92,7 @@ protected SingleTypeAdapter<Milestone> createAdapter(List<Milestone> items) {

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
final Milestone milestone = (Milestone) l.getItemAtPosition(position);
Toast.makeText(getContext(),milestone.getTitle(),Toast.LENGTH_SHORT).show();
//todo add open milestone view page
startActivity(MilestoneViewActivity.createIntent(repo, position));
startActivityForResult(MilestoneViewActivity.createIntent(repo, (Milestone) l.getItemAtPosition(position), position), MILESTONE_VIEW);
}

@Override
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/layout/milestone_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/Toolbar" />

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

</LinearLayout>
52 changes: 52 additions & 0 deletions app/src/main/res/layout/repo_milestone_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_milestone_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Milestone name" />

<TextView
android:id="@+id/tv_milestone_due_to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="31.12.2017" />

<TextView
android:id="@+id/tv_milestone_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem ipsum ............................................................................" />

<ProgressBar
android:id="@+id/pB_milestone_completion_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="20" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_milestone_progress_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="50" />

<TextView
android:id="@+id/lbl_milestone_progress_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="% completed" />
</LinearLayout>

</LinearLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Mar 04 11:22:22 CET 2017
#Wed Dec 20 02:21:43 MSK 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 comments on commit 3e97b5c

Please sign in to comment.