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

Update to latest support libraries, improve the dialog themes, fix issue with...

Update to latest support libraries, improve the dialog themes, fix issue with double share intent, and do a whole lot of improvements with Issues.
parent 40641f6c
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 458 additions and 254 deletions
Loading
Loading
@@ -10,8 +10,8 @@ android {
applicationId "com.commit451.gitlab"
minSdkVersion 16
targetSdkVersion 23
versionCode 211
versionName "2.1.1"
versionCode 212
versionName "2.1.2"
}
buildTypes {
release {
Loading
Loading
@@ -34,11 +34,11 @@ android {
 
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:palette-v7:23.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'net.danlew:android.joda:2.8.2'
compile 'com.squareup.picasso:picasso:2.5.2'
Loading
Loading
Loading
Loading
@@ -15,14 +15,17 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
 
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.NotesAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.dialogs.NewIssueDialog;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.model.Note;
import com.commit451.gitlab.model.Project;
import com.commit451.gitlab.model.User;
import com.commit451.gitlab.tools.IntentUtil;
import com.squareup.otto.Subscribe;
 
import org.parceler.Parcels;
 
Loading
Loading
@@ -36,6 +39,9 @@ import retrofit.Response;
import retrofit.Retrofit;
import timber.log.Timber;
 
/**
* Shows off an issue like a bar of gold
*/
public class IssueActivity extends BaseActivity {
 
private static final String EXTRA_PROJECT = "extra_project";
Loading
Loading
@@ -48,16 +54,31 @@ public class IssueActivity extends BaseActivity {
return intent;
}
 
@Bind(R.id.toolbar) Toolbar toolbar;
@Bind(R.id.swipe_layout) SwipeRefreshLayout swipeRefreshLayout;
@Bind(R.id.list) RecyclerView listView;
@Bind(R.id.new_note_edit) EditText newNoteEdit;
@Bind(R.id.progress) View progress;
@Bind(R.id.toolbar) Toolbar mToolbar;
@Bind(R.id.issue_title) TextView mIssueTitle;
@Bind(R.id.swipe_layout) SwipeRefreshLayout mSwipeRefreshLayout;
@Bind(R.id.list) RecyclerView mListView;
@Bind(R.id.new_note_edit) EditText mNewNoteEdit;
@Bind(R.id.progress) View mProgress;
 
private NotesAdapter notesAdapter;
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
@OnClick(R.id.fab_edit_issue)
public void onEditIssueClick() {
new NewIssueDialog(this, mProject, mIssue).show();
}
MenuItem mOpenCloseMenuItem;
NotesAdapter mNotesAdapter;
Project mProject;
Issue mIssue;
 
EventReceiver mEventReceiver;
private final Toolbar.OnMenuItemClickListener mOnMenuItemClickListener = new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Loading
Loading
@@ -65,41 +86,106 @@ public class IssueActivity extends BaseActivity {
case R.id.action_share:
IntentUtil.share(getWindow().getDecorView(), mIssue.getUrl(mProject));
return true;
case R.id.action_close:
closeIssue();
return true;
}
return false;
}
};
private Callback<List<Note>> notesCallback = new Callback<List<Note>>() {
@Override
public void onResponse(Response<List<Note>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
mNotesAdapter.addNotes(response.body());
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mSwipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private final Callback<Issue> mOpenCloseCallback = new Callback<Issue>() {
@Override
public void onResponse(Response<Issue> response, Retrofit retrofit) {
mProgress.setVisibility(View.GONE);
if (!response.isSuccess()) {
Snackbar.make(getWindow().getDecorView(), getString(R.string.error_changing_issue), Snackbar.LENGTH_SHORT)
.show();
return;
}
mIssue = response.body();
GitLabApp.bus().post(new IssueChangedEvent(mIssue));
setOpenCloseMenuStatus();
loadNotes();
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mProgress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.error_changing_issue), Snackbar.LENGTH_SHORT)
.show();
}
};
private Callback<Note> noteCallback = new Callback<Note>() {
@Override
public void onResponse(Response<Note> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
mProgress.setVisibility(View.GONE);
mNotesAdapter.addNote(response.body());
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mProgress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issue);
ButterKnife.bind(this);
mEventReceiver = new EventReceiver();
GitLabApp.bus().register(mEventReceiver);
 
mProject = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_PROJECT));
mIssue = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_SELECTED_ISSUE));
 
