List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.quarterfull.newsAndroid.LoginDialogFragment.java
public static void ShowAlertDialog(String title, String text, Activity activity) { // Linkify the message final SpannableString s = new SpannableString(text); Linkify.addLinks(s, Linkify.ALL);/*from w w w. j ava 2s . co m*/ AlertDialog aDialog = new AlertDialog.Builder(activity).setTitle(title).setMessage(s) .setPositiveButton(activity.getString(android.R.string.ok), null).create(); aDialog.show(); // Make the textview clickable. Must be called after show() ((TextView) aDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.exobel.routerkeygen.ui.Preferences.java
protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_ABOUT: { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.tabhost)); TabHost tabs = (TabHost) layout.findViewById(R.id.tabhost); tabs.setup();/* ww w . j av a 2 s.c o m*/ TabSpec tspec1 = tabs.newTabSpec("about"); tspec1.setIndicator(getString(R.string.pref_about)); tspec1.setContent(R.id.text_about_scroll); TextView text = ((TextView) layout.findViewById(R.id.text_about)); text.setMovementMethod(LinkMovementMethod.getInstance()); text.append(VERSION + "\n" + LAUNCH_DATE); tabs.addTab(tspec1); TabSpec tspec2 = tabs.newTabSpec("credits"); tspec2.setIndicator(getString(R.string.dialog_about_credits)); tspec2.setContent(R.id.about_credits_scroll); ((TextView) layout.findViewById(R.id.about_credits)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec2); TabSpec tspec3 = tabs.newTabSpec("license"); tspec3.setIndicator(getString(R.string.dialog_about_license)); tspec3.setContent(R.id.about_license_scroll); ((TextView) layout.findViewById(R.id.about_license)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec3); builder.setNeutralButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_ABOUT); } }); builder.setView(layout); break; } case DIALOG_ASK_DOWNLOAD: { DialogInterface.OnClickListener diOnClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Check if we have the latest dictionary version. try { checkCurrentDictionary(); } catch (Exception e) { e.printStackTrace(); } } }; builder.setTitle(R.string.pref_download); builder.setMessage(R.string.msg_dicislarge); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, diOnClickListener); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DIALOG_ASK_DOWNLOAD); } }); break; } case DIALOG_UPDATE_NEEDED: { builder.setTitle(R.string.update_title) .setMessage(getString(R.string.update_message, lastVersion.version)) .setNegativeButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPDATE_NEEDED); } }).setPositiveButton(R.string.bt_website, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(lastVersion.url))); } }); break; } case DIALOG_WAIT: { ProgressDialog pbarDialog = new ProgressDialog(Preferences.this); pbarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pbarDialog.setMessage(getString(R.string.msg_wait)); return pbarDialog; } case DIALOG_ERROR_TOO_ADVANCED: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_online_too_adv); break; } case DIALOG_ERROR: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_unkown); break; } case DIALOG_CHANGELOG: { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.dialog_changelog, (ViewGroup) this.getWindow().getDecorView().getRootView(), false); builder.setTitle(R.string.pref_changelog).setView(chgList).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); break; } } return builder.create(); }
From source file:com.rareventure.gps2.reviewer.map.OsmMapGpsTrailerReviewerMapActivity.java
private void initUI() { TextView ty = (TextView) findViewById(R.id.thankyou); ty.setMovementMethod(LinkMovementMethod.getInstance()); sasPanelButton = (ImageButton) findViewById(R.id.sas_open_close_button); sasPanelButton.setOnClickListener(this); gtgStatus = (OngoingProcessStatusFragment) getSupportFragmentManager().findFragmentById(R.id.status); toolTip = (ToolTipFragment) getSupportFragmentManager().findFragmentById(R.id.tooltip); infoNotice = (InfoNoticeStatusFragment) getSupportFragmentManager().findFragmentById(R.id.infoNotice); superThreadManager = new SuperThreadManager(); SuperThread cpuThread = new SuperThread(superThreadManager); SuperThread fileIOThread = new SuperThread(superThreadManager); fileIOThread.start();/*w ww . j ava 2 s.c om*/ cpuThread.start(); //co: this has been replaced by notifyProcessing() method // superThreadManager.setSleepingThreadsListener(new SuperThreadManager.SleepingThreadsListener() { // // @Override // public void notifySleepingThreadsChanged(final boolean allThreadsAreSleeping) { // runOnUiThread(new Runnable() { // // @Override // public void run() { // setProgressBarIndeterminateVisibility(!allThreadsAreSleeping); // } // }); // } // }); zoomControls = (ZoomControls) this.findViewById(R.id.zoomControls); zoomControls.setOnZoomInClickListener(new OnClickListener() { @Override public void onClick(View v) { osmMapView.zoomIn(); toolTip.setAction(UserAction.ZOOM_IN); } }); zoomControls.setOnZoomOutClickListener(new OnClickListener() { @Override public void onClick(View v) { osmMapView.zoomOut(); toolTip.setAction(UserAction.ZOOM_OUT); } }); osmMapView.addOverlay(gpsTrailerOverlay = new GpsTrailerOverlay(this, cpuThread, osmMapView)); osmMapView.addOverlay(locationOverlay = new GpsLocationOverlay(this)); osmMapView.init(fileIOThread, this); scaleWidget = (MapScaleWidget) this.findViewById(R.id.scaleWidget); osmMapView.setScaleWidget(scaleWidget); panToLocation = (ImageView) this.findViewById(R.id.pan_to_location); panToLocation.setOnClickListener(this); autoZoom = (ImageView) this.findViewById(R.id.AutoZoom); autoZoom.setOnClickListener(this); menuButton = (ImageButton) findViewById(R.id.menu_button); menuButton.setOnClickListener(this); datePicker = findViewById(R.id.date_picker); datePicker.setOnClickListener(this); timeView = (TimeView) findViewById(R.id.timeview); timeView.setListener(this); timeView.setActivity(this); // selectedAreaAddLock = (CheckBox) findViewById(R.id.selected_areas_add_lock); // selectedAreaAddLock.setOnCheckedChangeListener(new OnCheckedChangeListener() { // // @Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // GpsTrailerOverlayDrawer.doMethodTracing = true; // if(isChecked) // { // toolTip.setAction(ToolTipFragment.UserAction.SELECTED_AREA_ADD_LOCKED); // gpsTrailerOverlay.setSelectedAreaAddLock(true); // } // else // { // toolTip.setAction(ToolTipFragment.UserAction.SELECTED_AREA_ADD_UNLOCKED); // gpsTrailerOverlay.setSelectedAreaAddLock(false); // } // } // }); // sasPanel = findViewById(R.id.sas_panel); sasPanel.setVisibility(View.INVISIBLE); distanceView = (TextView) findViewById(R.id.dist_traveled); updateDistanceView(-1); initSasPanel(); }
From source file:foam.mongoose.StarwispBuilder.java
public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) { try {//from w ww. ja v a 2 s .co 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_CLASS_NUMBER | 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); if (arr.getString(5).equals("fancy")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_fancy, null); } if (arr.getString(5).equals("yes")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_yes, null); } if (arr.getString(5).equals("maybe")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_maybe, null); } if (arr.getString(5).equals("no")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_no, null); } 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(6); 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, R.layout.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; } }; spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); 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("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:org.liberty.android.fantastischmemo.ui.MiscTabFragment.java
@Override public void onClick(View v) { if (v == optionButton) { startActivity(new Intent(mActivity, OptionScreen.class)); }/* w ww. j av a 2 s. co m*/ /* Toggle visibility for import and export buttons */ if (v == importButton) { if (importItems.getVisibility() == View.GONE) { importItems.setVisibility(View.VISIBLE); } else { importItems.setVisibility(View.GONE); } } if (v == exportButton) { if (exportItems.getVisibility() == View.GONE) { exportItems.setVisibility(View.VISIBLE); } else { exportItems.setVisibility(View.GONE); } } if (v == importMnemosyneButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, MnemosyneXMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportMnemosyne"); } if (v == importSupermemoButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, SupermemoXMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportSuperMemo2008"); } if (v == importCSVButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, CSVImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".csv"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportCSV"); } if (v == importZipButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, ZipImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".zip"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportZip"); } if (v == importTabButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, TabTxtImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".txt"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportTabTxt"); } if (v == importQAButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, QATxtImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".txt"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportCSV"); } if (v == importSupermemo2008Button) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Supermemo2008XMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportSuperMemo2008"); } if (v == importMnemosyne2CardsButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Mnemosyne2CardsImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".cards"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportMnemosyne2Cards"); } if (v == exportMnemosyneButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, MnemosyneXMLExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportMnemosyne"); } if (v == exportCSVButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, CSVExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportCSV"); } if (v == exportTabButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, TabTxtExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportTabTxt"); } if (v == exportQAButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, QATxtExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportQA"); } if (v == exportZipButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, ZipExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportZip"); } if (v == exportMnemosyne2CardsButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Mnemosyne2CardsExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportMnemosyne2Cards"); } if (v == defaultSettingsButton) { Intent intent = new Intent(mActivity, SettingsScreen.class); String emptyDbPath = mActivity.getApplicationContext().getFilesDir().getAbsolutePath() + "/" + AMEnv.EMPTY_DB_NAME; intent.putExtra(SettingsScreen.EXTRA_DBPATH, emptyDbPath); startActivity(intent); } if (v == mergeButton) { Intent myIntent = new Intent(mActivity, DatabaseMerger.class); startActivity(myIntent); } if (v == resetButton) { new AlertDialog.Builder(mActivity).setTitle(R.string.clear_all_pref) .setMessage(R.string.reset_all_pref_warning) .setPositiveButton(R.string.ok_text, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity); SharedPreferences.Editor editor = settings.edit(); editor.clear(); editor.commit(); mActivity.finish(); } }).setNegativeButton(R.string.cancel_text, null).show(); } if (v == donateButton) { View alertView = View.inflate(mActivity, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setText(Html.fromHtml(getString(R.string.donate_summary))); textView.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(mActivity).setView(alertView).setTitle(R.string.donate_text) .setPositiveButton(getString(R.string.buy_pro_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(getString(R.string.anymemo_pro_link))); startActivity(myIntent); } }).setNegativeButton(getString(R.string.cancel_text), null).show(); } if (v == helpButton) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(WEBSITE_VERSION)); startActivity(myIntent); } if (v == aboutButton) { // Get the version defined in the AndroidManifest. String versionName = ""; try { versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "1.0"; } View alertView = View.inflate(mActivity, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setText(Html.fromHtml(getString(R.string.about_text))); textView.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(mActivity).setView(alertView) .setTitle(getString(R.string.app_full_name) + " " + versionName) .setPositiveButton(getString(R.string.ok_text), null) .setNegativeButton(getString(R.string.about_version), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(WEBSITE_VERSION)); startActivity(myIntent); } }).show(); } }
From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java
@UiThread(propagation = UiThread.Propagation.REUSE) void bindData() { String mTitleString = currentRecord.getName(); String subtitle = currentRecord.getCategory(); mTitle.setText(mTitleString);/* w w w .j a va2 s .c o m*/ mSubtitle.setText(subtitle); mReadPubButton.setVisibility(View.VISIBLE); mPhotoViewContainer.setBackgroundColor(UIUtils.scaleColor(0xe8552c, 0.65f, false)); updatePlusOneButton(); if (currentRecord.getUpdatesIgnored()) { showEnableUpdatesBackCard(); } else { final MessageCardView messageCardView = (MessageCardView) mRootView .findViewById(R.id.message_card_view); if (messageCardView != null) { messageCardView.setVisibility(View.GONE); } } updateRating(); String imagesUrl = currentRecord.getImagePageUrl(); if (!TextUtils.isEmpty(imagesUrl) && prefs.displayPubImages().get() && //TODO remove Gingerbread check on next release UIUtils.hasGingerbreadMR1()) { //Do a network request to detect number of images loadImageList(imagesUrl); //Add images //Add image view to pager. } else { mHasPhoto = false; delayedScrollCheck = true; recomputePhotoAndScrollingMetrics(); } //Check if file is new version of pub is loaded. if (mIsDownloading) { showPublicationState(PublicationState.DOWNLOADING, false); } else { boolean isRefreshable = false; if (getActivity() != null) { isRefreshable = ShareHelper.shouldRefreshPublication(getActivity(), currentRecord, prefs.downloadFolder().get()); } if (isRefreshable) { showPublicationState(PublicationState.WAITING_REFRESH, false); } else { showPublicationState(PublicationState.READY_FOR_READING, false); } } String pubAbstract = SamlibPageHelper.stripDescriptionOfImages(currentRecord.getDescription()); if (!TextUtils.isEmpty(pubAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, pubAbstract); mAbstract.setMovementMethod(LinkMovementMethod.getInstance()); mAbstract.setVisibility(View.VISIBLE); } else { mAbstract.setVisibility(View.GONE); } mHandler.post(new Runnable() { @Override public void run() { onScrollChanged(0, 0); // trigger scroll handling mScrollViewChild.setVisibility(View.VISIBLE); } }); }
From source file:com.esminis.server.library.activity.main.MainViewImpl.java
@Override public void setStatusLabel(CharSequence label) { viewServerStatusLabel.setText(label); viewServerStatusLabel.setLinksClickable(true); viewServerStatusLabel.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.github.michalbednarski.intentslab.browser.ComponentInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_component_info, container, false); // Header, icon, component name and description mTitleTextView = (TextView) v.findViewById(R.id.title); mComponentTextView = (TextView) v.findViewById(R.id.component); mIconView = (ImageView) v.findViewById(R.id.icon); mDescriptionTextView = (TextView) v.findViewById(R.id.description); mDescriptionTextView.setMovementMethod(LinkMovementMethod.getInstance()); // Go to intent editor button v.findViewById(R.id.go_to_intent_editor).setOnClickListener(new View.OnClickListener() { @Override/*from w ww. ja va2s . c o m*/ public void onClick(View v) { if (getArguments().getBoolean(ARG_LAUNCHED_FROM_INTENT_EDITOR, false)) { getActivity().finish(); return; } startActivity(new Intent(getActivity(), IntentEditorActivity.class) .putExtra(IntentEditorActivity.EXTRA_INTENT, new Intent().setClassName(mPackageName, mComponentName)) .putExtra(IntentEditorActivity.EXTRA_COMPONENT_TYPE, mExtendedComponentInfo.componentType) .putExtra(IntentEditorActivity.EXTRA_INTENT_FILTERS, mExtendedComponentInfo.intentFilters)); } }); // Receive broadcast button mReceiveBroadcastButton = v.findViewById(R.id.receive_broadcast); mReceiveBroadcastButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ReceiveBroadcastService.startReceiving(getActivity(), mExtendedComponentInfo.intentFilters, false); } }); mReceiveBroadcastButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ReceiveBroadcastService.startReceiving(getActivity(), mExtendedComponentInfo.intentFilters, true); return true; } }); // Fill it if have content if (haveContentLoaded()) { fillViews(); } return v; }
From source file:com.keepassdroid.EntryActivity.java
private void showSamsungDialog() { String text = getString(R.string.clipboard_error).concat(System.getProperty("line.separator")) .concat(getString(R.string.clipboard_error_url)); SpannableString s = new SpannableString(text); TextView tv = new TextView(this); tv.setText(s);//from w w w .j a v a 2 s .co m tv.setAutoLinkMask(RESULT_OK); tv.setMovementMethod(LinkMovementMethod.getInstance()); Linkify.addLinks(s, Linkify.WEB_URLS); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.clipboard_error_title) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setView(tv).show(); }
From source file:in.animeshpathak.nextbus.NextBusMain.java
/** * Creates the Application Info dialog with clickable links. * /*from www .j av a 2 s. c om*/ * @throws UnsupportedEncodingException * @throws IOException */ private void showVersionInfoDialog() throws UnsupportedEncodingException, IOException { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.app_name) + " " + getString(R.string.version_name)); AssetManager assetManager = getResources().getAssets(); String versionInfoFile = getString(R.string.versioninfo_asset); InputStreamReader reader = new InputStreamReader(assetManager.open(versionInfoFile), "UTF-8"); BufferedReader br = new BufferedReader(reader); StringBuffer sbuf = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sbuf.append(line); sbuf.append("\r\n"); } final ScrollView scroll = new ScrollView(this); final TextView message = new TextView(this); final SpannableString sWlinks = new SpannableString(sbuf.toString()); Linkify.addLinks(sWlinks, Linkify.WEB_URLS); message.setText(sWlinks); message.setMovementMethod(LinkMovementMethod.getInstance()); message.setPadding(15, 15, 15, 15); scroll.addView(message); alertDialog.setView(scroll); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing to do, just dismiss dialog } }); alertDialog.show(); }