更新了功能

master
JLY 2 months ago
parent a9cc5f93ef
commit 40cf91cf9e

@ -89,95 +89,109 @@ public class NotesProvider extends ContentProvider {
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) { String sortOrder) {
Cursor c = null; Cursor c = null;
SQLiteDatabase db = mHelper.getReadableDatabase(); SQLiteDatabase db = null;
String id = null; try {
switch (mMatcher.match(uri)) { db = mHelper.getReadableDatabase();
case URI_NOTE: String id = null;
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null, switch (mMatcher.match(uri)) {
sortOrder); case URI_NOTE:
break; c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
case URI_NOTE_ITEM: sortOrder);
id = uri.getPathSegments().get(1); break;
c = db.query(TABLE.NOTE, projection, NoteColumns.ID + "=" + id case URI_NOTE_ITEM:
+ parseSelection(selection), selectionArgs, null, null, sortOrder); id = uri.getPathSegments().get(1);
break; c = db.query(TABLE.NOTE, projection, NoteColumns.ID + "=" + id
case URI_DATA: + parseSelection(selection), selectionArgs, null, null, sortOrder);
c = db.query(TABLE.DATA, projection, selection, selectionArgs, null, null, break;
sortOrder); case URI_DATA:
break; c = db.query(TABLE.DATA, projection, selection, selectionArgs, null, null,
case URI_DATA_ITEM: sortOrder);
id = uri.getPathSegments().get(1); break;
c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id case URI_DATA_ITEM:
+ parseSelection(selection), selectionArgs, null, null, sortOrder); id = uri.getPathSegments().get(1);
break; c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id
case URI_SEARCH: + parseSelection(selection), selectionArgs, null, null, sortOrder);
case URI_SEARCH_SUGGEST: break;
if (sortOrder != null || projection != null) { case URI_SEARCH:
throw new IllegalArgumentException( case URI_SEARCH_SUGGEST:
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query"); if (sortOrder != null || projection != null) {
} throw new IllegalArgumentException(
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
}
String searchString = null; String searchString = null;
if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) { if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) {
if (uri.getPathSegments().size() > 1) { if (uri.getPathSegments().size() > 1) {
searchString = uri.getPathSegments().get(1); searchString = uri.getPathSegments().get(1);
}
} else {
searchString = uri.getQueryParameter("pattern");
} }
} else {
searchString = uri.getQueryParameter("pattern");
}
if (TextUtils.isEmpty(searchString)) { if (TextUtils.isEmpty(searchString)) {
return null; return null;
} }
try { try {
searchString = String.format("%%%s%%", searchString); searchString = String.format("%%%s%%", searchString);
c = db.rawQuery(NOTES_SNIPPET_SEARCH_QUERY, c = db.rawQuery(NOTES_SNIPPET_SEARCH_QUERY,
new String[] { searchString }); new String[] { searchString });
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
Log.e(TAG, "got exception: " + ex.toString()); Log.e(TAG, "got exception: " + ex.toString());
} }
break; break;
default: default:
throw new IllegalArgumentException("Unknown URI " + uri); throw new IllegalArgumentException("Unknown URI " + uri);
} }
if (c != null) { if (c != null) {
c.setNotificationUri(getContext().getContentResolver(), uri); c.setNotificationUri(getContext().getContentResolver(), uri);
}
} catch (Exception e) {
Log.e(TAG, "Error querying database: " + e.getMessage());
if (c != null) {
c.close();
}
return null;
} }
return c; return c;
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(Uri uri, ContentValues values) {
SQLiteDatabase db = mHelper.getWritableDatabase(); SQLiteDatabase db = null;
long dataId = 0, noteId = 0, insertedId = 0; long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) { try {
case URI_NOTE: db = mHelper.getWritableDatabase();
insertedId = noteId = db.insert(TABLE.NOTE, null, values); switch (mMatcher.match(uri)) {
break; case URI_NOTE:
case URI_DATA: insertedId = noteId = db.insert(TABLE.NOTE, null, values);
if (values.containsKey(DataColumns.NOTE_ID)) { break;
noteId = values.getAsLong(DataColumns.NOTE_ID); case URI_DATA:
} else { if (values.containsKey(DataColumns.NOTE_ID)) {
Log.d(TAG, "Wrong data format without note id:" + values.toString()); noteId = values.getAsLong(DataColumns.NOTE_ID);
} } else {
insertedId = dataId = db.insert(TABLE.DATA, null, values); Log.d(TAG, "Wrong data format without note id:" + values.toString());
break; }
default: insertedId = dataId = db.insert(TABLE.DATA, null, values);
throw new IllegalArgumentException("Unknown URI " + uri); break;
} default:
// Notify the note uri throw new IllegalArgumentException("Unknown URI " + uri);
if (noteId > 0) { }
getContext().getContentResolver().notifyChange( // Notify the note uri
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null); if (noteId > 0) {
} getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
}
// Notify the data uri // Notify the data uri
if (dataId > 0) { if (dataId > 0) {
getContext().getContentResolver().notifyChange( getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null); ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
}
} catch (Exception e) {
Log.e(TAG, "Error inserting into database: " + e.getMessage());
return null;
} }
return ContentUris.withAppendedId(uri, insertedId); return ContentUris.withAppendedId(uri, insertedId);
} }

