List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:ru.orangesoftware.financisto.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FlowzrSyncActivity.me = this; mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext()); nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); setContentView(R.layout.flowzr_sync); restoreUIFromPref();/*from w w w.j av a 2 s. c om*/ AccountManager accountManager = AccountManager.get(getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); if (accounts.length < 1) { new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error)) .setMessage(R.string.account_required) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); } //checkbox CheckBox chk = (CheckBox) findViewById(R.id.chk_sync_from_zero); OnClickListener chk_listener = new OnClickListener() { public void onClick(View v) { lastSyncLocalTimestamp = 0; renderLastTime(0); flowzrSyncEngine.resetLastTime(getApplicationContext()); } }; chk.setOnClickListener(chk_listener); //radio crendentials RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials); OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId()); for (Account account : accounts) { if (account.name == radioButtonSelected.getText()) { lastSyncLocalTimestamp = 0; renderLastTime(0); flowzrSyncEngine.resetLastTime(getApplicationContext()); useCredential = account; } } } }; radioGroupCredentials.setOnClickListener(radio_listener); //initialize value for (int i = 0; i < accounts.length; i++) { RadioButton rb = new RadioButton(this); radioGroupCredentials.addView(rb); //, 0, lp); rb.setOnClickListener(radio_listener); rb.setText(((Account) accounts[i]).name); String prefAccount = MyPreferences.getFlowzrAccount(this); if (prefAccount != null) { if (accounts[i].name.equals(prefAccount)) { useCredential = accounts[i]; rb.toggle(); //.setChecked(true); } } } bOk = (Button) findViewById(R.id.bOK); bOk.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startSync(); } }); Button bCancel = (Button) findViewById(R.id.bCancel); bCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (flowzrSyncEngine != null) { flowzrSyncEngine.isCanceled = true; } isRunning = false; setResult(RESULT_CANCELED); setReady(); startActivity(new Intent(getApplicationContext(), MainActivity.class)); //finish(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(useCredential); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:com.abcvoipsip.ui.prefs.CodecsFragment.java
@Override @SuppressWarnings("unchecked") public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info; try {// w w w .jav a2s.c om info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { Log.e(THIS_FILE, "bad menuInfo", e); return false; } HashMap<String, Object> codec = null; codec = (HashMap<String, Object>) mAdapter.getItem(info.position); if (codec == null) { // If for some reason the requested item isn't available, do nothing return false; } int selId = item.getItemId(); if (selId == MENU_ITEM_ACTIVATE) { boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0); final short newPrio = isDisabled ? (short) 1 : (short) 0; if (NON_FREE_CODECS.containsKey(codec.get(CODEC_ID)) && isDisabled) { final HashMap<String, Object> fCodec = codec; final TextView message = new TextView(getActivity()); final SpannableString s = new SpannableString( getString(R.string.this_codec_is_not_free) + NON_FREE_CODECS.get(codec.get(CODEC_ID))); Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); message.setPadding(10, 10, 10, 10); //Alert user that we will disable for all incoming calls as he want to quit new AlertDialog.Builder(getActivity()).setTitle(R.string.warning).setView(message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setCodecActivated(fCodec, newPrio); } }).setNegativeButton(R.string.cancel, null).show(); } else { setCodecActivated(codec, newPrio); } return true; } return false; }
From source file:com.anton.gavel.GavelMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gavel_main); // set up edit text input style for complaints (multiline, capitalize sentences) EditText edit = (EditText) findViewById(R.id.complaint_body); edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE); // set up cities spinner Spinner citiesSpinner = (Spinner) findViewById(R.id.cities_spinner); ArrayAdapter<CharSequence> citiesAdapter = ArrayAdapter.createFromResource(this, R.array.cities, android.R.layout.simple_spinner_item); citiesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); citiesSpinner.setAdapter(citiesAdapter); // set up complaints map List<String> standardComplaints = this.getStandardComplaints(); List<String> complaintSubmitValues = this.getComplaintSubmitValues(); Iterator<String> standard = standardComplaints.iterator(); Iterator<String> submit = complaintSubmitValues.iterator(); complaintsMap = new HashMap<String, String>(); //standard.next(); submit.next(); //skip the first item 'select a complaint' while (standard.hasNext() && submit.hasNext()) complaintsMap.put(standard.next().toString(), submit.next().toString()); // set up complaint spinner List<String> complaints_list = this.getStandardComplaints(); complaintSpinner = (Spinner) findViewById(R.id.complaint_spinner); complaintsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, complaints_list);//from ww w.ja v a 2 s .com complaintsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); complaintSpinner.setAdapter(complaintsAdapter); complaintSpinner.setOnItemSelectedListener(this); complaintSpinner.setOnItemLongClickListener(this);// this doesn't actually work yet bc not supported by API - events don't get fired //attach location listener to button findViewById(R.id.location_button).setOnClickListener(this); // make link in disclaimer clickable TextView disclaimer = (TextView) findViewById(R.id.disclaimer_textview); disclaimer.setMovementMethod(LinkMovementMethod.getInstance()); // check &or load shared preferences to populate saved personal information mPersonalInfo = new PersonalInfo(); SharedPreferences preferences = getPreferences(MODE_PRIVATE); mPersonalInfo.loadFromPreferences(preferences); // suppress keyboard this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // set complaint location to multiline for large layouts if (findViewById(R.id.layout_large_land) != null || findViewById(R.id.layout_large) != null) { ((EditText) findViewById(R.id.complaint_address)).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_WORDS); } }
From source file:de.mprengemann.hwr.timetabel.TimetableActivity.java
@SuppressWarnings("deprecation") @Override//from w w w . ja va 2 s. c o m protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder; switch (id) { case NEW_TIMETABLEPLAN: builder = new AlertDialog.Builder(this); builder.setMessage(R.string.dialog_new_message); builder.setTitle(R.string.dialog_new_title); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { subjectFragment.clear(); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); refreshItem.setVisible(false); Parser p = new Parser(TimetableActivity.this, parsingListener); p.execute(); } }); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TimetableActivity.this); Calendar calendar = Calendar.getInstance(); Editor edit = prefs.edit(); edit.putLong(getString(R.string.prefs_lastUpdated_user), calendar.getTimeInMillis()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); edit.putLong(getString(R.string.prefs_lastUpdated), calendar.getTimeInMillis()); edit.commit(); dialog.cancel(); } }); return builder.create(); case LICENSE_DIALOG: builder = new AlertDialog.Builder(this); TextView textView = new TextView(this); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(R.string.text_license); textView.setLinksClickable(true); textView.setPadding(10, 10, 10, 10); builder.setView(textView); builder.setTitle(R.string.menu_license); builder.setCancelable(true); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); return builder.create(); default: return super.onCreateDialog(id); } }
From source file:com.littlepancake.glpk.GlpkCodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.code_sample_layout, container, false); TextView tv = (TextView) v.findViewById(R.id.textViewCode); solveButton = (Button) v.findViewById(R.id.buttonSolve); solveButton.setOnClickListener(this); textViewSolution = (TextView) v.findViewById(R.id.textViewSolution); InputStream is;/*from ww w .j a v a 2s . c om*/ byte[] buffer = null; try { is = getActivity().getAssets().open("test.html"); int size = is.available(); buffer = new byte[size]; is.read(buffer); is.close(); } catch (IOException e) { tv.setMovementMethod(new ScrollingMovementMethod()); tv.setText(e.getMessage()); e.printStackTrace(); } if (buffer != null) { String str = new String(buffer); Spanned result = Html.fromHtml(str); tv.setMovementMethod(new ScrollingMovementMethod()); tv.setText(result); } return v; }
From source file:com.mine.psf.PsfFileBrowserActivity.java
@Override protected Dialog onCreateDialog(int id) { // show dialog according to the id final String msg; if (id == ID_ABOUT) { // Get version code String versionString = ""; PackageManager manager = getPackageManager(); try {/*from w w w. j a v a 2 s . co m*/ PackageInfo info = manager.getPackageInfo(getPackageName(), 0); versionString = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } // Format dialog msg msg = String.format(getString(R.string.sexypsf_about), versionString); } else { Log.e(LOGTAG, "Unknown dialog id"); msg = ""; } final TextView msgView = new TextView(this); msgView.setText(msg); msgView.setAutoLinkMask(Linkify.ALL); msgView.setTextAppearance(this, android.R.style.TextAppearance_Medium); msgView.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(this).setView(msgView).setCancelable(true) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ } }).create(); }
From source file:ru.orangesoftware.financisto2.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FlowzrSyncActivity.me = this; mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext()); nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); setContentView(R.layout.flowzr_sync); restoreUIFromPref();/* ww w. ja va 2 s. co m*/ if (useCredential != null) { } AccountManager accountManager = AccountManager.get(getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); if (accounts.length < 1) { new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error)) .setMessage(R.string.account_required) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); } //radio crendentials RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials); OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId()); for (Account account : accounts) { if (account.name == radioButtonSelected.getText()) { useCredential = account; } } } }; //initialize value for (int i = 0; i < accounts.length; i++) { RadioButton rb = new RadioButton(this); radioGroupCredentials.addView(rb); //, 0, lp); rb.setOnClickListener(radio_listener); rb.setText(((Account) accounts[i]).name); if (useCredential != null) { if (accounts[i].name.equals(useCredential.name)) { rb.toggle(); //.setChecked(true); } } } bOk = (Button) findViewById(R.id.bOK); bOk.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setRunning(); initProgressDialog(); // if (useCredential!=null) { // flowzrBilling=new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString()); // } if (useCredential == null) { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_choose_account); notifyUser(getString(R.string.flowzr_choose_account), 100); setReady(); } else if (!isOnline(FlowzrSyncActivity.this)) { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); notifyUser(getString(R.string.flowzr_sync_error_no_network), 100); setReady(); } else { saveOptionsFromUI(); //Play Service Billing //FlowzrBilling flowzrBilling = new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString()); //if (flowzrSyncTask.checkSubscription()) { flowzrSyncEngine = new FlowzrSyncEngine(FlowzrSyncActivity.this); //} } } }); Button bCancel = (Button) findViewById(R.id.bCancel); bCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (flowzrSyncEngine != null) { flowzrSyncEngine.isCanceled = true; } isRunning = false; setResult(RESULT_CANCELED); setReady(); startActivity(new Intent(getApplicationContext(), MainActivity.class)); //finish(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(useCredential); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
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 a va2 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.kyakujin.android.tagnotepad.ui.NoteListFragment.java
/** * About//from w w w . j a v a 2 s . c om */ private void showAboutDialog() { PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName; try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "N/A"; } SpannableStringBuilder aboutBody = new SpannableStringBuilder(); SpannableString mailAddress = new SpannableString(getString(R.string.mailto)); mailAddress.setSpan(new ClickableSpan() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse(getString(R.string.description_mailto))); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.description_mail_subject)); startActivity(intent); } }, 0, mailAddress.length(), 0); aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName))); aboutBody.append("\n"); aboutBody.append(mailAddress); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_about_dialog, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(LinkMovementMethod.getInstance()); AlertDialog dlg = new AlertDialog.Builder(getActivity()).setTitle(R.string.alert_title_about) .setView(aboutBodyView).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dlg.show(); }
From source file:com.happysanta.vkspy.Fragments.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity();/*from www. j a v a2 s . c om*/ if (savedInstanceState != null && UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); } View rootView = inflater.inflate(R.layout.fragment_main, null); View happySanta = inflater.inflate(R.layout.main_santa, null); TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText); happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description))); TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink); happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>")); happySantaLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta")); startActivity(browserIntent); } }); happySanta.setOnClickListener(new View.OnClickListener() { int i = 1; @Override public void onClick(View v) { if (i < 10) i++; else { i = 0; File F = Logs.getFile(); Uri U = Uri.fromFile(F); Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_STREAM, U); startActivity(Intent.createChooser(i, "What should we do with logs?")); } } }); SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll", Context.MODE_MULTI_PROCESS); boolean longpollStatus = longpollPreferences.getBoolean("status", true); /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline); BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile); tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT); santaGroundView.setBackgroundDrawable(tiledBitmapDrawable); BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource( getResources(), R.drawable.underline2)); bitmap.setTileModeX(Shader.TileMode.REPEAT); */ LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); // deprecated for (int i = 0; width % (341 * i + 1) < width; i++) { layout.addView(new ImageView(context) { { setImageResource(R.drawable.underline2); setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4))); setScaleType(ScaleType.CENTER_CROP); } }); } ListView preferencesView = (ListView) rootView.findViewById(R.id.preference); preferencesView.addHeaderView(happySanta, null, false); ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>(); /* preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) { @Override public void onClick() { if(UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog selector; View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null); SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS); boolean updateOnly = durovPreferences.getBoolean("loaded", false); if(updateOnly) ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated); if(Memory.users.getById(1)!=null && !updateOnly) { builder.setTitle(R.string.durov_joke_title); ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message); ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE); builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent("? ? "); } }); BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1"); }else{ builder.setTitle(R.string.durov_start_title); ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo)); builder. setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent(" "); ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(), context.getString(R.string.durov_function_activating_title), context.getString(R.string.durov_function_activating_message), true, false); UberFunktion.initialize(uberfunctionDialog); } }); builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("https://vk.com/id1") ); startActivity(browserIntent); }catch(Exception exp){ AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity()); if (exp instanceof ActivityNotFoundException) { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.no_browser); } else { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.unknown_error); } errorShower.show(); } BugSenseHandler.sendEvent("? ? "); } }); } builder.setView(durov); selector = builder.create(); selector.show(); } }); */ preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) { @Override public void onToggle(Boolean isChecked) { longpollToggle(isChecked); } }); preferences.add(new PreferenceItem(getAdvancedSettings()) { @Override public void onClick() { startActivity(new Intent(context, SettingsActivity.class)); } }); preferences.add(new PreferenceItem(getAbout()) { @Override public void onClick() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog aboutDialog; builder.setTitle(R.string.app_about).setCancelable(true) .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null); TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description); aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description))); aboutDescription.setMovementMethod(LinkMovementMethod.getInstance()); aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(context, InfoActivity.class); startActivity(browserIntent); } }); builder.setView(aboutView); aboutDialog = builder.create(); aboutDialog.setCanceledOnTouchOutside(true); aboutDialog.show(); } }); preferencesView.setAdapter(new PreferenceAdapter(context, preferences)); return rootView; }