1 /* 2 * Copyright (C) 2016 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * 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 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 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