• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.notepad;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import android.provider.LiveFolders;
24 
25 public class NotesLiveFolder extends Activity {
26     /**
27      * The URI for the Notes Live Folder content provider.
28      */
29     public static final Uri CONTENT_URI = Uri.parse("content://"
30             + NotePad.AUTHORITY + "/live_folders/notes");
31 
32     public static final Uri NOTE_URI = Uri.parse("content://"
33             + NotePad.AUTHORITY + "/notes/#");
34 
35     @Override
onCreate(Bundle savedInstanceState)36     protected void onCreate(Bundle savedInstanceState) {
37         super.onCreate(savedInstanceState);
38 
39         final Intent intent = getIntent();
40         final String action = intent.getAction();
41 
42         if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
43             // Build the live folder intent.
44             final Intent liveFolderIntent = new Intent();
45 
46             liveFolderIntent.setData(CONTENT_URI);
47             liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME,
48                     getString(R.string.live_folder_name));
49             liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
50                     Intent.ShortcutIconResource.fromContext(this,
51                             R.drawable.live_folder_notes));
52             liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,
53                     LiveFolders.DISPLAY_MODE_LIST);
54             liveFolderIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
55                     new Intent(Intent.ACTION_EDIT, NOTE_URI));
56 
57             // The result of this activity should be a live folder intent.
58             setResult(RESULT_OK, liveFolderIntent);
59         } else {
60             setResult(RESULT_CANCELED);
61         }
62 
63         finish();
64     }
65 }
66