~mcveat/tomdroid/fix-1038968

« back to all changes in this revision

Viewing changes to src/org/tomdroid/ui/Tomdroid.java

  • Committer: noahy
  • Date: 2012-08-19 17:47:29 UTC
  • Revision ID: noahy57@gmail.com-20120819174729-377kszi0ud67fhb5
fixed note comparison, layout (lp:1038699 ), set light theme for everything

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
package org.tomdroid.ui;
26
26
 
27
27
import java.util.HashMap;
 
28
import java.util.UUID;
28
29
import java.util.regex.Matcher;
29
30
import java.util.regex.Pattern;
30
31
 
134
135
        public void onCreate(Bundle savedInstanceState) {
135
136
                super.onCreate(savedInstanceState);
136
137
                Preferences.init(this, CLEAR_PREFERENCES);
137
 
                this.context = this;
 
138
                context = this;
138
139
        main =  View.inflate(this, R.layout.main, null);
139
 
 
140
 
                if (Preferences.getString(Preferences.Key.THEME_CHOICE).equals("dark"))
141
 
                        super.setTheme( R.style.DarkTheme);
142
140
                
143
141
        setContentView(main);
144
142
                
171
169
                listEmptyView = (TextView) findViewById(R.id.list_empty);
172
170
                getListView().setEmptyView(listEmptyView);
173
171
                
174
 
                // FIXME: why is this necessary?
175
 
                if (Preferences.getString(Preferences.Key.THEME_CHOICE).equals("dark"))
176
 
                        getListView().setBackgroundColor(0xFF000000);
177
 
                
178
172
                registerForContextMenu(findViewById(android.R.id.list));
179
173
                
180
174
                // add note to pane for tablet
188
182
                        updateTextAttributes();
189
183
                        showNoteInPane(-1);
190
184
                }
 
185
                
 
186
                // dev function, uncomment to test out the compare_notes activity
 
187
                //compareTestNotes();
191
188
        }
192
189
        private void updateTextAttributes() {
193
190
                float baseSize = Float.parseFloat(Preferences.getString(Preferences.Key.BASE_TEXT_SIZE));
961
958
                if(rightPane != null)
962
959
                        showNoteInPane(lastIndex);
963
960
        }
 
961
        
 
962
        // dev function, used for testing out the note conflict resolution
 
963
        public void compareTestNotes() {
 
964
                int position = 0;
 
965
                Cursor item = (Cursor) adapter.getItem(position);
 
966
                if (item == null || item.getCount() == 0) {
 
967
            TLog.d(TAG, "Index {0} not found in list", position);
 
968
            title.setText("");
 
969
            content.setText("");
 
970
                        return;
 
971
                }
 
972
                long noteId = item.getInt(item.getColumnIndexOrThrow(Note.ID)); 
 
973
                uri = Uri.parse(CONTENT_URI + "/" + noteId);
 
974
 
 
975
                TLog.d(TAG, "Getting note {0}", position);
 
976
 
 
977
        Note localNote = NoteManager.getNote(this, uri);
 
978
                Note remoteNote = new Note();
 
979
 
 
980
                remoteNote.setGuid(localNote.getGuid());
 
981
                remoteNote.setTitle(localNote.getTitle()+" Remote");
 
982
                Time time= new Time();
 
983
                remoteNote.setLastChangeDate(time.format3339(false));
 
984
                remoteNote.setXmlContent(localNote.getXmlContent()+"\nLorem ipsum dolor sit amet, \nconsetetur sadipscing elitr, \nsed diam nonumyeirmod tempor invidunt ut la");
 
985
                
 
986
                int compareBoth = Time.compare(localNote.getLastChangeDate(), remoteNote.getLastChangeDate());
 
987
                
 
988
                TLog.v(TAG, "note conflict... showing resolution dialog TITLE:{0} GUID:{1}", localNote.getTitle(), localNote.getGuid());
 
989
                
 
990
                // send everything to Tomdroid so it can show Sync Dialog
 
991
                
 
992
            Bundle bundle = new Bundle();       
 
993
                bundle.putString("title",remoteNote.getTitle());
 
994
                bundle.putString("file",remoteNote.getFileName());
 
995
                bundle.putString("guid",remoteNote.getGuid());
 
996
                bundle.putString("date",remoteNote.getLastChangeDate().format3339(false));
 
997
                bundle.putString("content", remoteNote.getXmlContent());
 
998
                bundle.putString("tags", remoteNote.getTags());
 
999
                bundle.putInt("datediff", compareBoth);
 
1000
                
 
1001
                // put local guid if conflicting titles
 
1002
 
 
1003
                if(!remoteNote.getGuid().equals(localNote.getGuid()))
 
1004
                        bundle.putString("localGUID", localNote.getGuid());
 
1005
                
 
1006
                Intent intent = new Intent(this, CompareNotes.class);   
 
1007
                intent.putExtras(bundle);
 
1008
 
 
1009
                startActivity(intent);
 
1010
        }
964
1011
}