mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Closes #557 : Remove refs to Browser.BookmarkColumns which isn't in API 23 / 6.0
This commit is contained in:
parent
1fbefcac31
commit
715be9a1a9
|
@ -25,6 +25,7 @@
|
|||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<!-- unavailable in API 23 -->
|
||||
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||
|
|
|
@ -19,7 +19,6 @@ package com.google.zxing.client.android.share;
|
|||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Browser;
|
||||
import android.view.View;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.ListView;
|
||||
|
@ -54,7 +53,7 @@ public final class AppPickerActivity extends ListActivity {
|
|||
String packageName = ((AppInfo) adapter.getItem(position)).getPackageName();
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Browser.BookmarkColumns.URL, "market://details?id=" + packageName);
|
||||
intent.putExtra("url", "market://details?id=" + packageName); // Browser.BookmarkColumns.URL
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
|
|
|
@ -35,15 +35,14 @@ public final class BookmarkPickerActivity extends ListActivity {
|
|||
private static final String TAG = BookmarkPickerActivity.class.getSimpleName();
|
||||
|
||||
private static final String[] BOOKMARK_PROJECTION = {
|
||||
Browser.BookmarkColumns.TITLE,
|
||||
Browser.BookmarkColumns.URL
|
||||
"title", // Browser.BookmarkColumns.TITLE
|
||||
"url", // Browser.BookmarkColumns.URL
|
||||
};
|
||||
|
||||
static final int TITLE_COLUMN = 0;
|
||||
static final int URL_COLUMN = 1;
|
||||
|
||||
private static final String BOOKMARK_SELECTION =
|
||||
Browser.BookmarkColumns.BOOKMARK + " = 1 AND " + Browser.BookmarkColumns.URL + " IS NOT NULL";
|
||||
private static final String BOOKMARK_SELECTION = "bookmark = 1 AND url IS NOT NULL";
|
||||
|
||||
private Cursor cursor;
|
||||
|
||||
|
@ -74,8 +73,8 @@ public final class BookmarkPickerActivity extends ListActivity {
|
|||
if (!cursor.isClosed() && cursor.moveToPosition(position)) {
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
|
||||
intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
|
||||
intent.putExtra("title", cursor.getString(TITLE_COLUMN)); // Browser.BookmarkColumns.TITLE
|
||||
intent.putExtra("url", cursor.getString(URL_COLUMN)); // Browser.BookmarkColumns.URL
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.google.zxing.client.android.share;
|
||||
|
||||
import android.os.Build;
|
||||
import android.provider.ContactsContract;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.client.android.Contents;
|
||||
|
@ -29,7 +30,6 @@ import android.database.Cursor;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.BaseColumns;
|
||||
import android.provider.Browser;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
@ -121,7 +121,12 @@ public final class ShareActivity extends Activity {
|
|||
setContentView(R.layout.share);
|
||||
|
||||
findViewById(R.id.share_contact_button).setOnClickListener(contactListener);
|
||||
findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener);
|
||||
if (Build.VERSION.SDK_INT >= 23) { // Marshmallow / 6.0
|
||||
// Can't access bookmarks in 6.0+
|
||||
findViewById(R.id.share_bookmark_button).setEnabled(false);
|
||||
} else {
|
||||
findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener);
|
||||
}
|
||||
findViewById(R.id.share_app_button).setOnClickListener(appListener);
|
||||
clipboardButton = findViewById(R.id.share_clipboard_button);
|
||||
clipboardButton.setOnClickListener(clipboardListener);
|
||||
|
@ -140,7 +145,7 @@ public final class ShareActivity extends Activity {
|
|||
switch (requestCode) {
|
||||
case PICK_BOOKMARK:
|
||||
case PICK_APP:
|
||||
showTextAsBarcode(intent.getStringExtra(Browser.BookmarkColumns.URL));
|
||||
showTextAsBarcode(intent.getStringExtra("url")); // Browser.BookmarkColumns.URL
|
||||
break;
|
||||
case PICK_CONTACT:
|
||||
// Data field is content://contacts/people/984
|
||||
|
|
Loading…
Reference in a new issue