blob: 2d533b53e06cd498afd4f172ebed0a5ea6ea86f9 [file] [log] [blame]
The Android Open Source Projectb64d3452009-03-03 19:32:20 -08001/*
2 * Copyright (C) 2007 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.camera;
18
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080019import android.app.Activity;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080020import android.content.Intent;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080021import android.net.Uri;
22import android.os.Bundle;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080023
24/**
Chih-Chung Chang0435bac2009-04-01 00:11:56 -070025 * Wallpaper picker for the camera application. This just redirects to the
26 * standard pick action.
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080027 */
28public class Wallpaper extends Activity {
Owen Lin71d56e22009-09-23 22:27:04 +080029 @SuppressWarnings("unused")
Chih-Chung Changc830ac22009-08-24 16:42:21 +080030 private static final String TAG = "Wallpaper";
31 private static final int PHOTO_PICKED = 1;
32 private static final int CROP_DONE = 2;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080033
34 @Override
35 protected void onCreate(Bundle icicle) {
36 super.onCreate(icicle);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080037
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080038 Uri imageToUse = getIntent().getData();
39 if (imageToUse != null) {
40 Intent intent = new Intent();
Chih-Chung Chang0435bac2009-04-01 00:11:56 -070041 intent.setClassName("com.android.camera",
42 "com.android.camera.CropImage");
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080043 intent.setData(imageToUse);
44 formatIntent(intent);
45 startActivityForResult(intent, CROP_DONE);
46 } else {
47 Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
48 intent.setType("image/*");
49 intent.putExtra("crop", "true");
50 formatIntent(intent);
51 startActivityForResult(intent, PHOTO_PICKED);
52 }
53 }
54
55 protected void formatIntent(Intent intent) {
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080056 int width = getWallpaperDesiredMinimumWidth();
57 int height = getWallpaperDesiredMinimumHeight();
58 intent.putExtra("outputX", width);
59 intent.putExtra("outputY", height);
60 intent.putExtra("aspectX", width);
61 intent.putExtra("aspectY", height);
62 intent.putExtra("scale", true);
63 intent.putExtra("noFaceDetection", true);
Chih-Chung Changc830ac22009-08-24 16:42:21 +080064 intent.putExtra("setWallpaper", true);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080065 }
66
67 @Override
Chih-Chung Chang0435bac2009-04-01 00:11:56 -070068 protected void onActivityResult(int requestCode, int resultCode,
69 Intent data) {
Chih-Chung Changc830ac22009-08-24 16:42:21 +080070 if ((requestCode == PHOTO_PICKED || requestCode == CROP_DONE)) {
71 setResult(resultCode);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080072 finish();
73 }
74 }
75}