long tempId = mIssue.getIid();
if(tempId < 1) {
tempId = mIssue.getId();
}
mToolbar.setNavigationIcon(R.drawable.ic_back_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mToolbar.setSubtitle(mProject.getNameWithNamespace());
mToolbar.inflateMenu(R.menu.issue);
mOpenCloseMenuItem = mToolbar.getMenu().findItem(R.id.action_close);
mToolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
mNotesAdapter = new NotesAdapter(mIssue);
mListView.setLayoutManager(new LinearLayoutManager(this));
mListView.setAdapter(mNotesAdapter);
 
toolbar.setNavigationIcon(R.drawable.ic_back_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
toolbar.setTitle("Issue #" + tempId);
toolbar.inflateMenu(R.menu.issue);
toolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
notesAdapter = new NotesAdapter(mIssue);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.setAdapter(notesAdapter);
newNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
mNewNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
postNote();
Loading
Loading
@@ -107,100 +193,83 @@ public class IssueActivity extends BaseActivity {
}
});
 
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
load();
loadNotes();
}
});
load();
bindIssue();
loadNotes();
}
@Override
protected void onDestroy() {
super.onDestroy();
GitLabApp.bus().unregister(mEventReceiver);
}
 
private void load() {
swipeRefreshLayout.setRefreshing(true);
private void bindIssue() {
mToolbar.setTitle(getString(R.string.issue_number) + mIssue.getId());
setOpenCloseMenuStatus();
mIssueTitle.setText(mIssue.getTitle());
mNotesAdapter.updateIssue(mIssue);
}
private void loadNotes() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
mSwipeRefreshLayout.setRefreshing(true);
GitLabClient.instance().getIssueNotes(mProject.getId(), mIssue.getId()).enqueue(notesCallback);
}
 
