|
|
|
|
@ -18,6 +18,8 @@ package net.micode.notes.data;
|
|
|
|
|
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
public class Notes {
|
|
|
|
|
private static final String UTILITY_CLASS = "Utility class";
|
|
|
|
|
private static final String CONTENT = "content://";
|
|
|
|
|
public static final String AUTHORITY = "micode_notes";
|
|
|
|
|
public static final String TAG = "Notes";
|
|
|
|
|
public static final int TYPE_NOTE = 0;
|
|
|
|
|
@ -47,6 +49,10 @@ public class Notes {
|
|
|
|
|
public static final int TYPE_WIDGET_4X = 1;
|
|
|
|
|
|
|
|
|
|
public static class DataConstants {
|
|
|
|
|
private DataConstants()
|
|
|
|
|
{
|
|
|
|
|
throw new IllegalStateException(UTILITY_CLASS);
|
|
|
|
|
}
|
|
|
|
|
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
|
|
|
|
|
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
|
|
|
|
|
}
|
|
|
|
|
@ -54,14 +60,26 @@ public class Notes {
|
|
|
|
|
/**
|
|
|
|
|
* Uri to query all notes and folders
|
|
|
|
|
*/
|
|
|
|
|
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
|
|
|
|
|
public static final Uri CONTENT_NOTE_URI = Uri.parse(CONTENT + AUTHORITY + "/note");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Uri to query data
|
|
|
|
|
*/
|
|
|
|
|
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
|
|
|
|
|
|
|
|
|
|
public interface NoteColumns {
|
|
|
|
|
public static final Uri CONTENT_DATA_URI = Uri.parse(CONTENT + AUTHORITY + "/data");
|
|
|
|
|
//常量接口模式是对接口的一种不良使用。
|
|
|
|
|
//一个类在内部使用一些常量是一个实现细节。
|
|
|
|
|
/*
|
|
|
|
|
实现一个常量接口会导致这个实现细节泄露到该类的输出API中。对于一个类的用户来说,该类实现了一个常量接口是没有任何意义的。
|
|
|
|
|
事实上,这甚至会使他们感到困惑。更糟糕的是,它代表了一种承诺:如果在未来的版本中,类被修改得不再需要使用常量,它仍然必须实现这个接口以确保二进制的兼容性。如果一个非最终版本的类实现了一个常量接口它的所有子类都会被接口中的常量污染它们的名字空间。
|
|
|
|
|
当一个接口只由字段组成,没有任何其他成员时,这个规则就会引起问题。
|
|
|
|
|
*/
|
|
|
|
|
//解决方法:将常量接口改成常量类或者枚举类
|
|
|
|
|
public final class NoteColumns {
|
|
|
|
|
//实用程序类(实用程序类是定义一组执行通用功能的方法的类),不能用自带的构造函数,实用程序类一般都是包含的静态方法。 它通常是用来包装一些的“有用”的算法
|
|
|
|
|
private NoteColumns()
|
|
|
|
|
{
|
|
|
|
|
throw new IllegalStateException(UTILITY_CLASS);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* The unique ID for a row
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
@ -167,7 +185,11 @@ public class Notes {
|
|
|
|
|
public static final String VERSION = "version";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface DataColumns {
|
|
|
|
|
public final class DataColumns {
|
|
|
|
|
private DataColumns()
|
|
|
|
|
{
|
|
|
|
|
throw new IllegalStateException(UTILITY_CLASS);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* The unique ID for a row
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
@ -241,12 +263,16 @@ public class Notes {
|
|
|
|
|
public static final String DATA5 = "data5";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final class TextNote implements DataColumns {
|
|
|
|
|
public static final class TextNote {
|
|
|
|
|
private TextNote()
|
|
|
|
|
{
|
|
|
|
|
throw new IllegalStateException(UTILITY_CLASS);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Mode to indicate the text in check list mode or not
|
|
|
|
|
* <P> Type: Integer 1:check list mode 0: normal mode </P>
|
|
|
|
|
*/
|
|
|
|
|
public static final String MODE = DATA1;
|
|
|
|
|
public static final String MODE = DataColumns.DATA1;
|
|
|
|
|
|
|
|
|
|
public static final int MODE_CHECK_LIST = 1;
|
|
|
|
|
|
|
|
|
|
@ -254,26 +280,30 @@ public class Notes {
|
|
|
|
|
|
|
|
|
|
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";
|
|
|
|
|
|
|
|
|
|
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
|
|
|
|
|
public static final Uri CONTENT_URI = Uri.parse(CONTENT + AUTHORITY + "/text_note");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final class CallNote implements DataColumns {
|
|
|
|
|
public static final class CallNote {
|
|
|
|
|
private CallNote()
|
|
|
|
|
{
|
|
|
|
|
throw new IllegalStateException(UTILITY_CLASS);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Call date for this record
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
public static final String CALL_DATE = DATA1;
|
|
|
|
|
public static final String CALL_DATE = DataColumns.DATA1;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Phone number for this record
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
public static final String PHONE_NUMBER = DATA3;
|
|
|
|
|
public static final String PHONE_NUMBER = DataColumns.DATA3;
|
|
|
|
|
|
|
|
|
|
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";
|
|
|
|
|
|
|
|
|
|
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note";
|
|
|
|
|
|
|
|
|
|
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
|
|
|
|
|
public static final Uri CONTENT_URI = Uri.parse(CONTENT + AUTHORITY + "/call_note");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|