Compare commits
No commits in common. 'main' and '任少龙_branch' have entirely different histories.
main
...
任少龙_branch
After Width: | Height: | Size: 205 KiB |
Before Width: | Height: | Size: 385 KiB |
@ -1,9 +0,0 @@
|
|||||||
# generated files
|
|
||||||
bin/
|
|
||||||
gen/
|
|
||||||
|
|
||||||
# Local configuration file (sdk path, etc)
|
|
||||||
project.properties
|
|
||||||
.settings/
|
|
||||||
.classpath
|
|
||||||
.project
|
|
@ -1,5 +0,0 @@
|
|||||||
<project version="4">
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/Notes-master.iml" filepath="$PROJECT_DIR$/Notes-master.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,190 +0,0 @@
|
|||||||
|
|
||||||
Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.micode.notes.data;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.provider.ContactsContract.CommonDataKinds.Phone;
|
|
||||||
import android.provider.ContactsContract.Data;
|
|
||||||
import android.telephony.PhoneNumberUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class Contact {
|
|
||||||
private static HashMap<String, String> sContactCache;
|
|
||||||
private static final String TAG = "Contact";
|
|
||||||
|
|
||||||
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
|
|
||||||
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
|
|
||||||
+ " AND " + Data.RAW_CONTACT_ID + " IN "
|
|
||||||
+ "(SELECT raw_contact_id "
|
|
||||||
+ " FROM phone_lookup"
|
|
||||||
+ " WHERE min_match = '+')";
|
|
||||||
|
|
||||||
public static String getContact(Context context, String phoneNumber) {
|
|
||||||
if(sContactCache == null) {
|
|
||||||
sContactCache = new HashMap<String, String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sContactCache.containsKey(phoneNumber)) {
|
|
||||||
return sContactCache.get(phoneNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
String selection = CALLER_ID_SELECTION.replace("+",
|
|
||||||
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
|
|
||||||
Cursor cursor = context.getContentResolver().query(
|
|
||||||
Data.CONTENT_URI,
|
|
||||||
new String [] { Phone.DISPLAY_NAME },
|
|
||||||
selection,
|
|
||||||
new String[] { phoneNumber },
|
|
||||||
null);
|
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
try {
|
|
||||||
String name = cursor.getString(0);
|
|
||||||
sContactCache.put(phoneNumber, name);
|
|
||||||
return name;
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
Log.e(TAG, " Cursor get string error " + e.toString());
|
|
||||||
return null;
|
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "No contact matched with number:" + phoneNumber);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,279 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.micode.notes.data;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
public class Notes {
|
|
||||||
public static final String AUTHORITY = "micode_notes";
|
|
||||||
public static final String TAG = "Notes";
|
|
||||||
public static final int TYPE_NOTE = 0;
|
|
||||||
public static final int TYPE_FOLDER = 1;
|
|
||||||
public static final int TYPE_SYSTEM = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Following IDs are system folders' identifiers
|
|
||||||
* {@link Notes#ID_ROOT_FOLDER } is default folder
|
|
||||||
* {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder
|
|
||||||
* {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records
|
|
||||||
*/
|
|
||||||
public static final int ID_ROOT_FOLDER = 0;
|
|
||||||
public static final int ID_TEMPARAY_FOLDER = -1;
|
|
||||||
public static final int ID_CALL_RECORD_FOLDER = -2;
|
|
||||||
public static final int ID_TRASH_FOLER = -3;
|
|
||||||
|
|
||||||
public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date";
|
|
||||||
public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id";
|
|
||||||
public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id";
|
|
||||||
public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type";
|
|
||||||
public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
|
|
||||||
public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";
|
|
||||||
|
|
||||||
public static final int TYPE_WIDGET_INVALIDE = -1;
|
|
||||||
public static final int TYPE_WIDGET_2X = 0;
|
|
||||||
public static final int TYPE_WIDGET_4X = 1;
|
|
||||||
|
|
||||||
public static class DataConstants {
|
|
||||||
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
|
|
||||||
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uri to query all notes and folders
|
|
||||||
*/
|
|
||||||
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 {
|
|
||||||
/**
|
|
||||||
* The unique ID for a row
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String ID = "_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The parent's id for note or folder
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String PARENT_ID = "parent_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created data for note or folder
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String CREATED_DATE = "created_date";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Latest modified date
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String MODIFIED_DATE = "modified_date";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alert date
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String ALERTED_DATE = "alert_date";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Folder's name or text content of note
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String SNIPPET = "snippet";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note's widget id
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String WIDGET_ID = "widget_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note's widget type
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String WIDGET_TYPE = "widget_type";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note's background color's id
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String BG_COLOR_ID = "bg_color_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For text note, it doesn't has attachment, for multi-media
|
|
||||||
* note, it has at least one attachment
|
|
||||||
* <P> Type: INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String HAS_ATTACHMENT = "has_attachment";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Folder's count of notes
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String NOTES_COUNT = "notes_count";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The file type: folder or note
|
|
||||||
* <P> Type: INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String TYPE = "type";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The last sync id
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String SYNC_ID = "sync_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sign to indicate local modified or not
|
|
||||||
* <P> Type: INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String LOCAL_MODIFIED = "local_modified";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Original parent id before moving into temporary folder
|
|
||||||
* <P> Type : INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The gtask id
|
|
||||||
* <P> Type : TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String GTASK_ID = "gtask_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The version code
|
|
||||||
* <P> Type : INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String VERSION = "version";
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface DataColumns {
|
|
||||||
/**
|
|
||||||
* The unique ID for a row
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String ID = "_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The MIME type of the item represented by this row.
|
|
||||||
* <P> Type: Text </P>
|
|
||||||
*/
|
|
||||||
public static final String MIME_TYPE = "mime_type";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The reference id to note that this data belongs to
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String NOTE_ID = "note_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created data for note or folder
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String CREATED_DATE = "created_date";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Latest modified date
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String MODIFIED_DATE = "modified_date";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data's content
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String CONTENT = "content";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
|
|
||||||
* integer data type
|
|
||||||
* <P> Type: INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String DATA1 = "data1";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
|
|
||||||
* integer data type
|
|
||||||
* <P> Type: INTEGER </P>
|
|
||||||
*/
|
|
||||||
public static final String DATA2 = "data2";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
|
|
||||||
* TEXT data type
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String DATA3 = "data3";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
|
|
||||||
* TEXT data type
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String DATA4 = "data4";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
|
|
||||||
* TEXT data type
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String DATA5 = "data5";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class TextNote implements DataColumns {
|
|
||||||
/**
|
|
||||||
* 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 int MODE_CHECK_LIST = 1;
|
|
||||||
|
|
||||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";
|
|
||||||
|
|
||||||
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 class CallNote implements DataColumns {
|
|
||||||
/**
|
|
||||||
* Call date for this record
|
|
||||||
* <P> Type: INTEGER (long) </P>
|
|
||||||
*/
|
|
||||||
public static final String CALL_DATE = DATA1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Phone number for this record
|
|
||||||
* <P> Type: TEXT </P>
|
|
||||||
*/
|
|
||||||
public static final String PHONE_NUMBER = 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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,362 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.micode.notes.data;
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import net.micode.notes.data.Notes.DataColumns;
|
|
||||||
import net.micode.notes.data.Notes.DataConstants;
|
|
||||||
import net.micode.notes.data.Notes.NoteColumns;
|
|
||||||
|
|
||||||
|
|
||||||
public class NotesDatabaseHelper extends SQLiteOpenHelper {
|
|
||||||
private static final String DB_NAME = "note.db";
|
|
||||||
|
|
||||||
private static final int DB_VERSION = 4;
|
|
||||||
|
|
||||||
public interface TABLE {
|
|
||||||
public static final String NOTE = "note";
|
|
||||||
|
|
||||||
public static final String DATA = "data";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String TAG = "NotesDatabaseHelper";
|
|
||||||
|
|
||||||
private static NotesDatabaseHelper mInstance;
|
|
||||||
|
|
||||||
private static final String CREATE_NOTE_TABLE_SQL =
|
|
||||||
"CREATE TABLE " + TABLE.NOTE + "(" +
|
|
||||||
NoteColumns.ID + " INTEGER PRIMARY KEY," +
|
|
||||||
NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.ALERTED_DATE + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.BG_COLOR_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
|
|
||||||
NoteColumns.HAS_ATTACHMENT + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
|
|
||||||
NoteColumns.NOTES_COUNT + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.SNIPPET + " TEXT NOT NULL DEFAULT ''," +
|
|
||||||
NoteColumns.TYPE + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.WIDGET_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.WIDGET_TYPE + " INTEGER NOT NULL DEFAULT -1," +
|
|
||||||
NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
|
|
||||||
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
|
|
||||||
")";
|
|
||||||
|
|
||||||
private static final String CREATE_DATA_TABLE_SQL =
|
|
||||||
"CREATE TABLE " + TABLE.DATA + "(" +
|
|
||||||
DataColumns.ID + " INTEGER PRIMARY KEY," +
|
|
||||||
DataColumns.MIME_TYPE + " TEXT NOT NULL," +
|
|
||||||
DataColumns.NOTE_ID + " INTEGER NOT NULL DEFAULT 0," +
|
|
||||||
NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
|
|
||||||
NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
|
|
||||||
DataColumns.CONTENT + " TEXT NOT NULL DEFAULT ''," +
|
|
||||||
DataColumns.DATA1 + " INTEGER," +
|
|
||||||
DataColumns.DATA2 + " INTEGER," +
|
|
||||||
DataColumns.DATA3 + " TEXT NOT NULL DEFAULT ''," +
|
|
||||||
DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
|
|
||||||
DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
|
|
||||||
")";
|
|
||||||
|
|
||||||
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
|
|
||||||
"CREATE INDEX IF NOT EXISTS note_id_index ON " +
|
|
||||||
TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase folder's note count when move note to the folder
|
|
||||||
*/
|
|
||||||
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
|
|
||||||
"CREATE TRIGGER increase_folder_count_on_update "+
|
|
||||||
" AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
|
|
||||||
" BEGIN " +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
|
|
||||||
" WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrease folder's note count when move note from folder
|
|
||||||
*/
|
|
||||||
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
|
|
||||||
"CREATE TRIGGER decrease_folder_count_on_update " +
|
|
||||||
" AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
|
|
||||||
" BEGIN " +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
|
|
||||||
" WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
|
|
||||||
" AND " + NoteColumns.NOTES_COUNT + ">0" + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase folder's note count when insert new note to the folder
|
|
||||||
*/
|
|
||||||
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
|
|
||||||
"CREATE TRIGGER increase_folder_count_on_insert " +
|
|
||||||
" AFTER INSERT ON " + TABLE.NOTE +
|
|
||||||
" BEGIN " +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
|
|
||||||
" WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrease folder's note count when delete note from the folder
|
|
||||||
*/
|
|
||||||
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =
|
|
||||||
"CREATE TRIGGER decrease_folder_count_on_delete " +
|
|
||||||
" AFTER DELETE ON " + TABLE.NOTE +
|
|
||||||
" BEGIN " +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
|
|
||||||
" WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
|
|
||||||
" AND " + NoteColumns.NOTES_COUNT + ">0;" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update note's content when insert data with type {@link DataConstants#NOTE}
|
|
||||||
*/
|
|
||||||
private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =
|
|
||||||
"CREATE TRIGGER update_note_content_on_insert " +
|
|
||||||
" AFTER INSERT ON " + TABLE.DATA +
|
|
||||||
" WHEN new." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
|
|
||||||
" BEGIN" +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
|
|
||||||
" WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update note's content when data with {@link DataConstants#NOTE} type has changed
|
|
||||||
*/
|
|
||||||
private static final String DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER =
|
|
||||||
"CREATE TRIGGER update_note_content_on_update " +
|
|
||||||
" AFTER UPDATE ON " + TABLE.DATA +
|
|
||||||
" WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
|
|
||||||
" BEGIN" +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
|
|
||||||
" WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update note's content when data with {@link DataConstants#NOTE} type has deleted
|
|
||||||
*/
|
|
||||||
private static final String DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER =
|
|
||||||
"CREATE TRIGGER update_note_content_on_delete " +
|
|
||||||
" AFTER delete ON " + TABLE.DATA +
|
|
||||||
" WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
|
|
||||||
" BEGIN" +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.SNIPPET + "=''" +
|
|
||||||
" WHERE " + NoteColumns.ID + "=old." + DataColumns.NOTE_ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete datas belong to note which has been deleted
|
|
||||||
*/
|
|
||||||
private static final String NOTE_DELETE_DATA_ON_DELETE_TRIGGER =
|
|
||||||
"CREATE TRIGGER delete_data_on_delete " +
|
|
||||||
" AFTER DELETE ON " + TABLE.NOTE +
|
|
||||||
" BEGIN" +
|
|
||||||
" DELETE FROM " + TABLE.DATA +
|
|
||||||
" WHERE " + DataColumns.NOTE_ID + "=old." + NoteColumns.ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete notes belong to folder which has been deleted
|
|
||||||
*/
|
|
||||||
private static final String FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER =
|
|
||||||
"CREATE TRIGGER folder_delete_notes_on_delete " +
|
|
||||||
" AFTER DELETE ON " + TABLE.NOTE +
|
|
||||||
" BEGIN" +
|
|
||||||
" DELETE FROM " + TABLE.NOTE +
|
|
||||||
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move notes belong to folder which has been moved to trash folder
|
|
||||||
*/
|
|
||||||
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
|
|
||||||
"CREATE TRIGGER folder_move_notes_on_trash " +
|
|
||||||
" AFTER UPDATE ON " + TABLE.NOTE +
|
|
||||||
" WHEN new." + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
|
|
||||||
" BEGIN" +
|
|
||||||
" UPDATE " + TABLE.NOTE +
|
|
||||||
" SET " + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
|
|
||||||
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
|
|
||||||
" END";
|
|
||||||
|
|
||||||
public NotesDatabaseHelper(Context context) {
|
|
||||||
super(context, DB_NAME, null, DB_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createNoteTable(SQLiteDatabase db) {
|
|
||||||
db.execSQL(CREATE_NOTE_TABLE_SQL);
|
|
||||||
reCreateNoteTableTriggers(db);
|
|
||||||
createSystemFolder(db);
|
|
||||||
Log.d(TAG, "note table has been created");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reCreateNoteTableTriggers(SQLiteDatabase db) {
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_delete");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS delete_data_on_delete");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_insert");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS folder_delete_notes_on_delete");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS folder_move_notes_on_trash");
|
|
||||||
|
|
||||||
db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);
|
|
||||||
db.execSQL(NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);
|
|
||||||
db.execSQL(NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER);
|
|
||||||
db.execSQL(NOTE_DELETE_DATA_ON_DELETE_TRIGGER);
|
|
||||||
db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER);
|
|
||||||
db.execSQL(FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER);
|
|
||||||
db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSystemFolder(SQLiteDatabase db) {
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* call record foler for call notes
|
|
||||||
*/
|
|
||||||
values.put(NoteColumns.ID, Notes.ID_CALL_RECORD_FOLDER);
|
|
||||||
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
|
|
||||||
db.insert(TABLE.NOTE, null, values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* root folder which is default folder
|
|
||||||
*/
|
|
||||||
values.clear();
|
|
||||||
values.put(NoteColumns.ID, Notes.ID_ROOT_FOLDER);
|
|
||||||
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
|
|
||||||
db.insert(TABLE.NOTE, null, values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* temporary folder which is used for moving note
|
|
||||||
*/
|
|
||||||
values.clear();
|
|
||||||
values.put(NoteColumns.ID, Notes.ID_TEMPARAY_FOLDER);
|
|
||||||
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
|
|
||||||
db.insert(TABLE.NOTE, null, values);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create trash folder
|
|
||||||
*/
|
|
||||||
values.clear();
|
|
||||||
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
|
|
||||||
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
|
|
||||||
db.insert(TABLE.NOTE, null, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createDataTable(SQLiteDatabase db) {
|
|
||||||
db.execSQL(CREATE_DATA_TABLE_SQL);
|
|
||||||
reCreateDataTableTriggers(db);
|
|
||||||
db.execSQL(CREATE_DATA_NOTE_ID_INDEX_SQL);
|
|
||||||
Log.d(TAG, "data table has been created");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reCreateDataTableTriggers(SQLiteDatabase db) {
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_delete");
|
|
||||||
|
|
||||||
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER);
|
|
||||||
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER);
|
|
||||||
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
|
|
||||||
}
|
|
||||||
|
|
||||||
static synchronized NotesDatabaseHelper getInstance(Context context) {
|
|
||||||
if (mInstance == null) {
|
|
||||||
mInstance = new NotesDatabaseHelper(context);
|
|
||||||
}
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
createNoteTable(db);
|
|
||||||
createDataTable(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
boolean reCreateTriggers = false;
|
|
||||||
boolean skipV2 = false;
|
|
||||||
|
|
||||||
if (oldVersion == 1) {
|
|
||||||
upgradeToV2(db);
|
|
||||||
skipV2 = true; // this upgrade including the upgrade from v2 to v3
|
|
||||||
oldVersion++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldVersion == 2 && !skipV2) {
|
|
||||||
upgradeToV3(db);
|
|
||||||
reCreateTriggers = true;
|
|
||||||
oldVersion++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldVersion == 3) {
|
|
||||||
upgradeToV4(db);
|
|
||||||
oldVersion++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reCreateTriggers) {
|
|
||||||
reCreateNoteTableTriggers(db);
|
|
||||||
reCreateDataTableTriggers(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldVersion != newVersion) {
|
|
||||||
throw new IllegalStateException("Upgrade notes database to version " + newVersion
|
|
||||||
+ "fails");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upgradeToV2(SQLiteDatabase db) {
|
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
|
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
|
|
||||||
createNoteTable(db);
|
|
||||||
createDataTable(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upgradeToV3(SQLiteDatabase db) {
|
|
||||||
// drop unused triggers
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete");
|
|
||||||
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_update");
|
|
||||||
// add a column for gtask id
|
|
||||||
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_ID
|
|
||||||
+ " TEXT NOT NULL DEFAULT ''");
|
|
||||||
// add a trash system folder
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
|
|
||||||
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
|
|
||||||
db.insert(TABLE.NOTE, null, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upgradeToV4(SQLiteDatabase db) {
|
|
||||||
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
|
|
||||||
+ " INTEGER NOT NULL DEFAULT 0");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,305 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.micode.notes.data;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.SearchManager;
|
|
||||||
import android.content.ContentProvider;
|
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.UriMatcher;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import net.micode.notes.R;
|
|
||||||
import net.micode.notes.data.Notes.DataColumns;
|
|
||||||
import net.micode.notes.data.Notes.NoteColumns;
|
|
||||||
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
|
|
||||||
|
|
||||||
|
|
||||||
public class NotesProvider extends ContentProvider {
|
|
||||||
private static final UriMatcher mMatcher;
|
|
||||||
|
|
||||||
private NotesDatabaseHelper mHelper;
|
|
||||||
|
|
||||||
private static final String TAG = "NotesProvider";
|
|
||||||
|
|
||||||
private static final int URI_NOTE = 1;
|
|
||||||
private static final int URI_NOTE_ITEM = 2;
|
|
||||||
private static final int URI_DATA = 3;
|
|
||||||
private static final int URI_DATA_ITEM = 4;
|
|
||||||
|
|
||||||
private static final int URI_SEARCH = 5;
|
|
||||||
private static final int URI_SEARCH_SUGGEST = 6;
|
|
||||||
|
|
||||||
static {
|
|
||||||
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, "note/#", URI_NOTE_ITEM);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, "data", URI_DATA);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, "data/#", URI_DATA_ITEM);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, "search", URI_SEARCH);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, URI_SEARCH_SUGGEST);
|
|
||||||
mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", URI_SEARCH_SUGGEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* x'0A' represents the '\n' character in sqlite. For title and content in the search result,
|
|
||||||
* we will trim '\n' and white space in order to show more information.
|
|
||||||
*/
|
|
||||||
private static final String NOTES_SEARCH_PROJECTION = NoteColumns.ID + ","
|
|
||||||
+ NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + ","
|
|
||||||
+ "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_1 + ","
|
|
||||||
+ "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ","
|
|
||||||
+ R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + ","
|
|
||||||
+ "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
|
|
||||||
+ "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
|
|
||||||
|
|
||||||
private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
|
|
||||||
+ " FROM " + TABLE.NOTE
|
|
||||||
+ " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
|
|
||||||
+ " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
|
|
||||||
+ " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreate() {
|
|
||||||
mHelper = NotesDatabaseHelper.getInstance(getContext());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
|
||||||
String sortOrder) {
|
|
||||||
Cursor c = null;
|
|
||||||
SQLiteDatabase db = mHelper.getReadableDatabase();
|
|
||||||
String id = null;
|
|
||||||
switch (mMatcher.match(uri)) {
|
|
||||||
case URI_NOTE:
|
|
||||||
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
|
|
||||||
sortOrder);
|
|
||||||
break;
|
|
||||||
case URI_NOTE_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
c = db.query(TABLE.NOTE, projection, NoteColumns.ID + "=" + id
|
|
||||||
+ parseSelection(selection), selectionArgs, null, null, sortOrder);
|
|
||||||
break;
|
|
||||||
case URI_DATA:
|
|
||||||
c = db.query(TABLE.DATA, projection, selection, selectionArgs, null, null,
|
|
||||||
sortOrder);
|
|
||||||
break;
|
|
||||||
case URI_DATA_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id
|
|
||||||
+ parseSelection(selection), selectionArgs, null, null, sortOrder);
|
|
||||||
break;
|
|
||||||
case URI_SEARCH:
|
|
||||||
case URI_SEARCH_SUGGEST:
|
|
||||||
if (sortOrder != null || projection != null) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
|
|
||||||
}
|
|
||||||
|
|
||||||
String searchString = null;
|
|
||||||
if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) {
|
|
||||||
if (uri.getPathSegments().size() > 1) {
|
|
||||||
searchString = uri.getPathSegments().get(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
searchString = uri.getQueryParameter("pattern");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(searchString)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
searchString = String.format("%%%s%%", searchString);
|
|
||||||
c = db.rawQuery(NOTES_SNIPPET_SEARCH_QUERY,
|
|
||||||
new String[] { searchString });
|
|
||||||
} catch (IllegalStateException ex) {
|
|
||||||
Log.e(TAG, "got exception: " + ex.toString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown URI " + uri);
|
|
||||||
}
|
|
||||||
if (c != null) {
|
|
||||||
c.setNotificationUri(getContext().getContentResolver(), uri);
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uri insert(Uri uri, ContentValues values) {
|
|
||||||
SQLiteDatabase db = mHelper.getWritableDatabase();
|
|
||||||
long dataId = 0, noteId = 0, insertedId = 0;
|
|
||||||
switch (mMatcher.match(uri)) {
|
|
||||||
case URI_NOTE:
|
|
||||||
insertedId = noteId = db.insert(TABLE.NOTE, null, values);
|
|
||||||
break;
|
|
||||||
case URI_DATA:
|
|
||||||
if (values.containsKey(DataColumns.NOTE_ID)) {
|
|
||||||
noteId = values.getAsLong(DataColumns.NOTE_ID);
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Wrong data format without note id:" + values.toString());
|
|
||||||
}
|
|
||||||
insertedId = dataId = db.insert(TABLE.DATA, null, values);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown URI " + uri);
|
|
||||||
}
|
|
||||||
// Notify the note uri
|
|
||||||
if (noteId > 0) {
|
|
||||||
getContext().getContentResolver().notifyChange(
|
|
||||||
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the data uri
|
|
||||||
if (dataId > 0) {
|
|
||||||
getContext().getContentResolver().notifyChange(
|
|
||||||
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ContentUris.withAppendedId(uri, insertedId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
|
||||||
int count = 0;
|
|
||||||
String id = null;
|
|
||||||
SQLiteDatabase db = mHelper.getWritableDatabase();
|
|
||||||
boolean deleteData = false;
|
|
||||||
switch (mMatcher.match(uri)) {
|
|
||||||
case URI_NOTE:
|
|
||||||
selection = "(" + selection + ") AND " + NoteColumns.ID + ">0 ";
|
|
||||||
count = db.delete(TABLE.NOTE, selection, selectionArgs);
|
|
||||||
break;
|
|
||||||
case URI_NOTE_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
/**
|
|
||||||
* ID that smaller than 0 is system folder which is not allowed to
|
|
||||||
* trash
|
|
||||||
*/
|
|
||||||
long noteId = Long.valueOf(id);
|
|
||||||
if (noteId <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
count = db.delete(TABLE.NOTE,
|
|
||||||
NoteColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
|
|
||||||
break;
|
|
||||||
case URI_DATA:
|
|
||||||
count = db.delete(TABLE.DATA, selection, selectionArgs);
|
|
||||||
deleteData = true;
|
|
||||||
break;
|
|
||||||
case URI_DATA_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
count = db.delete(TABLE.DATA,
|
|
||||||
DataColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
|
|
||||||
deleteData = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown URI " + uri);
|
|
||||||
}
|
|
||||||
if (count > 0) {
|
|
||||||
if (deleteData) {
|
|
||||||
getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
|
|
||||||
}
|
|
||||||
getContext().getContentResolver().notifyChange(uri, null);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
|
||||||
int count = 0;
|
|
||||||
String id = null;
|
|
||||||
SQLiteDatabase db = mHelper.getWritableDatabase();
|
|
||||||
boolean updateData = false;
|
|
||||||
switch (mMatcher.match(uri)) {
|
|
||||||
case URI_NOTE:
|
|
||||||
increaseNoteVersion(-1, selection, selectionArgs);
|
|
||||||
count = db.update(TABLE.NOTE, values, selection, selectionArgs);
|
|
||||||
break;
|
|
||||||
case URI_NOTE_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
increaseNoteVersion(Long.valueOf(id), selection, selectionArgs);
|
|
||||||
count = db.update(TABLE.NOTE, values, NoteColumns.ID + "=" + id
|
|
||||||
+ parseSelection(selection), selectionArgs);
|
|
||||||
break;
|
|
||||||
case URI_DATA:
|
|
||||||
count = db.update(TABLE.DATA, values, selection, selectionArgs);
|
|
||||||
updateData = true;
|
|
||||||
break;
|
|
||||||
case URI_DATA_ITEM:
|
|
||||||
id = uri.getPathSegments().get(1);
|
|
||||||
count = db.update(TABLE.DATA, values, DataColumns.ID + "=" + id
|
|
||||||
+ parseSelection(selection), selectionArgs);
|
|
||||||
updateData = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown URI " + uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
if (updateData) {
|
|
||||||
getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
|
|
||||||
}
|
|
||||||
getContext().getContentResolver().notifyChange(uri, null);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String parseSelection(String selection) {
|
|
||||||
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
|
|
||||||
StringBuilder sql = new StringBuilder(120);
|
|
||||||
sql.append("UPDATE ");
|
|
||||||
sql.append(TABLE.NOTE);
|
|
||||||
sql.append(" SET ");
|
|
||||||
sql.append(NoteColumns.VERSION);
|
|
||||||
sql.append("=" + NoteColumns.VERSION + "+1 ");
|
|
||||||
|
|
||||||
if (id > 0 || !TextUtils.isEmpty(selection)) {
|
|
||||||
sql.append(" WHERE ");
|
|
||||||
}
|
|
||||||
if (id > 0) {
|
|
||||||
sql.append(NoteColumns.ID + "=" + String.valueOf(id));
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(selection)) {
|
|
||||||
String selectString = id > 0 ? parseSelection(selection) : selection;
|
|
||||||
for (String args : selectionArgs) {
|
|
||||||
selectString = selectString.replaceFirst("\\?", args);
|
|
||||||
}
|
|
||||||
sql.append(selectString);
|
|
||||||
}
|
|
||||||
|
|
||||||
mHelper.getWritableDatabase().execSQL(sql.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType(Uri uri) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
@ -0,0 +1 @@
|
|||||||
|
Notes-master
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveExternalAnnotations" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,9 @@
|
|||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -0,0 +1,60 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
packaging {
|
||||||
|
resources.excludes.add("META-INF/DEPENDENCIES");
|
||||||
|
resources.excludes.add("META-INF/NOTICE");
|
||||||
|
resources.excludes.add("META-INF/LICENSE");
|
||||||
|
resources.excludes.add("META-INF/LICENSE.txt");
|
||||||
|
resources.excludes.add("META-INF/NOTICE.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace = "net.micode.notes"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "net.micode.notes"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 34
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
implementation(libs.appcompat)
|
||||||
|
implementation(libs.material)
|
||||||
|
implementation(libs.activity)
|
||||||
|
implementation(libs.constraintlayout)
|
||||||
|
// implementation(fileTree(mapOf(
|
||||||
|
// "dir" to "D:\\Notesmaster\\httpcomponents-client-4.5.14-bin\\lib",
|
||||||
|
// "include" to listOf("*.aar", "*.jar"),
|
||||||
|
// "exclude" to listOf("")
|
||||||
|
// )))
|
||||||
|
implementation(files("D:\\Notesmaster\\httpcomponents-client-4.5.14-bin\\lib\\httpclient-osgi-4.5.14.jar"))
|
||||||
|
implementation(files("D:\\Notesmaster\\httpcomponents-client-4.5.14-bin\\lib\\httpclient-win-4.5.14.jar"))
|
||||||
|
implementation(files("D:\\Notesmaster\\httpcomponents-client-4.5.14-bin\\lib\\httpcore-4.4.16.jar"))
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
androidTestImplementation(libs.ext.junit)
|
||||||
|
androidTestImplementation(libs.espresso.core)
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,26 @@
|
|||||||
|
package net.micode.notes;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("net.micode.notes", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package net.micode.notes;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
EdgeToEdge.enable(this);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||||
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 443 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 554 KiB After Width: | Height: | Size: 554 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |