-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from AndreySBer/milestones_list_view
Milestones list view
- Loading branch information
Showing
15 changed files
with
784 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
228 changes: 228 additions & 0 deletions
228
app/src/main/java/com/github/mobile/ui/milestone/EditMilestoneActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
package com.github.mobile.ui.milestone; | ||
|
||
|
||
import android.content.Intent; | ||
import android.support.v7.app.ActionBar; | ||
import android.os.Bundle; | ||
import android.text.Editable; | ||
import android.text.TextUtils; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.ScrollView; | ||
import android.widget.TextView; | ||
|
||
import com.github.mobile.Intents; | ||
import com.github.mobile.R; | ||
import org.eclipse.egit.github.core.Milestone; | ||
import com.github.mobile.ui.DialogFragmentActivity; | ||
import com.github.mobile.ui.TextWatcherAdapter; | ||
import com.github.mobile.ui.issue.AssigneeDialog; | ||
import com.github.mobile.ui.issue.LabelsDialog; | ||
import com.github.mobile.ui.issue.MilestoneDialog; | ||
import com.github.mobile.util.AvatarLoader; | ||
import com.google.inject.Inject; | ||
|
||
import org.eclipse.egit.github.core.Issue; | ||
import org.eclipse.egit.github.core.RepositoryId; | ||
import org.eclipse.egit.github.core.service.CollaboratorService; | ||
import org.eclipse.egit.github.core.service.LabelService; | ||
import org.eclipse.egit.github.core.service.MilestoneService; | ||
|
||
import static com.github.mobile.Intents.EXTRA_ISSUE; | ||
import static com.github.mobile.Intents.EXTRA_MILESTONE; | ||
import static com.github.mobile.RequestCodes.ISSUE_ASSIGNEE_UPDATE; | ||
import static com.github.mobile.RequestCodes.ISSUE_LABELS_UPDATE; | ||
import static com.github.mobile.RequestCodes.ISSUE_MILESTONE_UPDATE; | ||
|
||
/* | ||
* Activity to edit or create a milestone | ||
*/ | ||
public class EditMilestoneActivity extends DialogFragmentActivity { | ||
|
||
/** | ||
* Create intent to create a milestone | ||
* | ||
* @param issue | ||
* @return intent | ||
*/ | ||
public static Intent createIntent(Issue issue) { | ||
return createIntent(null, issue); | ||
} | ||
|
||
|
||
/** | ||
* Create intent to edit a milestone | ||
* | ||
* @param milestone | ||
* @param issue | ||
* @return intent | ||
*/ | ||
public static Intent createIntent(final Milestone milestone, | ||
final Issue issue) { | ||
Intents.Builder builder = new Intents.Builder("repo.milestones.edit.VIEW"); | ||
if (issue != null) | ||
builder.add(EXTRA_ISSUE, issue); | ||
if (milestone != null) | ||
builder.milestone(milestone); | ||
return builder.toIntent(); | ||
} | ||
|
||
private EditText titleText; | ||
|
||
private EditText descriptionText; | ||
|
||
private TextView dateText; | ||
|
||
private Button twoWeeksButton; | ||
|
||
private Button monthButton; | ||
|
||
private TextView clearText; | ||
|
||
private ScrollView milestoneContent; | ||
|
||
@Inject | ||
private AvatarLoader avatars; | ||
|
||
@Inject | ||
private MilestoneService milestoneService; | ||
|
||
@Inject | ||
private CollaboratorService collaboratorService; | ||
|
||
@Inject | ||
private LabelService labelService; | ||
|
||
private Milestone milestone; | ||
|
||
private RepositoryId repository; | ||
|
||
private MenuItem saveItem; | ||
|
||
private MilestoneDialog milestoneDialog; | ||
|
||
private AssigneeDialog assigneeDialog; | ||
|
||
private LabelsDialog labelsDialog; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.milestone_edit); | ||
|
||
titleText = finder.find(R.id.et_milestone_title); | ||
descriptionText = finder.find(R.id.et_milestone_description); | ||
dateText = finder.find(R.id.tv_milestone_date); | ||
twoWeeksButton = finder.find(R.id.b_two_weeks); | ||
monthButton = finder.find(R.id.b_month); | ||
clearText = finder.find(R.id.tv_clear); | ||
|
||
//todo checkCollaboratorStatus();? | ||
|
||
Intent intent = getIntent(); | ||
|
||
if (savedInstanceState != null) | ||
milestone = (Milestone) savedInstanceState.getSerializable(EXTRA_MILESTONE); | ||
if (milestone == null) | ||
milestone = (Milestone) intent.getSerializableExtra(EXTRA_MILESTONE); | ||
if (milestone == null) | ||
milestone = new Milestone(); | ||
|
||
//todo RepositoryId.create? | ||
|
||
ActionBar actionBar = getSupportActionBar(); | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
|
||
//todo staff with actionbar | ||
|
||
titleText.addTextChangedListener(new TextWatcherAdapter() { | ||
|
||
@Override | ||
public void afterTextChanged(Editable s) { | ||
updateSaveMenu(s); | ||
} | ||
}); | ||
|
||
updateSaveMenu(); | ||
titleText.setText(milestone.getTitle()); | ||
descriptionText.setText(milestone.getDescription()); | ||
} | ||
|
||
@Override | ||
public void onDialogResult(int requestCode, int resultCode, Bundle arguments) { | ||
if (RESULT_OK != resultCode) | ||
return; | ||
switch (requestCode) { | ||
case ISSUE_MILESTONE_UPDATE: | ||
//todo | ||
/*issue.setMilestone(MilestoneDialogFragment.getSelected(arguments)); | ||
updateMilestone(); | ||
break;*/ | ||
case ISSUE_ASSIGNEE_UPDATE: | ||
//todo | ||
case ISSUE_LABELS_UPDATE: | ||
//todo | ||
} | ||
} | ||
|
||
private void showMainContent() { | ||
finder.find(R.id.sv_milestone_content).setVisibility(View.VISIBLE); | ||
finder.find(R.id.pb_loading).setVisibility(View.GONE); | ||
} | ||
|
||
private void showCollaboratorOptions() { | ||
//todo | ||
} | ||
|
||
private void updateMilestone() { | ||
//todo | ||
} | ||
|
||
private void updateAssignee() { | ||
//todo | ||
} | ||
|
||
private void updateLabels() { | ||
//todo | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
outState.putSerializable(EXTRA_MILESTONE, milestone); | ||
} | ||
|
||
private void updateSaveMenu() { | ||
if (titleText != null) | ||
updateSaveMenu(titleText.getText()); | ||
} | ||
|
||
private void updateSaveMenu(final CharSequence text) { | ||
if (saveItem != null) | ||
saveItem.setEnabled(!TextUtils.isEmpty(text)); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu options) { | ||
getMenuInflater().inflate(R.menu.milestone_edit, options); | ||
saveItem = options.findItem(R.id.m_apply); | ||
updateSaveMenu(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
//todo | ||
default: | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} | ||
|
||
private void checkCollaboratorStatus() { | ||
//todo | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/github/mobile/ui/repo/MilestoneListAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2013 GitHub Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.mobile.ui.repo; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
|
||
import com.github.kevinsawicki.wishlist.SingleTypeAdapter; | ||
import com.github.mobile.R; | ||
import com.github.mobile.util.AvatarLoader; | ||
|
||
import org.eclipse.egit.github.core.Milestone; | ||
|
||
import java.text.SimpleDateFormat; | ||
/** | ||
* List adapter for a list of milestones | ||
*/ | ||
public class MilestoneListAdapter extends SingleTypeAdapter<Milestone> { | ||
|
||
private final Context context; | ||
/** | ||
* Create milestone list adapter | ||
* | ||
* @param context | ||
* @param elements | ||
* @param avatars | ||
*/ | ||
public MilestoneListAdapter(final Context context, | ||
final Milestone[] elements, final AvatarLoader avatars) { | ||
super(LayoutInflater.from(context), R.layout.milestone_item); | ||
this.context = context.getApplicationContext(); | ||
setItems(elements); | ||
} | ||
|
||
@Override | ||
protected int[] getChildViewIds() { | ||
return new int[]{R.id.tv_milestone_title, | ||
R.id.tv_milestone_due_to, | ||
R.id.tv_milestone_opened_iss_number, | ||
R.id.tv_milestone_closed_iss_number}; | ||
} | ||
|
||
@Override | ||
protected void update(int position, Milestone milestone) { | ||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy"); | ||
|
||
setText(0, milestone.getTitle()); | ||
setText(1, context.getString(R.string.ms_due_by) + sdf.format(milestone.getDueOn())); | ||
setText(2, context.getString(R.string.ms_opened_issues) + String.valueOf(milestone.getOpenIssues())); | ||
setText(3, context.getString(R.string.ms_closed_issues) + String.valueOf(milestone.getClosedIssues())); | ||
} | ||
} |
Oops, something went wrong.