Skip to content
Snippets Groups Projects
Commit 9109584d authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Fully implement label creation and addition to issues

parent 8184781e
No related branches found
No related tags found
No related merge requests found
Showing
with 390 additions and 74 deletions
Loading
Loading
@@ -23,7 +23,6 @@
 
# So that Fabric can still have line numbers
-keepattributes SourceFile,LineNumberTable
-keep class com.commit451.gitlab.ssl.CustomSSLSocketFactory
 
# Picasso rules
-dontwarn com.squareup.okhttp.**
Loading
Loading
@@ -125,4 +124,7 @@
-keep class org.parceler.Parceler$$Parcels
 
# Unicoding Bypass library
-keep class in.uncod.android.** { *; }
\ No newline at end of file
-keep class in.uncod.android.** { *; }
# Custom rules
-keep class com.commit451.gitlab.ssl.CustomSSLSocketFactory
\ No newline at end of file
Loading
Loading
@@ -66,6 +66,7 @@
android:theme="@style/Activity.Translucent"/>
<activity android:name=".activity.SettingsActivity"/>
<activity android:name=".activity.AddLabelActivity"/>
<activity android:name=".activity.AddNewLabelActivity"/>
 
<activity
android:name=".activity.RoutingActivity"
Loading
Loading
Loading
Loading
@@ -4,12 +4,14 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.Spinner;
Loading
Loading
@@ -87,10 +89,10 @@ public class AddIssueActivity extends MorphActivity {
TextView mLabelLabel;
@BindView(R.id.labels_progress)
View mLabelsProgress;
@BindView(R.id.root_add_labels)
ViewGroup mRootAddLabels;
@BindView(R.id.list_labels)
AdapterFlowLayout mListLabels;
@BindView(R.id.text_add_labels)
TextView mTextAddLabels;
 
private Project mProject;
private Issue mIssue;
Loading
Loading
@@ -98,7 +100,7 @@ public class AddIssueActivity extends MorphActivity {
private AddIssueLabelAdapter mLabelsAdapter;
private Teleprinter mTeleprinter;
 
@OnClick(R.id.text_add_labels)
@OnClick(R.id.root_add_labels)
void onAddLabelsClick() {
Navigator.navigateToAddLabels(AddIssueActivity.this, mProject, REQUEST_LABEL);
}
Loading
Loading
@@ -167,7 +169,7 @@ public class AddIssueActivity extends MorphActivity {
@Override
public void success(@NonNull List<Label> response) {
mLabelsProgress.setVisibility(View.GONE);
mListLabels.setVisibility(View.VISIBLE);
mRootAddLabels.setVisibility(View.VISIBLE);
setLabels(response);
}
 
Loading
Loading
@@ -292,8 +294,24 @@ public class AddIssueActivity extends MorphActivity {
if (!currentLabels.isEmpty()) {
mLabelsAdapter.setLabels(currentLabels);
}
} else {
mTextAddLabels.setVisibility(View.VISIBLE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_LABEL:
if (resultCode == RESULT_OK) {
Label label = Parcels.unwrap(data.getParcelableExtra(AddLabelActivity.KEY_LABEL));
if (mLabelsAdapter.containsLabel(label)) {
Snackbar.make(mRoot, R.string.label_already_added, Snackbar.LENGTH_SHORT)
.show();
} else {
mLabelsAdapter.addLabel(label);
}
}
break;
}
}
 
Loading
Loading
@@ -325,30 +343,35 @@ public class AddIssueActivity extends MorphActivity {
milestoneId = milestone.getId();
}
}
String labelsCommaSeperated = mLabelsAdapter.getCommaSeperatedStringOfLabels();
createOrSaveIssue(mTitleInput.getText().toString(),
mDescriptionInput.getText().toString(),
assigneeId,
milestoneId);
milestoneId,
labelsCommaSeperated);
} else {
mTitleInputLayout.setError(getString(R.string.required_field));
}
}
 
