OSDN Git Service

am 57c88834: (-s ours) am 9fe36302: (-s ours) am 9cb97c44: Merge "DO NOT MERGE Fix...
[android-x86/packages-apps-Settings.git] / src / com / android / settings / CreateShortcut.java
1 /*
2  * Copyright (C) 2010 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.android.settings;
18
19 import android.app.LauncherActivity;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.view.View;
23 import android.widget.ListView;
24
25 public class CreateShortcut extends LauncherActivity {
26
27     @Override
28     protected Intent getTargetIntent() {
29         Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
30         targetIntent.addCategory("com.android.settings.SHORTCUT");
31         targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
32         return targetIntent;
33     }
34
35     @Override
36     protected void onListItemClick(ListView l, View v, int position, long id) {
37         Intent shortcutIntent = intentForPosition(position);
38         shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
39         Intent intent = new Intent();
40         intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
41                 Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_settings));
42         intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
43         intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, itemForPosition(position).label);
44         setResult(RESULT_OK, intent);
45         finish();
46     }
47
48     @Override
49     protected boolean onEvaluateShowIcons() {
50         return false;
51     }
52 }