summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChih-Chung Chang <>2009-04-08 05:14:37 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-08 05:14:37 -0700
commit272c3fdc60d4b4f773dfdff46ad3dd643ce22d5c (patch)
tree0884290e23fc567f24347e79ea3eb902945839e2 /src
parent885e55815c304efe199bc220fd8473c69ece1138 (diff)
downloadLegacyCamera-272c3fdc60d4b4f773dfdff46ad3dd643ce22d5c.zip
LegacyCamera-272c3fdc60d4b4f773dfdff46ad3dd643ce22d5c.tar.gz
LegacyCamera-272c3fdc60d4b4f773dfdff46ad3dd643ce22d5c.tar.bz2
AI 145048: Code clean up.
Automated import of CL 145048
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/CameraSettings.java6
-rw-r--r--src/com/android/camera/DrmWallpaper.java4
-rw-r--r--src/com/android/camera/GalleryPicker.java2
-rw-r--r--src/com/android/camera/ImageGallery2.java4
-rw-r--r--src/com/android/camera/MenuHelper.java187
-rw-r--r--src/com/android/camera/MovieView.java19
-rw-r--r--src/com/android/camera/ThumbnailController.java22
-rw-r--r--src/com/android/camera/VideoCamera.java2
-rw-r--r--src/com/android/camera/ViewImage.java3
9 files changed, 80 insertions, 169 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 4d0ca21..fc87524 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -30,8 +30,8 @@ import android.util.Log;
/**
* CameraSettings
*/
-public class CameraSettings extends PreferenceActivity
- implements OnSharedPreferenceChangeListener {
+public class CameraSettings extends PreferenceActivity implements
+ OnSharedPreferenceChangeListener {
public static final String KEY_VIDEO_QUALITY =
"pref_camera_videoquality_key";
public static final String KEY_WHITE_BALANCE =
@@ -44,7 +44,6 @@ public class CameraSettings extends PreferenceActivity
private ListPreference mEffect;
private Parameters mParameters;
- /** Called with the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -148,4 +147,3 @@ public class CameraSettings extends PreferenceActivity
}
}
}
-
diff --git a/src/com/android/camera/DrmWallpaper.java b/src/com/android/camera/DrmWallpaper.java
index ab9d8a6..d6bf039 100644
--- a/src/com/android/camera/DrmWallpaper.java
+++ b/src/com/android/camera/DrmWallpaper.java
@@ -16,19 +16,15 @@
package com.android.camera;
-
import android.content.Intent;
-
/**
* Wallpaper picker for DRM images. This just redirects to the standard pick
* action.
*/
public class DrmWallpaper extends Wallpaper {
-
protected void formatIntent(Intent intent) {
super.formatIntent(intent);
intent.putExtra("pick-drm", true);
}
-
}
diff --git a/src/com/android/camera/GalleryPicker.java b/src/com/android/camera/GalleryPicker.java
index 60737b5..46ada67 100644
--- a/src/com/android/camera/GalleryPicker.java
+++ b/src/com/android/camera/GalleryPicker.java
@@ -177,7 +177,6 @@ public class GalleryPicker extends Activity {
mGridView.setOnCreateContextMenuListener(
new View.OnCreateContextMenuListener() {
- @Override
public void onCreateContextMenu(ContextMenu menu, View v,
final ContextMenuInfo menuInfo) {
onCreateGalleryPickerContextMenu(menu, menuInfo);
@@ -644,7 +643,6 @@ public class GalleryPicker extends Activity {
intentFilter.addDataScheme("file");
registerReceiver(mReceiver, intentFilter);
- MenuHelper.requestOrientation(this, mPrefs);
}
private void setBackgrounds(Resources r) {
diff --git a/src/com/android/camera/ImageGallery2.java b/src/com/android/camera/ImageGallery2.java
index 27890e3..e2c113c 100644
--- a/src/com/android/camera/ImageGallery2.java
+++ b/src/com/android/camera/ImageGallery2.java
@@ -544,9 +544,6 @@ public class ImageGallery2 extends Activity {
}
};
registerReceiver(mReceiver, intentFilter);
-
- MenuHelper.requestOrientation(this, mPrefs);
-
rebake(false, ImageManager.isMediaScannerScanning(this));
}
@@ -806,7 +803,6 @@ public class ImageGallery2 extends Activity {
MenuHelper.INCLUDE_ALL,
isImage,
ImageGallery2.this,
- mHandler,
mDeletePhotoRunnable,
new MenuHelper.MenuInvoker() {
public void run(MenuHelper.MenuCallback cb) {
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index b572232..3ea3090 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -23,8 +23,6 @@ import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Environment;
@@ -44,6 +42,7 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.Closeable;
+import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -73,8 +72,6 @@ public class MenuHelper {
public static final int MENU_IMAGE_SHARE = 10;
public static final int MENU_IMAGE_SET = 14;
public static final int MENU_IMAGE_SET_WALLPAPER = 15;
- public static final int MENU_IMAGE_SET_CONTACT = 16;
- public static final int MENU_IMAGE_SET_MYFAVE = 17;
public static final int MENU_IMAGE_CROP = 18;
public static final int MENU_IMAGE_ROTATE = 19;
public static final int MENU_IMAGE_ROTATE_LEFT = 20;
@@ -82,7 +79,6 @@ public class MenuHelper {
public static final int MENU_IMAGE_TOSS = 22;
public static final int MENU_VIDEO_PLAY = 23;
public static final int MENU_VIDEO_SHARE = 24;
- public static final int MENU_VIDEO_TOSS = 27;
private static final long SHARE_FILE_LENGTH_LIMIT = 3L * 1024L * 1024L;
@@ -106,11 +102,13 @@ public class MenuHelper {
public void run(Uri uri, IImage image);
}
- private static void closeSilently(Closeable target) {
- try {
- if (target != null) target.close();
- } catch (Throwable t) {
- // ignore all exceptions, that's what silently means
+ public static void closeSilently(Closeable c) {
+ if (c != null) {
+ try {
+ c.close();
+ } catch (Throwable e) {
+ // ignore
+ }
}
}
@@ -143,6 +141,8 @@ public class MenuHelper {
}
}
+ // Called when "Details" is clicked.
+ // Displays detailed information about the image/video.
private static boolean onDetailsClicked(MenuInvoker onInvoke,
final Activity activity,
final boolean isImage) {
@@ -334,30 +334,21 @@ public class MenuHelper {
return true;
}
- private static boolean onRotateLeftClicked(MenuInvoker onInvoke) {
- onInvoke.run(new MenuCallback() {
- public void run(Uri u, IImage image) {
- if (image == null || image.isReadonly()) {
- return;
- }
- image.rotateImageBy(-90);
- }
- });
- return true;
- }
-
- private static boolean onRotateRightClicked(MenuInvoker onInvoke) {
+ // Called when "Rotate left" or "Rotate right" is clicked.
+ private static boolean onRotateClicked(MenuInvoker onInvoke,
+ final int degree) {
onInvoke.run(new MenuCallback() {
public void run(Uri u, IImage image) {
if (image == null || image.isReadonly()) {
return;
}
- image.rotateImageBy(90);
+ image.rotateImageBy(degree);
}
});
return true;
}
+ // Called when "Crop" is clicked.
private static boolean onCropClicked(MenuInvoker onInvoke,
final Activity activity) {
onInvoke.run(new MenuCallback() {
@@ -376,18 +367,15 @@ public class MenuHelper {
return true;
}
- private static boolean onImageSaveClicked(MenuInvoker onInvoke,
- final Activity activity) {
+ // Called when "Set as" is clicked.
+ private static boolean onSetAsClicked(MenuInvoker onInvoke,
+ final Activity activity) {
onInvoke.run(new MenuCallback() {
public void run(Uri u, IImage image) {
if (u == null || image == null) {
return;
}
- if (Config.LOGV) {
- Log.v(TAG, "in callback u is " + u + "; mime type is "
- + image.getMimeType());
- }
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(u, image.getMimeType());
intent.putExtra("mimeType", image.getMimeType());
@@ -398,6 +386,7 @@ public class MenuHelper {
return true;
}
+ // Called when "Share" is clicked.
private static boolean onImageShareClicked(MenuInvoker onInvoke,
final Activity activity, final boolean isImage) {
onInvoke.run(new MenuCallback() {
@@ -433,6 +422,7 @@ public class MenuHelper {
return true;
}
+ // Called when "Play" is clicked.
private static boolean onViewPlayClicked(MenuInvoker onInvoke,
final Activity activity) {
onInvoke.run(new MenuCallback() {
@@ -451,7 +441,6 @@ public class MenuHelper {
int inclusions,
final boolean isImage,
final Activity activity,
- final Handler handler,
final Runnable onDelete,
final MenuInvoker onInvoke) {
final ArrayList<MenuItem> requiresWriteAccessItems =
@@ -475,7 +464,7 @@ public class MenuHelper {
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- return onRotateLeftClicked(onInvoke);
+ return onRotateClicked(onInvoke, -90);
}
}).setAlphabeticShortcut('l'));
requiresWriteAccessItems.add(
@@ -484,7 +473,7 @@ public class MenuHelper {
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- return onRotateRightClicked(onInvoke);
+ return onRotateClicked(onInvoke, 90);
}
}).setAlphabeticShortcut('r'));
}
@@ -510,7 +499,7 @@ public class MenuHelper {
setMenu.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- return onImageSaveClicked(onInvoke, activity);
+ return onSetAsClicked(onInvoke, activity);
}
});
}
@@ -564,7 +553,6 @@ public class MenuHelper {
});
}
-
return new MenuItemsResult() {
public void gettingReadyToOpen(Menu menu, IImage image) {
// protect against null here. this isn't strictly speaking
@@ -593,7 +581,8 @@ public class MenuHelper {
item.setEnabled(!isDrm);
}
}
-
+
+ // must override abstract method
public void aboutToCall(MenuItem menu, IImage image) {
}
};
@@ -628,7 +617,7 @@ public class MenuHelper {
}
}
- public static void displayDeleteDialog(Activity activity,
+ private static void displayDeleteDialog(Activity activity,
final Runnable onDelete, boolean isPhoto) {
android.app.AlertDialog.Builder b =
new android.app.AlertDialog.Builder(activity);
@@ -669,19 +658,24 @@ public class MenuHelper {
MenuItem item = menu.add(group, MENU_SWITCH_CAMERA_MODE, 0, labelId)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- String action = switchToVideo
- ? MediaStore.INTENT_ACTION_VIDEO_CAMERA
- : MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA;
- Intent intent = new Intent(action);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- activity.startActivity(intent);
- return true;
- }
+ return onSwitchModeClicked(activity, switchToVideo);
+ }
});
item.setIcon(iconId);
}
+ private static boolean onSwitchModeClicked(Activity activity,
+ boolean switchToVideo) {
+ String action = switchToVideo
+ ? MediaStore.INTENT_ACTION_VIDEO_CAMERA
+ : MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA;
+ Intent intent = new Intent(action);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+ activity.startActivity(intent);
+ return true;
+ }
+
static void gotoStillImageCapture(Activity activity) {
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -712,14 +706,6 @@ public class MenuHelper {
intent.putExtra("windowTitle", activity.getString(windowTitleId));
intent.putExtra("mediaTypes", mediaTypes);
- // Request unspecified so that we match the current camera orientation
- // rather than matching the "flip orientation" preference.
- // Disabled because people don't care for it. Also it's
- // not as compelling now that we have implemented have quick orientation
- // flipping.
- // intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,
- // android.content.pm.ActivityInfo
- // .SCREEN_ORIENTATION_UNSPECIFIED);
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {
@@ -732,93 +718,46 @@ public class MenuHelper {
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(
- MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- try {
- activity.startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- // Ignore exception
- }
- return true;
+ return onCapturePictureClicked(activity);
}
}).setIcon(android.R.drawable.ic_menu_camera);
}
+ private static boolean onCapturePictureClicked(Activity activity) {
+ Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ try {
+ activity.startActivity(intent);
+ } catch (android.content.ActivityNotFoundException e) {
+ // Ignore exception
+ }
+ return true;
+ }
+
static void addCaptureVideoMenuItems(Menu menu, final Activity activity) {
menu.add(0, MENU_CAPTURE_VIDEO, 2, R.string.capture_video)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(
- MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- try {
- activity.startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- // Ignore exception
- }
- return true;
+ return onCaptureVideoClicked(activity);
}
}).setIcon(R.drawable.ic_menu_camera_video_view);
}
- static void addCaptureMenuItems(Menu menu, final Activity activity) {
- addCapturePictureMenuItems(menu, activity);
- addCaptureVideoMenuItems(menu, activity);
- }
-
- private static boolean onFlipOrientationClicked(Activity activity,
- SharedPreferences prefs) {
- // Check what our actual orientation is
- int current = activity.getResources().getConfiguration().orientation;
- int newOrientation = android.content.pm.ActivityInfo
- .SCREEN_ORIENTATION_LANDSCAPE;
- if (current == Configuration.ORIENTATION_LANDSCAPE) {
- newOrientation = android.content.pm.ActivityInfo
- .SCREEN_ORIENTATION_UNSPECIFIED;
+ private static boolean onCaptureVideoClicked(Activity activity) {
+ Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ try {
+ activity.startActivity(intent);
+ } catch (android.content.ActivityNotFoundException e) {
+ // Ignore exception
}
- SharedPreferences.Editor editor = prefs.edit();
- editor.putInt("nuorientation", newOrientation);
- editor.commit();
- requestOrientation(activity, prefs, true);
return true;
}
- static MenuItem addFlipOrientation(Menu menu, final Activity activity,
- final SharedPreferences prefs) {
- // position 41 after rotate
- // D
- return menu
- .add(Menu.CATEGORY_SECONDARY, 304, 41,
- R.string.flip_orientation)
- .setOnMenuItemClickListener(
- new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- return onFlipOrientationClicked(activity, prefs);
- }
- }).setIcon(
- android.R.drawable.ic_menu_always_landscape_portrait);
- }
-
- static void requestOrientation(Activity activity, SharedPreferences prefs) {
- requestOrientation(activity, prefs, false);
- }
-
- private static void requestOrientation(Activity activity,
- SharedPreferences prefs, boolean ignoreIntentExtra) {
- // Disable orientation for now. If it is set to
- // SCREEN_ORIENTATION_SENSOR, a duplicated orientation will be observed.
-
- return;
- }
-
- static void setFlipOrientationEnabled(Activity activity,
- MenuItem flipItem) {
- int keyboard = activity.getResources().getConfiguration()
- .hardKeyboardHidden;
- flipItem.setEnabled(keyboard != android.content.res.Configuration
- .HARDKEYBOARDHIDDEN_NO);
+ public static void addCaptureMenuItems(Menu menu, final Activity activity) {
+ addCapturePictureMenuItems(menu, activity);
+ addCaptureVideoMenuItems(menu, activity);
}
public static String formatDuration(final Activity activity,
diff --git a/src/com/android/camera/MovieView.java b/src/com/android/camera/MovieView.java
index 28a56bc..33bbd16 100644
--- a/src/com/android/camera/MovieView.java
+++ b/src/com/android/camera/MovieView.java
@@ -31,13 +31,13 @@ import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.os.Message;
import android.provider.MediaStore;
import android.provider.MediaStore.Video;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;
+// This activity plays a video from a specified URI.
public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
MediaPlayer.OnCompletionListener {
private static final String TAG = "MovieView";
@@ -82,8 +82,8 @@ public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
// For streams that we expect to be slow to start up, show a
// progress spinner until playback starts.
String scheme = mUri.getScheme();
- if ("http".equalsIgnoreCase(scheme) ||
- "rtsp".equalsIgnoreCase(scheme)) {
+ if ("http".equalsIgnoreCase(scheme)
+ || "rtsp".equalsIgnoreCase(scheme)) {
mHandler.postDelayed(mPlayingChecker, 250);
} else {
mProgressView.setVisibility(View.GONE);
@@ -142,8 +142,11 @@ public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
return null;
}
- String[] projection = new String[]{Video.VideoColumns.DURATION,
- Video.VideoColumns.BOOKMARK};
+ String[] projection = new String[] {
+ Video.VideoColumns.DURATION,
+ Video.VideoColumns.BOOKMARK
+ };
+
try {
Cursor cursor = getContentResolver().query(mUri, projection,
null, null, null);
@@ -230,11 +233,7 @@ public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
super.onResume();
}
- Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- }
- };
+ Handler mHandler = new Handler();
Runnable mPlayingChecker = new Runnable() {
public void run() {
diff --git a/src/com/android/camera/ThumbnailController.java b/src/com/android/camera/ThumbnailController.java
index bcf41bf..6bbcf60 100644
--- a/src/com/android/camera/ThumbnailController.java
+++ b/src/com/android/camera/ThumbnailController.java
@@ -117,9 +117,9 @@ public class ThumbnailController {
} catch (IOException e) {
return false;
} finally {
- closeSilently(f);
- closeSilently(b);
- closeSilently(d);
+ MenuHelper.closeSilently(f);
+ MenuHelper.closeSilently(b);
+ MenuHelper.closeSilently(d);
}
return true;
}
@@ -141,23 +141,13 @@ public class ThumbnailController {
} catch (IOException e) {
return false;
} finally {
- closeSilently(f);
- closeSilently(b);
- closeSilently(d);
+ MenuHelper.closeSilently(f);
+ MenuHelper.closeSilently(b);
+ MenuHelper.closeSilently(d);
}
return true;
}
- private void closeSilently(Closeable c) {
- if (c != null) {
- try {
- c.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
public void updateDisplayIfNeeded() {
if (mUri == null) {
mButton.setVisibility(View.INVISIBLE);
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index e08021c..00f32b9 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -555,8 +555,6 @@ public class VideoCamera extends Activity implements View.OnClickListener,
menuFlags,
false,
VideoCamera.this,
- mHandler,
-
// Handler for deletion
new Runnable() {
public void run() {
diff --git a/src/com/android/camera/ViewImage.java b/src/com/android/camera/ViewImage.java
index d15b305..b9ee6dc 100644
--- a/src/com/android/camera/ViewImage.java
+++ b/src/com/android/camera/ViewImage.java
@@ -412,7 +412,6 @@ public class ViewImage extends Activity implements View.OnClickListener {
MenuHelper.INCLUDE_ALL,
true,
ViewImage.this,
- mHandler,
mDeletePhotoRunnable,
new MenuHelper.MenuInvoker() {
public void run(MenuHelper.MenuCallback cb) {
@@ -764,8 +763,6 @@ public class ViewImage extends Activity implements View.OnClickListener {
if (orientation != getRequestedOrientation()) {
setRequestedOrientation(orientation);
}
- } else {
- MenuHelper.requestOrientation(this, mPrefs);
}
}