private void createOrSaveIssue(String title, String description, Long assigneeId, Long milestoneId) {
private void createOrSaveIssue(String title, String description, @Nullable Long assigneeId,
@Nullable Long milestoneId, @Nullable String labels) {
if (mIssue == null) {
App.instance().getGitLab().createIssue(
mProject.getId(),
title,
description,
assigneeId,
milestoneId).enqueue(mIssueCreatedCallback);
milestoneId,
labels).enqueue(mIssueCreatedCallback);
} else {
App.instance().getGitLab().updateIssue(mProject.getId(),
mIssue.getId(),
title,
description,
assigneeId,
milestoneId).enqueue(mIssueCreatedCallback);
milestoneId,
labels).enqueue(mIssueCreatedCallback);
}
}
 
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@ import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
Loading
Loading
@@ -17,8 +18,11 @@ import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.LabelAdapter;
import com.commit451.gitlab.model.api.Label;
import com.commit451.gitlab.navigation.Navigator;
import com.commit451.gitlab.viewHolder.LabelViewHolder;
 
import org.parceler.Parcels;
import java.util.List;
 
import butterknife.BindView;
Loading
Loading
@@ -31,6 +35,9 @@ import timber.log.Timber;
public class AddLabelActivity extends BaseActivity {
 
private static final String KEY_PROJECT_ID = "project_id";
private static final int REQUEST_NEW_LABEL = 1;
public static final String KEY_LABEL = "label";
 
public static Intent newIntent(Context context, long projectId) {
Intent intent = new Intent(context, AddLabelActivity.class);
Loading
Loading
@@ -60,6 +67,18 @@ public class AddLabelActivity extends BaseActivity {
 
mProjectId = getIntent().getLongExtra(KEY_PROJECT_ID, -1);
mToolbar.setTitle(R.string.labels);
mToolbar.inflateMenu(R.menu.menu_add_label);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_label:
Navigator.navigateToAddNewLabel(AddLabelActivity.this, mProjectId, REQUEST_NEW_LABEL);
return true;
}
return false;
}
});
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
Loading
Loading
@@ -69,12 +88,10 @@ public class AddLabelActivity extends BaseActivity {
mLabelAdapter = new LabelAdapter(new LabelAdapter.Listener() {
@Override
public void onLabelClicked(Label label, LabelViewHolder viewHolder) {
}
@Override
public void onAddLabelClicked() {
Intent data = new Intent();
data.putExtra(KEY_LABEL, Parcels.wrap(label));
setResult(RESULT_OK, data);
finish();
}
});
mList.setAdapter(mLabelAdapter);
Loading
Loading
@@ -119,4 +136,17 @@ public class AddLabelActivity extends BaseActivity {
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_NEW_LABEL:
if (resultCode == RESULT_OK) {
Label newLabel = Parcels.unwrap(data.getParcelableExtra(AddNewLabelActivity.KEY_NEW_LABEL));
mLabelAdapter.addLabel(newLabel);
}
break;
}
}
}
package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.afollestad.materialdialogs.color.ColorChooserDialog;
import com.commit451.easycallback.EasyCallback;
import com.commit451.easycallback.HttpException;
import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.api.Label;
import com.commit451.gitlab.util.ColorUtil;
import com.commit451.gitlab.util.Validator;
import org.parceler.Parcels;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;
/**
* Create a brand new label
*/
public class AddNewLabelActivity extends BaseActivity implements ColorChooserDialog.ColorCallback {
private static final String KEY_PROJECT_ID = "project_id";
public static final String KEY_NEW_LABEL = "new_label";
public static Intent newIntent(Context context, long projectId) {
Intent intent = new Intent(context, AddNewLabelActivity.class);
intent.putExtra(KEY_PROJECT_ID, projectId);
return intent;
}
@BindView(R.id.root)
ViewGroup mRoot;
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.title_text_input_layout)
TextInputLayout mTextInputLayoutTitle;
@BindView(R.id.description)
TextView mDescription;
@BindView(R.id.image_color)
ImageView mImageColor;
@BindView(R.id.progress)
View mProgress;
int mChosenColor = -1;
private final EasyCallback<Label> mCreateLabelCallback = new EasyCallback<Label>() {
@Override
public void success(@NonNull Label response) {
Intent data = new Intent();
data.putExtra(KEY_NEW_LABEL, Parcels.wrap(response));
setResult(RESULT_OK, data);
finish();
}
@Override
public void failure(Throwable t) {
Timber.e(t, null);
mProgress.setVisibility(View.GONE);
if (t instanceof HttpException && ((HttpException) t).getCode() == 409) {
Snackbar.make(mRoot, R.string.label_already_exists, Snackbar.LENGTH_SHORT)
.show();
} else {
Snackbar.make(mRoot, R.string.failed_to_create_label, Snackbar.LENGTH_SHORT)
.show();
}
}
};
@OnClick(R.id.root_color)
void onChooseColorClicked() {
// Pass AppCompatActivity which implements ColorCallback, along with the title of the dialog
new ColorChooserDialog.Builder(this, R.string.add_new_label_choose_color)
.preselect(mChosenColor)
.show();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_new_label);
ButterKnife.bind(this);
mToolbar.setNavigationIcon(R.drawable.ic_back_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
mToolbar.inflateMenu(R.menu.menu_add_new_label);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_create:
createLabel();
return true;
}
return false;
}
});
}
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
mChosenColor = selectedColor;
mImageColor.setImageDrawable(new ColorDrawable(selectedColor));
}
private long getProjectId() {
return getIntent().getLongExtra(KEY_PROJECT_ID, -1);
}
private void createLabel() {
if (Validator.validateFieldsNotEmpty(getString(R.string.required_field), mTextInputLayoutTitle)) {
if (mChosenColor == -1) {
Snackbar.make(mRoot, R.string.add_new_label_color_is_required, Snackbar.LENGTH_SHORT)
.show();
return;
}
String title = mTextInputLayoutTitle.getEditText().getText().toString();
String description = null;
if (!TextUtils.isEmpty(mDescription.getText())) {
description = mDescription.getText().toString();
}
String color = null;
if (mChosenColor != -1) {
color = ColorUtil.convertColorIntToString(mChosenColor);
Timber.d("Setting color to " + color);
}
mProgress.setVisibility(View.VISIBLE);
mProgress.setAlpha(0.0f);
mProgress.animate().alpha(1.0f);
App.instance().getGitLab().createLabel(getProjectId(), title, color, description)
.enqueue(mCreateLabelCallback);
}
}
}
Loading
Loading
@@ -22,10 +22,9 @@ import android.widget.Toast;
 
