Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import jp.redmine.redmineclient.entity.RedmineFilterSortItem;
import jp.redmine.redmineclient.entity.RedmineUser;
import jp.redmine.redmineclient.fragment.IssueList;
import jp.redmine.redmineclient.fragment.ProjectFavoriteList;
import jp.redmine.redmineclient.fragment.ProjectList;
import jp.redmine.redmineclient.fragment.RecentIssueList;
import jp.redmine.redmineclient.model.ConnectionModel;
import jp.redmine.redmineclient.param.ConnectionArgument;
import jp.redmine.redmineclient.param.FilterArgument;
Expand Down Expand Up @@ -90,6 +92,34 @@ public Fragment getRawFragment(FilterArgument param) {
Log.e(TAG,"fetchCurrentUser", e);
}

ConnectionArgument argFavorite = new ConnectionArgument();
argFavorite.setArgument();
argFavorite.importArgument(intent);
list.add((new CorePage<ConnectionArgument>() {
@Override
public Fragment getRawFragment(ConnectionArgument param) {
return ProjectFavoriteList.newInstance(param);
}
})
.setParam(argFavorite)
.setName(getString(R.string.favorite))
.setIcon(android.R.drawable.btn_star)
);

ConnectionArgument argRecent = new ConnectionArgument();
argRecent.setArgument();
argRecent.importArgument(intent);
list.add((new CorePage<ConnectionArgument>() {
@Override
public Fragment getRawFragment(ConnectionArgument param) {
return RecentIssueList.newInstance(param);
}
})
.setParam(argRecent)
.setName(getString(R.string.recent_issues))
.setIcon(android.R.drawable.ic_menu_recent_history)
);

return list;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.widget.TextView;

import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.Where;

import java.sql.SQLException;

Expand All @@ -20,11 +21,21 @@