@ -53,7 +53,7 @@ public class AlarmInitReceiver extends BroadcastReceiver {
long alertDate = c.getLong(COLUMN_ALERTED_DATE); long alertDate = c.getLong(COLUMN_ALERTED_DATE);
Intent sender = new Intent(context, AlarmReceiver.class); Intent sender = new Intent(context, AlarmReceiver.class);
sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID))); sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID)));
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, 0); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, PendingIntent.FLAG_IMMUTABLE);
AlarmManager alermManager = (AlarmManager) context AlarmManager alermManager = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE); .getSystemService(Context.ALARM_SERVICE);
alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent); alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent);

@ -27,6 +27,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -51,6 +52,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ImageButton;
import net.micode.notes.R; import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
@ -128,7 +130,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private View mFontSizeSelector; private View mFontSizeSelector;
private EditText mNoteEditor; private NoteEditText mNoteEditor;
private View mNoteEditorPanel; private View mNoteEditorPanel;
@ -149,6 +151,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
private ImageButton mBoldButton;
private ImageButton mItalicButton;
private ImageButton mTextColorButton;
private static final int[] COLORS = {
Color.BLACK, Color.RED, Color.GREEN, Color.BLUE,
Color.YELLOW, Color.CYAN, Color.MAGENTA, Color.GRAY
};
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -371,7 +381,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view); mNoteEditor = (NoteEditText) findViewById(R.id.note_edit_view);
mNoteEditorPanel = findViewById(R.id.sv_note_edit); mNoteEditorPanel = findViewById(R.id.sv_note_edit);
mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);
for (int id : sBgSelectorBtnsMap.keySet()) { for (int id : sBgSelectorBtnsMap.keySet()) {
@ -395,6 +405,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
} }
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
mBoldButton = (ImageButton) findViewById(R.id.btn_bold);
mItalicButton = (ImageButton) findViewById(R.id.btn_italic);
mTextColorButton = (ImageButton) findViewById(R.id.btn_text_color);
mBoldButton.setOnClickListener(this);
mItalicButton.setOnClickListener(this);
mTextColorButton.setOnClickListener(this);
} }
@Override @Override
@ -425,12 +443,19 @@ public class NoteEditActivity extends Activity implements OnClickListener,
setResult(RESULT_OK, intent); setResult(RESULT_OK, intent);
} }
@Override
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.btn_set_bg_color) { if (id == R.id.btn_bold) {
mNoteEditor.setBold(!mNoteEditor.isBold());
} else if (id == R.id.btn_italic) {
mNoteEditor.setItalic(!mNoteEditor.isItalic());
} else if (id == R.id.btn_text_color) {
showColorPickerDialog();
} else if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE); mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
- View.VISIBLE); View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) { } else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE); View.GONE);
@ -623,7 +648,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (mWorkingNote.getNoteId() > 0) { if (mWorkingNote.getNoteId() > 0) {
Intent intent = new Intent(this, AlarmReceiver.class); Intent intent = new Intent(this, AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId())); intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
showAlertHeader(); showAlertHeader();
if(!set) { if(!set) {
@ -870,4 +895,30 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private void showToast(int resId, int duration) { private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show(); Toast.makeText(this, resId, duration).show();
} }
private void showColorPickerDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.format_text_color);
final View colorView = getLayoutInflater().inflate(R.layout.color_picker, null);
builder.setView(colorView);
final AlertDialog dialog = builder.create();
dialog.show();
for (int i = 0; i < COLORS.length; i++) {
final int color = COLORS[i];
View colorButton = colorView.findViewWithTag("color_" + i);
if (colorButton != null) {
colorButton.setBackgroundColor(color);
colorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mNoteEditor.setTextColor(color);
dialog.dismiss();
}
});
}
}
}
} }

