1 /*
2  * Copyright (C) 2012 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.dreams.web;
18 
19 import android.util.Log;
20 import android.content.SharedPreferences.Editor;
21 import android.content.SharedPreferences;
22 import android.preference.PreferenceManager;
23 import android.widget.Toast;
24 import android.os.Bundle;
25 import android.app.Activity;
26 import android.content.Intent;
27 import android.widget.Toast;
28 
29 public class SetURL extends Activity {
30     @Override
onCreate(Bundle stuff)31     public void onCreate(Bundle stuff) {
32         super.onCreate(stuff);
33 
34         final Intent intent = getIntent();
35 
36         final String action = intent.getAction();
37         String url = intent.getStringExtra(Intent.EXTRA_TEXT);
38 
39         if (url == null) {
40             finish();
41         } else if (Intent.ACTION_SEND.equals(action)) {
42             set(url);
43             finish();
44         }
45     }
46 
set(String url)47     protected void set(String url) {
48         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
49         final Editor editor = prefs.edit();
50         editor.putString("url", url);
51         editor.putBoolean("interactive", false);
52         editor.commit();
53 
54         Toast.makeText(this, "WebView dream URL set to: " + url, Toast.LENGTH_SHORT).show();
55     }
56 }
57