private void postNote() {
String body = newNoteEdit.getText().toString();
String body = mNewNoteEdit.getText().toString();
 
if(body.length() < 1) {
return;
}
 
progress.setVisibility(View.VISIBLE);
progress.setAlpha(0.0f);
progress.animate().alpha(1.0f);
mProgress.setVisibility(View.VISIBLE);
mProgress.setAlpha(0.0f);
mProgress.animate().alpha(1.0f);
// Clear text & collapse keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(newNoteEdit.getWindowToken(), 0);
newNoteEdit.setText("");
imm.hideSoftInputFromWindow(mNewNoteEdit.getWindowToken(), 0);
mNewNoteEdit.setText("");
 
GitLabClient.instance().postIssueNote(mProject.getId(), mIssue.getId(), body).enqueue(noteCallback);
}
private Callback<List<Note>> notesCallback = new Callback<List<Note>>() {
@Override
public void onResponse(Response<List<Note>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
swipeRefreshLayout.setRefreshing(false);
notesAdapter.addNotes(response.body());
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
swipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
private Callback<Note> noteCallback = new Callback<Note>() {
@Override
public void onResponse(Response<Note> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
progress.setVisibility(View.GONE);
notesAdapter.addNote(response.body());
}
private void closeIssue() {
mProgress.setVisibility(View.VISIBLE);
if (mIssue.getState().equals(Issue.STATE_CLOSED)) {
GitLabClient.instance().setIssueStatus(mProject.getId(), mIssue.getId(), Issue.STATE_REOPEN)
.enqueue(mOpenCloseCallback);
} else {
GitLabClient.instance().setIssueStatus(mProject.getId(), mIssue.getId(), Issue.STATE_CLOSE)
.enqueue(mOpenCloseCallback);
}
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
progress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private Callback<List<User>> usersCallback = new Callback<List<User>>() {
@Override
public void onResponse(Response<List<User>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
swipeRefreshLayout.setRefreshing(false);
notesAdapter.addUsers(response.body());
}
private void setOpenCloseMenuStatus() {
mOpenCloseMenuItem.setTitle(mIssue.getState().equals(Issue.STATE_CLOSED) ? R.string.reopen : R.string.close);
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
swipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private class EventReceiver {
@Subscribe
public void onIssueChanged(IssueChangedEvent event) {
if (mIssue.getId() == event.issue.getId()) {
mIssue = event.issue;
bindIssue();
}
}
}
}
Loading
Loading
@@ -70,4 +70,19 @@ public class IssuesAdapter extends RecyclerView.Adapter<IssueViewHolder> {
mValues.add(0, issue);
notifyItemInserted(0);
}
public void updateIssue(Issue issue) {
int indexToDelete = -1;
for (int i=0; i<mValues.size(); i++) {
if (mValues.get(i).getId() == issue.getId()) {
indexToDelete = i;
break;
}
}
if (indexToDelete != -1) {
mValues.remove(indexToDelete);
mValues.add(indexToDelete, issue);
}
notifyItemChanged(indexToDelete);
}
}
Loading
Loading
@@ -88,7 +88,6 @@ public class NotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
 
public void addNote(Note note) {
//TODO declare position that changed
mNotes.add(0, note);
notifyItemInserted(0);
}
Loading
Loading
@@ -108,4 +107,9 @@ public class NotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
notifyDataSetChanged();
}
public void updateIssue(Issue issue) {
mIssue = issue;
notifyItemChanged(0);
}
}
Loading
Loading
@@ -101,18 +101,6 @@ public interface GitLab {
@Field("title") String title,
@Field("description") String description);
 
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> editIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") String stateEvent,
@Query("assignee_id") long assigneeId,
@Query("milestone_id") long milestoneId);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> editIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") String stateEvent);
@GET(API_VERSION + "/projects/{id}/issues/{issue_id}/notes?per_page=100")
Call<List<Note>> getIssueNotes(@Path("id") long projectId,
@Path("issue_id") long issueId);
Loading
Loading
@@ -122,6 +110,17 @@ public interface GitLab {
Call<Note> postIssueNote(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Field("body") String body);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> setIssueStatus(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") @Issue.EditState String status);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> updateIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("title") String title,
@Query("description") String description);
/* --- FILES --- */
 
Loading
Loading
Loading
Loading
@@ -11,6 +11,7 @@ import android.widget.Toast;
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.events.IssueCreatedEvent;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.model.Project;
Loading
Loading
@@ -29,13 +30,14 @@ import timber.log.Timber;
*/
public class NewIssueDialog extends AppCompatDialog {
 
@Bind(R.id.titleInputLayout) TextInputLayout titleInputLayout;
@Bind(R.id.title_input) EditText titleInput;
@Bind(R.id.descriptionInputLayout) TextInputLayout descriptionInputLayout;
@Bind(R.id.description_input) EditText descriptionInput;
@Bind(R.id.progress) View progress;
@Bind(R.id.titleInputLayout) TextInputLayout mTitleInputLayout;
@Bind(R.id.title_input) EditText mTitleInput;
@Bind(R.id.descriptionInputLayout) TextInputLayout mDescriptionInputLayout;
@Bind(R.id.description_input) EditText mDescriptionInput;
@Bind(R.id.progress) View mProgress;
 
private Project mProject;
private Issue mIssue;
 
public NewIssueDialog(Context context, Project project) {
super(context);
Loading
Loading
@@ -44,16 +46,32 @@ public class NewIssueDialog extends AppCompatDialog {
mProject = project;
}
 
public NewIssueDialog(Context context, Project project, Issue issue) {
super(context);
setContentView(R.layout.dialog_add_issue);
ButterKnife.bind(this);
mProject = project;
mIssue = issue;
bindIssue();
}
@OnClick(R.id.save_button)
public void onSaveClick() {
if(!TextUtils.isEmpty(titleInput.getText())) {
progress.setVisibility(View.VISIBLE);
progress.setAlpha(0.0f);
progress.animate().alpha(1.0f);
GitLabClient.instance().postIssue(mProject.getId(), titleInput.getText().toString().trim(), descriptionInput.getText().toString().trim()).enqueue(issueCallback);
if(!TextUtils.isEmpty(mTitleInput.getText())) {
mTitleInputLayout.setError(null);
mProgress.setVisibility(View.VISIBLE);
mProgress.setAlpha(0.0f);
mProgress.animate().alpha(1.0f);
if (mIssue == null) {
GitLabClient.instance().postIssue(mProject.getId(), mTitleInput.getText().toString().trim(), mDescriptionInput.getText().toString().trim())
.enqueue(mIssueCallback);
} else {
GitLabClient.instance().updateIssue(mProject.getId(), mIssue.getId(), mTitleInput.getText().toString(), mDescriptionInput.getText().toString())
.enqueue(mIssueCallback);
}
}
else {
titleInputLayout.setError(getContext().getString(R.string.required_field));
mTitleInputLayout.setError(getContext().getString(R.string.required_field));
}
}
 
Loading
Loading
@@ -62,26 +80,36 @@ public class NewIssueDialog extends AppCompatDialog {
this.dismiss();
}
 
private Callback<Issue> issueCallback = new Callback<Issue>() {
private Callback<Issue> mIssueCallback = new Callback<Issue>() {
 
@Override
public void onResponse(Response<Issue> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
//TODO update the parent list when a new issue is created
GitLabApp.bus().post(new IssueCreatedEvent(response.body()));
//TODO fix this
// getContext().startActivity(IssueActivity.newInstance(getContext(), response.body()));
if (mIssue == null) {
GitLabApp.bus().post(new IssueCreatedEvent(response.body()));
} else {
GitLabApp.bus().post(new IssueChangedEvent(response.body()));
}
dismiss();
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
progress.setVisibility(View.GONE);
mProgress.setVisibility(View.GONE);
Toast.makeText(getContext(), getContext().getString(R.string.connection_error), Toast.LENGTH_SHORT)
.show();
}
};
private void bindIssue() {
if (!TextUtils.isEmpty(mIssue.getTitle())) {
mTitleInput.setText(mIssue.getTitle());
}
if (!TextUtils.isEmpty(mIssue.getDescription())) {
mDescriptionInput.setText(mIssue.getDescription());
}
}
}
package com.commit451.gitlab.events;
import com.commit451.gitlab.model.Issue;
/**
* Event indicating that an issue has changed
* Created by Jawnnypoo on 10/19/2015.
*/
public class IssueChangedEvent {
public Issue issue;
public IssueChangedEvent(Issue issue) {
this.issue = issue;
}
}
Loading
Loading
@@ -74,8 +74,9 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
listView.setAdapter(adapter);
mSwipeRefreshLayout.setOnRefreshListener(this);
if (getActivity() instanceof ProjectActivity) {
mProject = ((ProjectActivity) getActivity()).getProject();
mBranchName = ((ProjectActivity) getActivity()).getBranchName();
if (!TextUtils.isEmpty(mBranchName)) {
if (!TextUtils.isEmpty(mBranchName) && mProject != null) {
loadData();
}
} else {
Loading
Loading
@@ -117,12 +118,12 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Override
public void onResponse(Response<List<DiffLine>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
if (getView() == null) {
return;
}
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
 
if(response.body().size() > 0) {
Loading
Loading
@@ -137,6 +138,9 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Override
public void onFailure(Throwable t) {
if (getView() == null) {
return;
}
Timber.e(t.toString());
 
if(mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
Loading
Loading
Loading
Loading
@@ -16,6 +16,7 @@ import com.commit451.gitlab.activities.ProjectActivity;
import com.commit451.gitlab.adapter.IssuesAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.dialogs.NewIssueDialog;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.events.IssueCreatedEvent;
import com.commit451.gitlab.events.ProjectReloadEvent;
import com.commit451.gitlab.model.Issue;
Loading
Loading
@@ -108,12 +109,12 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
 
@Override
public void onResponse(Response<List<Issue>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
if (getView() == null) {
return;
}
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
issuesAdapter.setIssues(response.body());
 
Loading
Loading
@@ -123,6 +124,9 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
if (getView() == null) {
return;
}
 
if(mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
mSwipeRefreshLayout.setRefreshing(false);
Loading
Loading
@@ -154,10 +158,16 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
mProject = event.project;
loadData();
}
@Subscribe
public void onIssueAdded(IssueCreatedEvent event) {
issuesAdapter.addIssue(event.issue);
listView.smoothScrollToPosition(0);
}
@Subscribe
public void onIssueChanged(IssueChangedEvent event) {
issuesAdapter.updateIssue(event.issue);
}
}
}
\ No newline at end of file
Loading
Loading
@@ -71,7 +71,10 @@ public class ProjectsFragment extends BaseFragment {
}
mSwipeRefreshLayout.setRefreshing(false);
if (!response.isSuccess()) {
mRecyclerView.setVisibility(View.GONE);
mMessageText.setVisibility(View.VISIBLE);
mMessageText.setText(R.string.connection_error);
return;
}
if (response.body().isEmpty()) {
mMessageText.setText(R.string.no_projects);
Loading
Loading
Loading
Loading
@@ -68,8 +68,11 @@ public class DiffLine {
}
 
public List<Line> getLines() {
ArrayList<Line> lines = new ArrayList<Line>();
ArrayList<Line> lines = new ArrayList<>();
 
if (message == null) {
return null;
}
String[] temp = message.split("\\r?\\n");
 
for(String s : temp) {
Loading
Loading
package com.commit451.gitlab.model;
 
import android.support.annotation.StringDef;
import com.google.gson.annotations.SerializedName;
import org.parceler.Parcel;
 
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Date;
@Parcel
public class Issue {
@StringDef({STATE_REOPEN, STATE_CLOSE})
@Retention(RetentionPolicy.SOURCE)
public @interface State {}
public static final String STATE_REOPENED = "reopened";
public static final String STATE_CLOSED = "closed";
public static final String STATE_ACTIVE = "active";
public static final String STATE_OPENED = "opened";
@StringDef({STATE_REOPEN, STATE_CLOSE})
@Retention(RetentionPolicy.SOURCE)
public @interface EditState {}
public static final String STATE_REOPEN = "reopen";
public static final String STATE_CLOSE = "close";
@SerializedName("id")
long id;
@SerializedName("iid")
long iid;
@SerializedName("project_id")
long project_id;
@SerializedName("title")
String title;
@SerializedName("description")
String description;
@SerializedName("labels")
String[] labels;
@SerializedName("milestone")
Milestone milestone;
@SerializedName("assignee")
User assignee;
@SerializedName("author")
User author;
@SerializedName("state")
String state;
@SerializedName("updated_at")
Date updated_at;
@SerializedName("created_at")
Date created_at;
 
public Issue(){}
Loading
Loading
@@ -56,9 +89,10 @@ public class Issue {
public User getAuthor() {
return author;
}
@State
public String getState() {
return state;
return state;
}
public Date getUpdatedAt() {
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@ import android.view.View;
import com.commit451.gitlab.R;
 
/**
* All the things to do with intents
* Created by Jawn on 8/25/2015.
*/
public class IntentUtil {
Loading
Loading
@@ -28,11 +29,10 @@ public class IntentUtil {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
root.getContext().startActivity(Intent.createChooser(shareIntent, root.getContext().getString(R.string.action_share)));
try {
root.getContext().startActivity(shareIntent);
} catch (ActivityNotFoundException e) {
Snackbar.make(root, R.string.error_no_browser, Snackbar.LENGTH_SHORT)
Snackbar.make(root, R.string.error_could_not_share, Snackbar.LENGTH_SHORT)
.show();
}
}
Loading
Loading
package com.commit451.gitlab.viewHolders;
 
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
Loading
Loading
@@ -11,6 +12,7 @@ import android.widget.TextView;
 
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.tools.ImageUtil;
import com.squareup.picasso.Picasso;
 
import butterknife.Bind;
Loading
Loading
@@ -28,31 +30,33 @@ public class IssueHeaderViewHolder extends RecyclerView.ViewHolder {
return new IssueHeaderViewHolder(view);
}
 
@Bind(R.id.title) TextView title;
@Bind(R.id.description) TextView description;
@Bind(R.id.author_image) ImageView authorImage;
@Bind(R.id.author) TextView author;
@Bind(R.id.date_added) TextView dateAdded;
Bypass mBypass;
 
public IssueHeaderViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
mBypass = new Bypass(view.getContext());
}
 
public void bind(Issue issue) {
title.setText(issue.getTitle());
Bypass bypass = new Bypass();
String desc = issue.getDescription();
if(desc == null) {
desc = "";
if (TextUtils.isEmpty(issue.getDescription())) {
description.setVisibility(View.GONE);
} else {
description.setVisibility(View.VISIBLE);
description.setText(mBypass.markdownToSpannable(issue.getDescription()));
description.setMovementMethod(LinkMovementMethod.getInstance());
}
description.setText(bypass.markdownToSpannable(desc));
description.setMovementMethod(LinkMovementMethod.getInstance());
if (issue.getAuthor() != null) {
Picasso.with(itemView.getContext())
.load(issue.getAuthor().getAvatarUrl())
.load(ImageUtil.getGravatarUrl(issue.getAuthor(), itemView.getResources().getDimensionPixelSize(R.dimen.image_size)))
.into(authorImage);
author.setText(issue.getAuthor().getName());
author.setText(issue.getAuthor().getName() + " "
+ itemView.getResources().getString(R.string.created_issue) + " "
+ DateUtils.getRelativeTimeSpanString(issue.getCreatedAt().getTime()));
}
if (issue.getCreatedAt() != null) {
DateUtils.getRelativeTimeSpanString(issue.getCreatedAt().getTime());
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
Loading
Loading
@@ -124,8 +125,8 @@ public class GitLabNavigationView extends NavigationView {
private void init() {
setNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
inflateMenu(R.menu.navigation);
inflateHeaderView(R.layout.nav_drawer);
ButterKnife.bind(this);
View header = inflateHeaderView(R.layout.nav_drawer);
ButterKnife.bind(this, header);
mInsetForeground = new ColorDrawable(Color.parseColor("#44000000"));
setSelectedNavigationItem();
loadCurrentUser();
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Loading
Loading
@@ -24,6 +25,14 @@
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
 
<TextView
android:id="@+id/issue_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_marginRight="56dp"
tools:text="This is an issue"/>
</android.support.design.widget.AppBarLayout>
 
<com.commit451.gitlab.views.GitLabSwipeRefreshLayout
Loading
Loading
@@ -53,23 +62,34 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:hint="@string/new_note_hint"
android:inputType="text|textCapSentences|textAutoComplete" />
android:inputType="textCapSentences|textAutoCorrect|textMultiLine"
android:imeOptions="actionNone" />
 
<ImageButton
<ImageView
android:id="@+id/new_note_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:state_enabled="false"
android:focusable="true"
android:contentDescription="@string/add_note_content_description"
android:src="@drawable/ic_send_24dp" />
android:layout_height="match_parent"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:contentDescription="@null"
android:src="@drawable/ic_send_24dp"
android:background="?attr/selectableItemBackgroundBorderless"/>
 
</LinearLayout>
 
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_edit_issue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_edit_24dp"
app:fabSize="mini"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"/>
<include layout="@layout/progress_fullscreen"/>
 
</FrameLayout>
\ No newline at end of file
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
Loading
Loading
@@ -2,78 +2,85 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:minWidth="256dp">
 
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="16dp">
android:layout_height="wrap_content">
 
<android.support.design.widget.TextInputLayout
android:id="@+id/titleInputLayout"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
 
<EditText
android:id="@+id/title_input"
<android.support.design.widget.TextInputLayout
android:id="@+id/titleInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ems="10"
android:hint="@string/title_hint"
android:inputType="text|textCapWords">
android:layout_height="wrap_content">
 
<requestFocus />
</EditText>
<EditText
android:id="@+id/title_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_hint"
android:singleLine="false"
android:inputType="textCapSentences|textAutoCorrect|textMultiLine"
android:imeOptions="actionNone">
 
</android.support.design.widget.TextInputLayout>
<requestFocus />
</EditText>
 
<android.support.design.widget.TextInputLayout
android:id="@+id/descriptionInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.design.widget.TextInputLayout>
 
<EditText
android:id="@+id/description_input"
<android.support.design.widget.TextInputLayout
android:id="@+id/descriptionInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ems="10"
android:hint="@string/description_hint"
android:inputType="text|textCapSentences" />
android:layout_height="wrap_content">
 
</android.support.design.widget.TextInputLayout>
<EditText
android:id="@+id/description_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/description_hint"
android:singleLine="false"
android:inputType="textCapSentences|textAutoCorrect|textMultiLine"
android:imeOptions="actionNone" />
 
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</android.support.design.widget.TextInputLayout>
 
<Button
android:id="@+id/cancel_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:text="@string/cancel_button" />
<Button
android:id="@+id/save_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:text="@string/save_button" />
android:layout_gravity="right"
android:orientation="horizontal">
<Button
android:id="@+id/cancel_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:text="@string/cancel_button"
android:textColor="?attr/colorAccent" />
<Button
android:id="@+id/save_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:text="@string/save_button"
android:textColor="?attr/colorAccent" />
</LinearLayout>
 
</LinearLayout>
</ScrollView>
 
</LinearLayout>
<include layout="@layout/progress_fullscreen"/>
<include layout="@layout/progress_fullscreen" />
 
</FrameLayout>
\ No newline at end of file
Loading
Loading
@@ -2,12 +2,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
android:padding="16dp"
android:minWidth="256dp">
 
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/logout_title"
android:id="@+id/textView" />
 
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="256dp"
android:orientation="horizontal" >
 
<Button
Loading
Loading
Loading
Loading
@@ -6,26 +6,21 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
 
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_normal"
tools:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_normal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
tools:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
 
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:layout_margin="16dp">
 
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/author_image"
Loading
Loading
@@ -33,25 +28,16 @@
android:layout_height="@dimen/image_size"
android:contentDescription="@null"/>
 
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Jawnnypoo"
android:layout_marginLeft="@dimen/padding_normal"
android:layout_marginRight="@dimen/padding_normal"
android:layout_gravity="center_vertical"
tools:text="Jawnnypoo created issue 8 hours ago"
android:textAppearance="?android:attr/textAppearanceMedium" />
 
<TextView
android:id="@+id/date_added"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="3 Weeks ago"/>
</LinearLayout>
</LinearLayout>
 
 
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