import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.SectionsPagerAdapter;
import com.commit451.gitlab.adapter.ProjectSectionsPagerAdapter;
import com.commit451.gitlab.animation.HideRunnable;
import com.commit451.easycallback.EasyCallback;
import com.commit451.gitlab.api.GitLabFactory;
import com.commit451.gitlab.event.ProjectReloadEvent;
import com.commit451.gitlab.fragment.BaseFragment;
import com.commit451.gitlab.model.api.Branch;
Loading
Loading
@@ -245,9 +244,9 @@ public class ProjectActivity extends BaseActivity {
}
 
private void setupTabs() {
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
ProjectSectionsPagerAdapter projectSectionsPagerAdapter = new ProjectSectionsPagerAdapter(this, getSupportFragmentManager());
 
mViewPager.setAdapter(sectionsPagerAdapter);
mViewPager.setAdapter(projectSectionsPagerAdapter);
mTabLayout.setupWithViewPager(mViewPager);
}
 
Loading
Loading
package com.commit451.gitlab.adapter;
 
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
 
Loading
Loading
@@ -32,6 +33,11 @@ public class AddIssueLabelAdapter extends RecyclerView.Adapter<AddLabelViewHolde
notifyDataSetChanged();
}
 
public void addLabel(Label label) {
mValues.add(label);
notifyItemInserted(mValues.size()-1);
}
@Override
public AddLabelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return AddLabelViewHolder.inflate(parent);
Loading
Loading
@@ -50,4 +56,22 @@ public class AddIssueLabelAdapter extends RecyclerView.Adapter<AddLabelViewHolde
private Label getEntry(int position) {
return mValues.get(position);
}
public boolean containsLabel(Label label) {
return mValues.contains(label);
}
@Nullable
public String getCommaSeperatedStringOfLabels() {
if (mValues.isEmpty()) {
return null;
}
String labels = "";
for (Label label : mValues) {
labels = labels + label.getName() + ",";
}
//Remove last ","
labels = labels.substring(0, labels.length()-1);
return labels;
}
}
Loading
Loading
@@ -13,15 +13,11 @@ import java.util.ArrayList;
import java.util.Collection;
 
/**
* Shows a projects members and a groups members
* Shows a bunch of labels
*/
public class LabelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
 
private static final int TYPE_ITEM = 0;
private static final int TYPE_FOOTER = 1;
//TODO bring this back maybe?
private static final int FOOTER_COUNT = 0;
 
private Listener mListener;
 
Loading
Loading
@@ -36,13 +32,6 @@ public class LabelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
};
 