@ -23,6 +23,9 @@ import android.text.Selection;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.text.style.StyleSpan;
import android.text.style.ForegroundColorSpan;
import android.graphics.Color;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -31,6 +34,8 @@ import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener; import android.view.MenuItem.OnMenuItemClickListener;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.widget.EditText; import android.widget.EditText;
import android.text.Spannable;
import android.text.SpannableString;
import net.micode.notes.R; import net.micode.notes.R;
@ -214,4 +219,85 @@ public class NoteEditText extends EditText {
} }
super.onCreateContextMenu(menu); super.onCreateContextMenu(menu);
} }
public void setBold(boolean bold) {
int start = getSelectionStart();
int end = getSelectionEnd();
if (start < end) {
SpannableString spannableString = new SpannableString(getText());
if (bold) {
spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
StyleSpan[] spans = spannableString.getSpans(start, end, StyleSpan.class);
for (StyleSpan span : spans) {
if (span.getStyle() == android.graphics.Typeface.BOLD) {
spannableString.removeSpan(span);
}
}
}
setText(spannableString);
setSelection(start, end);
}
}
public void setItalic(boolean italic) {
int start = getSelectionStart();
int end = getSelectionEnd();
if (start < end) {
SpannableString spannableString = new SpannableString(getText());
if (italic) {
spannableString.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
StyleSpan[] spans = spannableString.getSpans(start, end, StyleSpan.class);
for (StyleSpan span : spans) {
if (span.getStyle() == android.graphics.Typeface.ITALIC) {
spannableString.removeSpan(span);
}
}
}
setText(spannableString);
setSelection(start, end);
}
}
public void setTextColor(int color) {
int start = getSelectionStart();
int end = getSelectionEnd();
if (start < end) {
SpannableString spannableString = new SpannableString(getText());
spannableString.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
setText(spannableString);
setSelection(start, end);
}
}
public boolean isBold() {
int start = getSelectionStart();
int end = getSelectionEnd();
if (start < end) {
SpannableString spannableString = new SpannableString(getText());
StyleSpan[] spans = spannableString.getSpans(start, end, StyleSpan.class);
for (StyleSpan span : spans) {
if (span.getStyle() == android.graphics.Typeface.BOLD) {
return true;
}
}
}
return false;
}
public boolean isItalic() {
int start = getSelectionStart();
int end = getSelectionEnd();
if (start < end) {
SpannableString spannableString = new SpannableString(getText());
StyleSpan[] spans = spannableString.getSpans(start, end, StyleSpan.class);
for (StyleSpan span : spans) {
if (span.getStyle() == android.graphics.Typeface.ITALIC) {
return true;
}
}
}
return false;
}
} }

@ -141,10 +141,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
setContentView(R.layout.note_list); setContentView(R.layout.note_list);
initResources(); initResources();
/** try {
* Insert an introduction when user firstly use this application setAppInfoFromRawRes();
*/ } catch (Exception e) {
setAppInfoFromRawRes(); Log.e(TAG, "Failed to set app info: " + e.getMessage());
// Continue without introduction note
}
} }
@Override @Override
@ -163,11 +165,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
InputStream in = null; InputStream in = null;
try { try {
in = getResources().openRawResource(R.raw.introduction); in = getResources().openRawResource(R.raw.introduction);
if (in != null) { if (in != null) {
InputStreamReader isr = new InputStreamReader(in); InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
char [] buf = new char[1024]; char[] buf = new char[1024];
int len = 0; int len = 0;
while ((len = br.read(buf)) > 0) { while ((len = br.read(buf)) > 0) {
sb.append(buf, 0, len); sb.append(buf, 0, len);
@ -177,28 +179,34 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return; return;
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Log.e(TAG, "Failed to read introduction: " + e.getMessage());
return; return;
} finally { } finally {
if(in != null) { if (in != null) {
try { try {
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block Log.e(TAG, "Failed to close introduction stream: " + e.getMessage());
e.printStackTrace();
} }
} }
} }
WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER, try {
AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE, WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
ResourceParser.RED); AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
note.setWorkingText(sb.toString()); ResourceParser.RED);
if (note.saveNote()) { if (note != null) {
sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit(); note.setWorkingText(sb.toString());
} else { if (note.saveNote()) {
Log.e(TAG, "Save introduction note error"); sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
return; } else {
Log.e(TAG, "Save introduction note error");
}
} else {
Log.e(TAG, "Failed to create empty note");
}
} catch (Exception e) {
Log.e(TAG, "Failed to create introduction note: " + e.getMessage());
} }
} }
} }
@ -206,7 +214,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
startAsyncNotesListQuery(); try {
startAsyncNotesListQuery();
} catch (Exception e) {
Log.e(TAG, "Failed to start notes query: " + e.getMessage());
Toast.makeText(this, R.string.error_loading_notes, Toast.LENGTH_SHORT).show();
}
} }
private void initResources() { private void initResources() {
@ -409,12 +422,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}; };
private void startAsyncNotesListQuery() { private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION try {
: NORMAL_SELECTION; String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null, : NORMAL_SELECTION;
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] { mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
String.valueOf(mCurrentFolderId) Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
} catch (Exception e) {
Log.e(TAG, "Failed to start notes query: " + e.getMessage());
Toast.makeText(this, R.string.error_loading_notes, Toast.LENGTH_SHORT).show();
}
} }
private final class BackgroundQueryHandler extends AsyncQueryHandler { private final class BackgroundQueryHandler extends AsyncQueryHandler {
@ -424,19 +442,30 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
@Override @Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) { protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
switch (token) { try {
case FOLDER_NOTE_LIST_QUERY_TOKEN: switch (token) {
mNotesListAdapter.changeCursor(cursor); case FOLDER_NOTE_LIST_QUERY_TOKEN:
break; if (cursor != null) {
case FOLDER_LIST_QUERY_TOKEN: mNotesListAdapter.changeCursor(cursor);
if (cursor != null && cursor.getCount() > 0) { } else {
showFolderListMenu(cursor); Log.e(TAG, "Query notes failed: cursor is null");
} else { Toast.makeText(NotesListActivity.this, R.string.error_loading_notes, Toast.LENGTH_SHORT).show();
Log.e(TAG, "Query folder failed"); }
} break;
break; case FOLDER_LIST_QUERY_TOKEN:
default: if (cursor != null && cursor.getCount() > 0) {
return; showFolderListMenu(cursor);
} else {
Log.e(TAG, "Query folder failed");
Toast.makeText(NotesListActivity.this, R.string.error_loading_folders, Toast.LENGTH_SHORT).show();
}
break;
default:
return;
}
} catch (Exception e) {
Log.e(TAG, "Error in query complete: " + e.getMessage());
Toast.makeText(NotesListActivity.this, R.string.error_loading_notes, Toast.LENGTH_SHORT).show();
} }
} }
} }

