com.google.zxing.client.android.R Java Examples
The following examples show how to use
com.google.zxing.client.android.R.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchBookContentsAdapter.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View view, ViewGroup viewGroup) { SearchBookContentsListItem listItem; if (view == null) { LayoutInflater factory = LayoutInflater.from(getContext()); listItem = (SearchBookContentsListItem) factory.inflate( R.layout.search_book_contents_list_item, viewGroup, false); } else { if (view instanceof SearchBookContentsListItem) { listItem = (SearchBookContentsListItem) view; } else { return view; } } SearchBookContentsResult result = getItem(position); listItem.set(result); return listItem; }
Example #2
Source File: QRCodeEncoder.java From ZXing-Orient with Apache License 2.0 | 6 votes |
private void encodeQRCodeContents(AddressBookParsedResult contact) { ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); String[] encoded = encoder.encode(toList(contact.getNames()), contact.getOrg(), toList(contact.getAddresses()), toList(contact.getPhoneNumbers()), null, toList(contact.getEmails()), toList(contact.getURLs()), null); // Make sure we've encoded at least one field. if (!encoded[1].isEmpty()) { contents = encoded[0]; displayContents = encoded[1]; title = activity.getString(R.string.contents_contact); } }
Example #3
Source File: SearchBookContentsAdapter.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View view, ViewGroup viewGroup) { SearchBookContentsListItem listItem; if (view == null) { LayoutInflater factory = LayoutInflater.from(getContext()); listItem = (SearchBookContentsListItem) factory.inflate( R.layout.search_book_contents_list_item, viewGroup, false); } else { if (view instanceof SearchBookContentsListItem) { listItem = (SearchBookContentsListItem) view; } else { return view; } } SearchBookContentsResult result = getItem(position); listItem.set(result); return listItem; }
Example #4
Source File: QRCodeEncoder.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
private void encodeQRCodeContents(AddressBookParsedResult contact) { ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); String[] encoded = encoder.encode(toList(contact.getNames()), contact.getOrg(), toList(contact.getAddresses()), toList(contact.getPhoneNumbers()), null, toList(contact.getEmails()), toList(contact.getURLs()), null); // Make sure we've encoded at least one field. if (!encoded[1].isEmpty()) { contents = encoded[0]; displayContents = encoded[1]; title = activity.getString(R.string.contents_contact); } }
Example #5
Source File: EncodeActivity.java From ZXing-Orient with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_share) { share(); return true; } else if (itemId == R.id.menu_encode) { Intent intent = getIntent(); if (intent == null) { return false; } intent.putExtra(USE_VCARD_KEY, !qrCodeEncoder.isUseVCard()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); return true; } else { return false; } }
Example #6
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
private void handleSearchResults(JSONObject json) { try { int count = json.getInt("number_of_results"); headerView.setText(getString(R.string.msg_sbc_results) + " : " + count); if (count > 0) { JSONArray results = json.getJSONArray("search_results"); SearchBookContentsResult.setQuery(queryTextView.getText().toString()); List<SearchBookContentsResult> items = new ArrayList<>(count); for (int x = 0; x < count; x++) { items.add(parseResult(results.getJSONObject(x))); } resultListView.setOnItemClickListener(new BrowseBookListener(SearchBookContentsActivity.this, items)); resultListView.setAdapter(new SearchBookContentsAdapter(SearchBookContentsActivity.this, items)); } else { String searchable = json.optString("searchable"); if ("false".equals(searchable)) { headerView.setText(R.string.msg_sbc_book_not_searchable); } resultListView.setAdapter(null); } } catch (JSONException e) { Log.w(TAG, "Bad JSON from book search", e); resultListView.setAdapter(null); headerView.setText(R.string.msg_sbc_failed); } }
Example #7
Source File: WifiResultHandler.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) { Log.w(TAG, "No WifiManager available from device"); return; } final Activity activity = getActivity(); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show(); } }); new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult); parent.restartPreviewAfterDelay(0L); } }
Example #8
Source File: LoadPackagesAsyncTask.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(final List<AppInfo> results) { ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); Drawable icon = results.get(position).getIcon(); if (icon != null) { ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon); } return view; } }; activity.setListAdapter(listAdapter); }
Example #9
Source File: BookmarkAdapter.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public View getView(int index, View view, ViewGroup viewGroup) { View layout; if (view instanceof LinearLayout) { layout = view; } else { LayoutInflater factory = LayoutInflater.from(context); layout = factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false); } if (!cursor.isClosed()) { cursor.moveToPosition(index); CharSequence title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN); ((TextView) layout.findViewById(R.id.bookmark_title)).setText(title); CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN); ((TextView) layout.findViewById(R.id.bookmark_url)).setText(url); } // Otherwise... just don't update as the object is shutting down return layout; }
Example #10
Source File: ShareActivity.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.share); findViewById(R.id.share_contact_button).setOnClickListener(contactListener); 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); findViewById(R.id.share_text_view).setOnKeyListener(textListener); }
Example #11
Source File: LoadPackagesAsyncTask.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(final List<AppInfo> results) { ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); Drawable icon = results.get(position).getIcon(); if (icon != null) { ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon); } return view; } }; activity.setListAdapter(listAdapter); }
Example #12
Source File: SearchBookContentsActivity.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
private void handleSearchResults(JSONObject json) { try { int count = json.getInt("number_of_results"); headerView.setText(getString(R.string.msg_sbc_results) + " : " + count); if (count > 0) { JSONArray results = json.getJSONArray("search_results"); SearchBookContentsResult.setQuery(queryTextView.getText().toString()); List<SearchBookContentsResult> items = new ArrayList<>(count); for (int x = 0; x < count; x++) { items.add(parseResult(results.getJSONObject(x))); } resultListView.setOnItemClickListener(new BrowseBookListener(SearchBookContentsActivity.this, items)); resultListView.setAdapter(new SearchBookContentsAdapter(SearchBookContentsActivity.this, items)); } else { String searchable = json.optString("searchable"); if ("false".equals(searchable)) { headerView.setText(R.string.msg_sbc_book_not_searchable); } resultListView.setAdapter(null); } } catch (JSONException e) { Log.w(TAG, "Bad JSON from book search", e); resultListView.setAdapter(null); headerView.setText(R.string.msg_sbc_failed); } }
Example #13
Source File: EncodeActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()== R.id.menu_share){ share(); return true; }else if(item.getItemId() == R.id.menu_encode){ Intent intent = getIntent(); if (intent == null) { return false; } intent.putExtra(USE_VCARD_KEY, !qrCodeEncoder.isUseVCard()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); return true; }else{ return false; } }
Example #14
Source File: WifiResultHandler.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) { Log.w(TAG, "No WifiManager available from device"); return; } final Activity activity = getActivity(); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show(); } }); new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult); parent.restartPreviewAfterDelay(0L); } }
Example #15
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example #16
Source File: EncodeActivity.java From ZXing-Orient with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); } else { String action = intent.getAction(); if (Intents.Encode.ZX_ACTION.equals(action) || Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) { setContentView(R.layout.encode); } else { finish(); } } }
Example #17
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(JSONObject result) { if (result == null) { headerView.setText(R.string.msg_sbc_failed); } else { handleSearchResults(result); } queryTextView.setEnabled(true); queryTextView.selectAll(); queryButton.setEnabled(true); }
Example #18
Source File: EncodeActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); } else { String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) { setContentView(R.layout.encode); } else { finish(); } } }
Example #19
Source File: EncodeActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.encode, menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard; MenuItem encodeItem = menu.findItem(R.id.menu_encode); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }
Example #20
Source File: QRCodeEncoder.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private boolean encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type == null || type.isEmpty()) { return false; } this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && !data.isEmpty()) { contents = data; displayContents = data; title = activity.getString(R.string.contents_text); } } return contents != null && !contents.isEmpty(); }
Example #21
Source File: QRCodeEncoder.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void encodeFromTextExtras(Intent intent) throws WriterException { // Notice: Google Maps shares both URL and details in one text, bummer! String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT)); if (theContents == null) { theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT")); // Intent.EXTRA_HTML_TEXT if (theContents == null) { theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT)); if (theContents == null) { String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL); if (emails != null) { theContents = ContactEncoder.trim(emails[0]); } else { theContents = "?"; } } } } // Trim text to avoid URL breaking. if (theContents == null || theContents.isEmpty()) { throw new WriterException("Empty EXTRA_TEXT"); } contents = theContents; // We only do QR code. format = BarcodeFormat.QR_CODE; if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT); } else if (intent.hasExtra(Intent.EXTRA_TITLE)) { displayContents = intent.getStringExtra(Intent.EXTRA_TITLE); } else { displayContents = contents; } title = activity.getString(R.string.contents_text); }
Example #22
Source File: HistoryActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if (historyManager.hasHistoryItems()) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.history, menu); } return super.onCreateOptionsMenu(menu); }
Example #23
Source File: QRCodeEncoder.java From ZXing-Orient with Apache License 2.0 | 5 votes |
private boolean encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type == null || type.isEmpty()) { return false; } this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && !data.isEmpty()) { contents = data; displayContents = data; title = activity.getString(R.string.contents_text); } } return contents != null && !contents.isEmpty(); }
Example #24
Source File: ResultHandler.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
/** * Like {@link #rawLaunchIntent(Intent)} but will show a user dialog if nothing is available to handle. */ final void launchIntent(Intent intent) { try { rawLaunchIntent(intent); } catch (ActivityNotFoundException ignored) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.app_name); builder.setMessage(R.string.msg_intent_failed); builder.setPositiveButton(R.string.button_ok, null); builder.show(); } }
Example #25
Source File: HistoryActivity.java From ZXing-Standalone-library with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position; if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) { menu.add(Menu.NONE, position, position, R.string.history_clear_one_history_text); } // else it's just that dummy "Empty" message }
Example #26
Source File: EncodeActivity.java From ZXing-Orient with Apache License 2.0 | 5 votes |
private void showErrorMessage(int message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message); builder.setPositiveButton(R.string.button_ok, new FinishListener(this)); builder.setOnCancelListener(new FinishListener(this)); builder.show(); }
Example #27
Source File: HistoryActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position; if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) { menu.add(Menu.NONE, position, position, R.string.history_clear_one_history_text); } // else it's just that dummy "Empty" message }
Example #28
Source File: ResultHandler.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
final void sendMMSFromUri(String uri, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri)); // The Messaging app needs to see a valid subject or else it will treat this an an SMS. if (subject == null || subject.isEmpty()) { putExtra(intent, "subject", activity.getString(R.string.msg_default_mms_subject)); } else { putExtra(intent, "subject", subject); } putExtra(intent, "sms_body", body); intent.putExtra("compose_mode", true); launchIntent(intent); }
Example #29
Source File: HistoryActivity.java From ZXing-Standalone-library with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if (historyManager.hasHistoryItems()) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.history, menu); } return super.onCreateOptionsMenu(menu); }
Example #30
Source File: EncodeActivity.java From ZXing-Orient with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.encode, menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard; MenuItem encodeItem = menu.findItem(R.id.menu_encode); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }