OSDN Git Service

T28079
authorYuji Konishi <yuji.k64613@gmail.com>
Sat, 14 Apr 2012 10:20:15 +0000 (19:20 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Sat, 14 Apr 2012 10:20:15 +0000 (19:20 +0900)
workspace/EverClip/src/com/yuji/ec/NoteTypeListActivity.java
workspace/EverClip/src/com/yuji/ec/NoteUpdatorActivity.java
workspace/EverClip/src/com/yuji/ec/SettingActivity.java
workspace/EverClip/src/com/yuji/ec/common/Constant.java
workspace/EverClip/src/com/yuji/ec/task/NoteUpdateTask.java
workspace/EverClip/src/com/yuji/ec/utility/NoteUpdator.java

index bb20472..9a47460 100644 (file)
@@ -48,7 +48,7 @@ public class NoteTypeListActivity extends BaseActivity {
                });\r
 \r
                // updateList();\r
-               int noteItemType = pref.getInt(Constant.PREF_NOTE_ITEM_TYPE,\r
+               int noteItemType = pref.getInt(Constant.PREF_NOTE_ITEM_TYPE_TMP,\r
                                Constant.NOTE_ITEM_TYPE_ALL);\r
                NoteTypeListTask task = new NoteTypeListTask(this, noteItemType);\r
                AsyncTaskCommand command = new AsyncTaskCommand(this, task);\r
index be7371b..5a600de 100644 (file)
@@ -1,5 +1,6 @@
 package com.yuji.ec;
 
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
@@ -13,6 +14,7 @@ import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.yuji.ec.common.CommonUtil;
 import com.yuji.ec.common.Constant;
 import com.yuji.ec.task.NoteUpdateTask;
 import com.yuji.ec.utility.AsyncTaskCommand;
@@ -110,9 +112,12 @@ public class NoteUpdatorActivity extends BaseActivity {
                        Bundle ex = data.getExtras();
                        String guid = ex.getString(Constant.EXTRA_GUID);
                        String title = ex.getString(Constant.EXTRA_TITLE);
+                       int noteItemType = noteTypeSpinner.getSelectedItemPosition();
 
+                       this.guid = guid;
                        pref.put(Constant.PREF_NOTE_ITEM_GUID_TMP, guid);
                        pref.put(Constant.PREF_NOTE_ITEM_TEXT, title);
+                       pref.put(Constant.PREF_NOTE_ITEM_GUID_TYPE_TMP, noteItemType);
                        pref.update();
 
                        noteTypeView.setText(title);
@@ -132,7 +137,9 @@ public class NoteUpdatorActivity extends BaseActivity {
        }
 
        private void updateButtonOnClick() {
-               NoteUpdateTask task = new NoteUpdateTask(this);
+               int noteItemType = noteTypeSpinner.getSelectedItemPosition();
+
+               NoteUpdateTask task = new NoteUpdateTask(this, noteItemType, guid);
                AsyncTaskCommand command = new AsyncTaskCommand(this, task);
                // command.setTitle(getString(R.string.noteListGetting)); // TODO
                command.setTitle("Title"); // TODO
@@ -159,10 +166,57 @@ public class NoteUpdatorActivity extends BaseActivity {
        }
 
        private void setStatus() {
-               int noteType = noteTypeSpinner.getSelectedItemPosition();
+               /*
+                       \81\9b\91Î\8fÛ
+                               type
+                               guid
+                               guidType(guid\82Ì\90Ý\92è\83^\83C\83~\83\93\83O\82Å\90Ý\92è\81A\8f\89\8aú\92lnull)
+                       
+                       \81\9b\8dX\90V\83{\83^\83\93\82Ì\8a\88\90«\83\8b\81[\83\8b(\8a\88\90«\82Ì\8fð\8c\8f)    
+                               type1=type2
+                               guid1<>guid2
+                               guidType=type2
+                               
+                               type1<>type2
+                               guidType=type2
+                */
+               int srcNoteItemType = pref.getInt(Constant.PREF_NOTE_ITEM_TYPE,
+                               Constant.NOTE_ITEM_TYPE_ALL);
+               String srcGuid = pref.get(Constant.PREF_NOTE_ITEM_GUID);
+               
+               int noteItemType = noteTypeSpinner.getSelectedItemPosition();
+               int guidType = pref.getInt(Constant.PREF_NOTE_ITEM_GUID_TYPE_TMP, -1);
+               
+               boolean enabled = false;
+               if (noteItemType == Constant.NOTE_ITEM_TYPE_ALL){
+                       enabled = true;
+               }
+               else if (srcNoteItemType == noteItemType){
+                       if (!CommonUtil.isNull(guid) && !guid.equals(srcGuid)){
+                               if (guidType >= 0 && guidType == noteItemType){
+                                       enabled = true;
+                               }
+                       }
+               }
+               else {
+                       if (guidType >= 0 && guidType == noteItemType){
+                               enabled = true;
+                       }                       
+               }
+
+               updateButton.setEnabled(enabled);
                noteTypeLayout
-                               .setVisibility((noteType == Constant.NOTE_ITEM_TYPE_ALL) ? View.GONE
+                               .setVisibility((noteItemType == Constant.NOTE_ITEM_TYPE_ALL) ? View.GONE
                                                : View.VISIBLE);
        }
 
+       public static void init(Context context){
+               EditPrefUtil pref = new EditPrefUtil(context);
+               
+               pref.copy(Constant.PREF_NOTE_ITEM_TYPE, Constant.PREF_NOTE_ITEM_TYPE_TMP);
+               pref.copy(Constant.PREF_NOTE_ITEM_GUID, Constant.PREF_NOTE_ITEM_GUID_TMP);
+               pref.remove(Constant.PREF_NOTE_ITEM_GUID_TYPE_TMP);             
+               
+               pref.update();
+       }       
 }
index 167f65d..0013feb 100644 (file)
@@ -3,6 +3,7 @@ package com.yuji.ec;
 import java.util.Calendar;
 
 import android.app.TimePickerDialog;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.KeyEvent;
@@ -282,9 +283,12 @@ public class SettingActivity extends BaseActivity {
 //     }
 
        private void noteButtonOnClick(){
-               pref.copy(Constant.PREF_NOTE_ITEM_TYPE, Constant.PREF_NOTE_ITEM_TYPE_TMP);
-               pref.copy(Constant.PREF_NOTE_ITEM_GUID, Constant.PREF_NOTE_ITEM_GUID_TMP);
+//             pref.copy(Constant.PREF_NOTE_ITEM_TYPE, Constant.PREF_NOTE_ITEM_TYPE_TMP);
+//             pref.copy(Constant.PREF_NOTE_ITEM_GUID, Constant.PREF_NOTE_ITEM_GUID_TMP);
+//             pref.remove(Constant.PREF_NOTE_ITEM_GUID_TYPE_TMP);
+//             pref.update();
                
+               NoteUpdatorActivity.init(this);
                Intent intent = new Intent(this, (Class<?>) NoteUpdatorActivity.class);
                startActivityForResult(intent, 1); // TODO              
        }
@@ -337,6 +341,14 @@ public class SettingActivity extends BaseActivity {
 
        protected void timeCheckBoxOnClick(CompoundButton buttonView,
                        boolean isChecked) {
+               if (isChecked){
+                       
+               }
+               else {
+                       pref.put(Constant.PREF_UPDATE_TIME_TMP, -1);                            
+                       pref.update();                  
+               }
+               
                setStatus();
        }
 
@@ -355,7 +367,10 @@ public class SettingActivity extends BaseActivity {
                                        
                                        updateTime = t;
                                        timeView.setText(str);
-                               }
+
+                                       pref.put(Constant.PREF_UPDATE_TIME_TMP, t);                             
+                                       pref.update();                  
+                               }
             }, hour, minute, true);
         timePickerDialog.show();
        }
@@ -401,4 +416,11 @@ public class SettingActivity extends BaseActivity {
                // noteButton.setEnabled(true);
                // headerButton.setEnabled(true);
        }
+       
+       public static void init(Context context){
+               EditPrefUtil pref = new EditPrefUtil(context);
+
+               pref.put(Constant.PREF_UPDATE_TIME_TMP, -1);                            
+               pref.update();
+       }               
 }
