diff --git a/app/app.iml b/app/app.iml
index b9a2691..cba1ebf 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -86,7 +86,7 @@
-
+
@@ -94,10 +94,10 @@
+
-
+
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 20d44f9..fa29568 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 21
+ compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "org.kore.kolabnotes.android"
- minSdkVersion 21
- targetSdkVersion 21
+ minSdkVersion 19
+ targetSdkVersion 22
versionCode 6
versionName "0.1.0-alpha6"
}
@@ -30,10 +30,10 @@ dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.yukuku:ambilwarna:2.0'
compile 'com.github.konradrenner:kolabnotes-java:0.6.3'
- compile 'com.android.support:support-v4:22.0.0'
- compile 'com.android.support:appcompat-v7:22.0.0'
- compile 'com.android.support:recyclerview-v7:21.0.3'
- compile 'com.android.support:cardview-v7:21.0.3'
+ compile 'com.android.support:support-v4:22.2.0'
+ compile 'com.android.support:appcompat-v7:22.2.0'
+ compile 'com.android.support:recyclerview-v7:22.2.0'
+ compile 'com.android.support:cardview-v7:22.2.0'
compile 'jp.wasabeef:richeditor-android:0.0.6@aar'
compile('com.mikepenz:materialdrawer:3.0.8@aar') {
transitive = true
diff --git a/app/src/main/java/org/kore/kolabnotes/android/DetailActivity.java b/app/src/main/java/org/kore/kolabnotes/android/DetailActivity.java
index 8a54465..6eb473e 100755
--- a/app/src/main/java/org/kore/kolabnotes/android/DetailActivity.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/DetailActivity.java
@@ -9,6 +9,8 @@
public class DetailActivity extends AppCompatActivity implements OnFragmentFinished{
+ public static String FROM_DETAIL = "fromDetailTrue";
+
private DetailFragment detailFragment;
@Override
@@ -29,7 +31,8 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void fragmentFinished(Intent resultIntent, ResultCode code) {
if(ResultCode.OK == code || ResultCode.SAVED == code || ResultCode.DELETED == code){
- setResult(RESULT_OK,resultIntent);
+ Utils.setReloadDataAfterDetail(this,true);
+ setResult(RESULT_OK, resultIntent);
}else{
setResult(RESULT_CANCELED,resultIntent);
}
diff --git a/app/src/main/java/org/kore/kolabnotes/android/MainActivity.java b/app/src/main/java/org/kore/kolabnotes/android/MainActivity.java
index 58f6a6c..864d4f8 100644
--- a/app/src/main/java/org/kore/kolabnotes/android/MainActivity.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/MainActivity.java
@@ -56,6 +56,16 @@ protected void onCreate(Bundle savedInstanceState) {
mAccountManager = AccountManager.get(this);
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if(Utils.getReloadDataAfterDetail(this)){
+ Utils.setReloadDataAfterDetail(this,false);
+ overviewFragment.setFromDetail();
+ }
+ }
+
@Override
public void fragmentFinished(Intent resultIntent, ResultCode code) {
if(ResultCode.DELETED == code){
diff --git a/app/src/main/java/org/kore/kolabnotes/android/Utils.java b/app/src/main/java/org/kore/kolabnotes/android/Utils.java
index 1521565..4ad3958 100755
--- a/app/src/main/java/org/kore/kolabnotes/android/Utils.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/Utils.java
@@ -3,11 +3,13 @@
import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
+import android.app.Activity;
import android.app.Application;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.graphics.Outline;
import android.os.Build;
import android.text.Html;
@@ -35,6 +37,8 @@ public class Utils {
public static final String NOTE_UID = "note_uid";
public static final String NOTEBOOK_UID = "notebook_uid";
public static final String SELECTED_NOTEBOOK_NAME = "selectedNotebookName";
+ public static final String SELECTED_TAG_NAME = "selectedNotebookTag";
+ public static final String RELOAD_DATA_AFTER_DETAIL = "reloadDataAfterDetail";
/*
public static void configureWindowEnterExitTransition(Window w) {
Explode ex = new Explode();
@@ -44,6 +48,49 @@ public static void configureWindowEnterExitTransition(Window w) {
}
*/
+ public static boolean getReloadDataAfterDetail(Context context){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref",Context.MODE_PRIVATE);
+ return sharedPref.getBoolean(Utils.RELOAD_DATA_AFTER_DETAIL,false);
+ }
+
+ public static void setReloadDataAfterDetail(Context context, boolean value){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref",Context.MODE_PRIVATE);
+ if(value){
+ sharedPref.edit().putBoolean(Utils.RELOAD_DATA_AFTER_DETAIL,value).commit();
+ }else{
+ sharedPref.edit().remove(Utils.RELOAD_DATA_AFTER_DETAIL).commit();
+ }
+ }
+
+
+ public static String getSelectedTagName(Context context){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref",Context.MODE_PRIVATE);
+ return sharedPref.getString(Utils.SELECTED_TAG_NAME,null);
+ }
+
+ public static void setSelectedTagName(Context context, String name){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref",Context.MODE_PRIVATE);
+ if(name == null){
+ sharedPref.edit().remove(Utils.SELECTED_TAG_NAME).commit();
+ }else{
+ sharedPref.edit().putString(Utils.SELECTED_TAG_NAME,name).commit();
+ }
+ }
+
+ public static String getSelectedNotebookName(Context context){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref",Context.MODE_PRIVATE);
+ return sharedPref.getString(Utils.SELECTED_NOTEBOOK_NAME,null);
+ }
+
+ public static void setSelectedNotebookName(Context context, String name){
+ SharedPreferences sharedPref = context.getSharedPreferences("org.kore.kolabnotes.android.pref", Context.MODE_PRIVATE);
+ if(name == null){
+ sharedPref.edit().remove(Utils.SELECTED_NOTEBOOK_NAME).commit();
+ }else{
+ sharedPref.edit().putString(Utils.SELECTED_NOTEBOOK_NAME,name).commit();
+ }
+ }
+
public static void configureFab(View fabButton) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -59,6 +106,12 @@ public void getOutline(View view, Outline outline) {
((ImageButton) fabButton).setScaleType(ImageView.ScaleType.FIT_CENTER);
}
}
+
+ public static void setElevation(View view, float elevation){
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
+ view.setElevation(elevation);
+ }
+ }
public static final String getNameOfActiveAccount(Context context, String pemail, String prootFolder){
AccountManager accountManager = AccountManager.get(context);
diff --git a/app/src/main/java/org/kore/kolabnotes/android/adapter/NoteAdapter.java b/app/src/main/java/org/kore/kolabnotes/android/adapter/NoteAdapter.java
index 6ca1cae..5c23675 100755
--- a/app/src/main/java/org/kore/kolabnotes/android/adapter/NoteAdapter.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/adapter/NoteAdapter.java
@@ -2,6 +2,7 @@
import android.content.Context;
import android.graphics.Color;
+import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -14,6 +15,7 @@
import org.kore.kolab.notes.Tag;
import org.kore.kolabnotes.android.MainActivity;
import org.kore.kolabnotes.android.R;
+import org.kore.kolabnotes.android.Utils;
import java.text.DateFormat;
import java.util.Collections;
@@ -80,11 +82,21 @@ public void onBindViewHolder(final ViewHolder viewHolder, int i) {
if(note != null && note.getColor() != null){
viewHolder.cardView.setCardBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+ viewHolder.name.setBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+ viewHolder.classification.setBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+ viewHolder.createdDate.setBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+ viewHolder.modificationDate.setBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+ viewHolder.categories.setBackgroundColor(Color.parseColor(note.getColor().getHexcode()));
+
}else{
viewHolder.cardView.setCardBackgroundColor(Color.WHITE);
+ viewHolder.name.setBackgroundColor(Color.WHITE);
+ viewHolder.classification.setBackgroundColor(Color.WHITE);
+ viewHolder.createdDate.setBackgroundColor(Color.WHITE);
+ viewHolder.modificationDate.setBackgroundColor(Color.WHITE);
+ viewHolder.categories.setBackgroundColor(Color.WHITE);
}
- viewHolder.cardView.setElevation(5);
-
+ Utils.setElevation(viewHolder.cardView,5);
viewHolder.itemView.setOnClickListener(new ClickListener(i));
}
@@ -103,11 +115,11 @@ public void onClick(View v) {
if(parent instanceof RecyclerView){
RecyclerView recyclerView = (RecyclerView)parent;
for(int i=0; i < recyclerView.getChildCount(); i++){
- recyclerView.getChildAt(i).setElevation(5);
+ Utils.setElevation(recyclerView.getChildAt(i),5);
}
}
- v.setElevation(30);
- listener.onSelect(notes.get(index),same);
+ Utils.setElevation(v,30);
+ listener.onSelect(notes.get(index), same);
}
}
diff --git a/app/src/main/java/org/kore/kolabnotes/android/fragment/DetailFragment.java b/app/src/main/java/org/kore/kolabnotes/android/fragment/DetailFragment.java
index 272605a..96c97b6 100644
--- a/app/src/main/java/org/kore/kolabnotes/android/fragment/DetailFragment.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/fragment/DetailFragment.java
@@ -6,7 +6,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
@@ -560,17 +559,20 @@ void saveNote(){
for (String tag : selectedTags) {
noteTagRepository.insert(activeAccountRepository.getActiveAccount().getAccount(), activeAccountRepository.getActiveAccount().getRootFolder(), uuid, tag);
}
+
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
+ if(selectedNotebookName != null && !selectedNotebookName.equals(book.getSummary())){
+ Utils.setSelectedNotebookName(activity,book.getSummary());
+ }
}
Intent returnIntent = new Intent();
if (isNewNote) {
- SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
- sharedPref.edit().putString(Utils.SELECTED_NOTEBOOK_NAME,notebookName);
- if(givenNotebook !=null){
- returnIntent.putExtra("selectedNotebookName", notebookName);
+ if(Utils.getSelectedNotebookName(activity) != null){
+ Utils.setSelectedNotebookName(activity,notebookName);
}
}
- Utils.updateWidgetsForChange(activity.getApplication());
+ Utils.updateWidgetsForChange(activity);
((OnFragmentFinished) activity).fragmentFinished(returnIntent, OnFragmentFinished.ResultCode.SAVED);
}
diff --git a/app/src/main/java/org/kore/kolabnotes/android/fragment/OverviewFragment.java b/app/src/main/java/org/kore/kolabnotes/android/fragment/OverviewFragment.java
index 3ea0f3f..e69ea6e 100644
--- a/app/src/main/java/org/kore/kolabnotes/android/fragment/OverviewFragment.java
+++ b/app/src/main/java/org/kore/kolabnotes/android/fragment/OverviewFragment.java
@@ -84,7 +84,6 @@ public class OverviewFragment extends Fragment implements NoteAdapter.NoteSelect
private SwipeRefreshLayout mSwipeRefreshLayout;
private AccountManager mAccountManager;
- private String selectedNotebookName;
private boolean fromDetailActivity = false;
private DataCaches dataCache;
@@ -125,8 +124,6 @@ public void onAttach(Activity activity) {
tagRepository = new TagRepository(activity);
notetagRepository = new NoteTagRepository(activity);
activeAccountRepository = new ActiveAccountRepository(activity);
-
- initCachesAsync(activeAccountRepository.getActiveAccount());
}
@Override
@@ -260,22 +257,6 @@ public void displayBlankFragment(){
}
}
- void initCachesAsync(final ActiveAccount account){
- new Thread(new Runnable() {
- @Override
- public void run() {
- dataCache.reloadTags();
- }
- }).start();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- dataCache.getNoteCache(account).reloadData();
- }
- }).start();
- }
-
public DrawerItemClickedListener getDrawerItemClickedListener(){
return drawerItemClickedListener;
}
@@ -285,6 +266,7 @@ void setDetailFragment(Note note, boolean sameSelection){
if (detail.getNote() == null || !sameSelection) {
String notebook = null;
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
if (selectedNotebookName != null) {
ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
notebook = notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedNotebookName).getIdentification().getUid();
@@ -334,6 +316,7 @@ public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(activity, DetailActivity.class);
i.putExtra(Utils.NOTE_UID, note.getIdentification().getUid());
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
if (selectedNotebookName != null) {
ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
i.putExtra(Utils.NOTEBOOK_UID, notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedNotebookName).getIdentification().getUid());
@@ -346,18 +329,11 @@ public void onClick(DialogInterface dialog, int which) {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
-
- if (requestCode == DETAIL_ACTIVITY_RESULT_CODE) {
- String nbName = data.getStringExtra("selectedNotebookName");
- setNotebookNameFromDetail(nbName);
+ if(requestCode == DETAIL_ACTIVITY_RESULT_CODE){
+ setFromDetail();
}
}
- public void setNotebookNameFromDetail(String name){
- selectedNotebookName = name;
- fromDetailActivity = true;
- }
-
public void setFromDetail(){
fromDetailActivity = true;
}
@@ -372,10 +348,8 @@ public void onResume(){
Intent startIntent = getActivity().getIntent();
String email = startIntent.getStringExtra(Utils.INTENT_ACCOUNT_EMAIL);
String rootFolder = startIntent.getStringExtra(Utils.INTENT_ACCOUNT_ROOT_FOLDER);
- //String notebookUID = startIntent.getStringExtra(Utils.NOTEBOOK_UID);
-
- SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
- selectedNotebookName = sharedPref.getString(Utils.SELECTED_NOTEBOOK_NAME,null);
+ //if called from the widget
+ String notebookUID = startIntent.getStringExtra(Utils.NOTEBOOK_UID);
ActiveAccount activeAccount;
if(email != null && rootFolder != null) {
@@ -384,6 +358,13 @@ public void onResume(){
activeAccount = activeAccountRepository.getActiveAccount();
}
+ //if called from the widget
+ if(notebookUID != null){
+ Utils.setSelectedNotebookName(activity, notebookRepository.getByUID(activeAccount.getAccount(),activeAccount.getRootFolder(),notebookUID).getSummary());
+ }
+
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
+
AccountHeader accountHeader = mAccount;
for(IProfile profile : accountHeader.getProfiles()){
@@ -402,7 +383,6 @@ public void onResume(){
return;
}
- String notebookUID = null;
if(fromDetailActivity || tabletMode){
if(selectedNotebookName != null) {
Notebook nb = notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedNotebookName);
@@ -428,12 +408,14 @@ class AccountChangeThread extends Thread{
private ActiveAccount activeAccount;
private String notebookUID;
private boolean changeDrawerAccount;
+ private boolean resetDrawerSelection;
AccountChangeThread(String account, String rootFolder) {
this.account = account;
this.rootFolder = rootFolder;
notebookUID = null;
changeDrawerAccount = true;
+ resetDrawerSelection = false;
}
AccountChangeThread(ActiveAccount activeAccount) {
@@ -450,6 +432,11 @@ public void disableProfileChangeing(){
changeDrawerAccount = false;
}
+ public void resetDrawerSelection(){
+ this.resetDrawerSelection = true;
+ }
+
+
@Override
public void run() {
if(activeAccount == null) {
@@ -475,8 +462,15 @@ public void run() {
List notes;
DataCache noteCache = dataCache.getNoteCache(activeAccount);
- if(notebookUID == null){
+ String selectedTagName = Utils.getSelectedTagName(activity);
+ if(resetDrawerSelection || (notebookUID == null && selectedTagName == null)){
+ if(resetDrawerSelection){
+ Utils.setSelectedNotebookName(activity, null);
+ Utils.setSelectedTagName(activity, null);
+ }
notes = noteCache.getNotes();
+ }else if(selectedTagName != null){
+ notes = notetagRepository.getNotesWith(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedTagName);
}else{
notes = noteCache.getNotesFromNotebook(notebookUID);
}
@@ -647,25 +641,24 @@ public void changeNoteSelection(BaseDrawerItem drawerItem){
String tag = drawerItem.getTag() == null || drawerItem.getTag().toString().trim().length() == 0 ? "ALL_NOTEBOOK" : drawerItem.getTag().toString();
List notes;
ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
- SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
if("NOTEBOOK".equalsIgnoreCase(tag)){
Notebook notebook = notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), drawerItem.getName());
notes = notesRepository.getFromNotebook(activeAccount.getAccount(),activeAccount.getRootFolder(),notebook.getIdentification().getUid());
- selectedNotebookName = notebook.getSummary();
- sharedPref.edit().putString(Utils.SELECTED_NOTEBOOK_NAME,selectedNotebookName);
+ Utils.setSelectedNotebookName(activity, notebook.getSummary());
+ Utils.setSelectedTagName(activity,null);
}else if("TAG".equalsIgnoreCase(tag)){
notes = notetagRepository.getNotesWith(activeAccount.getAccount(), activeAccount.getRootFolder(), drawerItem.getName());
- selectedNotebookName = null;
- sharedPref.edit().remove(Utils.SELECTED_NOTEBOOK_NAME);
+ Utils.setSelectedNotebookName(activity, null);
+ Utils.setSelectedTagName(activity,drawerItem.getName());
}else if("ALL_NOTES".equalsIgnoreCase(tag)){
notes = notesRepository.getAll();
- selectedNotebookName = null;
- sharedPref.edit().remove(Utils.SELECTED_NOTEBOOK_NAME);
+ Utils.setSelectedNotebookName(activity, null);
+ Utils.setSelectedTagName(activity,null);
}else{
notes = notesRepository.getAll(activeAccount.getAccount(),activeAccount.getRootFolder());
- selectedNotebookName = null;
- sharedPref.edit().remove(Utils.SELECTED_NOTEBOOK_NAME);
+ Utils.setSelectedNotebookName(activity, null);
+ Utils.setSelectedTagName(activity,null);
}
if(mAdapter != null) {
@@ -757,6 +750,7 @@ public void onClick(View v) {
ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();
Intent intent = new Intent(activity,DetailActivity.class);
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
Notebook notebook = selectedNotebookName == null ? null : notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedNotebookName);
if(notebookRepository.getAll(activeAccount.getAccount(),activeAccount.getRootFolder()).isEmpty()){
@@ -884,10 +878,8 @@ public void onClick(DialogInterface dialog, int which) {
AuditInformation audit = new AuditInformation(now,now);
String value = textField.getText().toString();
- selectedNotebookName = value;
- SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
- sharedPref.edit().putString(Utils.SELECTED_NOTEBOOK_NAME,selectedNotebookName);
+ Utils.setSelectedNotebookName(activity,value);
Notebook nb = new Notebook(ident,audit, Note.Classification.PUBLIC, value);
nb.setDescription(value);
@@ -972,12 +964,17 @@ public void run() {
selection--;
}
+ String selectedNotebookName = Utils.getSelectedNotebookName(activity);
+ String selectedTagName = Utils.getSelectedTagName(activity);
if(selectedNotebookName != null){
selected = selectedNotebookName;
notebookSelected = true;
}else if(selectionName != null){
selected = selectionName;
notebookSelected = true;
+ }else if(selectedTagName != null){
+ selected = selectedTagName;
+ notebookSelected = false;
}
Collections.sort(tags);
@@ -1060,7 +1057,9 @@ public boolean onProfileChanged(View view, IProfile profile, boolean current) {
if(changed){
AccountChangeThread thread = new AccountChangeThread(account,rootFolder);
thread.disableProfileChangeing();
+ thread.resetDrawerSelection();
thread.start();
+ mDrawer.setSelection(1);
}
mDrawer.closeDrawer();