Home | History | Annotate | Download | only in browser
      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.browser;
     18 
     19 import android.app.Activity;
     20 import android.content.Intent;
     21 import android.database.Cursor;
     22 import android.os.Bundle;
     23 import android.view.View;
     24 import android.view.View.OnClickListener;
     25 
     26 public class ShortcutActivity extends Activity
     27     implements BookmarksPageCallbacks, OnClickListener {
     28 
     29     private BrowserBookmarksPage mBookmarks;
     30 
     31     @Override
     32     protected void onCreate(Bundle savedInstanceState) {
     33         super.onCreate(savedInstanceState);
     34         setTitle(R.string.shortcut_bookmark_title);
     35         setContentView(R.layout.pick_bookmark);
     36         mBookmarks = (BrowserBookmarksPage) getFragmentManager()
     37                 .findFragmentById(R.id.bookmarks);
     38         mBookmarks.setEnableContextMenu(false);
     39         mBookmarks.setCallbackListener(this);
     40         View cancel = findViewById(R.id.cancel);
     41         if (cancel != null) {
     42             cancel.setOnClickListener(this);
     43         }
     44     }
     45 
     46     // BookmarksPageCallbacks
     47 
     48     @Override
     49     public boolean onBookmarkSelected(Cursor c, boolean isFolder) {
     50         if (isFolder) {
     51             return false;
     52         }
     53         Intent intent = BrowserBookmarksPage.createShortcutIntent(this, c);
     54         setResult(RESULT_OK, intent);
     55         finish();
     56         return true;
     57     }
     58 
     59     @Override
     60     public boolean onOpenInNewWindow(String... urls) {
     61         return false;
     62     }
     63 
     64     @Override
     65     public void onClick(View v) {
     66         switch (v.getId()) {
     67         case R.id.cancel:
     68             finish();
     69             break;
     70         }
     71     }
     72 }
     73