index 691478e..856457b 100644 (file)
@@ -8,11 +8,13 @@ public class Constant {
        public static final String PREF_NOTE_ITEM_GUID = "NOTE_ITEM_GUID";
        public static final String PREF_NOTE_ITEM_TYPE_TMP = "NOTE_ITEM_TYPE_TMP";
        public static final String PREF_NOTE_ITEM_GUID_TMP = "NOTE_ITEM_GUID_TMP";
+       public static final String PREF_NOTE_ITEM_GUID_TYPE_TMP = "NOTE_ITEM_GUID_TYPE_TMP";
        public static final String PREF_NOTE_ITEM_TEXT = "NOTE_ITEM_TEXT";
        public static final String PREF_NOTE_ORDER = "NOTE_ORDER";
        public static final String PREF_NOTE_ORDER_BY = "NOTE_ORDER_BY";
        public static final String PREF_AUTO_UPDATE = "AUTO_UPDATE";
        public static final String PREF_UPDATE_TIME = "UPDATE_TIME";
+       public static final String PREF_UPDATE_TIME_TMP = "UPDATE_TIME_TMP";
        
        public static final String EXTRA_GUID = "GUID";
        public static final String EXTRA_TITLE = "TITLE";
index 5ecb881..949d5a2 100644 (file)
@@ -14,16 +14,20 @@ public class NoteUpdateTask implements AsyncTaskIF {
        private NoteList noteList;
        private WeakReference<NoteUpdatorActivity> activityRef;
        private EvernoteUtil.Error errorCode = null;
+       private int noteItemType;
+       private String guid;
 
-       public NoteUpdateTask(NoteUpdatorActivity activity) {
+       public NoteUpdateTask(NoteUpdatorActivity activity, int noteItemType, String guid) {
                activityRef = new WeakReference<NoteUpdatorActivity>(activity);
+               this.noteItemType = noteItemType;
+               this.guid = guid;
        }
 
        public void doExecute() {
                synchronized (util) {
                        try {
                                NoteUpdator updator = new NoteUpdator();
-                               updator.update(activityRef.get());
+                               updator.update(activityRef.get(), noteItemType, guid);
                        } finally {
                                errorCode = util.getErrorCode();
                        }
index b50b12d..1eeb448 100644 (file)
@@ -13,10 +13,7 @@ import com.yuji.ec.db.Note;
 import com.yuji.ec.db.NoteDao;\r
 \r
 public class NoteUpdator {\r
-       private int itemType = Constant.NOTE_ITEM_TYPE_ALL;\r
-       private String guid = null;\r
-\r
-       public void update(Context context) {\r
+       public void update(Context context, int noteItemType, String guid) {\r
                try {\r
                        EvernoteUtil util = EvernoteUtil.getInstance();\r
                        String username = PasswordUtil.getUsername(context);\r
@@ -28,7 +25,7 @@ public class NoteUpdator {
                        }\r
 \r
                        NoteList noteList;\r
-                       switch (itemType) {\r
+                       switch (noteItemType) {\r
                        case Constant.NOTE_ITEM_TYPE_NOTE_BOOK:\r
                                noteList = util.getNoteListByNotebook(guid);\r
                                break;\r