Loading media/tests/CameraBrowser/res/layout/object_info.xml +12 −0 Original line number Diff line number Diff line Loading @@ -153,5 +153,17 @@ <TableRow> <ImageView android:id="@+id/thumbnail" /> </TableRow> <TableRow> <Button android:id="@+id/import_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/import_label"> </Button> <Button android:id="@+id/delete_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/delete_label"> </Button> </TableRow> </TableLayout> media/tests/CameraBrowser/res/menu/object_menu.xmldeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2010 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. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/save" android:title="@string/save_item" /> <item android:id="@+id/delete" android:title="@string/delete_item" /> </menu> media/tests/CameraBrowser/res/values/strings.xml +3 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,9 @@ <string name="modified_label">Modified: </string> <string name="keywords_label">Keywords: </string> <!-- menu items --> <string name="save_item">Save</string> <string name="delete_item">Delete</string> <!-- button labels --> <string name="import_label">Import</string> <string name="delete_label">Delete</string> <!-- toasts --> <string name="object_saved_message">Object saved</string> Loading media/tests/CameraBrowser/src/com/android/camerabrowser/DeviceDisconnectedReceiver.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.camerabrowser; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.Usb; import android.net.Uri; public class DeviceDisconnectedReceiver extends BroadcastReceiver { private final Activity mActivity; private final int mDeviceID; public DeviceDisconnectedReceiver(Activity activity, int deviceID) { mActivity = activity; mDeviceID = deviceID; IntentFilter filter = new IntentFilter(Usb.ACTION_USB_CAMERA_DETACHED); filter.addDataScheme("content"); activity.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { // close our activity if the device it is displaying is disconnected Uri uri = intent.getData(); int id = Integer.parseInt(uri.getPathSegments().get(1)); if (id == mDeviceID) { mActivity.finish(); } } } No newline at end of file media/tests/CameraBrowser/src/com/android/camerabrowser/ObjectBrowser.java +12 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class ObjectBrowser extends ListActivity { private int mDeviceID; private long mStorageID; private long mObjectID; private DeviceDisconnectedReceiver mDisconnectedReceiver; private static final String[] OBJECT_COLUMNS = new String[] { Mtp.Object._ID, Mtp.Object.NAME, Mtp.Object.FORMAT, Mtp.Object.THUMB }; Loading @@ -58,15 +59,17 @@ public class ObjectBrowser extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDeviceID = getIntent().getIntExtra("device", 0); mStorageID = getIntent().getLongExtra("storage", 0); mObjectID = getIntent().getLongExtra("object", 0); mDisconnectedReceiver = new DeviceDisconnectedReceiver(this, mDeviceID); } @Override protected void onResume() { super.onResume(); mDeviceID = getIntent().getIntExtra("device", 0); mStorageID = getIntent().getLongExtra("storage", 0); mObjectID = getIntent().getLongExtra("object", 0); if (mDeviceID != 0 && mStorageID != 0) { Cursor c; Uri uri; Loading @@ -86,6 +89,12 @@ public class ObjectBrowser extends ListActivity { } } @Override protected void onDestroy() { unregisterReceiver(mDisconnectedReceiver); super.onDestroy(); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { long rowID = mAdapter.getItemId(position); Loading Loading
media/tests/CameraBrowser/res/layout/object_info.xml +12 −0 Original line number Diff line number Diff line Loading @@ -153,5 +153,17 @@ <TableRow> <ImageView android:id="@+id/thumbnail" /> </TableRow> <TableRow> <Button android:id="@+id/import_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/import_label"> </Button> <Button android:id="@+id/delete_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/delete_label"> </Button> </TableRow> </TableLayout>
media/tests/CameraBrowser/res/menu/object_menu.xmldeleted 100644 → 0 +0 −23 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2010 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. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/save" android:title="@string/save_item" /> <item android:id="@+id/delete" android:title="@string/delete_item" /> </menu>
media/tests/CameraBrowser/res/values/strings.xml +3 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,9 @@ <string name="modified_label">Modified: </string> <string name="keywords_label">Keywords: </string> <!-- menu items --> <string name="save_item">Save</string> <string name="delete_item">Delete</string> <!-- button labels --> <string name="import_label">Import</string> <string name="delete_label">Delete</string> <!-- toasts --> <string name="object_saved_message">Object saved</string> Loading
media/tests/CameraBrowser/src/com/android/camerabrowser/DeviceDisconnectedReceiver.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.camerabrowser; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.Usb; import android.net.Uri; public class DeviceDisconnectedReceiver extends BroadcastReceiver { private final Activity mActivity; private final int mDeviceID; public DeviceDisconnectedReceiver(Activity activity, int deviceID) { mActivity = activity; mDeviceID = deviceID; IntentFilter filter = new IntentFilter(Usb.ACTION_USB_CAMERA_DETACHED); filter.addDataScheme("content"); activity.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { // close our activity if the device it is displaying is disconnected Uri uri = intent.getData(); int id = Integer.parseInt(uri.getPathSegments().get(1)); if (id == mDeviceID) { mActivity.finish(); } } } No newline at end of file
media/tests/CameraBrowser/src/com/android/camerabrowser/ObjectBrowser.java +12 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class ObjectBrowser extends ListActivity { private int mDeviceID; private long mStorageID; private long mObjectID; private DeviceDisconnectedReceiver mDisconnectedReceiver; private static final String[] OBJECT_COLUMNS = new String[] { Mtp.Object._ID, Mtp.Object.NAME, Mtp.Object.FORMAT, Mtp.Object.THUMB }; Loading @@ -58,15 +59,17 @@ public class ObjectBrowser extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDeviceID = getIntent().getIntExtra("device", 0); mStorageID = getIntent().getLongExtra("storage", 0); mObjectID = getIntent().getLongExtra("object", 0); mDisconnectedReceiver = new DeviceDisconnectedReceiver(this, mDeviceID); } @Override protected void onResume() { super.onResume(); mDeviceID = getIntent().getIntExtra("device", 0); mStorageID = getIntent().getLongExtra("storage", 0); mObjectID = getIntent().getLongExtra("object", 0); if (mDeviceID != 0 && mStorageID != 0) { Cursor c; Uri uri; Loading @@ -86,6 +89,12 @@ public class ObjectBrowser extends ListActivity { } } @Override protected void onDestroy() { unregisterReceiver(mDisconnectedReceiver); super.onDestroy(); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { long rowID = mAdapter.getItemId(position); Loading