private final View.OnClickListener mFooterClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onAddLabelClicked();
}
};
public LabelAdapter(Listener listener) {
mListener = listener;
mItems = new ArrayList<>();
Loading
Loading
@@ -61,8 +50,8 @@ public class LabelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
 
public void addLabel(Label label) {
mItems.add(label);
notifyItemInserted(mItems.size());
mItems.add(0, label);
notifyItemInserted(0);
}
 
@Override
Loading
Loading
@@ -72,10 +61,6 @@ public class LabelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
LabelViewHolder itemViewHolder = LabelViewHolder.inflate(parent);
itemViewHolder.itemView.setOnClickListener(mProjectMemberClickListener);
return itemViewHolder;
case TYPE_FOOTER:
ProjectMemberFooterViewHolder footerHolder = ProjectMemberFooterViewHolder.inflate(parent);
footerHolder.itemView.setOnClickListener(mFooterClickListener);
return footerHolder;
}
throw new IllegalStateException("No idea what to inflate with view type of " + viewType);
}
Loading
Loading
@@ -94,20 +79,15 @@ public class LabelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
 
@Override
public int getItemCount() {
return mItems.size() + FOOTER_COUNT;
return mItems.size();
}
 
@Override
public int getItemViewType(int position) {
if (position == mItems.size()) {
return TYPE_FOOTER;
} else {
return TYPE_ITEM;
}
return TYPE_ITEM;
}
 
