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 Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsAdapter.java License: 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 Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsActivity.java License: 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 #3
Source Project: ZXing-Standalone-library Author: tarun0 File: LoadPackagesAsyncTask.java License: 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 #4
Source Project: ZXing-Standalone-library Author: tarun0 File: ShareActivity.java License: 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 #5
Source Project: ZXing-Standalone-library Author: tarun0 File: QRCodeEncoder.java License: 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 #6
Source Project: ZXing-Standalone-library Author: tarun0 File: WifiResultHandler.java License: 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 #7
Source Project: ZXing-Orient Author: SudarAbisheck File: EncodeActivity.java License: 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 #8
Source Project: ZXing-Orient Author: SudarAbisheck File: QRCodeEncoder.java License: 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 #9
Source Project: Study_Android_Demo Author: RealMoMo File: SearchBookContentsAdapter.java License: 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 #10
Source Project: Study_Android_Demo Author: RealMoMo File: SearchBookContentsActivity.java License: 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 #11
Source Project: Study_Android_Demo Author: RealMoMo File: LoadPackagesAsyncTask.java License: 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 Project: Study_Android_Demo Author: RealMoMo File: BookmarkAdapter.java License: 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 #13
Source Project: Study_Android_Demo Author: RealMoMo File: EncodeActivity.java License: 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 Project: Study_Android_Demo Author: RealMoMo File: WifiResultHandler.java License: 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 Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsActivity.java License: 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 Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsActivity.java License: Apache License 2.0 | 5 votes |
private void launchSearch() { String query = queryTextView.getText().toString(); if (query != null && !query.isEmpty()) { AsyncTask<?,?,?> oldTask = networkTask; if (oldTask != null) { oldTask.cancel(true); } networkTask = new NetworkTask(); networkTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query, isbn); headerView.setText(R.string.msg_sbc_searching_book); resultListView.setAdapter(null); queryTextView.setEnabled(false); queryButton.setEnabled(false); } }
Example #17
Source Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsActivity.java License: 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 Project: ZXing-Standalone-library Author: tarun0 File: SearchBookContentsActivity.java License: Apache License 2.0 | 5 votes |
private SearchBookContentsResult parseResult(JSONObject json) { String pageId; String pageNumber; String snippet; try { pageId = json.getString("page_id"); pageNumber = json.optString("page_number"); snippet = json.optString("snippet_text"); } catch (JSONException e) { Log.w(TAG, e); // Never seen in the wild, just being complete. return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false); } if (pageNumber == null || pageNumber.isEmpty()) { // This can happen for text on the jacket, and possibly other reasons. pageNumber = ""; } else { pageNumber = getString(R.string.msg_sbc_page) + ' ' + pageNumber; } boolean valid = snippet != null && !snippet.isEmpty(); if (valid) { // Remove all HTML tags and encoded characters. snippet = TAG_PATTERN.matcher(snippet).replaceAll(""); snippet = LT_ENTITY_PATTERN.matcher(snippet).replaceAll("<"); snippet = GT_ENTITY_PATTERN.matcher(snippet).replaceAll(">"); snippet = QUOTE_ENTITY_PATTERN.matcher(snippet).replaceAll("'"); snippet = QUOT_ENTITY_PATTERN.matcher(snippet).replaceAll("\""); } else { snippet = '(' + getString(R.string.msg_sbc_snippet_unavailable) + ')'; } return new SearchBookContentsResult(pageId, pageNumber, snippet, valid); }
Example #19
Source Project: ZXing-Standalone-library Author: tarun0 File: EncodeActivity.java License: 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 #20
Source Project: ZXing-Standalone-library Author: tarun0 File: EncodeActivity.java License: 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 #21
Source Project: Study_Android_Demo Author: RealMoMo File: HistoryItemAdapter.java License: Apache License 2.0 | 5 votes |
@Override public View getView(int position, View view, ViewGroup viewGroup) { View layout; if (view instanceof LinearLayout) { layout = view; } else { LayoutInflater factory = LayoutInflater.from(activity); layout = factory.inflate(R.layout.history_list_item, viewGroup, false); } HistoryItem item = getItem(position); Result result = item.getResult(); CharSequence title; CharSequence detail; if (result != null) { title = result.getText(); detail = item.getDisplayAndDetails(); } else { Resources resources = getContext().getResources(); title = resources.getString(R.string.history_empty); detail = resources.getString(R.string.history_empty_detail); } ((TextView) layout.findViewById(R.id.history_title)).setText(title); ((TextView) layout.findViewById(R.id.history_detail)).setText(detail); return layout; }
Example #22
Source Project: ZXing-Standalone-library Author: tarun0 File: EncodeActivity.java License: 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 #23
Source Project: ZXing-Standalone-library Author: tarun0 File: QRCodeEncoder.java License: 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 #24
Source Project: Study_Android_Demo Author: RealMoMo File: ResultHandler.java License: 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 Project: Study_Android_Demo Author: RealMoMo File: ResultHandler.java License: 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 #26
Source Project: ZXing-Standalone-library Author: tarun0 File: HistoryActivity.java License: 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 #27
Source Project: ZXing-Standalone-library Author: tarun0 File: HistoryActivity.java License: 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 #28
Source Project: ZXing-Orient Author: SudarAbisheck File: EncodeActivity.java License: 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 #29
Source Project: ZXing-Orient Author: SudarAbisheck File: EncodeActivity.java License: 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 #30
Source Project: Study_Android_Demo Author: RealMoMo File: HistoryActivity.java License: 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 }