Skip to content

Commit

Permalink
Milestone state check + some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Motoaleks committed Jan 6, 2018
1 parent d1137ac commit f19b59f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

/**
* Fragment to display a milestone.
*
*/
public class MilestoneFragment extends DialogFragment {
private Milestone milestone;
Expand Down Expand Up @@ -113,16 +112,17 @@ private void updateMilestone(final Milestone milestone){

Date dueOn = milestone.getDueOn();
Date current = Calendar.getInstance().getTime();

String state = milestone.getState();
boolean open = state.equals("open");
long diff = dueOn.getTime() - current.getTime();
long days = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
GradientDrawable back = (GradientDrawable) milestoneTime.getBackground();
if (-100 <= days && days < 0){
milestoneTime.setText("past due by " + (-days) + " days");
if (-100 <= days && days < 0 && open){
milestoneTime.setText(getString(R.string.ms_time_past) + " " +(-days) + " " + getString(R.string.ms_days));
back.setColor(getResources().getColor(R.color.badge_red));
}
else if (0 <= days && days <= 100){
milestoneTime.setText(days + " days");
else if (0 <= days && days <= 100 && open){
milestoneTime.setText(days + " " + getString(R.string.ms_days));
back.setColor(getResources().getColor(R.color.badge_default));
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
package com.github.mobile.ui.milestone;

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;
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_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;


/**
* Created by Александр on 20.12.2017.
* Activity to display milestone detailed view
*/

public class MilestoneViewActivity extends DialogFragmentActivity {
/**
* Create intent for this activity
Expand Down
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 @@ -358,5 +358,7 @@
<string name="ms_percent_completed">% completed</string>
<string name="issues_display_closed">Display closed</string>
<string name="issues_display_opened">Display opened</string>
<string name="ms_time_past">past due by</string>
<string name="ms_days">days</string>

</resources>

0 comments on commit f19b59f

Please sign in to comment.