Skip to content

Commit

Permalink
icon in note overview if note has attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
konradrenner committed Jul 10, 2016
1 parent 387020f commit 5f08f4e
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.kore.kolabnotes.android"
minSdkVersion 16
targetSdkVersion 23
versionCode 73
versionName "2.0.8"
versionCode 74
versionName "2.1.0"

//Running test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand All @@ -25,6 +26,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

public class NoteAdapter extends SelectableAdapter<NoteAdapter.ViewHolder> {

Expand All @@ -34,17 +36,19 @@ public class NoteAdapter extends SelectableAdapter<NoteAdapter.ViewHolder> {
private ViewHolder.ClickListener clickListener;
private DateFormat dateFormatter;
private int COLOR_SELECTED_NOTE;
private Set<String> notesWithAttachment;

private List<ViewHolder> views;

public NoteAdapter(List<Note> notes, int rowLayout, Context context, ViewHolder.ClickListener clickListener) {
public NoteAdapter(List<Note> notes, int rowLayout, Context context, ViewHolder.ClickListener clickListener, Set<String> notesWithAttachment) {
this.notes = notes;
this.rowLayout = rowLayout;
this.context = context;
this.clickListener = clickListener;
this.dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
views = new ArrayList<>(notes.size());
COLOR_SELECTED_NOTE = ContextCompat.getColor(context, R.color.theme_selected_notes);
this.notesWithAttachment = notesWithAttachment;
}

public void clearNotes() {
Expand Down Expand Up @@ -108,7 +112,7 @@ public void onBindViewHolder(final ViewHolder viewHolder, int i) {
viewHolder.name.setText(note.getSummary());
viewHolder.classification.setText(context.getResources().getString(R.string.classification)+": "+note.getClassification());
viewHolder.createdDate.setText(context.getResources().getString(R.string.creationDate)+": "+ dateFormatter.format(note.getAuditInformation().getCreationDate()));
viewHolder.modificationDate.setText(context.getResources().getString(R.string.modificationDate)+": "+dateFormatter.format(note.getAuditInformation().getLastModificationDate()));
viewHolder.modificationDate.setText(context.getResources().getString(R.string.modificationDate) + ": " + dateFormatter.format(note.getAuditInformation().getLastModificationDate()));
viewHolder.categories.removeAllViews();

boolean useLightColor = Utils.useLightTextColor(context, note.getColor());
Expand Down Expand Up @@ -239,6 +243,18 @@ public void onBindViewHolder(final ViewHolder viewHolder, int i) {
}else{
viewHolder.hideCharacteristics();
}

if(notesWithAttachment.contains(note.getIdentification().getUid())){
viewHolder.attachmentImage.setVisibility(View.VISIBLE);

if(useLightColor){
viewHolder.attachmentImage.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_attach_file_white_24dp));
}
}
}

public void setNotesWithAttachment(Set<String> ids){
this.notesWithAttachment = ids;
}

public void restoreElevation(RecyclerView recyclerView){
Expand Down Expand Up @@ -267,6 +283,7 @@ public static class ViewHolder extends RecyclerView.ViewHolder implements View.O
TextView modificationDate;
LinearLayout categories;
CardView cardView;
ImageView attachmentImage;
private ClickListener listener;
private List<Note> notes;

Expand All @@ -285,6 +302,7 @@ public ViewHolder(View itemView, ClickListener listener, List<Note> notes) {
modificationDate = (TextView) itemView.findViewById(R.id.modificationDate);
categories = (LinearLayout) itemView.findViewById(R.id.categories);
cardView = (CardView)itemView;
attachmentImage = (ImageView)itemView.findViewById(R.id.attachmentHint);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* Created by koni on 12.03.15.
Expand Down Expand Up @@ -258,6 +261,25 @@ public boolean hasNoteAttachments(String account, String rootFolder, String note
return ret;
}

public Set<String> getNoteIDsWithAttachments(String account, String rootFolder) {
Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_ATTACHMENT,
new String[]{DatabaseHelper.COLUMN_IDNOTE},
DatabaseHelper.COLUMN_ACCOUNT + " = '" + account + "' AND " +
DatabaseHelper.COLUMN_ROOT_FOLDER + " = '" + rootFolder + "' ",
null,
null,
null,
null);

HashSet<String> ids = new HashSet<>();
while(cursor.moveToNext()){
ids.add(cursor.getString(0));
}

cursor.close();
return ids;
}

public boolean attachmentsCreatedAfterLastSync(String account, String rootFolder, String noteUID, Date date) {
List<Attachment> attachments = new ArrayList<Attachment>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ public void onActivityCreated(Bundle savedInstanceState) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
//mRecyclerView.setItemAnimator(new CustomItemAnimator());
//mRecyclerView.setItemAnimator(new ReboundItemAnimator());
final ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();

mAdapter = new NoteAdapter(new ArrayList<Note>(), R.layout.row_note_overview, activity, this);
mAdapter = new NoteAdapter(new ArrayList<Note>(), R.layout.row_note_overview, activity, this, attachmentRepository.getNoteIDsWithAttachments(activeAccount.getAccount(),activeAccount.getRootFolder()));
mRecyclerView.setAdapter(mAdapter);

mSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.swipe_container);
Expand Down Expand Up @@ -1678,9 +1679,15 @@ final synchronized void reloadData(List<Notebook> notebooks, List<Note> notes, M
orderDrawerItems(tags, mDrawer);

if(mAdapter == null){
mAdapter = new NoteAdapter(new ArrayList<Note>(), R.layout.row_note_overview, activity, this);
final ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
mAdapter = new NoteAdapter(new ArrayList<Note>(), R.layout.row_note_overview, activity, this, attachmentRepository.getNoteIDsWithAttachments(activeAccount.getAccount(),activeAccount.getRootFolder()));
}else{
final ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
mAdapter.setNotesWithAttachment(attachmentRepository.getNoteIDsWithAttachments(activeAccount.getAccount(),activeAccount.getRootFolder()));
}



mAdapter.clearNotes();
if(notes.size() == 0){
mAdapter.notifyDataSetChanged();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 23 additions & 7 deletions app/src/main/res/layout/row_note_overview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@
android:orientation="horizontal"
android:columnCount="1">

<TextView
android:id="@+id/noteSummary"
<LinearLayout android:id="@+id/summaryLine"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_rowSpan="2"
style="@style/NoteOverviewSummary"
android:clickable="false"
android:background="@drawable/button_rect_list_normal"
/>
android:layout_rowSpan="2">

<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_attach_file_black_24dp"
android:id="@+id/attachmentHint"
android:visibility="gone"/>

<TextView
android:id="@+id/noteSummary"
style="@style/NoteOverviewSummary"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:clickable="false"
android:background="@drawable/button_rect_list_normal"
/>

</LinearLayout>

<LinearLayout
android:id="@+id/categories"
Expand Down

0 comments on commit 5f08f4e

Please sign in to comment.