11 package com.freerdp.freerdpcore.presentation;
13 import android.app.AlertDialog;
14 import android.app.ListActivity;
15 import android.content.Context;
16 import android.content.DialogInterface;
17 import android.content.Intent;
18 import android.net.Uri;
19 import android.os.Bundle;
20 import android.os.Parcelable;
21 import android.view.View;
22 import android.widget.AdapterView;
23 import android.widget.EditText;
24 import android.widget.TextView;
26 import com.freerdp.freerdpcore.R;
27 import com.freerdp.freerdpcore.application.GlobalApp;
28 import com.freerdp.freerdpcore.domain.BookmarkBase;
29 import com.freerdp.freerdpcore.services.SessionRequestHandlerActivity;
30 import com.freerdp.freerdpcore.utils.BookmarkArrayAdapter;
32 import java.util.ArrayList;
37 public static final String TAG =
"ShortcutsActivity";
39 @Override
public void onCreate(Bundle savedInstanceState)
42 super.onCreate(savedInstanceState);
44 Intent intent = getIntent();
45 if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction()))
48 getListView().setOnItemClickListener(
new AdapterView.OnItemClickListener() {
49 public void onItemClick(AdapterView<?> parent, View view, int position, long id)
51 String refStr = view.getTag().toString();
53 ((TextView)(view.findViewById(R.id.bookmark_text1))).getText().toString();
54 setupShortcut(refStr, defLabel);
65 @Override
public void onResume()
69 ArrayList<BookmarkBase> bookmarks =
GlobalApp.getManualBookmarkGateway().findAll();
72 getListView().setAdapter(bookmarkAdapter);
78 getListView().setAdapter(
null);
109 private void setupShortcut(String strRef, String defaultLabel)
111 final String paramStrRef = strRef;
112 final String paramDefaultLabel = defaultLabel;
113 final Context paramContext =
this;
116 final EditText input =
new EditText(
this);
117 input.setText(defaultLabel);
119 AlertDialog.Builder builder =
new AlertDialog.Builder(
this);
120 builder.setTitle(R.string.dlg_title_create_shortcut)
121 .setMessage(R.string.dlg_msg_create_shortcut)
125 new DialogInterface.OnClickListener() {
126 @Override public void onClick(DialogInterface dialog, int which)
128 String label = input.getText().toString();
129 if (label.length() == 0)
130 label = paramDefaultLabel;
132 Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
133 shortcutIntent.setClassName(paramContext,
134 SessionRequestHandlerActivity.class.getName());
135 shortcutIntent.setData(Uri.parse(paramStrRef));
138 Intent intent = new Intent();
139 intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
140 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
141 Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
142 paramContext, R.drawable.icon_launcher_freerdp);
143 intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
146 setResult(RESULT_OK, intent);
150 .setNegativeButton(android.R.string.cancel,
151 new DialogInterface.OnClickListener() {
152 @Override public void onClick(DialogInterface dialog, int which)