List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:at.jclehner.rxdroid.NotificationReceiver.java
public void updateNotification(Date date, int doseTime, boolean isActiveDoseTime, int mode) { final List<Drug> drugsWithLowSupplies = new ArrayList<Drug>(); final int lowSupplyDrugCount = getDrugsWithLowSupplies(date, doseTime, drugsWithLowSupplies); final int missedDoseCount = getDrugsWithMissedDoses(date, doseTime, isActiveDoseTime, null); final int dueDoseCount = isActiveDoseTime ? getDrugsWithDueDoses(date, doseTime, null) : 0; int titleResId = R.string._title_notification_doses; int icon = R.drawable.ic_stat_normal; final StringBuilder sb = new StringBuilder(); final String[] lines = new String[2]; int lineCount = 0; if (missedDoseCount != 0 || dueDoseCount != 0) { if (dueDoseCount != 0) sb.append(RxDroid.getQuantityString(R.plurals._qmsg_due, dueDoseCount)); if (missedDoseCount != 0) { if (sb.length() != 0) sb.append(", "); sb.append(RxDroid.getQuantityString(R.plurals._qmsg_missed, missedDoseCount)); }/*from w w w.j ava2 s. c om*/ lines[1] = "<b>" + getString(R.string._title_notification_doses) + "</b> " + Util.escapeHtml(sb.toString()); } final boolean isShowingLowSupplyNotification; if (lowSupplyDrugCount != 0) { final String msg; final String first = drugsWithLowSupplies.get(0).getName(); icon = R.drawable.ic_stat_exclamation; isShowingLowSupplyNotification = sb.length() == 0; //titleResId = R.string._title_notification_low_supplies; if (lowSupplyDrugCount == 1) msg = getString(R.string._qmsg_low_supply_single, first); else { final String second = drugsWithLowSupplies.get(1).getName(); msg = RxDroid.getQuantityString(R.plurals._qmsg_low_supply_multiple, lowSupplyDrugCount - 1, first, second); } if (isShowingLowSupplyNotification) { sb.append(msg); titleResId = R.string._title_notification_low_supplies; } lines[0] = "<b>" + getString(R.string._title_notification_low_supplies) + "</b> " + Util.escapeHtml(msg); } else isShowingLowSupplyNotification = false; final int priority; if (isShowingLowSupplyNotification) priority = NotificationCompat.PRIORITY_DEFAULT; else priority = NotificationCompat.PRIORITY_HIGH; final String message = sb.toString(); final int currentHash = message.hashCode(); final int lastHash = Settings.getInt(Settings.Keys.LAST_MSG_HASH); if (message.length() == 0) { getNotificationManager().cancel(R.id.notification); return; } final StringBuilder source = new StringBuilder(); // final InboxStyle inboxStyle = new InboxStyle(); // inboxStyle.setBigContentTitle(getString(R.string.app_name) + // " (" + (dueDoseCount + missedDoseCount + lowSupplyDrugCount) + ")"); for (String line : lines) { if (line != null) { if (lineCount != 0) source.append("\n<br/>\n"); source.append(line); // inboxStyle.addLine(Html.fromHtml(line)); ++lineCount; } } final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); builder.setContentTitle(getString(titleResId)); builder.setContentIntent(createDrugListIntent(date)); builder.setContentText(message); builder.setTicker(getString(R.string._msg_new_notification)); builder.setSmallIcon(icon); builder.setOngoing(true); builder.setUsesChronometer(false); builder.setWhen(0); builder.setPriority(priority); if (lineCount > 1) { final BigTextStyle style = new BigTextStyle(); style.setBigContentTitle(getString(R.string.app_name)); style.bigText(Html.fromHtml(source.toString())); builder.setStyle(style); } // final long offset; // // if(isActiveDoseTime) // offset = Settings.getDoseTimeBeginOffset(doseTime); // else // offset = Settings.getTrueDoseTimeEndOffset(doseTime); // // builder.setWhen(date.getTime() + offset); if (mode == NOTIFICATION_FORCE_UPDATE || currentHash != lastHash) { builder.setOnlyAlertOnce(false); Settings.putInt(Settings.Keys.LAST_MSG_HASH, currentHash); } else builder.setOnlyAlertOnce(true); // Prevents low supplies from constantly annoying the user with // notification's sound and/or vibration if alarms are repeated. if (isShowingLowSupplyNotification) mode = NOTIFICATION_FORCE_SILENT; int defaults = 0; final String lightColor = Settings.getString(Settings.Keys.NOTIFICATION_LIGHT_COLOR, ""); if (lightColor.length() == 0) defaults |= Notification.DEFAULT_LIGHTS; else { try { int ledARGB = Integer.parseInt(lightColor, 16); if (ledARGB != 0) { ledARGB |= 0xff000000; // set alpha to ff builder.setLights(ledARGB, LED_ON_MS, LED_OFF_MS); } } catch (NumberFormatException e) { Log.e(TAG, "Failed to parse light color; using default", e); defaults |= Notification.DEFAULT_LIGHTS; } } if (mode != NOTIFICATION_FORCE_SILENT) { boolean isNowWithinQuietHours = false; do { if (!Settings.isChecked(Settings.Keys.QUIET_HOURS, false)) break; final String quietHoursStr = Settings.getString(Settings.Keys.QUIET_HOURS); if (quietHoursStr == null) break; final TimePeriod quietHours = TimePeriod.fromString(quietHoursStr); if (quietHours.contains(DumbTime.now())) isNowWithinQuietHours = true; } while (false); if (!isNowWithinQuietHours) { final String ringtone = Settings.getString(Settings.Keys.NOTIFICATION_SOUND); if (ringtone != null) builder.setSound(Uri.parse(ringtone)); else defaults |= Notification.DEFAULT_SOUND; if (LOGV) Log.i(TAG, "Sound: " + (ringtone != null ? ringtone.toString() : "(default)")); } else Log.i(TAG, "Currently within quiet hours; muting sound..."); } if (mode != NOTIFICATION_FORCE_SILENT && Settings.getBoolean(Settings.Keys.USE_VIBRATOR, true)) defaults |= Notification.DEFAULT_VIBRATE; builder.setDefaults(defaults); getNotificationManager().notify(R.id.notification, builder.build()); }
From source file:net.amdroid.metrosp.MetroSP.java
private void parseData(InputStream content) throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(content)); StringBuilder total = new StringBuilder(); String line, buffer;/*from www . j a va2 s .c om*/ while ((line = r.readLine()) != null) { total.append(line); } buffer = total.toString(); Log.d("MetroSP", "MetroSP()"); int where = buffer.indexOf("objArrLinhas") + 15; int end = buffer.indexOf("function abreDetalheLinha") - 1; String jsonstr = buffer.substring(where, end); JSONArray array = (JSONArray) new JSONTokener(jsonstr).nextValue(); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String cor = obj.getString("cor"); String linha = obj.getString("linha"); String status = obj.getString("status"); String msgstatus = Html.fromHtml(obj.getString("msgStatus")).toString(); String tmp = obj.getString("imagem"); String status_color = tmp.substring(tmp.indexOf("sinal-") + 6, tmp.indexOf("-linha")); String description = Html.fromHtml(obj.getString("descricao")).toString(); MetroLine item = new MetroLine(linha, cor, status, msgstatus, status_color, description); metroLines.add(item); } where = buffer.indexOf("dataAtualizacao\">") + "dataAtualizacao\">".length(); end = buffer.indexOf("</span>", where); last_refresh = Html.fromHtml(buffer.substring(where, end)).toString(); Log.d("MetroSP", "MetroSP() -> " + jsonstr); }
From source file:com.bookkos.bircle.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); _context = getApplicationContext();/* w w w . j a v a 2s . co m*/ _activity = this; currentTime = new Time("Asia/Tokyo"); // exceptionHandler = new ExceptionHandler(_context); // Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // sharedPreference???, user_id?group_id?registration_id?? getUserData(); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // ?? WindowManager window_manager = getWindowManager(); Display display = window_manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point); displayWidth = point.x; displayHeight = point.y; displayInch = getInch(); // ??4??????? textSize = 17 * (displayInch / 4); actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); String title_text = ""; subGroupText = ""; groupText = groupName; if (displayInch < 4.7) { title_text = "<small><small><small>??: </small></small></small>"; resizeTitleSizeTooSmall(); } else if (displayInch >= 4.7 && displayInch < 5.5) { title_text = "<small><small>??: </small></small>"; resizeTitleSizeSmall(); } else if (displayInch >= 5.5 && displayInch < 6.5) { title_text = "<small>??: </small>"; resizeTitleSizeMiddle(); } else if (displayInch >= 6.5 && displayInch < 8) { title_text = "<small>??: </small>"; resizeTitleSizeLarge(); } else { title_text = "??: "; } String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>"; actionBar.setTitle(Html.fromHtml(modify_group_text)); Resources resources = _context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); titleBarHeight = resources.getDimensionPixelSize(resourceId); setContentView(R.layout.capture); returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view); returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help); returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView = (ImageView) findViewById(R.id.regist_help_view); registHelpView.setImageResource(R.drawable.regist_help); registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView.setVisibility(View.GONE); leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); leftDrawer = (ListView) findViewById(R.id.left_drawer); textView = (TextView) findViewById(R.id.textView); modeText = (TextView) findViewById(R.id.mode_text); modeText.setTextColor(Color.rgb(56, 234, 123)); modeText.setTextSize(textSize); modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD); strokeColor = Color.rgb(56, 234, 123); borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton); registButton = (Button) findViewById(R.id.registButton); returnHistoryButton = (Button) findViewById(R.id.return_history_button); helpViewButton = (Button) findViewById(R.id.help_view_button); registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout); textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout); buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout); listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout); decisionButton = (Button) findViewById(R.id.decision_button); cancelButton = (Button) findViewById(R.id.cancel_button); shelfListView = (ListView) findViewById(R.id.shelf_list_view); tempTextView = (TextView) findViewById(R.id.temp_text_view); // bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this); bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout); bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout); bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout); bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view); bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view); bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button); registFlag = 0; int borrowReturnButton_width = displayWidth / 5 * 2; int borrowReturnButton_height = displayHeight / 10; int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2; int borrowReturnButton_y = displayHeight / 2 + titleBarHeight; borrowReturnButton.setTranslationX(borrowReturnButton_x); borrowReturnButton.setTranslationY(borrowReturnButton_y); borrowReturnButton .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height)); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); borrowReturnButton.setText("??\n"); borrowReturnButton.setTextSize(textSize * 7 / 10); borrowReturnButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 0; borrowReturnButton.setText("??\n"); borrowReturnButton.setEnabled(false); borrowReturnButton.setTextColor(Color.WHITE); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); registButton.setText("?\n??"); registButton.setEnabled(true); registButton.setTextColor(Color.GRAY); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); modeText.setText("??"); modeText.setTextColor(Color.rgb(56, 234, 123)); returnBorrowHelpView.setVisibility(View.VISIBLE); registHelpView.setVisibility(View.GONE); strokeColor = Color.rgb(56, 234, 123); } }); int registButton_width = displayWidth / 5 * 2; int registButton_height = displayHeight / 10; int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2; int registButton_y = displayHeight / 2 + titleBarHeight; registButton.setTranslationX(registButton_x); registButton.setTranslationY(registButton_y); registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height)); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); registButton.setTextColor(Color.GRAY); registButton.setTextSize(textSize * 7 / 10); registButton.setText("?\n??"); registButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 1; borrowReturnButton.setText("??\n??"); borrowReturnButton.setEnabled(true); borrowReturnButton.setTextColor(Color.GRAY); borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16)); registButton.setText("?\n"); registButton.setEnabled(false); registButton.setTextColor(Color.WHITE); registButton.setBackgroundColor(Color.rgb(62, 162, 229)); modeText.setText("?"); modeText.setTextColor(Color.rgb(62, 162, 229)); returnBorrowHelpView.setVisibility(View.GONE); registHelpView.setVisibility(View.VISIBLE); strokeColor = Color.rgb(62, 162, 229); } }); returnHistoryButton.setText("????"); returnHistoryButton.setTextSize(textSize * 7 / 10); returnHistoryButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { leftDrawerLayout.openDrawer(Gravity.RIGHT); // animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight); } }); getReturnHistory(); getCurrentTime(); setHelpView(); setScanUnregisterBookView(); setBookRegistView(); arrayList = new ArrayList<String>(); tempRegistIsbn = ""; initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId; initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code="; initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code="; getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId; hasSurface = false; inactivityTimer = new InactivityTimer(this); bircleBeepManager = new BircleBeepManager(this); ambientLightManager = new AmbientLightManager(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); toastText = ""; }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
public void handleExportTransactions() { // Create CSV file from transactions final File file = new File(Constants.Files.EXTERNAL_WALLET_BACKUP_DIR, Constants.Files.TX_EXPORT_NAME + "-" + getFileDate() + ".csv"); try {//w ww . j a v a2 s . com final BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append("Date,Label,Amount (" + MonetaryFormat.CODE_PPC + "),Fee (" + MonetaryFormat.CODE_PPC + "),Address,Transaction Hash,Confirmations\n"); if (txListAdapter == null || txListAdapter.transactions.isEmpty()) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed"); return; } final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm z"); dateFormat.setTimeZone(TimeZone.getDefault()); for (Transaction tx : txListAdapter.transactions) { TransactionsListAdapter.TransactionCacheEntry txCache = txListAdapter.getTxCache(tx); String memo = tx.getMemo() == null ? "" : StringEscapeUtils.escapeCsv(tx.getMemo()); String fee = tx.getFee() == null ? "" : tx.getFee().toPlainString(); String address = txCache.address == null ? getString(R.string.export_transactions_unknown) : txCache.address.toString(); writer.append(dateFormat.format(tx.getUpdateTime()) + ","); writer.append(memo + ","); writer.append(txCache.value.toPlainString() + ","); writer.append(fee + ","); writer.append(address + ","); writer.append(tx.getHash().toString() + ","); writer.append(tx.getConfidence().getDepthInBlocks() + "\n"); } writer.flush(); writer.close(); } catch (IOException x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); return; } final DialogBuilder dialog = new DialogBuilder(this); dialog.setMessage(Html.fromHtml(getString(R.string.export_transactions_dialog_success, file))); dialog.setPositiveButton(WholeStringBuilder.bold(getString(R.string.export_keys_dialog_button_archive)), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_transactions_mail_subject)); intent.putExtra(Intent.EXTRA_TEXT, makeEmailText(getString(R.string.export_transactions_mail_text))); intent.setType(Constants.MIMETYPE_TX_EXPORT); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); try { startActivity(Intent.createChooser(intent, getString(R.string.export_transactions_mail_intent_chooser))); log.info("invoked chooser for exporting transactions"); } catch (final Exception x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); } } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void initTopicSpinner() { // Get topics in category. Null accepts all user sources. Modify // according to user selection final String[] saTopicIDs = SearchTopicActivity.saTopicIDs; final String[] saTitles = SearchTopicActivity.saTopicTitles; final String[] saDates = SearchTopicActivity.saTopicDates; // TODO add TopicInfo for SearchResults as well and parse accordingly // final String[] saTopicIDs = extras.getStringArray("searchresults"); final TextView title = (TextView) findViewById(R.id.title); // Fill topic spinner ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, saTitles); final TextView tx = (TextView) findViewById(R.id.textView1); // tx.setMovementMethod(LinkMovementMethod.getInstance()); // final float minm = tx.getTextSize(); // final float maxm = (minm + 24); // create an invisible spinner just to control the summaries of the // category (i will use it later on Swipe) Spinner spinner = (Spinner) findViewById(R.id.spinner1); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/*from w w w . j av a 2s . co m*/ // Scroll view init final ScrollView scroll = (ScrollView) findViewById(R.id.scrollView1); // Add selection event spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // Show waiting dialog showWaitingDialog(); // Changing summary loading = true; // Update visibility of rating bar final RatingBar rb = (RatingBar) findViewById(R.id.ratingBar); rb.setRating(0.0f); rb.setVisibility(View.VISIBLE); final TextView rateLbl = (TextView) findViewById(R.id.rateLbl); rateLbl.setVisibility(View.VISIBLE); scroll.scrollTo(0, 0); // String[] saTopicIDs = sTopicIds.split(sSeparator); SharedPreferences settings = getSharedPreferences("urls", 0); // get user settings for sources String UserSources = settings.getString("UserLinks", "All"); String[] Summary = NewSumServiceClient.getSummary(saTopicIDs[arg2], UserSources); if (Summary.length == 0) { // WORK. Updated: CHECK // Close waiting dialog closeWaitingDialog(); AlertDialog.Builder alert = new AlertDialog.Builder(SearchViewActivity.this); alert.setMessage(R.string.shouldReloadSummaries); alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { startActivity(new Intent(getApplicationContext(), NewSumUiActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); } }); alert.setCancelable(false); alert.show(); loading = false; return; } // track summary views per Search and topic title if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(VIEW_SUMMARY_ACTION, "From Search", saTitles[arg2] + ": " + saDates[arg2], 0l); } // Generate summary text sText = ViewActivity.generateSummaryText(Summary, SearchViewActivity.this); pText = ViewActivity.generatesummarypost(Summary, SearchViewActivity.this); tx.setText(Html.fromHtml(sText)); tx.setMovementMethod(LinkMovementMethod.getInstance()); title.setText(saTitles[arg2] + ": " + saDates[arg2]); float defSize = tx.getTextSize(); SharedPreferences usersize = getSharedPreferences("textS", 0); float newSize = usersize.getFloat("size", defSize); tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize); // update the TopicActivity with viewed item TopicActivity.addVisitedTopicID(saTopicIDs[arg2]); // Close waiting dialog closeWaitingDialog(); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:it.mb.whatshare.MainActivity.java
private void onTellFriendsSelected() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(getResources().getString(R.string.email_body))); startActivity(Intent.createChooser(intent, getResources().getString(R.string.email_intent_msg))); }
From source file:com.example.okano.simpleroutesearch.MapsActivity.java
private void showMapInfo() { mPopupWindow = new PopupWindow(MapsActivity.this); // //from w w w. j ava2 s . c o m // View popupView = getLayoutInflater().inflate(R.layout.popup_route_info, null); View popupView = getLayoutInflater().inflate(R.layout.popup_route_info, null); // TextView textt = (TextView) popupView.findViewById(R.id.routeText); TextView textt = (TextView) popupView.findViewById(R.id.routeText); CharSequence htmlRoute = Html.fromHtml(routeDataText); // textt.setText(routeDataText); textt.setText(htmlRoute); mPopupWindow.setWindowLayoutMode(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT); mPopupWindow.setContentView(popupView); // mPopupWindow.showAsDropDown(popupView, 10,-10); mPopupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0); mPopupWindow.setFocusable(true); }
From source file:com.liato.bankdroid.banking.banks.Lansforsakringar.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); // No transaction history for funds and loans if (account.getType() != Account.REGULAR) return;// w w w . j ava 2 s . c om String response = null; Matcher matcher; if (mFirstTransactionPage) { try { response = urlopen.open("https://" + host + "/lfportal/appmanager/privat/main?_nfpb=true&_pageLabel=bank_konto&dialog=dialog:account.viewAccountTransactions&webapp=edb-account-web&stickyMenu=false&newUc=true&AccountNumber=" + account.getId() + "&_token=" + mRequestToken); matcher = reViewState.matcher(response); if (!matcher.find()) { Log.d(TAG, res.getText(R.string.unable_to_find).toString() + " ViewState. L237."); return; } mViewState = matcher.group(1); matcher = reToken.matcher(response); if (!matcher.find()) { Log.d(TAG, res.getText(R.string.unable_to_find).toString() + " token. L244."); return; } mRequestToken = matcher.group(1); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { List<NameValuePair> postData = new ArrayList<NameValuePair>(); if (mFirstTransactionPage) { postData.add(new BasicNameValuePair("dialog-account_viewAccountTransactions", "Submit Query")); postData.add(new BasicNameValuePair("_token", mRequestToken)); postData.add(new BasicNameValuePair("loginForm_SUBMIT", "1")); postData.add(new BasicNameValuePair("loginForm:_idcl", "")); postData.add(new BasicNameValuePair("loginForm:_link_hidden_", "")); postData.add(new BasicNameValuePair("javax.faces.ViewState", mViewState)); response = urlopen.open("https://" + host + "/lfportal/appmanager/privat/main?_nfpb=true&_windowLabel=account_1&_nffvid=%2Flfportal%2Findex_account.faces", postData); mFirstTransactionPage = false; } else { postData.add(new BasicNameValuePair("_token", mRequestToken)); postData.add(new BasicNameValuePair("viewAccountListTransactionsForm_SUBMIT", "1")); postData.add(new BasicNameValuePair("viewAccountListTransactionsForm:_idcl", "")); postData.add(new BasicNameValuePair("viewAccountListTransactionsForm:_link_hidden_", "")); postData.add(new BasicNameValuePair("javax.faces.ViewState", mViewState)); postData.add(new BasicNameValuePair("accountList", account.getId())); response = urlopen.open("https://" + host + "/lfportal/appmanager/privat/main?_nfpb=true&_windowLabel=account_1&_nffvid=%2Flfportal%2Fjsp%2Faccount%2Fview%2FviewAccountTransactions.faces", postData); } matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Book. date 2009-05-03 * 2: Trans. date 2009-05-03 * 3: Specification Överföring internet ... * 4: Note 829909945928712 * 5: Amount -54,00 * 6: Remaining 0,00 * */ transactions.add(new Transaction(matcher.group(2).trim(), Html.fromHtml(matcher.group(3)).toString().trim() + (matcher.group(4).trim().length() > 0 ? " (" + Html.fromHtml(matcher.group(4)).toString().trim() + ")" : ""), Helpers.parseBalance(matcher.group(5)))); } account.setTransactions(transactions); // Save token and viewstate for next request matcher = reViewState.matcher(response); // We need the second match, disregard the first one. matcher.find(); if (!matcher.find()) { Log.d(TAG, res.getText(R.string.unable_to_find).toString() + " ViewState. L304."); return; } mViewState = matcher.group(1); matcher = reToken.matcher(response); if (!matcher.find()) { Log.d(TAG, res.getText(R.string.unable_to_find).toString() + " token. L312."); return; } mRequestToken = matcher.group(1); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { super.updateComplete(); } }
From source file:foam.jellyfish.StarwispBuilder.java
public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) { try {//from ww w . j av a2 s. c o m String type = arr.getString(0); //Log.i("starwisp","building started "+type); if (type.equals("build-fragment")) { String name = arr.getString(1); int ID = arr.getInt(2); Fragment fragment = ActivityManager.GetFragment(name); LinearLayout inner = new LinearLayout(ctx); inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); inner.setId(ID); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(ID, fragment); fragmentTransaction.commit(); parent.addView(inner); return; } if (type.equals("linear-layout")) { LinearLayout v = new LinearLayout(ctx); v.setId(arr.getInt(1)); v.setOrientation(BuildOrientation(arr.getString(2))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); //v.setPadding(2,2,2,2); JSONArray col = arr.getJSONArray(4); v.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("frame-layout")) { FrameLayout v = new FrameLayout(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } /* if (type.equals("grid-layout")) { GridLayout v = new GridLayout(ctx); v.setId(arr.getInt(1)); v.setRowCount(arr.getInt(2)); //v.setColumnCount(arr.getInt(2)); v.setOrientation(BuildOrientation(arr.getString(3))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } return; } */ if (type.equals("scroll-view")) { HorizontalScrollView v = new HorizontalScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("scroll-view-vert")) { ScrollView v = new ScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("view-pager")) { ViewPager v = new ViewPager(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.setOffscreenPageLimit(3); final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } return null; } }); parent.addView(v); return; } if (type.equals("space")) { // Space v = new Space(ctx); (class not found runtime error??) TextView v = new TextView(ctx); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); } if (type.equals("image-view")) { ImageView v = new ImageView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); String image = arr.getString(2); if (image.startsWith("/")) { Bitmap bitmap = BitmapFactory.decodeFile(image); v.setImageBitmap(bitmap); } else { int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName()); v.setImageResource(id); } parent.addView(v); } if (type.equals("text-view")) { TextView v = new TextView(ctx); v.setId(arr.getInt(1)); v.setText(Html.fromHtml(arr.getString(2))); v.setTextSize(arr.getInt(3)); v.setMovementMethod(LinkMovementMethod.getInstance()); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); if (arr.length() > 5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity) ctx).m_Typeface); parent.addView(v); } if (type.equals("debug-text-view")) { TextView v = (TextView) ctx.getLayoutInflater().inflate(R.layout.debug_text, null); // v.setBackgroundResource(R.color.black); v.setId(arr.getInt(1)); // v.setText(Html.fromHtml(arr.getString(2))); // v.setTextColor(R.color.white); // v.setTextSize(arr.getInt(3)); // v.setMovementMethod(LinkMovementMethod.getInstance()); // v.setMaxLines(10); // v.setVerticalScrollBarEnabled(true); // v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); //v.setMovementMethod(new ScrollingMovementMethod()); /* if (arr.length()>5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity)ctx).m_Typeface);*/ parent.addView(v); } if (type.equals("web-view")) { WebView v = new WebView(ctx); v.setId(arr.getInt(1)); v.setVerticalScrollBarEnabled(false); v.loadData(arr.getString(2), "text/html", "utf-8"); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); parent.addView(v); } if (type.equals("edit-text")) { final EditText v = new EditText(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); String inputtype = arr.getString(4); if (inputtype.equals("text")) { //v.setInputType(InputType.TYPE_CLASS_TEXT); } else if (inputtype.equals("numeric")) { v.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else if (inputtype.equals("email")) { v.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS); } v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(5))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setSingleLine(true); v.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { CallbackArgs(ctx, ctxname, v.getId(), "\"" + s.toString() + "\""); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); parent.addView(v); } if (type.equals("button")) { Button v = new Button(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Callback(ctx, ctxname, v.getId()); } }); parent.addView(v); } if (type.equals("toggle-button")) { ToggleButton v = new ToggleButton(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, v.getId(), arg); } }); parent.addView(v); } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); v.setId(arr.getInt(1)); v.setMax(arr.getInt(2)); v.setProgress(arr.getInt(2) / 2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); final String fn = arr.getString(4); v.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar v, int a, boolean s) { CallbackArgs(ctx, ctxname, v.getId(), Integer.toString(a)); } public void onStartTrackingTouch(SeekBar v) { } public void onStopTrackingTouch(SeekBar v) { } }); parent.addView(v); } if (type.equals("spinner")) { Spinner v = new Spinner(ctx); final int wid = arr.getInt(1); v.setId(wid); final JSONArray items = arr.getJSONArray(2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, android.R.layout.simple_spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; v.setAdapter(spinnerArrayAdapter); v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { try { CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\""); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } } public void onNothingSelected(AdapterView<?> v) { } }); parent.addView(v); } if (type.equals("nomadic")) { final int wid = arr.getInt(1); NomadicSurfaceView v = new NomadicSurfaceView(ctx, wid); v.setId(wid); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); } /* if (type.equals("canvas")) { StarwispCanvas v = new StarwispCanvas(ctx); final int wid = arr.getInt(1); v.setId(wid); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.SetDrawList(arr.getJSONArray(3)); parent.addView(v); } if (type.equals("camera-preview")) { PictureTaker pt = new PictureTaker(); CameraPreview v = new CameraPreview(ctx,pt); final int wid = arr.getInt(1); v.setId(wid); // LinearLayout.LayoutParams lp = // new LinearLayout.LayoutParams(minWidth, minHeight, 1); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); // v.setLayoutParams(lp); parent.addView(v); } */ if (type.equals("button-grid")) { LinearLayout horiz = new LinearLayout(ctx); final int id = arr.getInt(1); final String buttontype = arr.getString(2); horiz.setId(id); horiz.setOrientation(LinearLayout.HORIZONTAL); parent.addView(horiz); int height = arr.getInt(3); int textsize = arr.getInt(4); LinearLayout.LayoutParams lp = BuildLayoutParams(arr.getJSONArray(5)); JSONArray buttons = arr.getJSONArray(6); int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } } } } catch (JSONException e) { Log.e("starwisp", "Error parsing [" + arr.toString() + "] " + e.toString()); } //Log.i("starwisp","building ended"); }
From source file:com.github.sgelb.booket.SearchResultActivity.java
private void saveBook(int position) { datasource.open();//from w w w. ja va 2s . co m boolean addedNewBook = datasource.createBook(bookList.get(position)); datasource.close(); String msg = getString(R.string.saved, bookList.get(position).getTitle()); if (!addedNewBook) { msg = getString(R.string.alreadySaved, bookList.get(position).getTitle()); } Toast.makeText(getBaseContext(), Html.fromHtml(msg), Toast.LENGTH_SHORT).show(); }