public interface Listener {
void onLabelClicked(Label label, LabelViewHolder viewHolder);
void onAddLabelClicked();
}
}
Loading
Loading
@@ -26,7 +26,7 @@ import timber.log.Timber;
/**
* Controls the sections that should be shown in a {@link com.commit451.gitlab.activity.ProjectActivity}
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public class ProjectSectionsPagerAdapter extends FragmentPagerAdapter {
 
private static final int PROJECT_POS = 0;
private static final int ACTIVITY_POS = 1;
Loading
Loading
@@ -43,7 +43,7 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
private final String[] mTitles;
private final Set<Integer> mDisabledSections = new HashSet<>();
 
public SectionsPagerAdapter(ProjectActivity context, FragmentManager fm) {
public ProjectSectionsPagerAdapter(ProjectActivity context, FragmentManager fm) {
super(fm);
 
mProject = context.getProject();
Loading
Loading
@@ -66,7 +66,7 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
Timber.d("Milestones are disabled");
mDisabledSections.add(MILESTONES_POS);
}
//TODO change this back when we do snippets
//TODO enable snippets when they are done
if (true){//!project.isSnippetsEnabled()) {
Timber.d("Snippets are disabled");
mDisabledSections.add(SNIPPETS_POS);
Loading
Loading
Loading
Loading
@@ -284,7 +284,8 @@ public interface GitLab {
@Field("title") String title,
@Field("description") String description,
@Field("assignee_id") @Nullable Long assigneeId,
@Field("milestone_id") @Nullable Long milestoneId);
@Field("milestone_id") @Nullable Long milestoneId,
@Field("labels") @Nullable String commaSeparatedLabelNames);
 
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> updateIssue(@Path("id") long projectId,
Loading
Loading
@@ -292,7 +293,8 @@ public interface GitLab {
@Query("title") String title,
@Query("description") String description,
@Query("assignee_id") @Nullable Long assigneeId,
@Query("milestone_id") @Nullable Long milestoneId);
@Query("milestone_id") @Nullable Long milestoneId,
@Query("labels") @Nullable String commaSeparatedLabelNames);
 
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> updateIssueStatus(@Path("id") long projectId,
Loading
Loading
@@ -363,7 +365,8 @@ public interface GitLab {
@POST(API_VERSION + "/projects/{id}/labels")
Call<Label> createLabel(@Path("id") long projectId,
@Query("name") String name,
@Query("color") String color);
@Query("color") String color,
@Query("description") @Nullable String description);
 
/**
* Delete the label by its name
Loading
Loading
Loading
Loading
@@ -13,13 +13,12 @@ import android.widget.TextView;
import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.easycallback.EasyCallback;
import com.commit451.gitlab.api.GitLabFactory;
import com.commit451.gitlab.event.BuildChangedEvent;
import com.commit451.gitlab.model.api.Build;
import com.commit451.gitlab.model.api.Project;
import com.commit451.gitlab.model.api.RepositoryCommit;
import com.commit451.gitlab.model.api.Runner;
import com.commit451.gitlab.util.DateUtils;
import com.commit451.gitlab.util.DateUtil;
import com.squareup.otto.Subscribe;
 
import org.parceler.Parcels;
Loading
Loading
@@ -127,13 +126,13 @@ public class BuildDescriptionFragment extends ButterKnifeFragment {
if (finishedTime == null) {
finishedTime = new Date();
}
String timeTaken = DateUtils.getTimeTaken(build.getStartedAt(), finishedTime);
String timeTaken = DateUtil.getTimeTaken(build.getStartedAt(), finishedTime);
String duration = String.format(getString(R.string.build_duration), timeTaken);
mTextDuration.setText(duration);
String created = String.format(getString(R.string.build_created), DateUtils.getRelativeTimeSpanString(getActivity(), build.getCreatedAt()));
String created = String.format(getString(R.string.build_created), DateUtil.getRelativeTimeSpanString(getActivity(), build.getCreatedAt()));
mTextCreated.setText(created);
if (build.getFinishedAt() != null) {
String finished = String.format(getString(R.string.build_finished), DateUtils.getRelativeTimeSpanString(getActivity(), build.getFinishedAt()));
String finished = String.format(getString(R.string.build_finished), DateUtil.getRelativeTimeSpanString(getActivity(), build.getFinishedAt()));
mTextFinished.setText(finished);
mTextFinished.setVisibility(View.VISIBLE);
} else {
Loading
Loading
Loading
Loading
@@ -19,16 +19,21 @@ public class Label {
String mColor;
@JsonField(name = "name")
String mName;
@JsonField(name = "description")
String mDescription;
@JsonField(name = "open_issues_count")
int mOpenIssuesCount;
@JsonField(name = "closed_issues_count")
int mClosedIssuesCount;
@JsonField(name = "open_merge_requests_count")
int mOpenMergeRequestsCount;
@JsonField(name = "subscribed")
boolean mSubscribed;
 
protected Label() {
//for json parsing
}
 
public Label(String name, String color) {
mName = name;
mColor = color;
}
public String getName() {
return mName;
}
Loading
Loading
@@ -41,4 +46,45 @@ public class Label {
return Color.TRANSPARENT;
}
}
public String getDescription() {
return mDescription;
}
public int getOpenIssuesCount() {
return mOpenIssuesCount;
}
public int getClosedIssuesCount() {
return mClosedIssuesCount;
}
public int getOpenMergeRequestsCount() {
return mOpenMergeRequestsCount;
}
public boolean isSubscribed() {
return mSubscribed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Label label = (Label) o;
if (mColor != null ? !mColor.equals(label.mColor) : label.mColor != null) return false;
if (mName != null ? !mName.equals(label.mName) : label.mName != null) return false;
return mDescription != null ? mDescription.equals(label.mDescription) : label.mDescription == null;
}
@Override
public int hashCode() {
int result = mColor != null ? mColor.hashCode() : 0;
result = 31 * result + (mName != null ? mName.hashCode() : 0);
result = 31 * result + (mDescription != null ? mDescription.hashCode() : 0);
return result;
}
}
Loading
Loading
@@ -15,6 +15,7 @@ import com.commit451.gitlab.activity.ActivityActivity;
import com.commit451.gitlab.activity.AddIssueActivity;
import com.commit451.gitlab.activity.AddLabelActivity;
import com.commit451.gitlab.activity.AddMilestoneActivity;
import com.commit451.gitlab.activity.AddNewLabelActivity;
import com.commit451.gitlab.activity.AddUserActivity;
import com.commit451.gitlab.activity.BuildActivity;
import com.commit451.gitlab.activity.DiffActivity;
Loading
Loading
@@ -185,6 +186,11 @@ public class Navigator {
activity.startActivityForResult(intent, requestCode);
}
 
public static void navigateToAddNewLabel(Activity activity, long projectId, int requestCode) {
Intent intent = AddNewLabelActivity.newIntent(activity, projectId);
activity.startActivityForResult(intent, requestCode);
}
public static void navigateToAddMilestone(Activity activity, View fab, Project project) {
Intent intent = AddMilestoneActivity.newIntent(activity, project.getId());
startMorphActivity(activity, fab, intent);
Loading
Loading
package com.commit451.gitlab.util;
import android.support.annotation.ColorInt;
/**
* Does cool things with colors
*/
public class ColorUtil {
public static String convertColorIntToString(@ColorInt int color) {
return String.format("#%06X", (0xFFFFFF & color));
}
}
package com.commit451.gitlab.util;
 
