am a7178809: Fresh new change for: Add Live Folder support to NotePad sample, and add new icons for the app and Live Folder (separate for Donut and Eclair).
Merge commit 'a7178809f6aecff7c4e3ae3374b7cba5adc692bf' into eclair-mr2 * commit 'a7178809f6aecff7c4e3ae3374b7cba5adc692bf': Fresh new change for:
@@ -74,9 +74,10 @@
|
|||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="TitleEditor" android:label="@string/title_edit_title"
|
<activity android:name="TitleEditor"
|
||||||
android:theme="@android:style/Theme.Dialog"
|
android:label="@string/title_edit_title"
|
||||||
android:windowSoftInputMode="stateVisible">
|
android:theme="@android:style/Theme.Dialog"
|
||||||
|
android:windowSoftInputMode="stateVisible">
|
||||||
<!-- This activity implements an alternative action that can be
|
<!-- This activity implements an alternative action that can be
|
||||||
performed on notes: editing their title. It can be used as
|
performed on notes: editing their title. It can be used as
|
||||||
a default operation if the user invokes this action, and is
|
a default operation if the user invokes this action, and is
|
||||||
@@ -99,6 +100,16 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
|
||||||
|
android:icon="@drawable/live_folder_notes">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
<uses-sdk android:targetSdkVersion="4" android:minSdkVersion="3"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ It demonstrates:</p>
|
|||||||
<li>Accessing a database</li>
|
<li>Accessing a database</li>
|
||||||
<li>Using an intent to open a new window</li>
|
<li>Using an intent to open a new window</li>
|
||||||
<li>Managing activity lifecycle</li>
|
<li>Managing activity lifecycle</li>
|
||||||
|
<li>Creating <a href="../../../reference/android/provider/LiveFolders.html">Live Folders</a></li>
|
||||||
<li>And more...</li>
|
<li>And more...</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
BIN
samples/NotePad/res/drawable-hdpi-v6/app_notes.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
samples/NotePad/res/drawable-hdpi-v6/live_folder_notes.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
samples/NotePad/res/drawable-ldpi-v6/app_notes.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
samples/NotePad/res/drawable-ldpi-v6/live_folder_notes.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
samples/NotePad/res/drawable-mdpi-v6/app_notes.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
samples/NotePad/res/drawable-mdpi-v6/live_folder_notes.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
samples/NotePad/res/drawable-mdpi/live_folder_notes.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
@@ -30,6 +30,7 @@
|
|||||||
<string name="title_edit_title">Note title:</string>
|
<string name="title_edit_title">Note title:</string>
|
||||||
|
|
||||||
<string name="app_name">Note Pad</string>
|
<string name="app_name">Note Pad</string>
|
||||||
|
<string name="live_folder_name">Notes</string>
|
||||||
|
|
||||||
<string name="button_ok">OK</string>
|
<string name="button_ok">OK</string>
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.database.sqlite.SQLiteDatabase;
|
|||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.database.sqlite.SQLiteQueryBuilder;
|
import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.provider.LiveFolders;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -48,9 +49,11 @@ public class NotePadProvider extends ContentProvider {
|
|||||||
private static final String NOTES_TABLE_NAME = "notes";
|
private static final String NOTES_TABLE_NAME = "notes";
|
||||||
|
|
||||||
private static HashMap<String, String> sNotesProjectionMap;
|
private static HashMap<String, String> sNotesProjectionMap;
|
||||||
|
private static HashMap<String, String> sLiveFolderProjectionMap;
|
||||||
|
|
||||||
private static final int NOTES = 1;
|
private static final int NOTES = 1;
|
||||||
private static final int NOTE_ID = 2;
|
private static final int NOTE_ID = 2;
|
||||||
|
private static final int LIVE_FOLDER_NOTES = 3;
|
||||||
|
|
||||||
private static final UriMatcher sUriMatcher;
|
private static final UriMatcher sUriMatcher;
|
||||||
|
|
||||||
@@ -95,19 +98,22 @@ public class NotePadProvider extends ContentProvider {
|
|||||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
||||||
String sortOrder) {
|
String sortOrder) {
|
||||||
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
|
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
|
||||||
|
qb.setTables(NOTES_TABLE_NAME);
|
||||||
|
|
||||||
switch (sUriMatcher.match(uri)) {
|
switch (sUriMatcher.match(uri)) {
|
||||||
case NOTES:
|
case NOTES:
|
||||||
qb.setTables(NOTES_TABLE_NAME);
|
|
||||||
qb.setProjectionMap(sNotesProjectionMap);
|
qb.setProjectionMap(sNotesProjectionMap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOTE_ID:
|
case NOTE_ID:
|
||||||
qb.setTables(NOTES_TABLE_NAME);
|
|
||||||
qb.setProjectionMap(sNotesProjectionMap);
|
qb.setProjectionMap(sNotesProjectionMap);
|
||||||
qb.appendWhere(Notes._ID + "=" + uri.getPathSegments().get(1));
|
qb.appendWhere(Notes._ID + "=" + uri.getPathSegments().get(1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LIVE_FOLDER_NOTES:
|
||||||
|
qb.setProjectionMap(sLiveFolderProjectionMap);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown URI " + uri);
|
throw new IllegalArgumentException("Unknown URI " + uri);
|
||||||
}
|
}
|
||||||
@@ -133,6 +139,7 @@ public class NotePadProvider extends ContentProvider {
|
|||||||
public String getType(Uri uri) {
|
public String getType(Uri uri) {
|
||||||
switch (sUriMatcher.match(uri)) {
|
switch (sUriMatcher.match(uri)) {
|
||||||
case NOTES:
|
case NOTES:
|
||||||
|
case LIVE_FOLDER_NOTES:
|
||||||
return Notes.CONTENT_TYPE;
|
return Notes.CONTENT_TYPE;
|
||||||
|
|
||||||
case NOTE_ID:
|
case NOTE_ID:
|
||||||
@@ -238,6 +245,7 @@ public class NotePadProvider extends ContentProvider {
|
|||||||
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||||
sUriMatcher.addURI(NotePad.AUTHORITY, "notes", NOTES);
|
sUriMatcher.addURI(NotePad.AUTHORITY, "notes", NOTES);
|
||||||
sUriMatcher.addURI(NotePad.AUTHORITY, "notes/#", NOTE_ID);
|
sUriMatcher.addURI(NotePad.AUTHORITY, "notes/#", NOTE_ID);
|
||||||
|
sUriMatcher.addURI(NotePad.AUTHORITY, "live_folders/notes", LIVE_FOLDER_NOTES);
|
||||||
|
|
||||||
sNotesProjectionMap = new HashMap<String, String>();
|
sNotesProjectionMap = new HashMap<String, String>();
|
||||||
sNotesProjectionMap.put(Notes._ID, Notes._ID);
|
sNotesProjectionMap.put(Notes._ID, Notes._ID);
|
||||||
@@ -245,5 +253,13 @@ public class NotePadProvider extends ContentProvider {
|
|||||||
sNotesProjectionMap.put(Notes.NOTE, Notes.NOTE);
|
sNotesProjectionMap.put(Notes.NOTE, Notes.NOTE);
|
||||||
sNotesProjectionMap.put(Notes.CREATED_DATE, Notes.CREATED_DATE);
|
sNotesProjectionMap.put(Notes.CREATED_DATE, Notes.CREATED_DATE);
|
||||||
sNotesProjectionMap.put(Notes.MODIFIED_DATE, Notes.MODIFIED_DATE);
|
sNotesProjectionMap.put(Notes.MODIFIED_DATE, Notes.MODIFIED_DATE);
|
||||||
|
|
||||||
|
// Support for Live Folders.
|
||||||
|
sLiveFolderProjectionMap = new HashMap<String, String>();
|
||||||
|
sLiveFolderProjectionMap.put(LiveFolders._ID, Notes._ID + " AS " +
|
||||||
|
LiveFolders._ID);
|
||||||
|
sLiveFolderProjectionMap.put(LiveFolders.NAME, Notes.TITLE + " AS " +
|
||||||
|
LiveFolders.NAME);
|
||||||
|
// Add more columns here for more robust Live Folders.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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 com.example.android.notepad;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.LiveFolders;
|
||||||
|
|
||||||
|
public class NotesLiveFolder extends Activity {
|
||||||
|
/**
|
||||||
|
* The URI for the Notes Live Folder content provider.
|
||||||
|
*/
|
||||||
|
public static final Uri CONTENT_URI = Uri.parse("content://"
|
||||||
|
+ NotePad.AUTHORITY + "/live_folders/notes");
|
||||||
|
|
||||||
|
public static final Uri NOTE_URI = Uri.parse("content://"
|
||||||
|
+ NotePad.AUTHORITY + "/notes/#");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
final String action = intent.getAction();
|
||||||
|
|
||||||
|
if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
|
||||||
|
// Build the live folder intent.
|
||||||
|
final Intent liveFolderIntent = new Intent();
|
||||||
|
|
||||||
|
liveFolderIntent.setData(CONTENT_URI);
|
||||||
|
liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,
|
||||||
|
getString(R.string.live_folder_name));
|
||||||
|
liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
|
||||||
|
Intent.ShortcutIconResource.fromContext(this,
|
||||||
|
R.drawable.live_folder_notes));
|
||||||
|
liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,
|
||||||
|
LiveFolders.DISPLAY_MODE_LIST);
|
||||||
|
liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
|
||||||
|
new Intent(Intent.ACTION_EDIT, NOTE_URI));
|
||||||
|
|
||||||
|
// The result of this activity should be a live folder intent.
|
||||||
|
setResult(RESULT_OK, liveFolderIntent);
|
||||||
|
} else {
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
}
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||