• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.googlecode.android_scripting.activity;
18 
19 import android.app.Activity;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.Intent.ShortcutIconResource;
23 import android.net.Uri;
24 import android.os.Bundle;
25 import android.provider.LiveFolders;
26 
27 import com.googlecode.android_scripting.R;
28 import com.googlecode.android_scripting.provider.ScriptProvider;
29 
30 public class ScriptsLiveFolder extends Activity {
31 
32   public static final Uri CONTENT_URI =
33       Uri.parse("content://" + ScriptProvider.AUTHORITY + "/" + ScriptProvider.LIVEFOLDER);
34 
35   @Override
onCreate(Bundle savedInstanceState)36   protected void onCreate(Bundle savedInstanceState) {
37     super.onCreate(savedInstanceState);
38     final Intent intent = getIntent();
39     final String action = intent.getAction();
40     if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
41       setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI, "Scripts", R.drawable.live_folder));
42     } else {
43       setResult(RESULT_CANCELED);
44     }
45     finish();
46   }
47 
createLiveFolder(Context context, Uri uri, String name, int icon)48   private Intent createLiveFolder(Context context, Uri uri, String name, int icon) {
49     final Intent intent = new Intent();
50     intent.setData(uri);
51     intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, name);
52     intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, ShortcutIconResource
53         .fromContext(this, icon));
54     intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);
55     return intent;
56   }
57 }
58