import android.content.Context;
import android.text.format.DateUtils;
 
import com.commit451.gitlab.R;
 
Loading
Loading
@@ -8,10 +9,10 @@ import java.util.Date;
import java.util.concurrent.TimeUnit;
 
/**
* Our own DateUtils, which call forwards to {@link android.text.format.DateUtils} with some
* Our own DateUtil, which call forwards to {@link android.text.format.DateUtils} with some
* nice defaults
*/
public class DateUtils {
public class DateUtil {
 
public static CharSequence getRelativeTimeSpanString(Context context, Date startTime) {
Date now = new Date();
Loading
Loading
@@ -19,7 +20,7 @@ public class DateUtils {
return context.getString(R.string.just_now);
}
 
return android.text.format.DateUtils.getRelativeTimeSpanString(startTime.getTime(),
return DateUtils.getRelativeTimeSpanString(startTime.getTime(),
now.getTime(),
android.text.format.DateUtils.SECOND_IN_MILLIS)
.toString();
Loading
Loading
package com.commit451.gitlab.util;
import android.support.design.widget.TextInputLayout;
import android.text.TextUtils;
/**
* Validates input
*/
public class Validator {
/**
* Make sure all the edittexts are not empty and fill in an error message if they are
*
* @param textInputLayouts all the input layouts you wish to validate
* @return true if all the fields were valid.
*/
public static boolean validateFieldsNotEmpty(String errorText, TextInputLayout... textInputLayouts) {
boolean valid = true;
for (TextInputLayout textInputLayout : textInputLayouts) {
if (textInputLayout.getEditText() != null && TextUtils.isEmpty(textInputLayout.getEditText().getText().toString().trim())) {
textInputLayout.setError(errorText);
valid = false;
} else {
//clear out a possible previous error
textInputLayout.setError(null);
}
}
return valid;
}
}
Loading
Loading
@@ -8,7 +8,7 @@ import android.widget.TextView;
 
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.api.Build;
import com.commit451.gitlab.util.DateUtils;
import com.commit451.gitlab.util.DateUtil;
 
import java.util.Date;
 
Loading
Loading
@@ -47,7 +47,7 @@ public class BuildViewHolder extends RecyclerView.ViewHolder {
if (startedAt == null) {
startedAt = new Date();
}
String timeTaken = DateUtils.getTimeTaken(startedAt, finishedTime);
String timeTaken = DateUtil.getTimeTaken(startedAt, finishedTime);
String durationStr = String.format(itemView.getResources().getString(R.string.build_duration), timeTaken);
duration.setText(durationStr);
}
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.api.RepositoryCommit;
import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.DateUtils;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
 
import butterknife.BindView;
Loading
Loading
@@ -47,7 +47,7 @@ public class CommitViewHolder extends RecyclerView.ViewHolder {
mMessageView.setText(commit.getTitle());
mAuthorView.setText(commit.getAuthorName());
if (commit.getCreatedAt() != null) {
mTimeView.setText(DateUtils.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
mTimeView.setText(DateUtil.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
} else {
mTimeView.setText(R.string.unknown);
}
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.api.RepositoryCommit;
import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.DateUtils;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
 
import butterknife.BindView;
Loading
Loading
@@ -46,7 +46,7 @@ public class DiffHeaderViewHolder extends RecyclerView.ViewHolder {
.into(mImageView);
 
mAuthorView.setText(commit.getAuthorName());
mTimeView.setText(DateUtils.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
mTimeView.setText(DateUtil.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
mTitleView.setText(commit.getTitle());
String message = extractMessage(commit.getTitle(), commit.getMessage());
mMessageView.setText(message);
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.api.Issue;
import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.DateUtils;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
 
import butterknife.BindView;
Loading
Loading
@@ -65,7 +65,7 @@ public class IssueHeaderViewHolder extends RecyclerView.ViewHolder {
}
author += itemView.getResources().getString(R.string.created_issue);
if (issue.getCreatedAt() != null) {
author = author + " " + DateUtils.getRelativeTimeSpanString(itemView.getContext(), issue.getCreatedAt());
author = author + " " + DateUtil.getRelativeTimeSpanString(itemView.getContext(), issue.getCreatedAt());
}
mAuthorView.setText(author);
if (issue.getMilestone() != null) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment