List of usage examples for android.text SpannableString setSpan
public void setSpan(Object what, int start, int end, int flags)
From source file:com.android.launcher3.Utilities.java
/** * Wraps a message with a TTS span, so that a different message is spoken than * what is getting displayed./*w ww .j ava 2 s. c o m*/ * @param msg original message * @param ttsMsg message to be spoken */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static CharSequence wrapForTts(CharSequence msg, String ttsMsg) { if (Utilities.ATLEAST_LOLLIPOP) { SpannableString spanned = new SpannableString(msg); spanned.setSpan(new TtsSpan.TextBuilder(ttsMsg).build(), 0, spanned.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return spanned; } else { return msg; } }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
@SuppressLint("SetTextI18n") public void update(Lyrics lyrics, View layout, boolean animation) { File musicFile = null;/* www. jav a2 s .c om*/ Bitmap cover = null; if (PermissionsChecker.hasPermission(getActivity(), "android.permission.READ_EXTERNAL_STORAGE")) { musicFile = Id3Reader.getFile(getActivity(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack()); cover = Id3Reader.getCover(getActivity(), lyrics.getArtist(), lyrics.getTitle()); } setCoverArt(cover, null); boolean artCellDownload = Integer.valueOf( PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("pref_artworks", "0")) == 0; if (cover == null) new CoverArtLoader().execute(lyrics, this.getActivity(), artCellDownload || OnlineAccessVerifier.isConnectedWifi(getActivity())); getActivity().findViewById(R.id.edit_tags_btn).setEnabled(true); getActivity().findViewById(R.id.edit_tags_btn) .setVisibility(musicFile == null || !musicFile.canWrite() || lyrics.isLRC() || Id3Reader.getLyrics(getActivity(), lyrics.getArtist(), lyrics.getTitle()) == null ? View.GONE : View.VISIBLE); TextSwitcher textSwitcher = ((TextSwitcher) layout.findViewById(R.id.switcher)); LrcView lrcView = (LrcView) layout.findViewById(R.id.lrc_view); View v = getActivity().findViewById(R.id.tracks_msg); if (v != null) ((ViewGroup) v.getParent()).removeView(v); TextView artistTV = (TextView) getActivity().findViewById(R.id.artist); TextView songTV = (TextView) getActivity().findViewById(R.id.song); final TextView id3TV = (TextView) layout.findViewById(R.id.source_tv); TextView writerTV = (TextView) layout.findViewById(R.id.writer_tv); TextView copyrightTV = (TextView) layout.findViewById(R.id.copyright_tv); RelativeLayout bugLayout = (RelativeLayout) layout.findViewById(R.id.error_msg); this.mLyrics = lyrics; if (SDK_INT >= ICE_CREAM_SANDWICH) beamLyrics(lyrics, this.getActivity()); new PresenceChecker().execute(this, new String[] { lyrics.getArtist(), lyrics.getTitle(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack() }); if (lyrics.getArtist() != null) artistTV.setText(lyrics.getArtist()); else artistTV.setText(""); if (lyrics.getTitle() != null) songTV.setText(lyrics.getTitle()); else songTV.setText(""); if (lyrics.getCopyright() != null) { copyrightTV.setText("Copyright: " + lyrics.getCopyright()); copyrightTV.setVisibility(View.VISIBLE); } else { copyrightTV.setText(""); copyrightTV.setVisibility(View.GONE); } if (lyrics.getWriter() != null) { if (lyrics.getWriter().contains(",")) writerTV.setText("Writers:\n" + lyrics.getWriter()); else writerTV.setText("Writer:" + lyrics.getWriter()); writerTV.setVisibility(View.VISIBLE); } else { writerTV.setText(""); writerTV.setVisibility(View.GONE); } if (isActiveFragment) ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).show(); EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics); if (newLyrics != null) newLyrics.setText(""); if (lyrics.getFlag() == Lyrics.POSITIVE_RESULT) { if (!lyrics.isLRC()) { textSwitcher.setVisibility(View.VISIBLE); lrcView.setVisibility(View.GONE); if (animation) textSwitcher.setText(Html.fromHtml(lyrics.getText())); else textSwitcher.setCurrentText(Html.fromHtml(lyrics.getText())); } else { textSwitcher.setVisibility(View.GONE); lrcView.setVisibility(View.VISIBLE); lrcView.setOriginalLyrics(lyrics); lrcView.setSourceLrc(lyrics.getText()); if (isActiveFragment) ((ControllableAppBarLayout) getActivity().findViewById(R.id.appbar)).expandToolbar(true); updateLRC(); } bugLayout.setVisibility(View.INVISIBLE); id3TV.setMovementMethod(LinkMovementMethod.getInstance()); if ("Storage".equals(lyrics.getSource())) { id3TV.setVisibility(View.VISIBLE); SpannableString text = new SpannableString(getString(R.string.from_id3)); text.setSpan(new UnderlineSpan(), 1, text.length() - 1, 0); id3TV.setText(text); id3TV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).id3PopUp(id3TV); } }); } else { id3TV.setOnClickListener(null); id3TV.setVisibility(View.GONE); } mScrollView.post(new Runnable() { @Override public void run() { mScrollView.scrollTo(0, 0); //only useful when coming from localLyricsFragment mScrollView.smoothScrollTo(0, 0); } }); } else { textSwitcher.setText(""); textSwitcher.setVisibility(View.INVISIBLE); lrcView.setVisibility(View.INVISIBLE); bugLayout.setVisibility(View.VISIBLE); int message; int whyVisibility; if (lyrics.getFlag() == Lyrics.ERROR || !OnlineAccessVerifier.check(getActivity())) { message = R.string.connection_error; whyVisibility = TextView.GONE; } else { message = R.string.no_results; whyVisibility = TextView.VISIBLE; updateSearchView(false, lyrics.getTitle(), false); } TextView whyTextView = ((TextView) bugLayout.findViewById(R.id.bugtext_why)); ((TextView) bugLayout.findViewById(R.id.bugtext)).setText(message); whyTextView.setVisibility(whyVisibility); whyTextView.setPaintFlags(whyTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); id3TV.setVisibility(View.GONE); } stopRefreshAnimation(); getActivity().getIntent().setAction(""); getActivity().invalidateOptionsMenu(); }
From source file:com.android.mail.utils.NotificationUtils.java
/** * Gets the title for a notification for a single new conversation * @param context/*from w ww. ja v a 2 s. c o m*/ * @param sender Sender of the new message that triggered the notification. * @param subject Subject of the new message that triggered the notification * @return a {@link CharSequence} suitable for use as a {@link Notification} title. */ private static CharSequence getSingleMessageNotificationTitle(Context context, String sender, String subject) { if (TextUtils.isEmpty(subject)) { // If the subject is empty, just set the title to the sender's information. return sender; } else { final String notificationTitleFormat = context.getResources() .getString(R.string.single_new_message_notification_title); // Localizers may change the order of the parameters, look at how the format // string is structured. final boolean isSubjectLast = notificationTitleFormat.indexOf("%2$s") > notificationTitleFormat .indexOf("%1$s"); final String titleString = String.format(notificationTitleFormat, sender, subject); // Format the string so the subject is using the secondaryText style final SpannableString titleSpannable = new SpannableString(titleString); // Find the offset of the subject. final int subjectOffset = isSubjectLast ? titleString.lastIndexOf(subject) : titleString.indexOf(subject); final TextAppearanceSpan notificationSubjectSpan = new TextAppearanceSpan(context, R.style.NotificationSecondaryText); titleSpannable.setSpan(notificationSubjectSpan, subjectOffset, subjectOffset + subject.length(), 0); return titleSpannable; } }
From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_playlist_view, container, false); assert root != null; if (mPlaylist == null) { // If playlist couldn't load, abort early return root; }/* w w w .ja v a 2 s .c o m*/ mListViewContents = (PlaylistListView) root.findViewById(R.id.lvPlaylistContents); // Setup the parallaxed header View headerView = inflater.inflate(R.layout.header_listview_songs, mListViewContents, false); mListViewContents.addParallaxedHeaderView(headerView); mAdapter = new PlaylistAdapter(); mListViewContents.setAdapter(mAdapter); mListViewContents.setOnScrollListener(new ScrollStatusBarColorListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (view.getChildCount() == 0 || getActivity() == null) { return; } final float heroHeight = mIvHero.getMeasuredHeight(); final float scrollY = getScroll(view); final float toolbarBgAlpha = Math.min(1, scrollY / heroHeight); final int toolbarAlphaInteger = (((int) (toolbarBgAlpha * 255)) << 24) | 0xFFFFFF; mColorDrawable.setColor(toolbarAlphaInteger & getResources().getColor(R.color.primary)); SpannableString spannableTitle = new SpannableString( mPlaylist.getName() != null ? mPlaylist.getName() : ""); mAlphaSpan.setAlpha(toolbarBgAlpha); ActionBar actionbar = ((AppActivity) getActivity()).getSupportActionBar(); if (actionbar != null) { actionbar.setBackgroundDrawable(mColorDrawable); spannableTitle.setSpan(mAlphaSpan, 0, spannableTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionbar.setTitle(spannableTitle); if (Utils.hasLollipop()) { getActivity().getWindow().setStatusBarColor( toolbarAlphaInteger & getResources().getColor(R.color.primary_dark)); } } } }); headerView.findViewById(R.id.pbAlbumLoading).setVisibility(View.GONE); mIvHero = (ImageView) headerView.findViewById(R.id.ivHero); mTvPlaylistName = (TextView) headerView.findViewById(R.id.tvAlbumName); // Download button mOfflineBtn = (CircularProgressButton) headerView.findViewById(R.id.cpbOffline); mOfflineBtn.setAlpha(0.0f); mOfflineBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ProviderIdentifier pi = mPlaylist.getProvider(); IMusicProvider provider = PluginsLookup.getDefault().getProvider(pi).getBinder(); try { if (mPlaylist.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_NO) { provider.setPlaylistOfflineMode(mPlaylist.getRef(), true); mOfflineBtn.setIndeterminateProgressMode(true); mOfflineBtn.setProgress(1); if (ProviderAggregator.getDefault().isOfflineMode()) { Toast.makeText(getActivity(), R.string.toast_offline_playlist_sync, Toast.LENGTH_SHORT) .show(); } } else { provider.setPlaylistOfflineMode(mPlaylist.getRef(), false); mOfflineBtn.setProgress(0); } } catch (RemoteException e) { Log.e(TAG, "Cannot set this playlist to offline mode", e); mOfflineBtn.setProgress(-1); } } }); mHandler.sendEmptyMessageDelayed(UPDATE_OFFLINE_STATUS, 300); mTvPlaylistName.setText(mPlaylist.getName()); Bitmap hero = Utils.dequeueBitmap(PlaylistActivity.BITMAP_PLAYLIST_HERO); if (hero == null) { mIvHero.setImageResource(R.drawable.album_placeholder); } else { mIvHero.setImageBitmap(hero); // Request the higher resolution loadArt(); } mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay); // Set source logo mIvSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo); mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mPlaylist); mIvSource.setImageDrawable(mLogoBitmap); // Set the FAB animated drawable mFabDrawable = new PlayPauseDrawable(getResources(), 1); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mFabDrawable.setYOffset(6); mPlayFab.setImageDrawable(mFabDrawable); mPlayFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) { if (mFabShouldResume) { PlaybackProxy.play(); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabDrawable.setBuffering(true); } else { playNow(); } if (Utils.hasLollipop()) { showMaterialReelBar(mPlayFab); } } else { mFabShouldResume = true; PlaybackProxy.pause(); mFabDrawable.setBuffering(true); } } }); // Fill the playlist mAdapter.setPlaylist(mPlaylist); // Set the list listener mListViewContents.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Song song = mAdapter.getItem(i - 1); if (Utils.canPlaySong(song)) { PlaybackProxy.clearQueue(); PlaybackProxy.queuePlaylist(mPlaylist, false); PlaybackProxy.playAtIndex(i - 1); // Update FAB mFabShouldResume = true; mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabDrawable.setBuffering(true); if (Utils.hasLollipop()) { showMaterialReelBar(mPlayFab); } } } }); // Set the display animation AlphaAnimation anim = new AlphaAnimation(0.f, 1.f); anim.setDuration(200); mListViewContents.setLayoutAnimation(new LayoutAnimationController(anim)); setupMaterialReelBar(root, mReelFabClickListener); // Setup the opening animations for non-Lollipop devices if (!Utils.hasLollipop()) { mTvPlaylistName.setVisibility(View.VISIBLE); mTvPlaylistName.setAlpha(0.0f); mTvPlaylistName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start(); } mIvSource.setAlpha(0.0f); mIvSource.animate().alpha(1).setDuration(200).start(); return root; }
From source file:com.google.android.exoplayer2.demo.MediaPlayerFragment.java
private CharSequence generateFastForwardOrRewindTxt(long changingTime) { long duration = player == null ? 0 : player.getDuration(); String result = stringForTime(changingTime) + " / " + stringForTime(duration); int index = result.indexOf("/"); SpannableString spannableString = new SpannableString(result); TypedValue typedValue = new TypedValue(); TypedArray a = getContext().obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle();/*from w ww .ja v a2s .c om*/ spannableString.setSpan(new ForegroundColorSpan(color), 0, index, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); return spannableString; }
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
private Spannable getHighlightQueryResult(String fullText, String userQuery) { SpannableString spannable = new SpannableString(fullText == null ? "" : fullText); if (!TextUtils.isEmpty(userQuery)) { mPattern = Pattern.compile(userQuery); Matcher m = mPattern.matcher(fullText); int start = 0; while (m.find(start)) { spannable.setSpan( new BackgroundColorSpan(this.getResources().getColor(R.color.user_query_highlight)), m.start(), m.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); start = m.end();/*from w w w. j av a 2 s . c o m*/ } } return spannable; }
From source file:com.eleybourn.bookcatalogue.utils.Utils.java
/** * Linkify partial HTML. Linkify methods remove all spans before building links, this * method preserves them.//from www .jav a 2 s .c o m * * See: http://stackoverflow.com/questions/14538113/using-linkify-addlinks-combine-with-html-fromhtml * * @param html Partial HTML * @param linkifyMask Linkify mask to use in Linkify.addLinks * * @return Spannable with all links */ public static Spannable linkifyHtml(String html, int linkifyMask) { // Get the spannable HTML Spanned text = Html.fromHtml(html); // Save the span details for later restoration URLSpan[] currentSpans = text.getSpans(0, text.length(), URLSpan.class); // Build an empty spannable then add the links SpannableString buffer = new SpannableString(text); Linkify.addLinks(buffer, linkifyMask); // Add back the HTML spannables for (URLSpan span : currentSpans) { int end = text.getSpanEnd(span); int start = text.getSpanStart(span); buffer.setSpan(span, start, end, 0); } return buffer; }
From source file:com.heath_bar.tvdb.SeriesOverview.java
/** Populate the GUI with the episode information */ private void PopulateStuffPartTwo() { // Populate the next/last episodes TvEpisode last = episodeList.getLastAired(); TvEpisode next = episodeList.getNextAired(); SpannableString text = null; TextView richTextView = (TextView) findViewById(R.id.last_episode); if (last == null) { text = new SpannableString("Last Episode: unknown"); } else {/* w ww. ja va 2s . c om*/ text = new SpannableString( "Last Episode: " + last.getName() + " (" + DateUtil.toString(last.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + last.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(last.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); text = null; richTextView = (TextView) findViewById(R.id.next_episode); if (seriesInfo != null && seriesInfo.getStatus() != null && !seriesInfo.getStatus().equals("Ended")) { if (next == null) { text = new SpannableString("Next Episode: unknown"); } else { text = new SpannableString( "Next Episode: " + next.getName() + " (" + DateUtil.toString(next.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + next.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(next.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); } }
From source file:org.awesomeapp.messenger.ui.MessageListItem.java
private SpannableString formatTimeStamp(Date date, int messageType, MessageListItem.DeliveryState delivery, EncryptionState encryptionState, String nickname) { StringBuilder deliveryText = new StringBuilder(); if (nickname != null) { deliveryText.append(nickname);//ww w . ja v a 2 s . co m deliveryText.append(' '); } deliveryText.append(sPrettyTime.format(date)); SpannableString spanText = null; spanText = new SpannableString(deliveryText.toString()); if (delivery != null) { deliveryText.append(' '); //this is for delivery if (messageType == Imps.MessageType.POSTPONED) { //do nothing deliveryText.append("X"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_message_wait_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else if (delivery == DeliveryState.DELIVERED) { if (encryptionState == EncryptionState.ENCRYPTED || encryptionState == EncryptionState.ENCRYPTED_AND_VERIFIED) { deliveryText.append("XX"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_delivered_grey), len - 2, len - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_encrypted_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { deliveryText.append("X"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_delivered_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } else if (delivery == DeliveryState.UNDELIVERED) { if (encryptionState == EncryptionState.ENCRYPTED || encryptionState == EncryptionState.ENCRYPTED_AND_VERIFIED) { deliveryText.append("XX"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_sent_grey), len - 2, len - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_encrypted_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { deliveryText.append("XX"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_sent_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } else if (delivery == DeliveryState.NEUTRAL) { if (encryptionState == EncryptionState.ENCRYPTED || encryptionState == EncryptionState.ENCRYPTED_AND_VERIFIED) { deliveryText.append("XX"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_sent_grey), len - 2, len - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_encrypted_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { deliveryText.append("X"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_sent_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } else { if (encryptionState == EncryptionState.ENCRYPTED || encryptionState == EncryptionState.ENCRYPTED_AND_VERIFIED) { deliveryText.append('X'); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); if (encryptionState == EncryptionState.ENCRYPTED || encryptionState == EncryptionState.ENCRYPTED_AND_VERIFIED) spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_encrypted_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else if (messageType == Imps.MessageType.OUTGOING) { //do nothing deliveryText.append("X"); spanText = new SpannableString(deliveryText.toString()); int len = spanText.length(); spanText.setSpan(new ImageSpan(getContext(), R.drawable.ic_message_wait_grey), len - 1, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } return spanText; }
From source file:org.de.jmg.learn.SettingsActivity.java
public void init(boolean blnRestart) throws Exception { if (_Intent == null || _main == null || SettingsView == null || _blnInitialized) { return;/*from w ww . ja va2 s. co m*/ } try { //lib.ShowToast(_main, "Settings Start"); RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutSettings); // id fetch from xml ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class int pxPadding = lib.dpToPx(10); rectShapeDrawable.setPadding(pxPadding, pxPadding, pxPadding, pxPadding * ((lib.NookSimpleTouch()) ? 2 : 1)); Paint paint = rectShapeDrawable.getPaint(); paint.setColor(Color.BLACK); paint.setStyle(Style.STROKE); paint.setStrokeWidth(5); // you can change the value of 5 lib.setBg(layout, rectShapeDrawable); mainView = _main.findViewById(Window.ID_ANDROID_CONTENT); //Thread.setDefaultUncaughtExceptionHandler(ErrorHandler); prefs = _main.getPreferences(Context.MODE_PRIVATE); TextView txtSettings = (TextView) findViewById(R.id.txtSettings); SpannableString Settings = new SpannableString(txtSettings.getText()); Settings.setSpan(new UnderlineSpan(), 0, Settings.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); txtSettings.setText(Settings); initCheckBoxes(); initSpinners(blnRestart); initButtons(); initHelp(); edDataDir = (EditText) findViewById(R.id.edDataDir); edDataDir.setSingleLine(true); edDataDir.setText(_main.JMGDataDirectory); edDataDir.setImeOptions(EditorInfo.IME_ACTION_DONE); edDataDir.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { String strDataDir = edDataDir.getText().toString(); File fileSelected = new File(strDataDir); if (fileSelected.isDirectory() && fileSelected.exists()) { _main.setJMGDataDirectory(fileSelected.getPath()); edDataDir.setText(_main.JMGDataDirectory); Editor editor = prefs.edit(); editor.putString("JMGDataDirectory", fileSelected.getPath()); editor.commit(); } } return true; } }); edDataDir.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ShowDataDirDialog(); return true; } }); if (!(lib.NookSimpleTouch()) && !_main.isSmallDevice) { SettingsView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Ensure you call it only once : lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this); // Here you can get the size :) resize(0); //lib.ShowToast(_main, "Resize End"); } }); } else { //resize(1.8f); mScale = 1.0f; } _blnInitialized = true; } catch (Exception ex) { lib.ShowException(_main, ex); } }