@ -111,11 +111,11 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
rv.setTextViewText(R.id.widget_text, rv.setTextViewText(R.id.widget_text,
context.getString(R.string.widget_under_visit_mode)); context.getString(R.string.widget_under_visit_mode));
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent( pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent(
context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); context, NotesListActivity.class), PendingIntent.FLAG_IMMUTABLE);
} else { } else {
rv.setTextViewText(R.id.widget_text, snippet); rv.setTextViewText(R.id.widget_text, snippet);
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent, pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_IMMUTABLE);
} }
rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent); rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent);

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M6,4h8c2.21,0 4,1.79 4,4s-1.79,4 -4,4H6V4zM6,12h9c2.21,0 4,1.79 4,4s-1.79,4 -4,4H6V12z"/>
</vector>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M2,20h20v4H2v-4zM5.49,17h2.42l1.27,-3.58h5.65L16.09,17h2.42L13.25,3h-2.5L5.49,17zM9.91,11.39l2.03,-5.79h0.12l2.03,5.79H9.91z"/>
</vector>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M10,4v3h2.21l-3.42,8H6v3h8v-3h-2.21l3.42,-8H18V4z"/>
</vector>

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="4"
android:rowCount="2">
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/black"
android:tag="color_0" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_red_dark"
android:tag="color_1" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_green_dark"
android:tag="color_2" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_blue_dark"
android:tag="color_3" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_orange_light"
android:tag="color_4" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_purple"
android:tag="color_5" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/holo_blue_light"
android:tag="color_6" />
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:background="@android:color/darker_gray"
android:tag="color_7" />
</GridLayout>
</LinearLayout>

@ -63,6 +63,39 @@
android:background="@drawable/bg_btn_set_color" /> android:background="@drawable/bg_btn_set_color" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/formatting_toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
android:background="#F5F5F5">
<ImageButton
android:id="@+id/btn_bold"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_format_bold"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/format_bold" />
<ImageButton
android:id="@+id/btn_italic"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_format_italic"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/format_italic" />
<ImageButton
android:id="@+id/btn_text_color"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_format_color_text"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/format_text_color" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/sv_note_edit" android:id="@+id/sv_note_edit"
android:layout_width="fill_parent" android:layout_width="fill_parent"

@ -132,4 +132,12 @@
<item quantity="other"><xliff:g id="number" example="15">%1$s</xliff:g> results for \"<xliff:g id="search" example="???">%2$s</xliff:g>\"</item> <item quantity="other"><xliff:g id="number" example="15">%1$s</xliff:g> results for \"<xliff:g id="search" example="???">%2$s</xliff:g>\"</item>
</plurals> </plurals>
<string name="format_bold">Bold</string>
<string name="format_italic">Italic</string>
<string name="format_text_color">Text Color</string>
<!-- Error messages -->
<string name="error_loading_notes">Failed to load notes</string>
<string name="error_loading_folders">Failed to load folders</string>
</resources> </resources>

Loading…
Cancel
Save