public class FavoriteProjectListAdapter extends RedmineDaoAdapter<RedmineProject, Long, DatabaseCacheHelper> implements StickyListHeadersAdapter {
private ConnectionModel mConnection;
protected Integer connection_id;

public FavoriteProjectListAdapter(DatabaseCacheHelper helper, Context context){
super(helper, context, RedmineProject.class);
mConnection = new ConnectionModel(context);
}

/**
* Setup parameter
* this method is optional.
* @param connection connection id
*/
public void setupParameter(int connection){
connection_id = connection;
}
@Override
public View getHeaderView(int i, View convertView, ViewGroup parent) {
if (convertView == null) {
Expand Down Expand Up @@ -64,9 +75,15 @@ protected void setupView(View view, RedmineProject proj) {
}

@Override
protected QueryBuilder getQueryBuilder() throws SQLException {
protected QueryBuilder<RedmineProject, Long> getQueryBuilder() throws SQLException {
QueryBuilder<RedmineProject, Long> builder = dao.queryBuilder();
builder.setWhere(builder.where().gt(RedmineProject.FAVORITE, 0));

Where<RedmineProject, Long> where = builder.where()
.gt(RedmineProject.FAVORITE, 0);
if(connection_id != null)
where.and().eq(RedmineProject.CONNECTION, connection_id);

builder.setWhere(where);
builder.orderBy(RedmineProject.CONNECTION, true);
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package jp.redmine.redmineclient.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.j256.ormlite.stmt.QueryBuilder;

import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;

import jp.redmine.redmineclient.R;
import jp.redmine.redmineclient.adapter.form.IssueForm;
import jp.redmine.redmineclient.db.cache.DatabaseCacheHelper;
import jp.redmine.redmineclient.db.cache.RedmineProjectModel;
import jp.redmine.redmineclient.entity.RedmineConnection;
import jp.redmine.redmineclient.entity.RedmineProject;
import jp.redmine.redmineclient.entity.RedmineRecentIssue;
import jp.redmine.redmineclient.form.helper.HtmlHelper;
import jp.redmine.redmineclient.model.ConnectionModel;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;

public class RecentConnectionIssueListAdapter extends RedmineDaoAdapter<RedmineRecentIssue, Long, DatabaseCacheHelper> implements StickyListHeadersAdapter {
private static final String TAG = RecentConnectionIssueListAdapter.class.getSimpleName();
private RedmineProjectModel mProject;
private int mConnectionId;

public RecentConnectionIssueListAdapter(DatabaseCacheHelper helper, Context context){
super(helper, context, RedmineRecentIssue.class);
mProject = new RedmineProjectModel(helper);
}
public void setParameter(int connection_id){
mConnectionId = connection_id;
}

@Override
public View getHeaderView(int i, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = infrator.inflate(R.layout.listheader_project, parent, false);
if(convertView == null)
return null;
}
RedmineProject project = null;
TextView text = (TextView)convertView.findViewById(R.id.name);
try {
project = mProject.fetchById(getHeaderId(i));
} catch (SQLException e) {
Log.e(TAG, "getHeaderView", e);
}
if(text != null)
text.setText((project == null || TextUtils.isEmpty(project.getName())) ? "" : project.getName());
//fix background to hide transparent headers
convertView.setBackgroundColor(HtmlHelper.getBackgroundColor(convertView.getContext()));
return convertView;
}

@Override
public long getHeaderId(int i) {
RedmineRecentIssue proj = (RedmineRecentIssue)getItem(i);
return proj == null ? 0 : proj.getProject().getId();
}

@Override
protected long getDbItemId(RedmineRecentIssue item) {
return item.getId();
}

@Override
protected int getItemViewId() {
return R.layout.listitem_issue;
}

@Override
protected void setupView(View view, RedmineRecentIssue history) {
IssueForm form = new IssueForm(view);
form.setValue(history);
}

@Override
protected QueryBuilder getQueryBuilder() throws SQLException {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_YEAR, -14);
QueryBuilder<RedmineRecentIssue, Long> builder = dao.queryBuilder();
builder.setWhere(builder.where()
.ge(RedmineRecentIssue.MODIFIED, cal.getTime())
.and()
.eq(RedmineRecentIssue.CONNECTION, mConnectionId)
);
builder.orderBy(RedmineRecentIssue.PROJECT, true);
builder.orderBy(RedmineRecentIssue.MODIFIED, false);
return builder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import jp.redmine.redmineclient.db.cache.DatabaseCacheHelper;
import jp.redmine.redmineclient.entity.RedmineProject;
import jp.redmine.redmineclient.fragment.helper.ActivityHandler;
import jp.redmine.redmineclient.param.ConnectionArgument;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;

public class ProjectFavoriteList extends OrmLiteFragment<DatabaseCacheHelper> {
Expand All @@ -27,7 +28,11 @@ public ProjectFavoriteList(){
}

static public ProjectFavoriteList newInstance(){
return new ProjectFavoriteList();
}
static public ProjectFavoriteList newInstance(ConnectionArgument arg){
ProjectFavoriteList instance = new ProjectFavoriteList();
instance.setArguments(arg.getArgument());
return instance;
}

Expand All @@ -45,6 +50,10 @@ public void onActivityCreated(Bundle savedInstanceState) {
list.setFastScrollEnabled(true);

FavoriteProjectListAdapter adapter = new FavoriteProjectListAdapter(getHelper(), getActivity());
ConnectionArgument arg = new ConnectionArgument();
arg.setArgument(getArguments());
if(arg.getConnectionId() != -1)
adapter.setupParameter(arg.getConnectionId());

list.setAdapter(adapter);
adapter.notifyDataSetChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;

import com.j256.ormlite.android.apptools.OrmLiteFragment;

import jp.redmine.redmineclient.R;
import jp.redmine.redmineclient.activity.handler.IssueActionInterface;
import jp.redmine.redmineclient.adapter.RecentConnectionIssueListAdapter;
import jp.redmine.redmineclient.adapter.RecentIssueListAdapter;
import jp.redmine.redmineclient.db.cache.DatabaseCacheHelper;
import jp.redmine.redmineclient.entity.RedmineRecentIssue;
import jp.redmine.redmineclient.fragment.helper.ActivityHandler;
import jp.redmine.redmineclient.param.FilterArgument;
import jp.redmine.redmineclient.param.ConnectionArgument;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;

public class RecentIssueList extends OrmLiteFragment<DatabaseCacheHelper> {
private RecentIssueListAdapter adapter;
private BaseAdapter adapter;
private IssueActionInterface mListener;
private StickyListHeadersListView list;

Expand All @@ -31,6 +33,12 @@ static public RecentIssueList newInstance(){
return fragment;
}

static public RecentIssueList newInstance(ConnectionArgument intent){
RecentIssueList fragment = new RecentIssueList();
fragment.setArguments(intent.getArgument());
return fragment;
}

@Override
public void onDestroyView() {
list.setAdapter(null);
Expand All @@ -43,11 +51,19 @@ public void onActivityCreated(Bundle savedInstanceState) {
mListener = ActivityHandler.getHandler(getActivity(), IssueActionInterface.class);
list.setFastScrollEnabled(true);

adapter = new RecentIssueListAdapter(getHelper(), getActivity());
FilterArgument intent = new FilterArgument();
ConnectionArgument intent = new ConnectionArgument();
intent.setArgument( getArguments() );
if (intent.getConnectionId() == -1){
RecentIssueListAdapter _adapter = new RecentIssueListAdapter(getHelper(), getActivity());
adapter = _adapter;
list.setAdapter(_adapter);
} else {
RecentConnectionIssueListAdapter _adapter = new RecentConnectionIssueListAdapter(getHelper(), getActivity());
_adapter.setParameter(intent.getConnectionId());
adapter = _adapter;
list.setAdapter(_adapter);
}
onRefreshList();
list.setAdapter(adapter);

list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
Expand Down
3 changes: 3 additions & 0 deletions OpenRedmine/src/main/res/layout/listheader_connection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
android:src="@android:drawable/btn_star_big_on"
android:contentDescription="@string/ticket_relations"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:text="Connection Name"
tools:ignore="HardcodedText"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_toRightOf="@+id/icon"
android:layout_toEndOf="@+id/icon"
android:layout_centerVertical="true"/>
</RelativeLayout>
32 changes: 32 additions & 0 deletions OpenRedmine/src/main/res/layout/listheader_project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">

<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/ticket_relations"
android:src="@android:drawable/ic_menu_mapmode"/>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:text="Project Name"
tools:ignore="HardcodedText"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_toRightOf="@+id/icon"
android:layout_toEndOf="@+id/icon"
android:layout_centerVertical="true"/>
</RelativeLayout>
2 changes: 2 additions & 0 deletions OpenRedmine/src/main/res/raw/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ TODO

Next Release
===========
- Add favorite project list to connection
- Add recent issue list to connection

v3.19 - 52 - 2016/06/30
===========
Expand Down