blob: 3a11070219f40c3e501f2e824d943cebec17b7cb [file] [log] [blame]
Daniel Sandler5c9c1572012-08-16 10:57:52 -04001/*
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
17package com.android.dreams.web;
18
Daniel Sandler5c9c1572012-08-16 10:57:52 -040019import android.util.Log;
20import android.content.SharedPreferences.Editor;
21import android.content.SharedPreferences;
22import android.preference.PreferenceManager;
23import android.widget.Toast;
24import android.os.Bundle;
25import android.app.Activity;
26import android.content.Intent;
27import android.widget.Toast;
28
29public class SetURLInteractive extends Activity {
30 @Override
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
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", true);
52 editor.commit();
53
54 Toast.makeText(this, "WebView dream URL set to: " + url, Toast.LENGTH_SHORT).show();
55 }
56}