summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/GearsShortcutDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser/GearsShortcutDialog.java')
-rw-r--r--src/com/android/browser/GearsShortcutDialog.java151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/com/android/browser/GearsShortcutDialog.java b/src/com/android/browser/GearsShortcutDialog.java
deleted file mode 100644
index 11d936d..0000000
--- a/src/com/android/browser/GearsShortcutDialog.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.browser;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.util.Log;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Gears Shortcut dialog
- */
-class GearsShortcutDialog extends GearsBaseDialog {
-
- private static final String TAG = "GearsPermissionsDialog";
-
- private final String ICON_16 = "icon16x16";
- private final String ICON_32 = "icon32x32";
- private final String ICON_48 = "icon48x48";
- private final String ICON_128 = "icon128x128";
- private int mNotification = 0;
-
- public GearsShortcutDialog(Activity activity,
- Handler handler,
- String arguments) {
- super (activity, handler, arguments);
- }
-
- public void setup() {
- inflate(R.layout.gears_dialog_shortcut, R.id.panel_content);
- setupButtons(R.string.shortcut_button_alwaysdeny,
- R.string.shortcut_button_allow,
- R.string.shortcut_button_deny);
-
- try {
- JSONObject json = new JSONObject(mDialogArguments);
-
- String iconUrl = pickIconToRender(json);
- if (iconUrl != null) {
- downloadIcon(iconUrl);
- }
-
- setupDialog();
-
- setLabel(json, "name", R.id.shortcut_name);
- setLabel(json, "link", R.id.origin_subtitle);
- setLabel(json, "description", R.id.origin_message);
- } catch (JSONException e) {
- Log.e(TAG, "JSON exception", e);
- }
-
- TextView msg = (TextView) findViewById(R.id.permission_dialog_message);
- msg.setText(R.string.shortcut_message);
-
- View shortcutIcon = findViewById(R.id.shortcut_panel);
- if (shortcutIcon != null) {
- shortcutIcon.setVisibility(View.VISIBLE);
- }
- }
-
- public void setupDialog(TextView message, ImageView icon) {
- message.setText(R.string.shortcut_prompt);
- icon.setImageResource(R.drawable.ic_dialog_menu_generic);
- }
-
- /**
- * Utility method to validate an icon url. Used in the
- * shortcut dialog.
- */
- boolean validIcon(JSONObject json, String name) {
- try {
- if (json.has(name)) {
- String str = json.getString(name);
- if (str.length() > 0) {
- return true;
- }
- }
- } catch (JSONException e) {
- Log.e(TAG, "JSON exception", e);
- }
- return false;
- }
-
-
- /**
- * Utility method to pick the best indicated icon
- * from the dialogs' arguments. Used in the
- * shortcut dialog.
- */
- String pickIconToRender(JSONObject json) {
- try {
- if (validIcon(json, ICON_48)) { // ideal size
- mChoosenIconSize = 48;
- return json.getString(ICON_48);
- } else if (validIcon(json, ICON_32)) {
- mChoosenIconSize = 32;
- return json.getString(ICON_32);
- } else if (validIcon(json, ICON_128)) {
- mChoosenIconSize = 128;
- return json.getString(ICON_128);
- } else if (validIcon(json, ICON_16)) {
- mChoosenIconSize = 16;
- return json.getString(ICON_16);
- }
- } catch (JSONException e) {
- Log.e(TAG, "JSON exception", e);
- }
- mChoosenIconSize = 0;
- return null;
- }
-
- public String closeDialog(int closingType) {
- String ret = null;
- switch (closingType) {
- case ALWAYS_DENY:
- ret = "{\"allow\": false, \"permanently\": true }";
- break;
- case ALLOW:
- ret = "{\"allow\": true, \"locations\": 0 }";
- mNotification = R.string.shortcut_notification;
- break;
- case DENY:
- ret = null;
- break;
- }
- return ret;
- }
-
- public int notification() {
- return mNotification;
- }
-}