summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-09-23 02:04:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-23 02:04:47 -0700
commitf02dacf2c5d46eb65a4d6b7ba7a85964b04001e2 (patch)
tree8583f6b8e39cdd2a6cbf8999351b8f022c807f10
parent65e26535c22da813e1a8cb08cfa4f586a233af34 (diff)
parenta64e3e5327e7a007877ed3081d15738913de1fc9 (diff)
downloadandroid_packages_apps_Snap-f02dacf2c5d46eb65a4d6b7ba7a85964b04001e2.tar.gz
android_packages_apps_Snap-f02dacf2c5d46eb65a4d6b7ba7a85964b04001e2.tar.bz2
android_packages_apps_Snap-f02dacf2c5d46eb65a4d6b7ba7a85964b04001e2.zip
Merge "Fix 5349519: The Select photo/video activity should use action bar."
-rw-r--r--src/com/android/gallery3d/app/AlbumPicker.java28
-rw-r--r--src/com/android/gallery3d/app/DialogPicker.java28
-rw-r--r--src/com/android/gallery3d/app/PickerActivity.java96
3 files changed, 98 insertions, 54 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPicker.java b/src/com/android/gallery3d/app/AlbumPicker.java
index b86aee879..ef5847e16 100644
--- a/src/com/android/gallery3d/app/AlbumPicker.java
+++ b/src/com/android/gallery3d/app/AlbumPicker.java
@@ -18,26 +18,17 @@ package com.android.gallery3d.app;
import com.android.gallery3d.R;
import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLRootView;
import android.content.Intent;
import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-public class AlbumPicker extends AbstractGalleryActivity
- implements OnClickListener {
+public class AlbumPicker extends PickerActivity {
public static final String KEY_ALBUM_PATH = "album-path";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- setContentView(R.layout.dialog_picker);
- ((GLRootView) findViewById(R.id.gl_root_view)).setZOrderOnTop(true);
- findViewById(R.id.cancel).setOnClickListener(this);
setTitle(R.string.select_album);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
@@ -48,21 +39,4 @@ public class AlbumPicker extends AbstractGalleryActivity
getDataManager().getTopSetPath(DataManager.INCLUDE_IMAGE));
getStateManager().startState(AlbumSetPage.class, data);
}
-
- @Override
- public void onBackPressed() {
- // send the back event to the top sub-state
- GLRoot root = getGLRoot();
- root.lockRenderThread();
- try {
- getStateManager().getTopState().onBackPressed();
- } finally {
- root.unlockRenderThread();
- }
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.cancel) finish();
- }
}
diff --git a/src/com/android/gallery3d/app/DialogPicker.java b/src/com/android/gallery3d/app/DialogPicker.java
index ebfc52158..8a5782478 100644
--- a/src/com/android/gallery3d/app/DialogPicker.java
+++ b/src/com/android/gallery3d/app/DialogPicker.java
@@ -17,26 +17,17 @@
package com.android.gallery3d.app;
import com.android.gallery3d.R;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLRootView;
import com.android.gallery3d.util.GalleryUtils;
import android.content.Intent;
import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-public class DialogPicker extends AbstractGalleryActivity
- implements OnClickListener {
+public class DialogPicker extends PickerActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.dialog_picker);
- ((GLRootView) findViewById(R.id.gl_root_view)).setZOrderOnTop(true);
- findViewById(R.id.cancel).setOnClickListener(this);
-
int typeBits = GalleryUtils.determineTypeBits(this, getIntent());
setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
Intent intent = getIntent();
@@ -48,21 +39,4 @@ public class DialogPicker extends AbstractGalleryActivity
getDataManager().getTopSetPath(typeBits));
getStateManager().startState(AlbumSetPage.class, data);
}
-
- @Override
- public void onBackPressed() {
- // send the back event to the top sub-state
- GLRoot root = getGLRoot();
- root.lockRenderThread();
- try {
- getStateManager().getTopState().onBackPressed();
- } finally {
- root.unlockRenderThread();
- }
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.cancel) finish();
- }
}
diff --git a/src/com/android/gallery3d/app/PickerActivity.java b/src/com/android/gallery3d/app/PickerActivity.java
new file mode 100644
index 000000000..944192dd4
--- /dev/null
+++ b/src/com/android/gallery3d/app/PickerActivity.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.app;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.ui.GLRoot;
+import com.android.gallery3d.ui.GLRootView;
+
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+
+public class PickerActivity extends AbstractGalleryActivity
+ implements OnClickListener {
+
+ public static final String KEY_ALBUM_PATH = "album-path";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // We show the picker in two ways. One smaller screen we use a full
+ // screen window with an action bar. On larger screen we use a dialog.
+ boolean isDialog = getResources().getBoolean(R.bool.picker_is_dialog);
+
+ if (!isDialog) {
+ requestWindowFeature(Window.FEATURE_ACTION_BAR);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+ }
+
+ setContentView(R.layout.dialog_picker);
+
+ if (isDialog) {
+ // In dialog mode, we don't have the action bar to show the
+ // "cancel" action, so we show an additional "cancel" button.
+ View view = findViewById(R.id.cancel);
+ view.setOnClickListener(this);
+ view.setVisibility(View.VISIBLE);
+
+ // We need this, otherwise the view will be dimmed because it
+ // is "behind" the dialog.
+ ((GLRootView) findViewById(R.id.gl_root_view)).setZOrderOnTop(true);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.pickup, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == R.id.action_cancel) {
+ finish();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onBackPressed() {
+ // send the back event to the top sub-state
+ GLRoot root = getGLRoot();
+ root.lockRenderThread();
+ try {
+ getStateManager().getTopState().onBackPressed();
+ } finally {
+ root.unlockRenderThread();
+ }
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.cancel) finish();
+ }
+}