diff options
| author | Bobby Georgescu <georgescu@google.com> | 2013-01-18 01:12:40 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-01-18 01:12:40 +0000 |
| commit | 48e376325d812fdbdcee569b48641cd4073e4973 (patch) | |
| tree | 8bd6bd5dd5960aa0c9bd7d86b776ed4a11e2dbf7 | |
| parent | bb4ae131edc0b1b2bedd82785a40f682e646170b (diff) | |
| parent | 6516d271e11f9ae9928be3bb70c99531a842c577 (diff) | |
| download | android_packages_apps_Gallery2-48e376325d812fdbdcee569b48641cd4073e4973.tar.gz android_packages_apps_Gallery2-48e376325d812fdbdcee569b48641cd4073e4973.tar.bz2 android_packages_apps_Gallery2-48e376325d812fdbdcee569b48641cd4073e4973.zip | |
Merge "Show status in importer for empty or no device" into gb-ub-photos-bryce
| -rw-r--r-- | res/layout/ingest_activity_item_list.xml | 47 | ||||
| -rw-r--r-- | res/values/strings.xml | 6 | ||||
| -rw-r--r-- | src/com/android/gallery3d/ingest/IngestActivity.java | 48 | ||||
| -rw-r--r-- | src/com/android/gallery3d/ingest/MtpDeviceIndex.java | 4 | ||||
| -rw-r--r-- | src/com/android/gallery3d/ingest/adapter/MtpAdapter.java | 8 |
5 files changed, 98 insertions, 15 deletions
diff --git a/res/layout/ingest_activity_item_list.xml b/res/layout/ingest_activity_item_list.xml index 120cf15cb..23a95f658 100644 --- a/res/layout/ingest_activity_item_list.xml +++ b/res/layout/ingest_activity_item_list.xml @@ -13,13 +13,40 @@ See the License for the specific language governing permissions and limitations under the License. --> -<GridView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/ingest_gridview" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:columnWidth="200px" - android:numColumns="auto_fit" - android:fastScrollEnabled="true" - android:background="@android:color/background_dark" - android:choiceMode="multipleChoiceModal" - android:stretchMode="columnWidth" /> +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <GridView + android:id="@+id/ingest_gridview" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnWidth="200px" + android:numColumns="auto_fit" + android:fastScrollEnabled="true" + android:background="@android:color/background_dark" + android:choiceMode="multipleChoiceModal" + android:stretchMode="columnWidth" /> + + <LinearLayout + android:id="@+id/ingest_warning_overlay" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="20dip" + android:gravity="center" + android:orientation="horizontal" + android:visibility="gone" > + + <ImageView + android:id="@+id/ingest_warning_overlay_icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:src="@android:drawable/ic_dialog_alert" /> + + <TextView + android:id="@+id/ingest_warning_overlay_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dip" + android:textAppearance="?android:attr/textAppearanceSmall" /> + </LinearLayout> +</merge> + diff --git a/res/values/strings.xml b/res/values/strings.xml index 94f56460f..9cbf72f96 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -542,4 +542,10 @@ <!-- Status message shown when content from an external camera is being imported --> <string name="ingest_importing">Importing...</string> + + <!-- Status message shown when there is no content available to be imported --> + <string name="ingest_empty_device">There is no content available for importing on this device.</string> + + <!-- Status message shown when there is no MTP device connected --> + <string name="ingest_no_device">There is no MTP device connected</string> </resources> diff --git a/src/com/android/gallery3d/ingest/IngestActivity.java b/src/com/android/gallery3d/ingest/IngestActivity.java index feaf465c3..4e603bed3 100644 --- a/src/com/android/gallery3d/ingest/IngestActivity.java +++ b/src/com/android/gallery3d/ingest/IngestActivity.java @@ -37,6 +37,7 @@ import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.GridView; +import android.widget.TextView; import com.android.gallery3d.R; import com.android.gallery3d.ingest.adapter.MtpAdapter; @@ -56,6 +57,9 @@ public class IngestActivity extends Activity implements private ProgressDialog mProgressDialog; private ActionMode mActiveActionMode; + private View mWarningOverlay; + private TextView mWarningOverlayText; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -171,6 +175,7 @@ public class IngestActivity extends Activity implements DateTileView.refreshLocale(); mActive = true; if (mHelperService != null) mHelperService.setClientActivity(this); + updateWarningOverlay(); super.onResume(); } @@ -182,12 +187,45 @@ public class IngestActivity extends Activity implements super.onPause(); } - protected void notifyIndexChanged() { + private void showWarningOverlay(int textResId) { + if (mWarningOverlay == null) { + mWarningOverlay = findViewById(R.id.ingest_warning_overlay); + mWarningOverlayText = + (TextView)mWarningOverlay.findViewById(R.id.ingest_warning_overlay_text); + } + mWarningOverlayText.setText(textResId); + mWarningOverlay.setVisibility(View.VISIBLE); + mGridView.setVisibility(View.GONE); + } + + private void hideWarningOverlay() { + if (mWarningOverlay != null) { + mWarningOverlay.setVisibility(View.GONE); + mGridView.setVisibility(View.VISIBLE); + } + } + + private void updateWarningOverlay() { + if (!mAdapter.deviceConnected()) { + showWarningOverlay(R.string.ingest_no_device); + } else if (mAdapter.indexReady() && mAdapter.getCount() == 0) { + showWarningOverlay(R.string.ingest_empty_device); + } else { + hideWarningOverlay(); + } + } + + private void UiThreadNotifyIndexChanged() { mAdapter.notifyDataSetChanged(); if (mActiveActionMode != null) { mActiveActionMode.finish(); mActiveActionMode = null; } + updateWarningOverlay(); + } + + protected void notifyIndexChanged() { + mHandler.sendEmptyMessage(ItemListHandler.MSG_NOTIFY_CHANGED); } private static class ProgressState { @@ -229,7 +267,7 @@ public class IngestActivity extends Activity implements public void onIndexFinish() { // Not guaranteed to be called on the UI thread mHandler.sendEmptyMessage(ItemListHandler.MSG_PROGRESS_HIDE); - mHandler.sendEmptyMessage(ItemListHandler.MSG_ADAPTER_NOTIFY_CHANGED); + mHandler.sendEmptyMessage(ItemListHandler.MSG_NOTIFY_CHANGED); } @Override @@ -291,7 +329,7 @@ public class IngestActivity extends Activity implements private static class ItemListHandler extends Handler { public static final int MSG_PROGRESS_UPDATE = 0; public static final int MSG_PROGRESS_HIDE = 1; - public static final int MSG_ADAPTER_NOTIFY_CHANGED = 2; + public static final int MSG_NOTIFY_CHANGED = 2; WeakReference<IngestActivity> mParentReference; @@ -311,8 +349,8 @@ public class IngestActivity extends Activity implements case MSG_PROGRESS_UPDATE: parent.updateProgressDialog(); break; - case MSG_ADAPTER_NOTIFY_CHANGED: - parent.notifyIndexChanged(); + case MSG_NOTIFY_CHANGED: + parent.UiThreadNotifyIndexChanged(); break; default: break; diff --git a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java index 10ccb82ac..5a0f9481e 100644 --- a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java +++ b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java @@ -143,6 +143,10 @@ public class MtpDeviceIndex { }; } + synchronized public boolean indexReady() { + return mProgress == Progress.Finished; + } + synchronized public Progress getProgress() { return mProgress; } diff --git a/src/com/android/gallery3d/ingest/adapter/MtpAdapter.java b/src/com/android/gallery3d/ingest/adapter/MtpAdapter.java index e09fcd962..3cf0df2cf 100644 --- a/src/com/android/gallery3d/ingest/adapter/MtpAdapter.java +++ b/src/com/android/gallery3d/ingest/adapter/MtpAdapter.java @@ -53,6 +53,14 @@ public class MtpAdapter extends BaseAdapter implements SectionIndexer { notifyDataSetChanged(); } + public boolean deviceConnected() { + return (mModel != null) && (mModel.getDevice() != null); + } + + public boolean indexReady() { + return (mModel != null) && mModel.indexReady(); + } + @Override public int getCount() { return mModel != null ? mModel.size() : 0; |
