Skip to content

Commit

Permalink
bugfixing and added support for Android 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
konradrenner committed Jun 30, 2015
1 parent d0b6d31 commit 48fd499
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 68 deletions.
6 changes: 3 additions & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="iconics-1.1.0" level="project" />
<orderEntry type="library" exported="" name="kore-javamail-1.0.1" level="project" />
<orderEntry type="library" exported="" name="materialdrawer-3.0.8" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="kolabnotes-java-0.6.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="richeditor-android-0.0.6" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ambilwarna-2.0" level="project" />
</component>
</module>
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

public class DetailActivity extends AppCompatActivity implements OnFragmentFinished{

public static String FROM_DETAIL = "fromDetailTrue";

private DetailFragment detailFragment;

@Override
Expand All @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/kore/kolabnotes/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
53 changes: 53 additions & 0 deletions app/src/main/java/org/kore/kolabnotes/android/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 48fd499

Please sign in to comment.