diff --git a/1.txt b/1.txt deleted file mode 100644 index 1f1a45f..0000000 --- a/1.txt +++ /dev/null @@ -1,6 +0,0 @@ -1121324 -334 -5662893要有人8238 -今年计划和 -健康减肥的更丰富的细胞 -韩国v和v好久不见 diff --git a/2.txt b/2.txt deleted file mode 100644 index 087b71c..0000000 --- a/2.txt +++ /dev/null @@ -1,5 +0,0 @@ -1234656798 -456455 -789461665 -sssssssssss -dddddd \ No newline at end of file diff --git a/Notes-master/.gradle/7.5/checksums/checksums.lock b/Notes-master/.gradle/7.5/checksums/checksums.lock new file mode 100644 index 0000000..7af4910 Binary files /dev/null and b/Notes-master/.gradle/7.5/checksums/checksums.lock differ diff --git a/Notes-master/.gradle/7.5/dependencies-accessors/dependencies-accessors.lock b/Notes-master/.gradle/7.5/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..d2a4fa3 Binary files /dev/null and b/Notes-master/.gradle/7.5/dependencies-accessors/dependencies-accessors.lock differ diff --git a/小米便签-Notes-master/.idea/.gitignore b/Notes-master/.gradle/7.5/dependencies-accessors/gc.properties similarity index 100% rename from 小米便签-Notes-master/.idea/.gitignore rename to Notes-master/.gradle/7.5/dependencies-accessors/gc.properties diff --git a/Notes-master/.gradle/7.5/executionHistory/executionHistory.lock b/Notes-master/.gradle/7.5/executionHistory/executionHistory.lock new file mode 100644 index 0000000..34d05f5 Binary files /dev/null and b/Notes-master/.gradle/7.5/executionHistory/executionHistory.lock differ diff --git a/Notes-master/.gradle/7.5/fileChanges/last-build.bin b/Notes-master/.gradle/7.5/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/Notes-master/.gradle/7.5/fileChanges/last-build.bin differ diff --git a/Notes-master/.gradle/7.5/fileHashes/fileHashes.bin b/Notes-master/.gradle/7.5/fileHashes/fileHashes.bin new file mode 100644 index 0000000..75bfeb2 Binary files /dev/null and b/Notes-master/.gradle/7.5/fileHashes/fileHashes.bin differ diff --git a/Notes-master/.gradle/7.5/fileHashes/fileHashes.lock b/Notes-master/.gradle/7.5/fileHashes/fileHashes.lock new file mode 100644 index 0000000..7bbbb17 Binary files /dev/null and b/Notes-master/.gradle/7.5/fileHashes/fileHashes.lock differ diff --git a/Notes-master/.gradle/7.5/gc.properties b/Notes-master/.gradle/7.5/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/Notes-master/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Notes-master/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..05c043c Binary files /dev/null and b/Notes-master/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Notes-master/.gradle/buildOutputCleanup/cache.properties b/Notes-master/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..62b9efb --- /dev/null +++ b/Notes-master/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri May 05 09:13:30 CST 2023 +gradle.version=7.5 diff --git a/Notes-master/.gradle/vcs-1/gc.properties b/Notes-master/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/小米便签-Notes-master/Notes-master/.idea/.gitignore b/Notes-master/.idea/.gitignore similarity index 100% rename from 小米便签-Notes-master/Notes-master/.idea/.gitignore rename to Notes-master/.idea/.gitignore diff --git a/Notes-master/.idea/compiler.xml b/Notes-master/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/Notes-master/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Notes-master/.idea/deploymentTargetDropDown.xml b/Notes-master/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..3f4abfb --- /dev/null +++ b/Notes-master/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Notes-master/.idea/gradle.xml b/Notes-master/.idea/gradle.xml new file mode 100644 index 0000000..6e5389e --- /dev/null +++ b/Notes-master/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/Notes-master/.idea/jarRepositories.xml b/Notes-master/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/Notes-master/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Notes-master/.idea/misc.xml b/Notes-master/.idea/misc.xml new file mode 100644 index 0000000..bdd9278 --- /dev/null +++ b/Notes-master/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/小米便签-Notes-master/.idea/vcs.xml b/Notes-master/.idea/vcs.xml similarity index 100% rename from 小米便签-Notes-master/.idea/vcs.xml rename to Notes-master/.idea/vcs.xml diff --git a/Notes-master/app/build.gradle b/Notes-master/app/build.gradle new file mode 100644 index 0000000..01816e2 --- /dev/null +++ b/Notes-master/app/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.application' + + +android { + compileSdkVersion 32 + buildToolsVersion "33.0.2" + useLibrary 'org.apache.http.legacy' + + defaultConfig { + applicationId "net.micode.notes" + minSdkVersion 14 + targetSdkVersion 31 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} +dependencies { + //noinspection GradleCompatible + + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' +} +sonarqube { + properties { + property 'sonar.sourceEncoding', 'UTF-8' + property 'sonar.projectKey', 'projectkey' //projectkey + property 'sonar.projectName', project.name //projectname + property 'sonar.sources', 'src/main/java' //源码,写这个就行 + property 'sonar.projectVersion', project.version //版本,随意 + property 'sonar.binaries”, “build/intermediates/classes' + } +} + diff --git a/Notes-master/app/src/main/AndroidManifest.xml b/Notes-master/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..64315e4 --- /dev/null +++ b/Notes-master/app/src/main/AndroidManifest.xml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/data/Contact.java b/Notes-master/app/src/main/java/net/micode/notes/data/Contact.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/data/Contact.java rename to Notes-master/app/src/main/java/net/micode/notes/data/Contact.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/data/Notes.java b/Notes-master/app/src/main/java/net/micode/notes/data/Notes.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/data/Notes.java rename to Notes-master/app/src/main/java/net/micode/notes/data/Notes.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/data/NotesDatabaseHelper.java b/Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/data/NotesDatabaseHelper.java rename to Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/data/NotesProvider.java b/Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/data/NotesProvider.java rename to Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/MetaData.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/MetaData.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/Node.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/Node.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/SqlData.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/SqlData.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/Task.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/Task.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/exception/ActionFailureException.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/exception/ActionFailureException.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/exception/NetworkFailureException.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/exception/NetworkFailureException.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java diff --git a/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java new file mode 100644 index 0000000..25edecf --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java @@ -0,0 +1,125 @@ + +/* + * 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.gtask.remote; + +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.os.AsyncTask; + +import net.micode.notes.R; +import net.micode.notes.ui.NotesListActivity; +import net.micode.notes.ui.NotesPreferenceActivity; + + +public class GTaskASyncTask extends AsyncTask { + + private static int GTASK_SYNC_NOTIFICATION_ID = 5234235; + + public interface OnCompleteListener { + void onComplete(); + } + + private Context mContext; + + private NotificationManager mNotifiManager; + + private GTaskManager mTaskManager; + + private OnCompleteListener mOnCompleteListener; + + public GTaskASyncTask(Context context, OnCompleteListener listener) { + mContext = context; + mOnCompleteListener = listener; + mNotifiManager = (NotificationManager) mContext + .getSystemService(Context.NOTIFICATION_SERVICE); + mTaskManager = GTaskManager.getInstance(); + } + + public void cancelSync() { + mTaskManager.cancelSync(); + } + + public void publishProgess(String message) { + publishProgress(new String[] { + message + }); + } + + private void showNotification(int tickerId, String content) { + PendingIntent pendingIntent; + if (tickerId != R.string.ticker_success) { + pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, + NotesPreferenceActivity.class), 0); + + } else { + pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, + NotesListActivity.class), 0); + } + + Notification.Builder builder = new Notification.Builder(mContext) + .setAutoCancel(true) + .setContentTitle(mContext.getString(R.string.app_name)) //设置标题 + .setContentText(content) //消息内容 + .setContentIntent(pendingIntent)//点击通知后跳转的页面 + .setWhen(System.currentTimeMillis()) + .setOngoing(true); + Notification notification=builder.getNotification(); + mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); + } + @Override + protected Integer doInBackground(Void... unused) { + publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity + .getSyncAccountName(mContext))); + return mTaskManager.sync(mContext, this); + } + + @Override + protected void onProgressUpdate(String... progress) { + showNotification(R.string.ticker_syncing, progress[0]); + if (mContext instanceof GTaskSyncService) { + ((GTaskSyncService) mContext).sendBroadcast(progress[0]); + } + } + + @Override + protected void onPostExecute(Integer result) { + if (result == GTaskManager.STATE_SUCCESS) { + showNotification(R.string.ticker_success, mContext.getString( + R.string.success_sync_account, mTaskManager.getSyncAccount())); + NotesPreferenceActivity.setLastSyncTime(mContext, System.currentTimeMillis()); + } else if (result == GTaskManager.STATE_NETWORK_ERROR) { + showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_network)); + } else if (result == GTaskManager.STATE_INTERNAL_ERROR) { + showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_internal)); + } else if (result == GTaskManager.STATE_SYNC_CANCELLED) { + showNotification(R.string.ticker_cancel, mContext + .getString(R.string.error_sync_cancelled)); + } + if (mOnCompleteListener != null) { + new Thread(new Runnable() { + + public void run() { + mOnCompleteListener.onComplete(); + } + }).start(); + } + } +} diff --git a/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java new file mode 100644 index 0000000..f306414 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java @@ -0,0 +1,586 @@ +/* + * 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.gtask.remote; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.accounts.AccountManagerFuture; +import android.app.Activity; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; + +import net.micode.notes.gtask.data.Node; +import net.micode.notes.gtask.data.Task; +import net.micode.notes.gtask.data.TaskList; +import net.micode.notes.gtask.exception.ActionFailureException; +import net.micode.notes.gtask.exception.NetworkFailureException; +import net.micode.notes.tool.GTaskStringUtils; +import net.micode.notes.ui.NotesPreferenceActivity; +import java.net.HttpURLConnection; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.cookie.Cookie; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.List; +import java.util.zip.GZIPInputStream; +import java.util.zip.Inflater; +import java.util.zip.InflaterInputStream; + + +public class GTaskClient { + private static final String TAG = GTaskClient.class.getSimpleName(); + + private static final String GTASK_URL = "https://mail.google.com/tasks/"; + + private static final String GTASK_GET_URL = "https://mail.google.com/tasks/ig"; + + private static final String GTASK_POST_URL = "https://mail.google.com/tasks/r/ig"; + + private static GTaskClient mInstance = null; + + private DefaultHttpClient mHttpClient; + + private String mGetUrl; + + private String mPostUrl; + + private long mClientVersion; + + private boolean mLoggedin; + + private long mLastLoginTime; + + private int mActionId; + + private Account mAccount; + + private JSONArray mUpdateArray; + + private GTaskClient() { + mHttpClient = null; + mGetUrl = GTASK_GET_URL; + mPostUrl = GTASK_POST_URL; + mClientVersion = -1; + mLoggedin = false; + mLastLoginTime = 0; + mActionId = 1; + mAccount = null; + mUpdateArray = null; + } + + public static synchronized GTaskClient getInstance() { + if (mInstance == null) { + mInstance = new GTaskClient(); + } + return mInstance; + } + + public boolean login(Activity activity) { + // we suppose that the cookie would expire after 5 minutes + // then we need to re-login + final long interval = 1000 * 60 * 5; + if (mLastLoginTime + interval < System.currentTimeMillis()) { + mLoggedin = false; + } + + // need to re-login after account switch + if (mLoggedin + && !TextUtils.equals(getSyncAccount().name, NotesPreferenceActivity + .getSyncAccountName(activity))) { + mLoggedin = false; + } + + if (mLoggedin) { + Log.d(TAG, "already logged in"); + return true; + } + + mLastLoginTime = System.currentTimeMillis(); + String authToken = loginGoogleAccount(activity, false); + if (authToken == null) { + Log.e(TAG, "login google account failed"); + return false; + } + + // login with custom domain if necessary + if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase() + .endsWith("googlemail.com"))) { + StringBuilder url = new StringBuilder(GTASK_URL).append("a/"); + int index = mAccount.name.indexOf('@') + 1; + String suffix = mAccount.name.substring(index); + url.append(suffix + "/"); + mGetUrl = url.toString() + "ig"; + mPostUrl = url.toString() + "r/ig"; + + if (tryToLoginGtask(activity, authToken)) { + mLoggedin = true; + } + } + + // try to login with google official url + if (!mLoggedin) { + mGetUrl = GTASK_GET_URL; + mPostUrl = GTASK_POST_URL; + if (!tryToLoginGtask(activity, authToken)) { + return false; + } + } + + mLoggedin = true; + return true; + } + + private String loginGoogleAccount(Activity activity, boolean invalidateToken) { + String authToken; + AccountManager accountManager = AccountManager.get(activity); + Account[] accounts = accountManager.getAccountsByType("com.google"); + + if (accounts.length == 0) { + Log.e(TAG, "there is no available google account"); + return null; + } + + String accountName = NotesPreferenceActivity.getSyncAccountName(activity); + Account account = null; + for (Account a : accounts) { + if (a.name.equals(accountName)) { + account = a; + break; + } + } + if (account != null) { + mAccount = account; + } else { + Log.e(TAG, "unable to get an account with the same name in the settings"); + return null; + } + + // get the token now + AccountManagerFuture accountManagerFuture = accountManager.getAuthToken(account, + "goanna_mobile", null, activity, null, null); + try { + Bundle authTokenBundle = accountManagerFuture.getResult(); + authToken = authTokenBundle.getString(AccountManager.KEY_AUTHTOKEN); + if (invalidateToken) { + accountManager.invalidateAuthToken("com.google", authToken); + loginGoogleAccount(activity, false); + } + } catch (Exception e) { + Log.e(TAG, "get auth token failed"); + authToken = null; + } + + return authToken; + } + + private boolean tryToLoginGtask(Activity activity, String authToken) { + if (!loginGtask(authToken)) { + // maybe the auth token is out of date, now let's invalidate the + // token and try again + authToken = loginGoogleAccount(activity, true); + if (authToken == null) { + Log.e(TAG, "login google account failed"); + return false; + } + + if (!loginGtask(authToken)) { + Log.e(TAG, "login gtask failed"); + return false; + } + } + return true; + } + + private boolean loginGtask(String authToken) { + int timeoutConnection = 10000; + int timeoutSocket = 15000; + HttpParams httpParameters = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); + HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); + mHttpClient = new DefaultHttpClient(httpParameters); + BasicCookieStore localBasicCookieStore = new BasicCookieStore(); + mHttpClient.setCookieStore(localBasicCookieStore); + HttpProtocolParams.setUseExpectContinue(mHttpClient.getParams(), false); + + // login gtask + try { + String loginUrl = mGetUrl + "?auth=" + authToken; + HttpGet httpGet = new HttpGet(loginUrl); + HttpResponse response = null; + response = mHttpClient.execute(httpGet); + + // get the cookie now + List cookies = mHttpClient.getCookieStore().getCookies(); + boolean hasAuthCookie = false; + for (Cookie cookie : cookies) { + if (cookie.getName().contains("GTL")) { + hasAuthCookie = true; + } + } + if (!hasAuthCookie) { + Log.w(TAG, "it seems that there is no auth cookie"); + } + + // get the client version + String resString = getResponseContent(response.getEntity()); + String jsBegin = "_setup("; + String jsEnd = ")}"; + int begin = resString.indexOf(jsBegin); + int end = resString.lastIndexOf(jsEnd); + String jsString = null; + if (begin != -1 && end != -1 && begin < end) { + jsString = resString.substring(begin + jsBegin.length(), end); + } + JSONObject js = new JSONObject(jsString); + mClientVersion = js.getLong("v"); + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + return false; + } catch (Exception e) { + // simply catch all exceptions + Log.e(TAG, "httpget gtask_url failed"); + return false; + } + + return true; + } + + private int getActionId() { + return mActionId++; + } + + private HttpPost createHttpPost() { + HttpPost httpPost = new HttpPost(mPostUrl); + httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); + httpPost.setHeader("AT", "1"); + return httpPost; + } + + private String getResponseContent(HttpEntity entity) throws IOException { + String contentEncoding = null; + if (entity.getContentEncoding() != null) { + contentEncoding = entity.getContentEncoding().getValue(); + Log.d(TAG, "encoding: " + contentEncoding); + } + + InputStream input = entity.getContent(); + if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) { + input = new GZIPInputStream(entity.getContent()); + } else if (contentEncoding != null && contentEncoding.equalsIgnoreCase("deflate")) { + Inflater inflater = new Inflater(true); + input = new InflaterInputStream(entity.getContent(), inflater); + } + + try { + InputStreamReader isr = new InputStreamReader(input); + BufferedReader br = new BufferedReader(isr); + StringBuilder sb = new StringBuilder(); + + while (true) { + String buff = br.readLine(); + if (buff == null) { + return sb.toString(); + } + sb = sb.append(buff); + } + } finally { + input.close(); + } + } + + private JSONObject postRequest(JSONObject js) throws NetworkFailureException { + if (!mLoggedin) { + Log.e(TAG, "please login first"); + throw new ActionFailureException("not logged in"); + } + + HttpPost httpPost = createHttpPost(); + try { + LinkedList list = new LinkedList(); + list.add(new BasicNameValuePair("r", js.toString())); + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8"); + httpPost.setEntity(entity); + + // execute the post + HttpResponse response = mHttpClient.execute(httpPost); + String jsString = getResponseContent(response.getEntity()); + return new JSONObject(jsString); + + } catch (ClientProtocolException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new NetworkFailureException("postRequest failed"); + } catch (IOException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new NetworkFailureException("postRequest failed"); + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("unable to convert response content to jsonobject"); + } catch (Exception e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("error occurs when posting request"); + } + } + + public void createTask(Task task) throws NetworkFailureException { + commitUpdate(); + try { + JSONObject jsPost = new JSONObject(); + JSONArray actionList = new JSONArray(); + + // action_list + actionList.put(task.getCreateAction(getActionId())); + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList); + + // client_version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + // post + JSONObject jsResponse = postRequest(jsPost); + JSONObject jsResult = (JSONObject) jsResponse.getJSONArray( + GTaskStringUtils.GTASK_JSON_RESULTS).get(0); + task.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID)); + + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("create task: handing jsonobject failed"); + } + } + + public void createTaskList(TaskList tasklist) throws NetworkFailureException { + commitUpdate(); + try { + JSONObject jsPost = new JSONObject(); + JSONArray actionList = new JSONArray(); + + // action_list + actionList.put(tasklist.getCreateAction(getActionId())); + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList); + + // client version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + // post + JSONObject jsResponse = postRequest(jsPost); + JSONObject jsResult = (JSONObject) jsResponse.getJSONArray( + GTaskStringUtils.GTASK_JSON_RESULTS).get(0); + tasklist.setGid(jsResult.getString(GTaskStringUtils.GTASK_JSON_NEW_ID)); + + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("create tasklist: handing jsonobject failed"); + } + } + + public void commitUpdate() throws NetworkFailureException { + if (mUpdateArray != null) { + try { + JSONObject jsPost = new JSONObject(); + + // action_list + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, mUpdateArray); + + // client_version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + postRequest(jsPost); + mUpdateArray = null; + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("commit update: handing jsonobject failed"); + } + } + } + + public void addUpdateNode(Node node) throws NetworkFailureException { + if (node != null) { + // too many update items may result in an error + // set max to 10 items + if (mUpdateArray != null && mUpdateArray.length() > 10) { + commitUpdate(); + } + + if (mUpdateArray == null) + mUpdateArray = new JSONArray(); + mUpdateArray.put(node.getUpdateAction(getActionId())); + } + } + + public void moveTask(Task task, TaskList preParent, TaskList curParent) + throws NetworkFailureException { + commitUpdate(); + try { + JSONObject jsPost = new JSONObject(); + JSONArray actionList = new JSONArray(); + JSONObject action = new JSONObject(); + + // action_list + action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, + GTaskStringUtils.GTASK_JSON_ACTION_TYPE_MOVE); + action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId()); + action.put(GTaskStringUtils.GTASK_JSON_ID, task.getGid()); + if (preParent == curParent && task.getPriorSibling() != null) { + // put prioring_sibing_id only if moving within the tasklist and + // it is not the first one + action.put(GTaskStringUtils.GTASK_JSON_PRIOR_SIBLING_ID, task.getPriorSibling()); + } + action.put(GTaskStringUtils.GTASK_JSON_SOURCE_LIST, preParent.getGid()); + action.put(GTaskStringUtils.GTASK_JSON_DEST_PARENT, curParent.getGid()); + if (preParent != curParent) { + // put the dest_list only if moving between tasklists + action.put(GTaskStringUtils.GTASK_JSON_DEST_LIST, curParent.getGid()); + } + actionList.put(action); + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList); + + // client_version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + postRequest(jsPost); + + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("move task: handing jsonobject failed"); + } + } + + public void deleteNode(Node node) throws NetworkFailureException { + commitUpdate(); + try { + JSONObject jsPost = new JSONObject(); + JSONArray actionList = new JSONArray(); + + // action_list + node.setDeleted(true); + actionList.put(node.getUpdateAction(getActionId())); + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList); + + // client_version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + postRequest(jsPost); + mUpdateArray = null; + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("delete node: handing jsonobject failed"); + } + } + + public JSONArray getTaskLists() throws NetworkFailureException { + if (!mLoggedin) { + Log.e(TAG, "please login first"); + throw new ActionFailureException("not logged in"); + } + + try { + HttpGet httpGet = new HttpGet(mGetUrl); + HttpResponse response = null; + response = mHttpClient.execute(httpGet); + + // get the task list + String resString = getResponseContent(response.getEntity()); + String jsBegin = "_setup("; + String jsEnd = ")}"; + int begin = resString.indexOf(jsBegin); + int end = resString.lastIndexOf(jsEnd); + String jsString = null; + if (begin != -1 && end != -1 && begin < end) { + jsString = resString.substring(begin + jsBegin.length(), end); + } + JSONObject js = new JSONObject(jsString); + return js.getJSONObject("t").getJSONArray(GTaskStringUtils.GTASK_JSON_LISTS); + } catch (ClientProtocolException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new NetworkFailureException("gettasklists: httpget failed"); + } catch (IOException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new NetworkFailureException("gettasklists: httpget failed"); + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("get task lists: handing jasonobject failed"); + } + } + + public JSONArray getTaskList(String listGid) throws NetworkFailureException { + commitUpdate(); + try { + JSONObject jsPost = new JSONObject(); + JSONArray actionList = new JSONArray(); + JSONObject action = new JSONObject(); + + // action_list + action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, + GTaskStringUtils.GTASK_JSON_ACTION_TYPE_GETALL); + action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId()); + action.put(GTaskStringUtils.GTASK_JSON_LIST_ID, listGid); + action.put(GTaskStringUtils.GTASK_JSON_GET_DELETED, false); + actionList.put(action); + jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList); + + // client_version + jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion); + + JSONObject jsResponse = postRequest(jsPost); + return jsResponse.getJSONArray(GTaskStringUtils.GTASK_JSON_TASKS); + } catch (JSONException e) { + Log.e(TAG, e.toString()); + e.printStackTrace(); + throw new ActionFailureException("get task list: handing jsonobject failed"); + } + } + + public Account getSyncAccount() { + return mAccount; + } + + public void resetUpdateArray() { + mUpdateArray = null; + } +} diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/remote/GTaskManager.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/remote/GTaskManager.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/remote/GTaskSyncService.java b/Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/gtask/remote/GTaskSyncService.java rename to Notes-master/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java diff --git a/Notes-master/app/src/main/java/net/micode/notes/model/Note.java b/Notes-master/app/src/main/java/net/micode/notes/model/Note.java new file mode 100644 index 0000000..42eca06 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/model/Note.java @@ -0,0 +1,254 @@ +/* + * 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.model; +import android.content.ContentProviderOperation;//批量的更新、插入、删除数据。 +import android.content.ContentProviderResult;//操作的结果 +import android.content.ContentUris;//用于添加和获取Uri后面的ID +import android.content.ContentValues;//一种用来存储基本数据类型数据的存储机制 +import android.content.Context;//一种用来存储基本数据类型数据的存储机制 +import android.content.OperationApplicationException;//操作应用程序容错 +import android.net.Uri;//表示待操作的数据 +import android.os.RemoteException;//远程容错 +import android.util.Log;//输出日志,比如说出错、警告等 + +import net.micode.notes.data.Notes; +import net.micode.notes.data.Notes.CallNote; +import net.micode.notes.data.Notes.DataColumns; +import net.micode.notes.data.Notes.NoteColumns; +import net.micode.notes.data.Notes.TextNote; + +import java.util.ArrayList; + + +public class Note { + private ContentValues mNoteDiffValues; + private NoteData mNoteData; + private static final String TAG = "Note"; + /** + * Create a new note id for adding a new note to databases + */ + public static synchronized long getNewNoteId(Context context, long folderId) { + // Create a new note in the database + ContentValues values = new ContentValues(); + long createdTime = System.currentTimeMillis(); + values.put(NoteColumns.CREATED_DATE, createdTime); + values.put(NoteColumns.MODIFIED_DATE, createdTime); + values.put(NoteColumns.TYPE, Notes.TYPE_NOTE); + values.put(NoteColumns.LOCAL_MODIFIED, 1); + values.put(NoteColumns.PARENT_ID, folderId); + Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values); + //ContentResolver()主要是实现外部应用对ContentProvider中的数据 + //进行添加、删除、修改和查询操作 + long noteId = 0; + try { + noteId = Long.valueOf(uri.getPathSegments().get(1)); + } catch (NumberFormatException e) { + Log.e(TAG, "Get note id error :" + e.toString()); + noteId = 0; + } + if (noteId == -1) { + throw new IllegalStateException("Wrong note id:" + noteId); + } + return noteId; + } + + public Note() { + mNoteDiffValues = new ContentValues(); + mNoteData = new NoteData(); + } + + public void setNoteValue(String key, String value) { + mNoteDiffValues.put(key, value); + mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1); + mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis()); + } + + public void setTextData(String key, String value) { + mNoteData.setTextData(key, value); + } + + public void setTextDataId(long id) { + mNoteData.setTextDataId(id); + } + + public long getTextDataId() { + return mNoteData.mTextDataId; + } + + public void setCallDataId(long id) { + mNoteData.setCallDataId(id); + } + + public void setCallData(String key, String value) { + mNoteData.setCallData(key, value); + } + + public boolean isLocalModified() { + return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified(); + } + + public boolean syncNote(Context context, long noteId) { + if (noteId <= 0) { + throw new IllegalArgumentException("Wrong note id:" + noteId); + } + + if (!isLocalModified()) { + return true; + } + + /** + * In theory, once data changed, the note should be updated on {@link NoteColumns#LOCAL_MODIFIED} and + * {@link NoteColumns#MODIFIED_DATE}. For data safety, though update note fails, we also update the + * note data info + */ + if (context.getContentResolver().update( + ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), mNoteDiffValues, null, + null) == 0) { + Log.e(TAG, "Update note error, should not happen"); + // Do not return, fall through + } + mNoteDiffValues.clear(); + + if (mNoteData.isLocalModified() + && (mNoteData.pushIntoContentResolver(context, noteId) == null)) { + return false; + } + + return true; + } + + private class NoteData { + private long mTextDataId; + + private ContentValues mTextDataValues; + + private long mCallDataId; + + private ContentValues mCallDataValues; + + private static final String TAG = "NoteData"; + + public NoteData() { + mTextDataValues = new ContentValues(); + mCallDataValues = new ContentValues(); + mTextDataId = 0; + mCallDataId = 0; + } + + boolean isLocalModified() { + return mTextDataValues.size() > 0 || mCallDataValues.size() > 0; + } + + void setTextDataId(long id) { + if(id <= 0) { + throw new IllegalArgumentException("Text data id should larger than 0"); + } + mTextDataId = id; + } + + void setCallDataId(long id) { + if (id <= 0) { + throw new IllegalArgumentException("Call data id should larger than 0"); + } + mCallDataId = id; + } + + void setCallData(String key, String value) { + mCallDataValues.put(key, value); + mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1); + mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis()); + } + + void setTextData(String key, String value) { + mTextDataValues.put(key, value); + mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1); + mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis()); + } + + Uri pushIntoContentResolver(Context context, long noteId) { + /** + * Check for safety + */ + if (noteId <= 0) { + throw new IllegalArgumentException("Wrong note id:" + noteId); + } + + ArrayList operationList = new ArrayList(); + ContentProviderOperation.Builder builder = null; + + if(mTextDataValues.size() > 0) { + mTextDataValues.put(DataColumns.NOTE_ID, noteId); + if (mTextDataId == 0) { + mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE); + Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI, + mTextDataValues); + try { + setTextDataId(Long.valueOf(uri.getPathSegments().get(1))); + } catch (NumberFormatException e) { + Log.e(TAG, "Insert new text data fail with noteId" + noteId); + mTextDataValues.clear(); + return null; + } + } else { + builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId( + Notes.CONTENT_DATA_URI, mTextDataId)); + builder.withValues(mTextDataValues); + operationList.add(builder.build()); + } + mTextDataValues.clear(); + } + + if(mCallDataValues.size() > 0) { + mCallDataValues.put(DataColumns.NOTE_ID, noteId); + if (mCallDataId == 0) { + mCallDataValues.put(DataColumns.MIME_TYPE, CallNote.CONTENT_ITEM_TYPE); + Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI, + mCallDataValues); + try { + setCallDataId(Long.valueOf(uri.getPathSegments().get(1))); + } catch (NumberFormatException e) { + Log.e(TAG, "Insert new call data fail with noteId" + noteId); + mCallDataValues.clear(); + return null; + } + } else { + builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId( + Notes.CONTENT_DATA_URI, mCallDataId)); + builder.withValues(mCallDataValues); + operationList.add(builder.build()); + } + mCallDataValues.clear(); + } + + if (operationList.size() > 0) { + try { + ContentProviderResult[] results = context.getContentResolver().applyBatch( + Notes.AUTHORITY, operationList); + return (results == null || results.length == 0 || results[0] == null) ? null + : ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId); + } catch (RemoteException e) { + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + return null; + } catch (OperationApplicationException e) { + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + return null; + } + } + return null; + } + } +} diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/model/WorkingNote.java b/Notes-master/app/src/main/java/net/micode/notes/model/WorkingNote.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/model/WorkingNote.java rename to Notes-master/app/src/main/java/net/micode/notes/model/WorkingNote.java diff --git a/Notes-master/app/src/main/java/net/micode/notes/tool/BackupUtils.java b/Notes-master/app/src/main/java/net/micode/notes/tool/BackupUtils.java new file mode 100644 index 0000000..e9c30d2 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/tool/BackupUtils.java @@ -0,0 +1,345 @@ +/* + * 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.tool; + +import android.content.Context; +import android.database.Cursor; +import android.os.Environment; +import android.text.TextUtils; +import android.text.format.DateFormat; +import android.util.Log; + +import net.micode.notes.R; +import net.micode.notes.data.Notes; +import net.micode.notes.data.Notes.DataColumns; +import net.micode.notes.data.Notes.DataConstants; +import net.micode.notes.data.Notes.NoteColumns; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; + + +public class BackupUtils { + private static final String TAG = "BackupUtils"; + // Singleton stuff + private static BackupUtils sInstance; + + public static synchronized BackupUtils getInstance(Context context) { + if (sInstance == null) {//如果当前备份不存在,则声明一个 + sInstance = new BackupUtils(context); + } + return sInstance; + } + + /** + * Following states are signs to represents backup or restore + * status + */ + // Currently, the sdcard is not mounted + public static final int STATE_SD_CARD_UNMOUONTED = 0; + // The backup file not exist + public static final int STATE_BACKUP_FILE_NOT_EXIST = 1; + // The data is not well formated, may be changed by other programs + public static final int STATE_DATA_DESTROIED = 2; + // Some run-time exception which causes restore or backup fails + public static final int STATE_SYSTEM_ERROR = 3; + // Backup or restore success + public static final int STATE_SUCCESS = 4; + + private TextExport mTextExport; + + private BackupUtils(Context context) { + mTextExport = new TextExport(context); + }//初始化函数 + + private static boolean externalStorageAvailable() { + return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); + } + + public int exportToText() { + return mTextExport.exportToText(); + } + + public String getExportedTextFileName() { + return mTextExport.mFileName; + } + + public String getExportedTextFileDir() { + return mTextExport.mFileDirectory; + } + + private static class TextExport { + private static final String[] NOTE_PROJECTION = { + NoteColumns.ID, + NoteColumns.MODIFIED_DATE, + NoteColumns.SNIPPET, + NoteColumns.TYPE + }; + + private static final int NOTE_COLUMN_ID = 0; + + private static final int NOTE_COLUMN_MODIFIED_DATE = 1; + + private static final int NOTE_COLUMN_SNIPPET = 2; + + private static final String[] DATA_PROJECTION = { + DataColumns.CONTENT, + DataColumns.MIME_TYPE, + DataColumns.DATA1, + DataColumns.DATA2, + DataColumns.DATA3, + DataColumns.DATA4, + }; + + private static final int DATA_COLUMN_CONTENT = 0; + + private static final int DATA_COLUMN_MIME_TYPE = 1; + + private static final int DATA_COLUMN_CALL_DATE = 2; + + private static final int DATA_COLUMN_PHONE_NUMBER = 4; + + private final String [] TEXT_FORMAT; + private static final int FORMAT_FOLDER_NAME = 0; + private static final int FORMAT_NOTE_DATE = 1; + private static final int FORMAT_NOTE_CONTENT = 2; + + private Context mContext; + private String mFileName; + private String mFileDirectory; + + public TextExport(Context context) {//将便签内容显示 + TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note); + mContext = context; + mFileName = ""; + mFileDirectory = ""; + } + + private String getFormat(int id) { + return TEXT_FORMAT[id]; + } + + /** + * Export the folder identified by folder id to text + */ + private void exportFolderToText(String folderId, PrintStream ps) {//寻找文件夹 + // Query notes belong to this folder 通过查询parent ,id是文件夹id的note来选出制定ID文件夹下的Note + Cursor notesCursor = mContext.getContentResolver().query(Notes.CONTENT_NOTE_URI, + NOTE_PROJECTION, NoteColumns.PARENT_ID + "=?", new String[] { + folderId + }, null); + + if (notesCursor != null) { + if (notesCursor.moveToFirst()) { + do { + // Print note's last modified date ,ps里面保存有这份note的日期 + ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format( + mContext.getString(R.string.format_datetime_mdhm), + notesCursor.getLong(NOTE_COLUMN_MODIFIED_DATE)))); + // Query data belong to this note + String noteId = notesCursor.getString(NOTE_COLUMN_ID); + exportNoteToText(noteId, ps);//将文件导出到text + } while (notesCursor.moveToNext()); + } + notesCursor.close(); + } + } + + /** + * Export note identified by id to a print stream + */ + private void exportNoteToText(String noteId, PrintStream ps) { + Cursor dataCursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, + DATA_PROJECTION, DataColumns.NOTE_ID + "=?", new String[] { + noteId + }, null); + + if (dataCursor != null) {//利用光标来扫描内容,区别位callnote和note两种 + if (dataCursor.moveToFirst()) { + do { + String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE); + if (DataConstants.CALL_NOTE.equals(mimeType)) { + // Print phone number 打印电话号码 + String phoneNumber = dataCursor.getString(DATA_COLUMN_PHONE_NUMBER); + long callDate = dataCursor.getLong(DATA_COLUMN_CALL_DATE); + String location = dataCursor.getString(DATA_COLUMN_CONTENT); + + if (!TextUtils.isEmpty(phoneNumber)) {//判断是否为空字符 + ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), + phoneNumber)); + } + // Print call date 打印呼叫日期 + ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), DateFormat + .format(mContext.getString(R.string.format_datetime_mdhm), + callDate))); + // Print call attachment location + if (!TextUtils.isEmpty(location)) { + ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), + location)); + } + } else if (DataConstants.NOTE.equals(mimeType)) { + String content = dataCursor.getString(DATA_COLUMN_CONTENT); + if (!TextUtils.isEmpty(content)) { + ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), + content)); + } + } + } while (dataCursor.moveToNext()); + } + dataCursor.close(); + } + // print a line separator between note + try { + ps.write(new byte[] { + Character.LINE_SEPARATOR, Character.LETTER_NUMBER + }); + } catch (IOException e) { + Log.e(TAG, e.toString()); + } + } + + /** + * Note will be exported as text which is user readable + * note 将被导出为文本,用户可见 + */ + public int exportToText() { + if (!externalStorageAvailable()) { //总函数,调用上面的exportFolder和exportNote + Log.d(TAG, "Media was not mounted"); + return STATE_SD_CARD_UNMOUONTED; + } + + PrintStream ps = getExportToTextPrintStream(); + if (ps == null) { + Log.e(TAG, "get print stream error"); + return STATE_SYSTEM_ERROR; + } + // First export folder and its notes, 导出文件夹,导出里面包含的便签 + Cursor folderCursor = mContext.getContentResolver().query( + Notes.CONTENT_NOTE_URI, + NOTE_PROJECTION, + "(" + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + " AND " + + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + ") OR " + + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null); + + if (folderCursor != null) {//文件夹光标指向不为空文件夹 + if (folderCursor.moveToFirst()) {//当前光标指向第一个文件夹 + do { + // Print folder's name + String folderName = ""; + if(folderCursor.getLong(NOTE_COLUMN_ID) == Notes.ID_CALL_RECORD_FOLDER) {//便签的内容 + folderName = mContext.getString(R.string.call_record_folder_name); + } else { + folderName = folderCursor.getString(NOTE_COLUMN_SNIPPET);//获取便签名 + } + if (!TextUtils.isEmpty(folderName)) {//便签名获取失败 + ps.println(String.format(getFormat(FORMAT_FOLDER_NAME), folderName)); + } + String folderId = folderCursor.getString(NOTE_COLUMN_ID); + exportFolderToText(folderId, ps); + } while (folderCursor.moveToNext()); + } + folderCursor.close(); + } + + // Export notes in root's folder ,将根目录里面的便签导出 + Cursor noteCursor = mContext.getContentResolver().query( + Notes.CONTENT_NOTE_URI, + NOTE_PROJECTION, + NoteColumns.TYPE + "=" + +Notes.TYPE_NOTE + " AND " + NoteColumns.PARENT_ID + + "=0", null, null); + + if (noteCursor != null) { + if (noteCursor.moveToFirst()) { + do { + ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format( + mContext.getString(R.string.format_datetime_mdhm), + noteCursor.getLong(NOTE_COLUMN_MODIFIED_DATE)))); + // Query data belong to this note查询数据属于本笔记 + String noteId = noteCursor.getString(NOTE_COLUMN_ID); + exportNoteToText(noteId, ps); + } while (noteCursor.moveToNext()); + } + noteCursor.close(); + } + ps.close(); + + return STATE_SUCCESS; + } + + /** + * Get a print stream pointed to the file {@generateExportedTextFile}获取一个指向文件{@generateExportedTextFile}的打印流 + */ + private PrintStream getExportToTextPrintStream() {//打印输出流 + File file = generateFileMountedOnSDcard(mContext, R.string.file_path, + R.string.file_name_txt_format); + if (file == null) {//文件不存在 + Log.e(TAG, "create file to exported failed"); + return null; + } + mFileName = file.getName();//获取文件名 + mFileDirectory = mContext.getString(R.string.file_path);//获取文件目录 + PrintStream ps = null; + try { + FileOutputStream fos = new FileOutputStream(file); + ps = new PrintStream(fos);//将ps输出流输出到特定的文件,目的就是导出到文件,而部署直接输出 + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } catch (NullPointerException e) { + e.printStackTrace(); + return null; + } + return ps; + } + } + + /** + * Generate the text file to store imported data + */ + private static File generateFileMountedOnSDcard(Context context, int filePathResId, int fileNameFormatResId) { + StringBuilder sb = new StringBuilder(); + sb.append(Environment.getExternalStorageDirectory());//外部(SD卡)的存储路径 + sb.append(context.getString(filePathResId));//文件的存储路径 + File filedir = new File(sb.toString());//filedir存储路径信息 + sb.append(context.getString( + fileNameFormatResId, + DateFormat.format(context.getString(R.string.format_date_ymd), + System.currentTimeMillis()))); + File file = new File(sb.toString()); + + try { + if (!filedir.exists()) {//文件不存在,则新建文件 + filedir.mkdir(); + } + if (!file.exists()) { + file.createNewFile(); + } + return file; + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } +} + + diff --git a/Notes-master/app/src/main/java/net/micode/notes/tool/DataUtils.java b/Notes-master/app/src/main/java/net/micode/notes/tool/DataUtils.java new file mode 100644 index 0000000..986d3b0 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/tool/DataUtils.java @@ -0,0 +1,296 @@ +/* + * 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.tool; + +import android.content.ContentProviderOperation; +import android.content.ContentProviderResult; +import android.content.ContentResolver; +import android.content.ContentUris; +import android.content.ContentValues; +import android.content.OperationApplicationException; +import android.database.Cursor; +import android.os.RemoteException; +import android.util.Log; + +import net.micode.notes.data.Notes; +import net.micode.notes.data.Notes.CallNote; +import net.micode.notes.data.Notes.NoteColumns; +import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute; + +import java.util.ArrayList; +import java.util.HashSet; + + +public class DataUtils { + public static final String TAG = "DataUtils"; + public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) {//删除多个便签 + if (ids == null) { //便签id不存在 + Log.d(TAG, "the ids is null"); + return true; + } + if (ids.size() == 0) { //哈希表中便签ID不存在 + Log.d(TAG, "no id is in the hashset"); + return true; + } + + ArrayList operationList = new ArrayList();//提供一个任务列表 + for (long id : ids) { + if(id == Notes.ID_ROOT_FOLDER) { //若为根文件夹,则警告不可删除 + Log.e(TAG, "Don't delete system folder root"); + continue; + } + ContentProviderOperation.Builder builder = ContentProviderOperation + .newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id)); + operationList.add(builder.build()); + } + try { + ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList); + if (results == null || results.length == 0 || results[0] == null) {//便签删除失败 + Log.d(TAG, "delete notes failed, ids:" + ids.toString()); + return false; + } + return true; + } catch (RemoteException e) {//网络出错 + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + } catch (OperationApplicationException e) {//操作指令错误 + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + } + return false; + } + + public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {//转移笔记到其他文件夹 + ContentValues values = new ContentValues(); + values.put(NoteColumns.PARENT_ID, desFolderId); + values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId); + values.put(NoteColumns.LOCAL_MODIFIED, 1); + resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);//对需要移动的便签进行数据更新,然后用update实现 + } + + public static boolean batchMoveToFolder(ContentResolver resolver, HashSet ids, + long folderId) { //一次转移多个便签 + if (ids == null) { //出现空的便签ID + Log.d(TAG, "the ids is null"); + return true; + } + + ArrayList operationList = new ArrayList(); + for (long id : ids) { + ContentProviderOperation.Builder builder = ContentProviderOperation + .newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id)); + builder.withValue(NoteColumns.PARENT_ID, folderId); + builder.withValue(NoteColumns.LOCAL_MODIFIED, 1); + operationList.add(builder.build()); + } + + try { + ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);//主机名(或叫Authority)用于唯一标识这个ContentProvider,外部调用者可以根据这个标识来找到它。 + //数据库事务,数据库事务是由一组数据库操作序列组成,事务作为一个整体被执行 + if (results == null || results.length == 0 || results[0] == null) { + Log.d(TAG, "delete notes failed, ids:" + ids.toString()); + return false; + } + return true; + } catch (RemoteException e) { + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + } catch (OperationApplicationException e) { + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + } + return false; + } + + /** + * Get the all folder count except system folders {@link Notes#TYPE_SYSTEM}} + */ + public static int getUserFolderCount(ContentResolver resolver) { + Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI, + new String[] { "COUNT(*)" }, + NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?", + new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)}, + null);//筛选条件:源文件不为trash folder + + int count = 0; + if(cursor != null) { + if(cursor.moveToFirst()) { + try { + count = cursor.getInt(0); + } catch (IndexOutOfBoundsException e) { + Log.e(TAG, "get folder count failed:" + e.toString()); + } finally { + cursor.close(); + } + } + } + return count; + } + + public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) { + Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),//通过withAppendedId方法,为该Uri加上ID + null, + NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER, + new String [] {String.valueOf(type)}, + null);//查询条件:type符合,且不属于垃圾文件夹 + + boolean exist = false; + if (cursor != null) { + if (cursor.getCount() > 0) {//用getcount函数判断cursor是否为空 + exist = true; + } + cursor.close(); + } + return exist; + } + + public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) { + Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), + null, null, null, null); + + boolean exist = false; + if (cursor != null) { + if (cursor.getCount() > 0) { + exist = true; + } + cursor.close(); + } + return exist; + } + + public static boolean existInDataDatabase(ContentResolver resolver, long dataId) { + Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), + null, null, null, null); + + boolean exist = false; + if (cursor != null) { + if (cursor.getCount() > 0) { + exist = true; + } + cursor.close(); + } + return exist; + } + + public static boolean checkVisibleFolderName(ContentResolver resolver, String name) { + Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null, + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + + " AND " + NoteColumns.SNIPPET + "=?", + new String[] { name }, null); //通过名字查询文件是否存在 + boolean exist = false; + if(cursor != null) { + if(cursor.getCount() > 0) { + exist = true; + } + cursor.close(); + } + return exist; + } + + public static HashSet getFolderNoteWidget(ContentResolver resolver, long folderId) { + Cursor c = resolver.query(Notes.CONTENT_NOTE_URI, + new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE }, + NoteColumns.PARENT_ID + "=?", + new String[] { String.valueOf(folderId) }, + null);//查询条件:父ID是传入的folderId; + + HashSet set = null; + if (c != null) { + if (c.moveToFirst()) { + set = new HashSet(); + do { + try { + AppWidgetAttribute widget = new AppWidgetAttribute(); + widget.widgetId = c.getInt(0);//0对应的NoteColumns.WIDGET_ID + widget.widgetType = c.getInt(1);//1对应的NoteColumns.WIDGET_TYPE + set.add(widget); + } catch (IndexOutOfBoundsException e) { + Log.e(TAG, e.toString()); + } + } while (c.moveToNext());//查询下一条 + } + c.close(); + } + return set; + } + + public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) { + Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, + new String [] { CallNote.PHONE_NUMBER }, + CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?", + new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE }, + null); + + if (cursor != null && cursor.moveToFirst()) { + try { + return cursor.getString(0); + } catch (IndexOutOfBoundsException e) { + Log.e(TAG, "Get call number fails " + e.toString()); + } finally { + cursor.close(); + } + } + return ""; + } + + public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) { + Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, + new String [] { CallNote.NOTE_ID }, + CallNote.CALL_DATE + "=? AND " + CallNote.MIME_TYPE + "=? AND PHONE_NUMBERS_EQUAL(" + + CallNote.PHONE_NUMBER + ",?)", + new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber }, + null); + //通过数据库操作,查询条件是(callDate和phoneNumber匹配传入参数的值) + if (cursor != null) { + if (cursor.moveToFirst()) { + try { + return cursor.getLong(0);//0对应的CallNote.NOTE_ID + } catch (IndexOutOfBoundsException e) { + Log.e(TAG, "Get call note id fails " + e.toString()); + } + } + cursor.close(); + } + return 0; + } + + public static String getSnippetById(ContentResolver resolver, long noteId) { + Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, + new String [] { NoteColumns.SNIPPET }, + NoteColumns.ID + "=?", + new String [] { String.valueOf(noteId)}, + null);//查询条件:noteId + + if (cursor != null) { + String snippet = ""; + if (cursor.moveToFirst()) { + snippet = cursor.getString(0); + } + cursor.close(); + return snippet; + } + throw new IllegalArgumentException("Note is not found with id: " + noteId); + } + + public static String getFormattedSnippet(String snippet) {//对字符串进行格式处理,将字符串两头的空格去掉,同时将换行符去掉 + if (snippet != null) { + snippet = snippet.trim(); + int index = snippet.indexOf('\n'); + if (index != -1) { + snippet = snippet.substring(0, index); + } + } + return snippet; + } +} diff --git a/Notes-master/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java b/Notes-master/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java new file mode 100644 index 0000000..e69b1d3 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java @@ -0,0 +1,115 @@ +/* + * 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. + */ + +//简介:定义了很多的静态字符串,目的就是为了提供jsonObject中相应字符串的"key"。 +package net.micode.notes.tool; + +public class GTaskStringUtils { + //这个类就是定义了一堆static string,实际就是为jsonObject提供Key,把这些定义全部写到一个类里,方便查看管理 + + public final static String GTASK_JSON_ACTION_ID = "action_id"; + + public final static String GTASK_JSON_ACTION_LIST = "action_list"; + + public final static String GTASK_JSON_ACTION_TYPE = "action_type"; + + public final static String GTASK_JSON_ACTION_TYPE_CREATE = "create"; + + public final static String GTASK_JSON_ACTION_TYPE_GETALL = "get_all"; + + public final static String GTASK_JSON_ACTION_TYPE_MOVE = "move"; + + public final static String GTASK_JSON_ACTION_TYPE_UPDATE = "update"; + + public final static String GTASK_JSON_CREATOR_ID = "creator_id"; + + public final static String GTASK_JSON_CHILD_ENTITY = "child_entity"; + + public final static String GTASK_JSON_CLIENT_VERSION = "client_version"; + + public final static String GTASK_JSON_COMPLETED = "completed"; + + public final static String GTASK_JSON_CURRENT_LIST_ID = "current_list_id"; + + public final static String GTASK_JSON_DEFAULT_LIST_ID = "default_list_id"; + + public final static String GTASK_JSON_DELETED = "deleted"; + + public final static String GTASK_JSON_DEST_LIST = "dest_list"; + + public final static String GTASK_JSON_DEST_PARENT = "dest_parent"; + + public final static String GTASK_JSON_DEST_PARENT_TYPE = "dest_parent_type"; + + public final static String GTASK_JSON_ENTITY_DELTA = "entity_delta"; + + public final static String GTASK_JSON_ENTITY_TYPE = "entity_type"; + + public final static String GTASK_JSON_GET_DELETED = "get_deleted"; + + public final static String GTASK_JSON_ID = "id"; + + public final static String GTASK_JSON_INDEX = "index"; + + public final static String GTASK_JSON_LAST_MODIFIED = "last_modified"; + + public final static String GTASK_JSON_LATEST_SYNC_POINT = "latest_sync_point"; + + public final static String GTASK_JSON_LIST_ID = "list_id"; + + public final static String GTASK_JSON_LISTS = "lists"; + + public final static String GTASK_JSON_NAME = "name"; + + public final static String GTASK_JSON_NEW_ID = "new_id"; + + public final static String GTASK_JSON_NOTES = "notes"; + + public final static String GTASK_JSON_PARENT_ID = "parent_id"; + + public final static String GTASK_JSON_PRIOR_SIBLING_ID = "prior_sibling_id"; + + public final static String GTASK_JSON_RESULTS = "results"; + + public final static String GTASK_JSON_SOURCE_LIST = "source_list"; + + public final static String GTASK_JSON_TASKS = "tasks"; + + public final static String GTASK_JSON_TYPE = "type"; + + public final static String GTASK_JSON_TYPE_GROUP = "GROUP"; + + public final static String GTASK_JSON_TYPE_TASK = "TASK"; + + public final static String GTASK_JSON_USER = "user"; + + public final static String MIUI_FOLDER_PREFFIX = "[MIUI_Notes]"; + + public final static String FOLDER_DEFAULT = "Default"; + + public final static String FOLDER_CALL_NOTE = "Call_Note"; + + public final static String FOLDER_META = "METADATA"; + + public final static String META_HEAD_GTASK_ID = "meta_gid"; + + public final static String META_HEAD_NOTE = "meta_note"; + + public final static String META_HEAD_DATA = "meta_data"; + + public final static String META_NOTE_NAME = "[META INFO] DON'T UPDATE AND DELETE"; + +} diff --git a/Notes-master/app/src/main/java/net/micode/notes/tool/ResourceParser.java b/Notes-master/app/src/main/java/net/micode/notes/tool/ResourceParser.java new file mode 100644 index 0000000..e8e9e03 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/tool/ResourceParser.java @@ -0,0 +1,195 @@ +/* + * 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.tool; + +/*简介:字面意义是资源分析器,实际上就是获取资源并且在程序中使用,比如颜色图片等 + * 实现方法:主要利用R.java这个类,其中包括 + * R.id 组件资源引用 + * R.drawable 图片资源 (被使用) + * R.layout 布局资源 + * R.menu 菜单资源 + * R.String 文字资源 + * R.style 主题资源 (被使用) + * 在按顺序设置好相应的id后,就可以编写简单的getXXX函数获取需要的资源 + * + * 特殊的变量 : + * @BG_DEFAULT_COLOR 默认背景颜色(黄) + * BG_DEFAULT_FONT_SIZE 默认文本大小(中) + */ +import android.content.Context; +import android.preference.PreferenceManager; + +import net.micode.notes.R; +import net.micode.notes.ui.NotesPreferenceActivity; + +public class ResourceParser { + + public static final int YELLOW = 0; + public static final int BLUE = 1; + public static final int WHITE = 2; + public static final int GREEN = 3; + public static final int RED = 4; + + public static final int BG_DEFAULT_COLOR = YELLOW; + + public static final int TEXT_SMALL = 0; + public static final int TEXT_MEDIUM = 1; + public static final int TEXT_LARGE = 2; + public static final int TEXT_SUPER = 3; + + public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM; + + public static class NoteBgResources { + private final static int [] BG_EDIT_RESOURCES = new int [] { + R.drawable.edit_yellow, + R.drawable.edit_blue, + R.drawable.edit_white, + R.drawable.edit_green, + R.drawable.edit_red + }; + + private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] { + R.drawable.edit_title_yellow, + R.drawable.edit_title_blue, + R.drawable.edit_title_white, + R.drawable.edit_title_green, + R.drawable.edit_title_red + }; + + public static int getNoteBgResource(int id) { + return BG_EDIT_RESOURCES[id]; + } + + public static int getNoteTitleBgResource(int id) { + return BG_EDIT_TITLE_RESOURCES[id]; + } + } + //直接获取默认的背景颜色。看不太懂,这个PREFERENCE_SET_BG_COLOR_KEY是个final string,也就是说getBoolean肯定执行else + public static int getDefaultBgId(Context context) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean( + NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) { + return (int) (Math.random() * NoteBgResources.BG_EDIT_RESOURCES.length); + } else { + return BG_DEFAULT_COLOR; + } + } + + public static class NoteItemBgResources { + private final static int [] BG_FIRST_RESOURCES = new int [] { + R.drawable.list_yellow_up, + R.drawable.list_blue_up, + R.drawable.list_white_up, + R.drawable.list_green_up, + R.drawable.list_red_up + }; + + private final static int [] BG_NORMAL_RESOURCES = new int [] { + R.drawable.list_yellow_middle, + R.drawable.list_blue_middle, + R.drawable.list_white_middle, + R.drawable.list_green_middle, + R.drawable.list_red_middle + }; + + private final static int [] BG_LAST_RESOURCES = new int [] { + R.drawable.list_yellow_down, + R.drawable.list_blue_down, + R.drawable.list_white_down, + R.drawable.list_green_down, + R.drawable.list_red_down, + }; + + private final static int [] BG_SINGLE_RESOURCES = new int [] { + R.drawable.list_yellow_single, + R.drawable.list_blue_single, + R.drawable.list_white_single, + R.drawable.list_green_single, + R.drawable.list_red_single + }; + + public static int getNoteBgFirstRes(int id) { + return BG_FIRST_RESOURCES[id]; + } + + public static int getNoteBgLastRes(int id) { + return BG_LAST_RESOURCES[id]; + } + + public static int getNoteBgSingleRes(int id) { + return BG_SINGLE_RESOURCES[id]; + } + + public static int getNoteBgNormalRes(int id) { + return BG_NORMAL_RESOURCES[id]; + } + + public static int getFolderBgRes() { + return R.drawable.list_folder; + } + } + + public static class WidgetBgResources { + private final static int [] BG_2X_RESOURCES = new int [] { + R.drawable.widget_2x_yellow, + R.drawable.widget_2x_blue, + R.drawable.widget_2x_white, + R.drawable.widget_2x_green, + R.drawable.widget_2x_red, + }; + + public static int getWidget2xBgResource(int id) { + return BG_2X_RESOURCES[id]; + } + + private final static int [] BG_4X_RESOURCES = new int [] { + R.drawable.widget_4x_yellow, + R.drawable.widget_4x_blue, + R.drawable.widget_4x_white, + R.drawable.widget_4x_green, + R.drawable.widget_4x_red + }; + + public static int getWidget4xBgResource(int id) { + return BG_4X_RESOURCES[id]; + } + } + + public static class TextAppearanceResources { + private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] { + R.style.TextAppearanceNormal, + R.style.TextAppearanceMedium, + R.style.TextAppearanceLarge, + R.style.TextAppearanceSuper + }; + //这里有一个容错的函数,防止输入的id大于资源总量,若如此,则自动返回默认的设置结果 + public static int getTexAppearanceResource(int id) { + /** + * HACKME: Fix bug of store the resource id in shared preference. + * The id may larger than the length of resources, in this case, + * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE} + */ + if (id >= TEXTAPPEARANCE_RESOURCES.length) { + return BG_DEFAULT_FONT_SIZE; + } + return TEXTAPPEARANCE_RESOURCES[id]; + } + + public static int getResourcesSize() { + return TEXTAPPEARANCE_RESOURCES.length; + } + } +} diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmAlertActivity.java b/Notes-master/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmAlertActivity.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmInitReceiver.java b/Notes-master/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmInitReceiver.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmReceiver.java b/Notes-master/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/AlarmReceiver.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DateTimePicker.java b/Notes-master/app/src/main/java/net/micode/notes/ui/DateTimePicker.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DateTimePicker.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/DateTimePicker.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DateTimePickerDialog.java b/Notes-master/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DateTimePickerDialog.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DropdownMenu.java b/Notes-master/app/src/main/java/net/micode/notes/ui/DropdownMenu.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/DropdownMenu.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/DropdownMenu.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java b/Notes-master/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java diff --git a/Notes-master/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java new file mode 100644 index 0000000..4f3be7b --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -0,0 +1,874 @@ +/* + * 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.ui; + +import android.app.Activity; +import android.app.AlarmManager; +import android.app.AlertDialog; +import android.app.PendingIntent; +import android.app.SearchManager; +import android.appwidget.AppWidgetManager; +import android.content.ContentUris; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Paint; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v7.app.AppCompatActivity; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.TextUtils; +import android.text.format.DateUtils; +import android.text.style.BackgroundColorSpan; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.WindowManager; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import net.micode.notes.R; +import net.micode.notes.data.Notes; +import net.micode.notes.data.Notes.TextNote; +import net.micode.notes.model.WorkingNote; +import net.micode.notes.model.WorkingNote.NoteSettingChangedListener; +import net.micode.notes.tool.DataUtils; +import net.micode.notes.tool.ResourceParser; +import net.micode.notes.tool.ResourceParser.TextAppearanceResources; +import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener; +import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener; +import net.micode.notes.widget.NoteWidgetProvider_2x; +import net.micode.notes.widget.NoteWidgetProvider_4x; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class NoteEditActivity extends AppCompatActivity implements OnClickListener, + NoteSettingChangedListener, OnTextViewChangeListener { + private class HeadViewHolder { + public TextView tvModified; + + public ImageView ivAlertIcon; + + public TextView tvAlertDate; + + public ImageView ibSetBgColor; + } + + private static final Map sBgSelectorBtnsMap = new HashMap(); + static { + sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW); + sBgSelectorBtnsMap.put(R.id.iv_bg_red, ResourceParser.RED); + sBgSelectorBtnsMap.put(R.id.iv_bg_blue, ResourceParser.BLUE); + sBgSelectorBtnsMap.put(R.id.iv_bg_green, ResourceParser.GREEN); + sBgSelectorBtnsMap.put(R.id.iv_bg_white, ResourceParser.WHITE); + } + + private static final Map sBgSelectorSelectionMap = new HashMap(); + static { + sBgSelectorSelectionMap.put(ResourceParser.YELLOW, R.id.iv_bg_yellow_select); + sBgSelectorSelectionMap.put(ResourceParser.RED, R.id.iv_bg_red_select); + sBgSelectorSelectionMap.put(ResourceParser.BLUE, R.id.iv_bg_blue_select); + sBgSelectorSelectionMap.put(ResourceParser.GREEN, R.id.iv_bg_green_select); + sBgSelectorSelectionMap.put(ResourceParser.WHITE, R.id.iv_bg_white_select); + } + + private static final Map sFontSizeBtnsMap = new HashMap(); + static { + sFontSizeBtnsMap.put(R.id.ll_font_large, ResourceParser.TEXT_LARGE); + sFontSizeBtnsMap.put(R.id.ll_font_small, ResourceParser.TEXT_SMALL); + sFontSizeBtnsMap.put(R.id.ll_font_normal, ResourceParser.TEXT_MEDIUM); + sFontSizeBtnsMap.put(R.id.ll_font_super, ResourceParser.TEXT_SUPER); + } + + private static final Map sFontSelectorSelectionMap = new HashMap(); + static { + sFontSelectorSelectionMap.put(ResourceParser.TEXT_LARGE, R.id.iv_large_select); + sFontSelectorSelectionMap.put(ResourceParser.TEXT_SMALL, R.id.iv_small_select); + sFontSelectorSelectionMap.put(ResourceParser.TEXT_MEDIUM, R.id.iv_medium_select); + sFontSelectorSelectionMap.put(ResourceParser.TEXT_SUPER, R.id.iv_super_select); + } + + private static final String TAG = "NoteEditActivity"; + + private HeadViewHolder mNoteHeaderHolder; + + private View mHeadViewPanel; + + private View mNoteBgColorSelector; + + private View mFontSizeSelector; + + private EditText mNoteEditor; + + private View mNoteEditorPanel; + + private WorkingNote mWorkingNote; + + private SharedPreferences mSharedPrefs; + private int mFontSizeId; + + private static final String PREFERENCE_FONT_SIZE = "pref_font_size"; + + private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10; + + public static final String TAG_CHECKED = String.valueOf('\u221A'); + public static final String TAG_UNCHECKED = String.valueOf('\u25A1'); + + private LinearLayout mEditTextList; + + private String mUserQuery; + private Pattern mPattern; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.setContentView(R.layout.note_edit); + + if (savedInstanceState == null && !initActivityState(getIntent())) { + finish(); + return; + } + initResources(); + } + + /** + * Current activity may be killed when the memory is low. Once it is killed, for another time + * user load this activity, we should restore the former state + */ + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + if (savedInstanceState != null && savedInstanceState.containsKey(Intent.EXTRA_UID)) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.putExtra(Intent.EXTRA_UID, savedInstanceState.getLong(Intent.EXTRA_UID)); + if (!initActivityState(intent)) { + finish(); + return; + } + Log.d(TAG, "Restoring from killed activity"); + } + } + + private boolean initActivityState(Intent intent) { + /** + * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id, + * then jump to the NotesListActivity + */ + mWorkingNote = null; + if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) { + long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0); + mUserQuery = ""; + + /** + * Starting from the searched result + */ + if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) { + noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); + mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY); + } + + if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) { + Intent jump = new Intent(this, NotesListActivity.class); + startActivity(jump); + showToast(R.string.error_note_not_exist); + finish(); + return false; + } else { + mWorkingNote = WorkingNote.load(this, noteId); + if (mWorkingNote == null) { + Log.e(TAG, "load note failed with note id" + noteId); + finish(); + return false; + } + } + getWindow().setSoftInputMode( + WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN + | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + } else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) { + // New note + long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0); + int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, + AppWidgetManager.INVALID_APPWIDGET_ID); + int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, + Notes.TYPE_WIDGET_INVALIDE); + int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, + ResourceParser.getDefaultBgId(this)); + + // Parse call-record note + String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); + long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0); + if (callDate != 0 && phoneNumber != null) { + if (TextUtils.isEmpty(phoneNumber)) { + Log.w(TAG, "The call record number is null"); + } + long noteId = 0; + if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), + phoneNumber, callDate)) > 0) { + mWorkingNote = WorkingNote.load(this, noteId); + if (mWorkingNote == null) { + Log.e(TAG, "load call note failed with note id" + noteId); + finish(); + return false; + } + } else { + mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, + widgetType, bgResId); + mWorkingNote.convertToCallNote(phoneNumber, callDate); + } + } else { + mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, + bgResId); + } + + getWindow().setSoftInputMode( + WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE + | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); + } else { + Log.e(TAG, "Intent not specified action, should not support"); + finish(); + return false; + } + mWorkingNote.setOnSettingStatusChangedListener(this); + return true; + } + + @Override + protected void onResume() { + super.onResume(); + initNoteScreen(); + } + + private void initNoteScreen() { + mNoteEditor.setTextAppearance(this, TextAppearanceResources + .getTexAppearanceResource(mFontSizeId)); + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + switchToListMode(mWorkingNote.getContent()); + } else { + mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); + mNoteEditor.setSelection(mNoteEditor.getText().length()); + } + for (Integer id : sBgSelectorSelectionMap.keySet()) { + findViewById(sBgSelectorSelectionMap.get(id)).setVisibility(View.GONE); + } + mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); + mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); + + mNoteHeaderHolder.tvModified.setText(DateUtils.formatDateTime(this, + mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE + | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME + | DateUtils.FORMAT_SHOW_YEAR)); + + /** + * TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker + * is not ready + */ + showAlertHeader(); + } + + private void showAlertHeader() { + if (mWorkingNote.hasClockAlert()) { + long time = System.currentTimeMillis(); + if (time > mWorkingNote.getAlertDate()) { + mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired); + } else { + mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString( + mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS)); + } + mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE); + mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE); + } else { + mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE); + mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE); + }; + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + initActivityState(intent); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + /** + * For new note without note id, we should firstly save it to + * generate a id. If the editing note is not worth saving, there + * is no id which is equivalent to create new note + */ + if (!mWorkingNote.existInDatabase()) { + saveNote(); + } + outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId()); + Log.d(TAG, "Save working note id: " + mWorkingNote.getNoteId() + " onSaveInstanceState"); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + if (mNoteBgColorSelector.getVisibility() == View.VISIBLE + && !inRangeOfView(mNoteBgColorSelector, ev)) { + mNoteBgColorSelector.setVisibility(View.GONE); + return true; + } + + if (mFontSizeSelector.getVisibility() == View.VISIBLE + && !inRangeOfView(mFontSizeSelector, ev)) { + mFontSizeSelector.setVisibility(View.GONE); + return true; + } + return super.dispatchTouchEvent(ev); + } + + private boolean inRangeOfView(View view, MotionEvent ev) { + int []location = new int[2]; + view.getLocationOnScreen(location); + int x = location[0]; + int y = location[1]; + if (ev.getX() < x + || ev.getX() > (x + view.getWidth()) + || ev.getY() < y + || ev.getY() > (y + view.getHeight())) { + return false; + } + return true; + } + + private void initResources() { + mHeadViewPanel = findViewById(R.id.note_title); + mNoteHeaderHolder = new HeadViewHolder(); + mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date); + mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon); + mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); + mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); + mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); + mNoteEditor = (EditText) findViewById(R.id.note_edit_view); + mNoteEditorPanel = findViewById(R.id.sv_note_edit); + mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); + for (int id : sBgSelectorBtnsMap.keySet()) { + ImageView iv = (ImageView) findViewById(id); + iv.setOnClickListener(this); + } + + mFontSizeSelector = findViewById(R.id.font_size_selector); + for (int id : sFontSizeBtnsMap.keySet()) { + View view = findViewById(id); + view.setOnClickListener(this); + }; + mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); + mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE); + /** + * HACKME: Fix bug of store the resource id in shared preference. + * The id may larger than the length of resources, in this case, + * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE} + */ + if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) { + mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; + } + mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); + } + + @Override + protected void onPause() { + super.onPause(); + if(saveNote()) { + Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length()); + } + clearSettingState(); + } + + private void updateWidget() { + Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) { + intent.setClass(this, NoteWidgetProvider_2x.class); + } else if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_4X) { + intent.setClass(this, NoteWidgetProvider_4x.class); + } else { + Log.e(TAG, "Unspported widget type"); + return; + } + + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { + mWorkingNote.getWidgetId() + }); + + sendBroadcast(intent); + setResult(RESULT_OK, intent); + } + + public void onClick(View v) { + int id = v.getId(); + if (id == R.id.btn_set_bg_color) { + mNoteBgColorSelector.setVisibility(View.VISIBLE); + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( + View.VISIBLE); + } else if (sBgSelectorBtnsMap.containsKey(id)) { + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( + View.GONE); + mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id)); + mNoteBgColorSelector.setVisibility(View.GONE); + } else if (sFontSizeBtnsMap.containsKey(id)) { + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE); + mFontSizeId = sFontSizeBtnsMap.get(id); + mSharedPrefs.edit().putInt(PREFERENCE_FONT_SIZE, mFontSizeId).commit(); + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + getWorkingText(); + switchToListMode(mWorkingNote.getContent()); + } else { + mNoteEditor.setTextAppearance(this, + TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); + } + mFontSizeSelector.setVisibility(View.GONE); + } + } + + @Override + public void onBackPressed() { + if(clearSettingState()) { + return; + } + + saveNote(); + super.onBackPressed(); + } + + private boolean clearSettingState() { + if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) { + mNoteBgColorSelector.setVisibility(View.GONE); + return true; + } else if (mFontSizeSelector.getVisibility() == View.VISIBLE) { + mFontSizeSelector.setVisibility(View.GONE); + return true; + } + return false; + } + + public void onBackgroundColorChanged() { + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( + View.VISIBLE); + mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); + mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + if (isFinishing()) { + return true; + } + clearSettingState(); + menu.clear(); + if (mWorkingNote.getFolderId() == Notes.ID_CALL_RECORD_FOLDER) { + getMenuInflater().inflate(R.menu.call_note_edit, menu); + } else { + getMenuInflater().inflate(R.menu.note_edit, menu); + } + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode); + } else { + menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_list_mode); + } + if (mWorkingNote.hasClockAlert()) { + menu.findItem(R.id.menu_alert).setVisible(false); + } else { + menu.findItem(R.id.menu_delete_remind).setVisible(false); + } + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_new_note: + createNewNote(); + break; + case R.id.menu_delete: + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getString(R.string.alert_title_delete)); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(getString(R.string.alert_message_delete_note)); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + deleteCurrentNote(); + finish(); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + break; + case R.id.menu_font_size: + mFontSizeSelector.setVisibility(View.VISIBLE); + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); + break; + case R.id.menu_list_mode: + mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ? + TextNote.MODE_CHECK_LIST : 0); + break; + case R.id.menu_share: + getWorkingText(); + sendTo(this, mWorkingNote.getContent()); + break; + case R.id.menu_send_to_desktop: + sendToDesktop(); + break; + case R.id.menu_alert: + setReminder(); + break; + case R.id.menu_delete_remind: + mWorkingNote.setAlertDate(0, false); + break; + default: + break; + } + return true; + } + + private void setReminder() { + DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis()); + d.setOnDateTimeSetListener(new OnDateTimeSetListener() { + public void OnDateTimeSet(AlertDialog dialog, long date) { + mWorkingNote.setAlertDate(date , true); + } + }); + d.show(); + } + + /** + * Share note to apps that support {@link Intent#ACTION_SEND} action + * and {@text/plain} type + */ + private void sendTo(Context context, String info) { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.putExtra(Intent.EXTRA_TEXT, info); + intent.setType("text/plain"); + context.startActivity(intent); + } + + private void createNewNote() { + // Firstly, save current editing notes + saveNote(); + + // For safety, start a new NoteEditActivity + finish(); + Intent intent = new Intent(this, NoteEditActivity.class); + intent.setAction(Intent.ACTION_INSERT_OR_EDIT); + intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId()); + startActivity(intent); + } + + private void deleteCurrentNote() { + if (mWorkingNote.existInDatabase()) { + HashSet ids = new HashSet(); + long id = mWorkingNote.getNoteId(); + if (id != Notes.ID_ROOT_FOLDER) { + ids.add(id); + } else { + Log.d(TAG, "Wrong note id, should not happen"); + } + if (!isSyncMode()) { + if (!DataUtils.batchDeleteNotes(getContentResolver(), ids)) { + Log.e(TAG, "Delete Note error"); + } + } else { + if (!DataUtils.batchMoveToFolder(getContentResolver(), ids, Notes.ID_TRASH_FOLER)) { + Log.e(TAG, "Move notes to trash folder error, should not happens"); + } + } + } + mWorkingNote.markDeleted(true); + } + + private boolean isSyncMode() { + return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; + } + + public void onClockAlertChanged(long date, boolean set) { + /** + * User could set clock to an unsaved note, so before setting the + * alert clock, we should save the note first + */ + if (!mWorkingNote.existInDatabase()) { + saveNote(); + } + if (mWorkingNote.getNoteId() > 0) { + Intent intent = new Intent(this, AlarmReceiver.class); + intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId())); + PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); + AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); + showAlertHeader(); + if(!set) { + alarmManager.cancel(pendingIntent); + } else { + alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent); + } + } else { + /** + * There is the condition that user has input nothing (the note is + * not worthy saving), we have no note id, remind the user that he + * should input something + */ + Log.e(TAG, "Clock alert setting error"); + showToast(R.string.error_note_empty_for_clock); + } + } + + public void onWidgetChanged() { + updateWidget(); + } + + public void onEditTextDelete(int index, String text) { + int childCount = mEditTextList.getChildCount(); + if (childCount == 1) { + return; + } + + for (int i = index + 1; i < childCount; i++) { + ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)) + .setIndex(i - 1); + } + + mEditTextList.removeViewAt(index); + NoteEditText edit = null; + if(index == 0) { + edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById( + R.id.et_edit_text); + } else { + edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById( + R.id.et_edit_text); + } + int length = edit.length(); + edit.append(text); + edit.requestFocus(); + edit.setSelection(length); + } + + public void onEditTextEnter(int index, String text) { + /** + * Should not happen, check for debug + */ + if(index > mEditTextList.getChildCount()) { + Log.e(TAG, "Index out of mEditTextList boundrary, should not happen"); + } + + View view = getListItem(text, index); + mEditTextList.addView(view, index); + NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + edit.requestFocus(); + edit.setSelection(0); + for (int i = index + 1; i < mEditTextList.getChildCount(); i++) { + ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)) + .setIndex(i); + } + } + + private void switchToListMode(String text) { + mEditTextList.removeAllViews(); + String[] items = text.split("\n"); + int index = 0; + for (String item : items) { + if(!TextUtils.isEmpty(item)) { + mEditTextList.addView(getListItem(item, index)); + index++; + } + } + mEditTextList.addView(getListItem("", index)); + mEditTextList.getChildAt(index).findViewById(R.id.et_edit_text).requestFocus(); + + mNoteEditor.setVisibility(View.GONE); + mEditTextList.setVisibility(View.VISIBLE); + } + + private Spannable getHighlightQueryResult(String fullText, String userQuery) { + SpannableString spannable = new SpannableString(fullText == null ? "" : fullText); + if (!TextUtils.isEmpty(userQuery)) { + mPattern = Pattern.compile(userQuery); + Matcher m = mPattern.matcher(fullText); + int start = 0; + while (m.find(start)) { + spannable.setSpan( + new BackgroundColorSpan(this.getResources().getColor( + R.color.user_query_highlight)), m.start(), m.end(), + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + start = m.end(); + } + } + return spannable; + } + + private View getListItem(String item, int index) { + View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null); + final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); + CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item)); + cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + } else { + edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); + } + } + }); + + if (item.startsWith(TAG_CHECKED)) { + cb.setChecked(true); + edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + item = item.substring(TAG_CHECKED.length(), item.length()).trim(); + } else if (item.startsWith(TAG_UNCHECKED)) { + cb.setChecked(false); + edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); + item = item.substring(TAG_UNCHECKED.length(), item.length()).trim(); + } + + edit.setOnTextViewChangeListener(this); + edit.setIndex(index); + edit.setText(getHighlightQueryResult(item, mUserQuery)); + return view; + } + + public void onTextChange(int index, boolean hasText) { + if (index >= mEditTextList.getChildCount()) { + Log.e(TAG, "Wrong index, should not happen"); + return; + } + if(hasText) { + mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE); + } else { + mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE); + } + } + + public void onCheckListModeChanged(int oldMode, int newMode) { + if (newMode == TextNote.MODE_CHECK_LIST) { + switchToListMode(mNoteEditor.getText().toString()); + } else { + if (!getWorkingText()) { + mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ", + "")); + } + mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); + mEditTextList.setVisibility(View.GONE); + mNoteEditor.setVisibility(View.VISIBLE); + } + } + + private boolean getWorkingText() { + boolean hasChecked = false; + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mEditTextList.getChildCount(); i++) { + View view = mEditTextList.getChildAt(i); + NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + if (!TextUtils.isEmpty(edit.getText())) { + if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) { + sb.append(TAG_CHECKED).append(" ").append(edit.getText()).append("\n"); + hasChecked = true; + } else { + sb.append(TAG_UNCHECKED).append(" ").append(edit.getText()).append("\n"); + } + } + } + mWorkingNote.setWorkingText(sb.toString()); + } else { + mWorkingNote.setWorkingText(mNoteEditor.getText().toString()); + } + return hasChecked; + } + + private boolean saveNote() { + getWorkingText(); + boolean saved = mWorkingNote.saveNote(); + if (saved) { + /** + * There are two modes from List view to edit view, open one note, + * create/edit a node. Opening node requires to the original + * position in the list when back from edit view, while creating a + * new node requires to the top of the list. This code + * {@link #RESULT_OK} is used to identify the create/edit state + */ + setResult(RESULT_OK); + } + return saved; + } + + private void sendToDesktop() { + /** + * Before send message to home, we should make sure that current + * editing note is exists in databases. So, for new note, firstly + * save it + */ + if (!mWorkingNote.existInDatabase()) { + saveNote(); + } + + if (mWorkingNote.getNoteId() > 0) { + Intent sender = new Intent(); + Intent shortcutIntent = new Intent(this, NoteEditActivity.class); + shortcutIntent.setAction(Intent.ACTION_VIEW); + shortcutIntent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId()); + sender.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); + sender.putExtra(Intent.EXTRA_SHORTCUT_NAME, + makeShortcutIconTitle(mWorkingNote.getContent())); + sender.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, + Intent.ShortcutIconResource.fromContext(this, R.drawable.icon_app)); + sender.putExtra("duplicate", true); + sender.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); + showToast(R.string.info_note_enter_desktop); + sendBroadcast(sender); + } else { + /** + * There is the condition that user has input nothing (the note is + * not worthy saving), we have no note id, remind the user that he + * should input something + */ + Log.e(TAG, "Send to desktop error"); + showToast(R.string.error_note_empty_for_send_to_desktop); + } + } + + private String makeShortcutIconTitle(String content) { + content = content.replace(TAG_CHECKED, ""); + content = content.replace(TAG_UNCHECKED, ""); + return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0, + SHORTCUT_ICON_TITLE_MAX_LEN) : content; + } + + private void showToast(int resId) { + showToast(resId, Toast.LENGTH_SHORT); + } + + private void showToast(int resId, int duration) { + Toast.makeText(this, resId, duration).show(); + } +} diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NoteEditText.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NoteEditText.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NoteEditText.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/NoteEditText.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NoteItemData.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NoteItemData.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NoteItemData.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/NoteItemData.java diff --git a/Notes-master/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NotesListActivity.java new file mode 100644 index 0000000..93bef89 --- /dev/null +++ b/Notes-master/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -0,0 +1,955 @@ +/* + * 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.ui; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.appwidget.AppWidgetManager; +import android.content.AsyncQueryHandler; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v7.app.AppCompatActivity; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.util.Log; +import android.view.ActionMode; +import android.view.ContextMenu; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.Display; +import android.view.HapticFeedbackConstants; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MenuItem.OnMenuItemClickListener; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnCreateContextMenuListener; +import android.view.View.OnTouchListener; +import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemLongClickListener; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.PopupMenu; +import android.widget.TextView; +import android.widget.Toast; + +import net.micode.notes.R; +import net.micode.notes.data.Notes; +import net.micode.notes.data.Notes.NoteColumns; +import net.micode.notes.gtask.remote.GTaskSyncService; +import net.micode.notes.model.WorkingNote; +import net.micode.notes.tool.BackupUtils; +import net.micode.notes.tool.DataUtils; +import net.micode.notes.tool.ResourceParser; +import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute; +import net.micode.notes.widget.NoteWidgetProvider_2x; +import net.micode.notes.widget.NoteWidgetProvider_4x; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.HashSet; + +public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener { + private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0; + + private static final int FOLDER_LIST_QUERY_TOKEN = 1; + + private static final int MENU_FOLDER_DELETE = 0; + + private static final int MENU_FOLDER_VIEW = 1; + + private static final int MENU_FOLDER_CHANGE_NAME = 2; + + private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction"; + + private enum ListEditState { + NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER + }; + + private ListEditState mState; + + private BackgroundQueryHandler mBackgroundQueryHandler; + + private NotesListAdapter mNotesListAdapter; + + private ListView mNotesListView; + + private Button mAddNewNote; + + private boolean mDispatch; + + private int mOriginY; + + private int mDispatchY; + + private TextView mTitleBar; + + private long mCurrentFolderId; + + private ContentResolver mContentResolver; + + private ModeCallback mModeCallBack; + + private static final String TAG = "NotesListActivity"; + + public static final int NOTES_LISTVIEW_SCROLL_RATE = 30; + + private NoteItemData mFocusNoteDataItem; + + private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?"; + + private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>" + + Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR (" + + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND " + + NoteColumns.NOTES_COUNT + ">0)"; + + private final static int REQUEST_CODE_OPEN_NODE = 102; + private final static int REQUEST_CODE_NEW_NODE = 103; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.note_list); + initResources(); + + /** + * Insert an introduction when user firstly use this application + */ + setAppInfoFromRawRes(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (resultCode == RESULT_OK + && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) { + mNotesListAdapter.changeCursor(null); + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } + + private void setAppInfoFromRawRes() { + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); + if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) { + StringBuilder sb = new StringBuilder(); + InputStream in = null; + try { + in = getResources().openRawResource(R.raw.introduction); + if (in != null) { + InputStreamReader isr = new InputStreamReader(in); + BufferedReader br = new BufferedReader(isr); + char [] buf = new char[1024]; + int len = 0; + while ((len = br.read(buf)) > 0) { + sb.append(buf, 0, len); + } + } else { + Log.e(TAG, "Read introduction file error"); + return; + } + } catch (IOException e) { + e.printStackTrace(); + return; + } finally { + if(in != null) { + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER, + AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE, + ResourceParser.RED); + note.setWorkingText(sb.toString()); + if (note.saveNote()) { + sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit(); + } else { + Log.e(TAG, "Save introduction note error"); + return; + } + } + } + + @Override + protected void onStart() { + super.onStart(); + startAsyncNotesListQuery(); + } + + private void initResources() { + mContentResolver = this.getContentResolver(); + mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mNotesListView = (ListView) findViewById(R.id.notes_list); + mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), + null, false); + mNotesListView.setOnItemClickListener(new OnListItemClickListener()); + mNotesListView.setOnItemLongClickListener(this); + mNotesListAdapter = new NotesListAdapter(this); + mNotesListView.setAdapter(mNotesListAdapter); + mAddNewNote = (Button) findViewById(R.id.btn_new_note); + mAddNewNote.setOnClickListener(this); + mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener()); + mDispatch = false; + mDispatchY = 0; + mOriginY = 0; + mTitleBar = (TextView) findViewById(R.id.tv_title_bar); + mState = ListEditState.NOTE_LIST; + mModeCallBack = new ModeCallback(); + } + + private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener { + private DropdownMenu mDropDownMenu; + private ActionMode mActionMode; + private MenuItem mMoveMenu; + + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + getMenuInflater().inflate(R.menu.note_list_options, menu); + menu.findItem(R.id.delete).setOnMenuItemClickListener(this); + mMoveMenu = menu.findItem(R.id.move); + if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER + || DataUtils.getUserFolderCount(mContentResolver) == 0) { + mMoveMenu.setVisible(false); + } else { + mMoveMenu.setVisible(true); + mMoveMenu.setOnMenuItemClickListener(this); + } + mActionMode = mode; + mNotesListAdapter.setChoiceMode(true); + mNotesListView.setLongClickable(false); + mAddNewNote.setVisibility(View.GONE); + + View customView = LayoutInflater.from(NotesListActivity.this).inflate( + R.layout.note_list_dropdown_menu, null); + mode.setCustomView(customView); + mDropDownMenu = new DropdownMenu(NotesListActivity.this, + (Button) customView.findViewById(R.id.selection_menu), + R.menu.note_list_dropdown); + mDropDownMenu.setOnDropdownMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ + public boolean onMenuItemClick(MenuItem item) { + mNotesListAdapter.selectAll(!mNotesListAdapter.isAllSelected()); + updateMenu(); + return true; + } + + }); + return true; + } + + private void updateMenu() { + int selectedCount = mNotesListAdapter.getSelectedCount(); + // Update dropdown menu + String format = getResources().getString(R.string.menu_select_title, selectedCount); + mDropDownMenu.setTitle(format); + MenuItem item = mDropDownMenu.findItem(R.id.action_select_all); + if (item != null) { + if (mNotesListAdapter.isAllSelected()) { + item.setChecked(true); + item.setTitle(R.string.menu_deselect_all); + } else { + item.setChecked(false); + item.setTitle(R.string.menu_select_all); + } + } + } + + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + // TODO Auto-generated method stub + return false; + } + + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + // TODO Auto-generated method stub + return false; + } + + public void onDestroyActionMode(ActionMode mode) { + mNotesListAdapter.setChoiceMode(false); + mNotesListView.setLongClickable(true); + mAddNewNote.setVisibility(View.VISIBLE); + } + + public void finishActionMode() { + mActionMode.finish(); + } + + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, + boolean checked) { + mNotesListAdapter.setCheckedItem(position, checked); + updateMenu(); + } + + public boolean onMenuItemClick(MenuItem item) { + if (mNotesListAdapter.getSelectedCount() == 0) { + Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none), + Toast.LENGTH_SHORT).show(); + return true; + } + + switch (item.getItemId()) { + case R.id.delete: + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(getString(R.string.alert_title_delete)); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(getString(R.string.alert_message_delete_notes, + mNotesListAdapter.getSelectedCount())); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + batchDelete(); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + break; + case R.id.move: + startQueryDestinationFolders(); + break; + default: + return false; + } + return true; + } + } + + private class NewNoteOnTouchListener implements OnTouchListener { + + public boolean onTouch(View v, MotionEvent event) { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: { + Display display = getWindowManager().getDefaultDisplay(); + int screenHeight = display.getHeight(); + int newNoteViewHeight = mAddNewNote.getHeight(); + int start = screenHeight - newNoteViewHeight; + int eventY = start + (int) event.getY(); + /** + * Minus TitleBar's height + */ + if (mState == ListEditState.SUB_FOLDER) { + eventY -= mTitleBar.getHeight(); + start -= mTitleBar.getHeight(); + } + /** + * HACKME:When click the transparent part of "New Note" button, dispatch + * the event to the list view behind this button. The transparent part of + * "New Note" button could be expressed by formula y=-0.12x+94(Unit:pixel) + * and the line top of the button. The coordinate based on left of the "New + * Note" button. The 94 represents maximum height of the transparent part. + * Notice that, if the background of the button changes, the formula should + * also change. This is very bad, just for the UI designer's strong requirement. + */ + if (event.getY() < (event.getX() * (-0.12) + 94)) { + View view = mNotesListView.getChildAt(mNotesListView.getChildCount() - 1 + - mNotesListView.getFooterViewsCount()); + if (view != null && view.getBottom() > start + && (view.getTop() < (start + 94))) { + mOriginY = (int) event.getY(); + mDispatchY = eventY; + event.setLocation(event.getX(), mDispatchY); + mDispatch = true; + return mNotesListView.dispatchTouchEvent(event); + } + } + break; + } + case MotionEvent.ACTION_MOVE: { + if (mDispatch) { + mDispatchY += (int) event.getY() - mOriginY; + event.setLocation(event.getX(), mDispatchY); + return mNotesListView.dispatchTouchEvent(event); + } + break; + } + default: { + if (mDispatch) { + event.setLocation(event.getX(), mDispatchY); + mDispatch = false; + return mNotesListView.dispatchTouchEvent(event); + } + break; + } + } + return false; + } + + }; + + private void startAsyncNotesListQuery() { + String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION + : NORMAL_SELECTION; + mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null, + Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] { + String.valueOf(mCurrentFolderId) + }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); + } + + private final class BackgroundQueryHandler extends AsyncQueryHandler { + public BackgroundQueryHandler(ContentResolver contentResolver) { + super(contentResolver); + } + + @Override + protected void onQueryComplete(int token, Object cookie, Cursor cursor) { + switch (token) { + case FOLDER_NOTE_LIST_QUERY_TOKEN: + mNotesListAdapter.changeCursor(cursor); + break; + case FOLDER_LIST_QUERY_TOKEN: + if (cursor != null && cursor.getCount() > 0) { + showFolderListMenu(cursor); + } else { + Log.e(TAG, "Query folder failed"); + } + break; + default: + return; + } + } + } + + private void showFolderListMenu(Cursor cursor) { + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(R.string.menu_title_select_folder); + final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor); + builder.setAdapter(adapter, new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, int which) { + DataUtils.batchMoveToFolder(mContentResolver, + mNotesListAdapter.getSelectedItemIds(), adapter.getItemId(which)); + Toast.makeText( + NotesListActivity.this, + getString(R.string.format_move_notes_to_folder, + mNotesListAdapter.getSelectedCount(), + adapter.getFolderName(NotesListActivity.this, which)), + Toast.LENGTH_SHORT).show(); + mModeCallBack.finishActionMode(); + } + }); + builder.show(); + } + + private void createNewNote() { + Intent intent = new Intent(this, NoteEditActivity.class); + intent.setAction(Intent.ACTION_INSERT_OR_EDIT); + intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId); + this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE); + } + + private void batchDelete() { + new AsyncTask>() { + protected HashSet doInBackground(Void... unused) { + HashSet widgets = mNotesListAdapter.getSelectedWidget(); + if (!isSyncMode()) { + // if not synced, delete notes directly + if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter + .getSelectedItemIds())) { + } else { + Log.e(TAG, "Delete notes error, should not happens"); + } + } else { + // in sync mode, we'll move the deleted note into the trash + // folder + if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter + .getSelectedItemIds(), Notes.ID_TRASH_FOLER)) { + Log.e(TAG, "Move notes to trash folder error, should not happens"); + } + } + return widgets; + } + + @Override + protected void onPostExecute(HashSet widgets) { + if (widgets != null) { + for (AppWidgetAttribute widget : widgets) { + if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID + && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) { + updateWidget(widget.widgetId, widget.widgetType); + } + } + } + mModeCallBack.finishActionMode(); + } + }.execute(); + } + + private void deleteFolder(long folderId) { + if (folderId == Notes.ID_ROOT_FOLDER) { + Log.e(TAG, "Wrong folder id, should not happen " + folderId); + return; + } + + HashSet ids = new HashSet(); + ids.add(folderId); + HashSet widgets = DataUtils.getFolderNoteWidget(mContentResolver, + folderId); + if (!isSyncMode()) { + // if not synced, delete folder directly + DataUtils.batchDeleteNotes(mContentResolver, ids); + } else { + // in sync mode, we'll move the deleted folder into the trash folder + DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER); + } + if (widgets != null) { + for (AppWidgetAttribute widget : widgets) { + if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID + && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) { + updateWidget(widget.widgetId, widget.widgetType); + } + } + } + } + + private void openNode(NoteItemData data) { + Intent intent = new Intent(this, NoteEditActivity.class); + intent.setAction(Intent.ACTION_VIEW); + intent.putExtra(Intent.EXTRA_UID, data.getId()); + this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE); + } + + private void openFolder(NoteItemData data) { + mCurrentFolderId = data.getId(); + startAsyncNotesListQuery(); + if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { + mState = ListEditState.CALL_RECORD_FOLDER; + mAddNewNote.setVisibility(View.GONE); + } else { + mState = ListEditState.SUB_FOLDER; + } + if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { + mTitleBar.setText(R.string.call_record_folder_name); + } else { + mTitleBar.setText(data.getSnippet()); + } + mTitleBar.setVisibility(View.VISIBLE); + } + + public void onClick(View v) { + switch (v.getId()) { + case R.id.btn_new_note: + createNewNote(); + break; + default: + break; + } + } + + private void showSoftInput() { + InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (inputMethodManager != null) { + inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + } + + private void hideSoftInput(View view) { + InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + + private void showCreateOrModifyFolderDialog(final boolean create) { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); + final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); + showSoftInput(); + if (!create) { + if (mFocusNoteDataItem != null) { + etName.setText(mFocusNoteDataItem.getSnippet()); + builder.setTitle(getString(R.string.menu_folder_change_name)); + } else { + Log.e(TAG, "The long click data item is null"); + return; + } + } else { + etName.setText(""); + builder.setTitle(this.getString(R.string.menu_create_folder)); + } + + builder.setPositiveButton(android.R.string.ok, null); + builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + hideSoftInput(etName); + } + }); + + final Dialog dialog = builder.setView(view).show(); + final Button positive = (Button)dialog.findViewById(android.R.id.button1); + positive.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + hideSoftInput(etName); + String name = etName.getText().toString(); + if (DataUtils.checkVisibleFolderName(mContentResolver, name)) { + Toast.makeText(NotesListActivity.this, getString(R.string.folder_exist, name), + Toast.LENGTH_LONG).show(); + etName.setSelection(0, etName.length()); + return; + } + if (!create) { + if (!TextUtils.isEmpty(name)) { + ContentValues values = new ContentValues(); + values.put(NoteColumns.SNIPPET, name); + values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); + values.put(NoteColumns.LOCAL_MODIFIED, 1); + mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID + + "=?", new String[] { + String.valueOf(mFocusNoteDataItem.getId()) + }); + } + } else if (!TextUtils.isEmpty(name)) { + ContentValues values = new ContentValues(); + values.put(NoteColumns.SNIPPET, name); + values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); + mContentResolver.insert(Notes.CONTENT_NOTE_URI, values); + } + dialog.dismiss(); + } + }); + + if (TextUtils.isEmpty(etName.getText())) { + positive.setEnabled(false); + } + /** + * When the name edit text is null, disable the positive button + */ + etName.addTextChangedListener(new TextWatcher() { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + // TODO Auto-generated method stub + + } + + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (TextUtils.isEmpty(etName.getText())) { + positive.setEnabled(false); + } else { + positive.setEnabled(true); + } + } + + public void afterTextChanged(Editable s) { + // TODO Auto-generated method stub + + } + }); + } + + @Override + public void onBackPressed() { + switch (mState) { + case SUB_FOLDER: + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + startAsyncNotesListQuery(); + mTitleBar.setVisibility(View.GONE); + break; + case CALL_RECORD_FOLDER: + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + mAddNewNote.setVisibility(View.VISIBLE); + mTitleBar.setVisibility(View.GONE); + startAsyncNotesListQuery(); + break; + case NOTE_LIST: + super.onBackPressed(); + break; + default: + break; + } + } + + private void updateWidget(int appWidgetId, int appWidgetType) { + Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + if (appWidgetType == Notes.TYPE_WIDGET_2X) { + intent.setClass(this, NoteWidgetProvider_2x.class); + } else if (appWidgetType == Notes.TYPE_WIDGET_4X) { + intent.setClass(this, NoteWidgetProvider_4x.class); + } else { + Log.e(TAG, "Unspported widget type"); + return; + } + + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { + appWidgetId + }); + + sendBroadcast(intent); + setResult(RESULT_OK, intent); + } + + private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() { + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { + if (mFocusNoteDataItem != null) { + menu.setHeaderTitle(mFocusNoteDataItem.getSnippet()); + menu.add(0, MENU_FOLDER_VIEW, 0, R.string.menu_folder_view); + menu.add(0, MENU_FOLDER_DELETE, 0, R.string.menu_folder_delete); + menu.add(0, MENU_FOLDER_CHANGE_NAME, 0, R.string.menu_folder_change_name); + } + } + }; + + @Override + public void onContextMenuClosed(Menu menu) { + if (mNotesListView != null) { + mNotesListView.setOnCreateContextMenuListener(null); + } + super.onContextMenuClosed(menu); + } + + @Override + public boolean onContextItemSelected(MenuItem item) { + if (mFocusNoteDataItem == null) { + Log.e(TAG, "The long click data item is null"); + return false; + } + switch (item.getItemId()) { + case MENU_FOLDER_VIEW: + openFolder(mFocusNoteDataItem); + break; + case MENU_FOLDER_DELETE: + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getString(R.string.alert_title_delete)); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(getString(R.string.alert_message_delete_folder)); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + deleteFolder(mFocusNoteDataItem.getId()); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + break; + case MENU_FOLDER_CHANGE_NAME: + showCreateOrModifyFolderDialog(false); + break; + default: + break; + } + + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.clear(); + if (mState == ListEditState.NOTE_LIST) { + getMenuInflater().inflate(R.menu.note_list, menu); + // set sync or sync_cancel + menu.findItem(R.id.menu_sync).setTitle( + GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync); + } else if (mState == ListEditState.SUB_FOLDER) { + getMenuInflater().inflate(R.menu.sub_folder, menu); + } else if (mState == ListEditState.CALL_RECORD_FOLDER) { + getMenuInflater().inflate(R.menu.call_record_folder, menu); + } else { + Log.e(TAG, "Wrong state:" + mState); + } + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_new_folder: { + showCreateOrModifyFolderDialog(true); + break; + } + case R.id.menu_export_text: { + exportNoteToText(); + break; + } + case R.id.menu_sync: { + if (isSyncMode()) { + if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) { + GTaskSyncService.startSync(this); + } else { + GTaskSyncService.cancelSync(this); + } + } else { + startPreferenceActivity(); + } + break; + } + case R.id.menu_setting: { + startPreferenceActivity(); + break; + } + case R.id.menu_new_note: { + createNewNote(); + break; + } + case R.id.menu_search: + onSearchRequested(); + break; + default: + break; + } + return true; + } + + @Override + public boolean onSearchRequested() { + startSearch(null, false, null /* appData */, false); + return true; + } + + private void exportNoteToText() { + final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this); + new AsyncTask() { + + @Override + protected Integer doInBackground(Void... unused) { + return backup.exportToText(); + } + + @Override + protected void onPostExecute(Integer result) { + if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) { + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(NotesListActivity.this + .getString(R.string.failed_sdcard_export)); + builder.setMessage(NotesListActivity.this + .getString(R.string.error_sdcard_unmounted)); + builder.setPositiveButton(android.R.string.ok, null); + builder.show(); + } else if (result == BackupUtils.STATE_SUCCESS) { + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(NotesListActivity.this + .getString(R.string.success_sdcard_export)); + builder.setMessage(NotesListActivity.this.getString( + R.string.format_exported_file_location, backup + .getExportedTextFileName(), backup.getExportedTextFileDir())); + builder.setPositiveButton(android.R.string.ok, null); + builder.show(); + } else if (result == BackupUtils.STATE_SYSTEM_ERROR) { + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(NotesListActivity.this + .getString(R.string.failed_sdcard_export)); + builder.setMessage(NotesListActivity.this + .getString(R.string.error_sdcard_export)); + builder.setPositiveButton(android.R.string.ok, null); + builder.show(); + } + } + + }.execute(); + } + + private boolean isSyncMode() { + return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; + } + + private void startPreferenceActivity() { + Activity from = getParent() != null ? getParent() : this; + Intent intent = new Intent(from, NotesPreferenceActivity.class); + from.startActivityIfNeeded(intent, -1); + } + + private class OnListItemClickListener implements OnItemClickListener { + + public void onItemClick(AdapterView parent, View view, int position, long id) { + if (view instanceof NotesListItem) { + NoteItemData item = ((NotesListItem) view).getItemData(); + if (mNotesListAdapter.isInChoiceMode()) { + if (item.getType() == Notes.TYPE_NOTE) { + position = position - mNotesListView.getHeaderViewsCount(); + mModeCallBack.onItemCheckedStateChanged(null, position, id, + !mNotesListAdapter.isSelectedItem(position)); + } + return; + } + + switch (mState) { + case NOTE_LIST: + if (item.getType() == Notes.TYPE_FOLDER + || item.getType() == Notes.TYPE_SYSTEM) { + openFolder(item); + } else if (item.getType() == Notes.TYPE_NOTE) { + openNode(item); + } else { + Log.e(TAG, "Wrong note type in NOTE_LIST"); + } + break; + case SUB_FOLDER: + case CALL_RECORD_FOLDER: + if (item.getType() == Notes.TYPE_NOTE) { + openNode(item); + } else { + Log.e(TAG, "Wrong note type in SUB_FOLDER"); + } + break; + default: + break; + } + } + } + + } + + private void startQueryDestinationFolders() { + String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?"; + selection = (mState == ListEditState.NOTE_LIST) ? selection: + "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")"; + + mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, + null, + Notes.CONTENT_NOTE_URI, + FoldersListAdapter.PROJECTION, + selection, + new String[] { + String.valueOf(Notes.TYPE_FOLDER), + String.valueOf(Notes.ID_TRASH_FOLER), + String.valueOf(mCurrentFolderId) + }, + NoteColumns.MODIFIED_DATE + " DESC"); + } + + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + if (view instanceof NotesListItem) { + mFocusNoteDataItem = ((NotesListItem) view).getItemData(); + if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) { + if (mNotesListView.startActionMode(mModeCallBack) != null) { + mModeCallBack.onItemCheckedStateChanged(null, position, id, true); + mNotesListView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } else { + Log.e(TAG, "startActionMode fails"); + } + } else if (mFocusNoteDataItem.getType() == Notes.TYPE_FOLDER) { + mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener); + } + } + return false; + } +} diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesListAdapter.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesListAdapter.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesListItem.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NotesListItem.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesListItem.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/NotesListItem.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesPreferenceActivity.java b/Notes-master/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/ui/NotesPreferenceActivity.java rename to Notes-master/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider.java b/Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider.java rename to Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java b/Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java rename to Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java diff --git a/小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java b/Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java similarity index 100% rename from 小米便签-Notes-master/Notes-master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java rename to Notes-master/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java diff --git a/Notes-master/app/src/main/res/color/primary_text_dark.xml b/Notes-master/app/src/main/res/color/primary_text_dark.xml new file mode 100644 index 0000000..8ad98e3 --- /dev/null +++ b/Notes-master/app/src/main/res/color/primary_text_dark.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/Notes-master/app/src/main/res/color/secondary_text_dark.xml b/Notes-master/app/src/main/res/color/secondary_text_dark.xml new file mode 100644 index 0000000..9cf8a1a --- /dev/null +++ b/Notes-master/app/src/main/res/color/secondary_text_dark.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/bg_btn_set_color.png b/Notes-master/app/src/main/res/drawable-hdpi/bg_btn_set_color.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/bg_btn_set_color.png rename to Notes-master/app/src/main/res/drawable-hdpi/bg_btn_set_color.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/bg_color_btn_mask.png b/Notes-master/app/src/main/res/drawable-hdpi/bg_color_btn_mask.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/bg_color_btn_mask.png rename to Notes-master/app/src/main/res/drawable-hdpi/bg_color_btn_mask.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/call_record.png b/Notes-master/app/src/main/res/drawable-hdpi/call_record.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/call_record.png rename to Notes-master/app/src/main/res/drawable-hdpi/call_record.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/clock.png b/Notes-master/app/src/main/res/drawable-hdpi/clock.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/clock.png rename to Notes-master/app/src/main/res/drawable-hdpi/clock.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/delete.png b/Notes-master/app/src/main/res/drawable-hdpi/delete.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/delete.png rename to Notes-master/app/src/main/res/drawable-hdpi/delete.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/dropdown_icon.9.png b/Notes-master/app/src/main/res/drawable-hdpi/dropdown_icon.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/dropdown_icon.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/dropdown_icon.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_blue.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_blue.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_blue.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_blue.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_green.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_green.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_green.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_green.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_red.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_red.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_red.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_red.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_blue.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_title_blue.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_blue.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_title_blue.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_green.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_title_green.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_green.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_title_green.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_red.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_title_red.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_red.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_title_red.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_white.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_title_white.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_white.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_title_white.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_yellow.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_title_yellow.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_title_yellow.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_title_yellow.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_white.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_white.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_white.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_white.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_yellow.9.png b/Notes-master/app/src/main/res/drawable-hdpi/edit_yellow.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/edit_yellow.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/edit_yellow.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_large.png b/Notes-master/app/src/main/res/drawable-hdpi/font_large.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_large.png rename to Notes-master/app/src/main/res/drawable-hdpi/font_large.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_normal.png b/Notes-master/app/src/main/res/drawable-hdpi/font_normal.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_normal.png rename to Notes-master/app/src/main/res/drawable-hdpi/font_normal.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_size_selector_bg.9.png b/Notes-master/app/src/main/res/drawable-hdpi/font_size_selector_bg.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_size_selector_bg.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/font_size_selector_bg.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_small.png b/Notes-master/app/src/main/res/drawable-hdpi/font_small.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_small.png rename to Notes-master/app/src/main/res/drawable-hdpi/font_small.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_super.png b/Notes-master/app/src/main/res/drawable-hdpi/font_super.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/font_super.png rename to Notes-master/app/src/main/res/drawable-hdpi/font_super.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/icon_app.png b/Notes-master/app/src/main/res/drawable-hdpi/icon_app.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/icon_app.png rename to Notes-master/app/src/main/res/drawable-hdpi/icon_app.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_background.png b/Notes-master/app/src/main/res/drawable-hdpi/list_background.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_background.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_background.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_down.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_blue_down.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_down.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_blue_down.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_middle.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_blue_middle.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_middle.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_blue_middle.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_single.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_blue_single.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_single.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_blue_single.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_up.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_blue_up.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_blue_up.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_blue_up.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_folder.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_folder.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_folder.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_folder.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_footer_bg.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_footer_bg.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_footer_bg.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_footer_bg.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_down.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_green_down.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_down.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_green_down.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_middle.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_green_middle.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_middle.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_green_middle.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_single.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_green_single.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_single.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_green_single.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_up.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_green_up.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_green_up.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_green_up.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_down.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_red_down.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_down.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_red_down.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_middle.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_red_middle.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_middle.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_red_middle.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_single.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_red_single.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_single.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_red_single.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_up.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_red_up.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_red_up.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_red_up.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_down.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_white_down.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_down.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_white_down.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_middle.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_white_middle.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_middle.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_white_middle.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_single.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_white_single.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_single.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_white_single.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_up.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_white_up.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_white_up.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_white_up.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_down.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_yellow_down.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_down.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_yellow_down.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_middle.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_yellow_middle.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_middle.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_yellow_middle.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_single.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_yellow_single.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_single.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_yellow_single.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_up.9.png b/Notes-master/app/src/main/res/drawable-hdpi/list_yellow_up.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/list_yellow_up.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/list_yellow_up.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/menu_delete.png b/Notes-master/app/src/main/res/drawable-hdpi/menu_delete.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/menu_delete.png rename to Notes-master/app/src/main/res/drawable-hdpi/menu_delete.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/menu_move.png b/Notes-master/app/src/main/res/drawable-hdpi/menu_move.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/menu_move.png rename to Notes-master/app/src/main/res/drawable-hdpi/menu_move.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/new_note_normal.png b/Notes-master/app/src/main/res/drawable-hdpi/new_note_normal.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/new_note_normal.png rename to Notes-master/app/src/main/res/drawable-hdpi/new_note_normal.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/new_note_pressed.png b/Notes-master/app/src/main/res/drawable-hdpi/new_note_pressed.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/new_note_pressed.png rename to Notes-master/app/src/main/res/drawable-hdpi/new_note_pressed.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/note_edit_color_selector_panel.png b/Notes-master/app/src/main/res/drawable-hdpi/note_edit_color_selector_panel.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/note_edit_color_selector_panel.png rename to Notes-master/app/src/main/res/drawable-hdpi/note_edit_color_selector_panel.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/notification.png b/Notes-master/app/src/main/res/drawable-hdpi/notification.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/notification.png rename to Notes-master/app/src/main/res/drawable-hdpi/notification.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/search_result.png b/Notes-master/app/src/main/res/drawable-hdpi/search_result.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/search_result.png rename to Notes-master/app/src/main/res/drawable-hdpi/search_result.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/selected.png b/Notes-master/app/src/main/res/drawable-hdpi/selected.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/selected.png rename to Notes-master/app/src/main/res/drawable-hdpi/selected.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/title_alert.png b/Notes-master/app/src/main/res/drawable-hdpi/title_alert.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/title_alert.png rename to Notes-master/app/src/main/res/drawable-hdpi/title_alert.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/title_bar_bg.9.png b/Notes-master/app/src/main/res/drawable-hdpi/title_bar_bg.9.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/title_bar_bg.9.png rename to Notes-master/app/src/main/res/drawable-hdpi/title_bar_bg.9.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_blue.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_2x_blue.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_blue.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_2x_blue.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_green.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_2x_green.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_green.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_2x_green.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_red.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_2x_red.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_red.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_2x_red.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_white.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_2x_white.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_white.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_2x_white.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_yellow.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_2x_yellow.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_2x_yellow.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_2x_yellow.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_blue.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_4x_blue.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_blue.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_4x_blue.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_green.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_4x_green.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_green.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_4x_green.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_red.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_4x_red.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_red.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_4x_red.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_white.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_4x_white.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_white.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_4x_white.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_yellow.png b/Notes-master/app/src/main/res/drawable-hdpi/widget_4x_yellow.png similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable-hdpi/widget_4x_yellow.png rename to Notes-master/app/src/main/res/drawable-hdpi/widget_4x_yellow.png diff --git a/小米便签-Notes-master/Notes-master/res/drawable/new_note.xml b/Notes-master/app/src/main/res/drawable/new_note.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/drawable/new_note.xml rename to Notes-master/app/src/main/res/drawable/new_note.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/account_dialog_title.xml b/Notes-master/app/src/main/res/layout/account_dialog_title.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/account_dialog_title.xml rename to Notes-master/app/src/main/res/layout/account_dialog_title.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/add_account_text.xml b/Notes-master/app/src/main/res/layout/add_account_text.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/add_account_text.xml rename to Notes-master/app/src/main/res/layout/add_account_text.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/datetime_picker.xml b/Notes-master/app/src/main/res/layout/datetime_picker.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/datetime_picker.xml rename to Notes-master/app/src/main/res/layout/datetime_picker.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/dialog_edit_text.xml b/Notes-master/app/src/main/res/layout/dialog_edit_text.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/dialog_edit_text.xml rename to Notes-master/app/src/main/res/layout/dialog_edit_text.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/folder_list_item.xml b/Notes-master/app/src/main/res/layout/folder_list_item.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/folder_list_item.xml rename to Notes-master/app/src/main/res/layout/folder_list_item.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_edit.xml b/Notes-master/app/src/main/res/layout/note_edit.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_edit.xml rename to Notes-master/app/src/main/res/layout/note_edit.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_edit_list_item.xml b/Notes-master/app/src/main/res/layout/note_edit_list_item.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_edit_list_item.xml rename to Notes-master/app/src/main/res/layout/note_edit_list_item.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_item.xml b/Notes-master/app/src/main/res/layout/note_item.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_item.xml rename to Notes-master/app/src/main/res/layout/note_item.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_list.xml b/Notes-master/app/src/main/res/layout/note_list.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_list.xml rename to Notes-master/app/src/main/res/layout/note_list.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_list_dropdown_menu.xml b/Notes-master/app/src/main/res/layout/note_list_dropdown_menu.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_list_dropdown_menu.xml rename to Notes-master/app/src/main/res/layout/note_list_dropdown_menu.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/note_list_footer.xml b/Notes-master/app/src/main/res/layout/note_list_footer.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/note_list_footer.xml rename to Notes-master/app/src/main/res/layout/note_list_footer.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/settings_header.xml b/Notes-master/app/src/main/res/layout/settings_header.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/settings_header.xml rename to Notes-master/app/src/main/res/layout/settings_header.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/widget_2x.xml b/Notes-master/app/src/main/res/layout/widget_2x.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/widget_2x.xml rename to Notes-master/app/src/main/res/layout/widget_2x.xml diff --git a/小米便签-Notes-master/Notes-master/res/layout/widget_4x.xml b/Notes-master/app/src/main/res/layout/widget_4x.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/layout/widget_4x.xml rename to Notes-master/app/src/main/res/layout/widget_4x.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/call_note_edit.xml b/Notes-master/app/src/main/res/menu/call_note_edit.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/call_note_edit.xml rename to Notes-master/app/src/main/res/menu/call_note_edit.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/call_record_folder.xml b/Notes-master/app/src/main/res/menu/call_record_folder.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/call_record_folder.xml rename to Notes-master/app/src/main/res/menu/call_record_folder.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/note_edit.xml b/Notes-master/app/src/main/res/menu/note_edit.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/note_edit.xml rename to Notes-master/app/src/main/res/menu/note_edit.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/note_list.xml b/Notes-master/app/src/main/res/menu/note_list.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/note_list.xml rename to Notes-master/app/src/main/res/menu/note_list.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/note_list_dropdown.xml b/Notes-master/app/src/main/res/menu/note_list_dropdown.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/note_list_dropdown.xml rename to Notes-master/app/src/main/res/menu/note_list_dropdown.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/note_list_options.xml b/Notes-master/app/src/main/res/menu/note_list_options.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/note_list_options.xml rename to Notes-master/app/src/main/res/menu/note_list_options.xml diff --git a/小米便签-Notes-master/Notes-master/res/menu/sub_folder.xml b/Notes-master/app/src/main/res/menu/sub_folder.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/menu/sub_folder.xml rename to Notes-master/app/src/main/res/menu/sub_folder.xml diff --git a/小米便签-Notes-master/Notes-master/res/raw-zh-rCN/introduction b/Notes-master/app/src/main/res/raw-zh-rCN/introduction similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/raw-zh-rCN/introduction rename to Notes-master/app/src/main/res/raw-zh-rCN/introduction diff --git a/小米便签-Notes-master/Notes-master/res/raw/introduction b/Notes-master/app/src/main/res/raw/introduction similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/raw/introduction rename to Notes-master/app/src/main/res/raw/introduction diff --git a/小米便签-Notes-master/Notes-master/res/values-zh-rCN/arrays.xml b/Notes-master/app/src/main/res/values-zh-rCN/arrays.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values-zh-rCN/arrays.xml rename to Notes-master/app/src/main/res/values-zh-rCN/arrays.xml diff --git a/小米便签-Notes-master/Notes-master/res/values-zh-rCN/strings.xml b/Notes-master/app/src/main/res/values-zh-rCN/strings.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values-zh-rCN/strings.xml rename to Notes-master/app/src/main/res/values-zh-rCN/strings.xml diff --git a/小米便签-Notes-master/Notes-master/res/values-zh-rTW/arrays.xml b/Notes-master/app/src/main/res/values-zh-rTW/arrays.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values-zh-rTW/arrays.xml rename to Notes-master/app/src/main/res/values-zh-rTW/arrays.xml diff --git a/Notes-master/app/src/main/res/values-zh-rTW/strings.xml b/Notes-master/app/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 0000000..e29b79b --- /dev/null +++ b/Notes-master/app/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,127 @@ + + + + + + 便簽 + 便簽2x2 + 便簽4x4 + 沒有關聯內容,點擊新建便簽。 + 訪客模式下,便籤內容不可見 + ... + 新建便簽 + 成功刪除提醒 + 創建提醒 + 已過期 + yyyyMMdd + MM月dd日 kk:mm + 知道了 + 查看 + 呼叫電話 + 發送郵件 + 浏覽網頁 + 打開地圖 + 已將所選 %1$d 便籤移到 %2$s 文件夾 + + 新建文件夾 + 導出文本 + 同步 + 取消同步 + 設置 + 搜尋 + 刪除 + 移動到文件夾 + 選中了 %d 項 + 沒有選中項,操作無效 + 全選 + 取消全選 + 文字大小 + + 正常 + + 超大 + 進入清單模式 + 退出清單模式 + 查看文件夾 + 刪除文件夾 + 修改文件夾名稱 + 文件夾 %1$s 已存在,請重新命名 + 分享 + 發送到桌面 + 提醒我 + 刪除提醒 + 選擇文件夾 + 上一級文件夾 + 已添加到桌面 + 刪除 + 确认要刪除所選的 %d 條便籤嗎? + 确认要删除該條便籤嗎? + 確認刪除檔夾及所包含的便簽嗎? + SD卡被佔用,不能操作 + 導出TXT時發生錯誤,請檢查SD卡 + 要查看的便籤不存在 + 不能爲空便籤設置鬧鐘提醒 + 不能將空便籤發送到桌面 + 導出成功 + 導出失敗 + 已將文本文件(%1$s)導出至SD(%2$s)目錄 + + 同步便簽... + 同步成功 + 同步失敗 + 同步已取消 + 與%1$s同步成功 + 同步失敗,請檢查網絡和帳號設置 + 同步失敗,發生內部錯誤 + 同步已取消 + 登陸%1$s... + 正在獲取服務器便籤列表... + 正在同步本地便籤... + + 設置 + 同步賬號 + 与google task同步便簽記錄 + 上次同步于 %1$s + 添加賬號 + 更換賬號 + 刪除賬號 + 取消 + 立即同步 + 取消同步 + 當前帳號 %1$s + 如更換同步帳號,過去的帳號同步信息將被清空,再次切換的同時可能會造成數據重復 + 同步便簽 + 請選擇google帳號,便簽將與該帳號的google task內容同步。 + 正在同步中,不能修改同步帳號 + 同步帳號已設置為%1$s + 新建便籤背景顏色隨機 + + 刪除 + 通話便籤 + 請輸入名稱 + + 正在搜索便籤 + 搜索便籤 + 便籤中的文字 + 便籤 + 設置 + 取消 + + %1$s 條符合”%2$s“的搜尋結果 + + + diff --git a/小米便签-Notes-master/Notes-master/res/values/arrays.xml b/Notes-master/app/src/main/res/values/arrays.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values/arrays.xml rename to Notes-master/app/src/main/res/values/arrays.xml diff --git a/小米便签-Notes-master/Notes-master/res/values/colors.xml b/Notes-master/app/src/main/res/values/colors.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values/colors.xml rename to Notes-master/app/src/main/res/values/colors.xml diff --git a/小米便签-Notes-master/Notes-master/res/values/dimens.xml b/Notes-master/app/src/main/res/values/dimens.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values/dimens.xml rename to Notes-master/app/src/main/res/values/dimens.xml diff --git a/小米便签-Notes-master/Notes-master/res/values/strings.xml b/Notes-master/app/src/main/res/values/strings.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values/strings.xml rename to Notes-master/app/src/main/res/values/strings.xml diff --git a/小米便签-Notes-master/Notes-master/res/values/styles.xml b/Notes-master/app/src/main/res/values/styles.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/values/styles.xml rename to Notes-master/app/src/main/res/values/styles.xml diff --git a/小米便签-Notes-master/Notes-master/res/xml/preferences.xml b/Notes-master/app/src/main/res/xml/preferences.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/xml/preferences.xml rename to Notes-master/app/src/main/res/xml/preferences.xml diff --git a/小米便签-Notes-master/Notes-master/res/xml/searchable.xml b/Notes-master/app/src/main/res/xml/searchable.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/xml/searchable.xml rename to Notes-master/app/src/main/res/xml/searchable.xml diff --git a/小米便签-Notes-master/Notes-master/res/xml/widget_2x_info.xml b/Notes-master/app/src/main/res/xml/widget_2x_info.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/xml/widget_2x_info.xml rename to Notes-master/app/src/main/res/xml/widget_2x_info.xml diff --git a/小米便签-Notes-master/Notes-master/res/xml/widget_4x_info.xml b/Notes-master/app/src/main/res/xml/widget_4x_info.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/xml/widget_4x_info.xml rename to Notes-master/app/src/main/res/xml/widget_4x_info.xml diff --git a/Notes-master/build.gradle b/Notes-master/build.gradle new file mode 100644 index 0000000..d13abb3 --- /dev/null +++ b/Notes-master/build.gradle @@ -0,0 +1,20 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'org.sonarqube' + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} diff --git a/Notes-master/gradle/wrapper/gradle-wrapper.jar b/Notes-master/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/Notes-master/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Notes-master/gradle/wrapper/gradle-wrapper.properties b/Notes-master/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d2d1c95 --- /dev/null +++ b/Notes-master/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,9 @@ +#Fri May 05 09:13:16 CST 2023 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +systemProp.sonar.host.url=http://localhost:9000 +systemProp.sonar.login=admin +systemProp.sonar.password=admin \ No newline at end of file diff --git a/Notes-master/gradlew b/Notes-master/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/Notes-master/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/Notes-master/gradlew.bat b/Notes-master/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/Notes-master/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Notes-master/import-summary.txt b/Notes-master/import-summary.txt new file mode 100644 index 0000000..f2e6428 --- /dev/null +++ b/Notes-master/import-summary.txt @@ -0,0 +1,36 @@ +ECLIPSE ANDROID PROJECT IMPORT SUMMARY +====================================== + +Ignored Files: +-------------- +The following files were *not* copied into the new Gradle project; you +should evaluate whether these are still needed in your project and if +so manually move them: + +* .gitignore +* NOTICE +* README + +Moved Files: +------------ +Android Gradle projects use a different directory structure than ADT +Eclipse projects. Here's how the projects were restructured: + +* AndroidManifest.xml => app\src\main\AndroidManifest.xml +* res\ => app\src\main\res\ +* src\ => app\src\main\java\ + +Next Steps: +----------- +You can now build the project. The Gradle project needs network +connectivity to download dependencies. + +Bugs: +----- +If for some reason your project does not build, and you determine that +it is due to a bug or limitation of the Eclipse to Gradle importer, +please file a bug at http://b.android.com with category +Component-Tools. + +(This import summary is for your information only, and can be deleted +after import once you are satisfied with the results.) diff --git a/Notes-master/local.properties b/Notes-master/local.properties new file mode 100644 index 0000000..98623a3 --- /dev/null +++ b/Notes-master/local.properties @@ -0,0 +1,7 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# +#Fri May 05 09:13:16 CST 2023 +sdk.dir=F\:\\Android_SDK diff --git a/Notes-master/settings.gradle b/Notes-master/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/Notes-master/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/小米便签-Notes-master/Notes-master/.gitignore b/Notes-master1_1_1/Notes-master/.gitignore similarity index 100% rename from 小米便签-Notes-master/Notes-master/.gitignore rename to Notes-master1_1_1/Notes-master/.gitignore diff --git a/小米便签-Notes-master/Notes-master/AndroidManifest.xml b/Notes-master1_1_1/Notes-master/AndroidManifest.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/AndroidManifest.xml rename to Notes-master1_1_1/Notes-master/AndroidManifest.xml diff --git a/小米便签-Notes-master/Notes-master/NOTICE b/Notes-master1_1_1/Notes-master/NOTICE similarity index 100% rename from 小米便签-Notes-master/Notes-master/NOTICE rename to Notes-master1_1_1/Notes-master/NOTICE diff --git a/小米便签-Notes-master/Notes-master/README b/Notes-master1_1_1/Notes-master/README similarity index 100% rename from 小米便签-Notes-master/Notes-master/README rename to Notes-master1_1_1/Notes-master/README diff --git a/小米便签-Notes-master/Notes-master/res/color/primary_text_dark.xml b/Notes-master1_1_1/Notes-master/res/color/primary_text_dark.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/color/primary_text_dark.xml rename to Notes-master1_1_1/Notes-master/res/color/primary_text_dark.xml diff --git a/小米便签-Notes-master/Notes-master/res/color/secondary_text_dark.xml b/Notes-master1_1_1/Notes-master/res/color/secondary_text_dark.xml similarity index 100% rename from 小米便签-Notes-master/Notes-master/res/color/secondary_text_dark.xml rename to Notes-master1_1_1/Notes-master/res/color/secondary_text_dark.xml diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_btn_set_color.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_btn_set_color.png new file mode 100644 index 0000000..5eb5d44 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_btn_set_color.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_color_btn_mask.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_color_btn_mask.png new file mode 100644 index 0000000..100db77 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/bg_color_btn_mask.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/call_record.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/call_record.png new file mode 100644 index 0000000..fb88ca4 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/call_record.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/clock.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/clock.png new file mode 100644 index 0000000..5f2ae9a Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/clock.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/delete.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/delete.png new file mode 100644 index 0000000..643de3e Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/delete.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/dropdown_icon.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/dropdown_icon.9.png new file mode 100644 index 0000000..5525025 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/dropdown_icon.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_blue.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_blue.9.png new file mode 100644 index 0000000..55a1856 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_blue.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_green.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_green.9.png new file mode 100644 index 0000000..2cb2d60 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_green.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_red.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_red.9.png new file mode 100644 index 0000000..bae944a Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_red.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_blue.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_blue.9.png new file mode 100644 index 0000000..96e6092 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_blue.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_green.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_green.9.png new file mode 100644 index 0000000..08d8644 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_green.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_red.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_red.9.png new file mode 100644 index 0000000..9c430e5 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_red.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_white.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_white.9.png new file mode 100644 index 0000000..19e8d95 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_white.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_yellow.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_yellow.9.png new file mode 100644 index 0000000..bf8f580 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_title_yellow.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_white.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_white.9.png new file mode 100644 index 0000000..918f7a6 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_white.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_yellow.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_yellow.9.png new file mode 100644 index 0000000..10cb642 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/edit_yellow.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_large.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_large.png new file mode 100644 index 0000000..78cf2e6 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_large.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_normal.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_normal.png new file mode 100644 index 0000000..9de7ced Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_normal.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_size_selector_bg.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_size_selector_bg.9.png new file mode 100644 index 0000000..be8e64c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_size_selector_bg.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_small.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_small.png new file mode 100644 index 0000000..d3ff104 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_small.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_super.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_super.png new file mode 100644 index 0000000..85b13a1 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/font_super.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/icon_app.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/icon_app.png new file mode 100644 index 0000000..418aadc Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/icon_app.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_background.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_background.png new file mode 100644 index 0000000..087e1f9 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_background.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_down.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_down.9.png new file mode 100644 index 0000000..b88eebf Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_down.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_middle.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_middle.9.png new file mode 100644 index 0000000..96b1c8b Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_middle.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_single.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_single.9.png new file mode 100644 index 0000000..d7e7206 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_single.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_up.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_up.9.png new file mode 100644 index 0000000..632e88c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_blue_up.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_folder.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_folder.9.png new file mode 100644 index 0000000..829f61b Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_folder.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_footer_bg.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_footer_bg.9.png new file mode 100644 index 0000000..5325c25 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_footer_bg.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_down.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_down.9.png new file mode 100644 index 0000000..64a39d9 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_down.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_middle.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_middle.9.png new file mode 100644 index 0000000..897325a Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_middle.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_single.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_single.9.png new file mode 100644 index 0000000..c83405f Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_single.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_up.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_up.9.png new file mode 100644 index 0000000..141f9e1 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_green_up.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_down.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_down.9.png new file mode 100644 index 0000000..4224309 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_down.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_middle.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_middle.9.png new file mode 100644 index 0000000..9988f17 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_middle.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_single.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_single.9.png new file mode 100644 index 0000000..587c348 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_single.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_up.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_up.9.png new file mode 100644 index 0000000..46b4757 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_red_up.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_down.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_down.9.png new file mode 100644 index 0000000..29f9d8c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_down.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_middle.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_middle.9.png new file mode 100644 index 0000000..77a4ab4 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_middle.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_single.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_single.9.png new file mode 100644 index 0000000..3e79189 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_single.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_up.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_up.9.png new file mode 100644 index 0000000..e23cd5c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_white_up.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_down.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_down.9.png new file mode 100644 index 0000000..31cfc1e Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_down.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_middle.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_middle.9.png new file mode 100644 index 0000000..b6549b2 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_middle.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_single.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_single.9.png new file mode 100644 index 0000000..3faf507 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_single.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_up.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_up.9.png new file mode 100644 index 0000000..4ae791c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/list_yellow_up.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_delete.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_delete.png new file mode 100644 index 0000000..ccdfc4b Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_delete.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_move.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_move.png new file mode 100644 index 0000000..1140b71 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/menu_move.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_normal.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_normal.png new file mode 100644 index 0000000..e24e0d1 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_normal.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_pressed.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_pressed.png new file mode 100644 index 0000000..c748936 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/new_note_pressed.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/note_edit_color_selector_panel.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/note_edit_color_selector_panel.png new file mode 100644 index 0000000..fc49552 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/note_edit_color_selector_panel.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/notification.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/notification.png new file mode 100644 index 0000000..b13ab4a Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/notification.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/search_result.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/search_result.png new file mode 100644 index 0000000..ff2befd Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/search_result.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/selected.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/selected.png new file mode 100644 index 0000000..b889bef Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/selected.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_alert.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_alert.png new file mode 100644 index 0000000..544ee9c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_alert.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_bar_bg.9.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_bar_bg.9.png new file mode 100644 index 0000000..eb6bff0 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/title_bar_bg.9.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_blue.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_blue.png new file mode 100644 index 0000000..a1707f4 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_blue.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_green.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_green.png new file mode 100644 index 0000000..f86886c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_green.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_red.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_red.png new file mode 100644 index 0000000..0e66c29 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_red.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_white.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_white.png new file mode 100644 index 0000000..5f0619a Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_white.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_yellow.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_yellow.png new file mode 100644 index 0000000..12d1c2b Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_2x_yellow.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_blue.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_blue.png new file mode 100644 index 0000000..9183738 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_blue.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_green.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_green.png new file mode 100644 index 0000000..fa8b452 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_green.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_red.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_red.png new file mode 100644 index 0000000..62de074 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_red.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_white.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_white.png new file mode 100644 index 0000000..a37d67c Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_white.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_yellow.png b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_yellow.png new file mode 100644 index 0000000..d7c5fa4 Binary files /dev/null and b/Notes-master1_1_1/Notes-master/res/drawable-hdpi/widget_4x_yellow.png differ diff --git a/Notes-master1_1_1/Notes-master/res/drawable/new_note.xml b/Notes-master1_1_1/Notes-master/res/drawable/new_note.xml new file mode 100644 index 0000000..2154ebc --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/drawable/new_note.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/Notes-master1_1_1/Notes-master/res/layout/account_dialog_title.xml b/Notes-master1_1_1/Notes-master/res/layout/account_dialog_title.xml new file mode 100644 index 0000000..7717112 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/account_dialog_title.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Notes-master1_1_1/Notes-master/res/layout/add_account_text.xml b/Notes-master1_1_1/Notes-master/res/layout/add_account_text.xml new file mode 100644 index 0000000..c799178 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/add_account_text.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/Notes-master1_1_1/Notes-master/res/layout/datetime_picker.xml b/Notes-master1_1_1/Notes-master/res/layout/datetime_picker.xml new file mode 100644 index 0000000..f10d592 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/datetime_picker.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Notes-master1_1_1/Notes-master/res/layout/dialog_edit_text.xml b/Notes-master1_1_1/Notes-master/res/layout/dialog_edit_text.xml new file mode 100644 index 0000000..361b39a --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/dialog_edit_text.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/Notes-master1_1_1/Notes-master/res/layout/folder_list_item.xml b/Notes-master1_1_1/Notes-master/res/layout/folder_list_item.xml new file mode 100644 index 0000000..77e8148 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/folder_list_item.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/Notes-master1_1_1/Notes-master/res/layout/note_edit.xml b/Notes-master1_1_1/Notes-master/res/layout/note_edit.xml new file mode 100644 index 0000000..10b2aa7 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/note_edit.xml @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Notes-master1_1_1/Notes-master/res/layout/note_edit_list_item.xml b/Notes-master1_1_1/Notes-master/res/layout/note_edit_list_item.xml new file mode 100644 index 0000000..a885f9c --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/note_edit_list_item.xml @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/Notes-master1_1_1/Notes-master/res/layout/note_item.xml b/Notes-master1_1_1/Notes-master/res/layout/note_item.xml new file mode 100644 index 0000000..d541f6a --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/note_item.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Notes-master1_1_1/Notes-master/res/layout/note_list.xml b/Notes-master1_1_1/Notes-master/res/layout/note_list.xml new file mode 100644 index 0000000..6b25d38 --- /dev/null +++ b/Notes-master1_1_1/Notes-master/res/layout/note_list.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + +