List of usage examples for android.widget TextView getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w w w. j a v a 2 s.c o m private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL)); long currentTimeMillis = UIUtils.getCurrentTime(context); if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream && hasLivestream && currentTimeMillis > mSessionBlockStart && currentTimeMillis <= mSessionBlockEnd) { links.add(new Pair<Integer, Intent>(R.string.session_link_livestream, new Intent(Intent.ACTION_VIEW, mSessionUri).setClass(context, SessionLivestreamActivity.class))); } // Add session feedback link // links.add(new Pair<Integer, Intent>( // R.string.session_feedback_submitlink, // new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class) // )); for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null, mSubtitle, subtitle); EasyTracker.getTracker().sendView("Session: " + mTitleString); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.derrick.movies.MovieDetailsActivity.java
private void setTrailers(Videos videos) { videosList = videos.getResults();//w ww . j a v a 2 s.com int size = videosList.size(); if (size == 1) { txt_title_trailer.setText("Trailer"); } for (int i = 0; i < size; i++) { Result result = videosList.get(i); String url = IMAGE_YOUTUBE + result.getKey() + YOUTUBE_QUALITY; ImageView imageView; ImageView imageView_play; TextView txt_name; ViewGroup.LayoutParams lp = new RelativeLayout.LayoutParams(70, 70); ViewGroup.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); if (size == 1) { imageView = new ImageView(getApplicationContext()); imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { imageView = new ImageView(getApplicationContext()); imageView .setLayoutParams(new RelativeLayout.LayoutParams(500, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } imageView_play = new ImageView(getApplicationContext()); imageView_play.setLayoutParams(lp); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView_play .getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); imageView_play.setLayoutParams(layoutParams); imageView_play.setScaleType(ImageView.ScaleType.CENTER_CROP); Drawable drawable = getResources() .getDrawable(getResources().getIdentifier("play", "drawable", getPackageName())); imageView_play.setImageDrawable(drawable); txt_name = new TextView(getApplicationContext()); txt_name.setLayoutParams(lp2); RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) txt_name.getLayoutParams(); layoutParams2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams2.setMargins(8, 8, 8, 16); txt_name.setLayoutParams(layoutParams2); txt_name.setTypeface(robotoCondensed); txt_name.setText(result.getName()); txt_name.setTextColor(getResources().getColor(R.color.colorWhite)); Glide.with(getBaseContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { return false; } }).into(imageView); // trailerSlider.addView(imageView_play); relativeLayout.addView(imageView); relativeLayout.addView(imageView_play); relativeLayout.addView(txt_name); trailerSlider.addView(relativeLayout); } }
From source file:com.github.irshulx.Components.InputExtensions.java
public void UpdateTextStyle(EditorTextStyle style, TextView editText) { /// String type = getControlType(getActiveView()); try {/*from w ww. j av a2s. c om*/ if (editText == null) { editText = (EditText) editorCore.getActiveView(); } EditorControl tag = editorCore.getControlTag(editText); int pBottom = editText.getPaddingBottom(); int pRight = editText.getPaddingRight(); int pTop = editText.getPaddingTop(); if (isEditorTextStyleHeaders(style)) { updateTextStyle(editText, style); return; } if (isEditorTextStyleContentStyles(style)) { boolean containsHeadertextStyle = containsHeaderTextStyle(tag); if (style == EditorTextStyle.BOLD) { boldifyText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT); } else if (style == EditorTextStyle.ITALIC) { italicizeText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT); } return; } if (style == EditorTextStyle.INDENT) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setTag(tag); } else { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Insert); editText.setPadding(30, pTop, pRight, pBottom); editText.setTag(tag); } } else if (style == EditorTextStyle.OUTDENT) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setTag(tag); } } else if (style == EditorTextStyle.BLOCKQUOTE) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editText.getLayoutParams(); if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BLOCKQUOTE)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setBackgroundDrawable(ContextCompat.getDrawable(this.editorCore.getContext(), R.drawable.invisible_edit_text)); params.setMargins(0, 0, 0, (int) editorCore.getContext().getResources() .getDimension(R.dimen.edittext_margin_bottom)); } else { float marginExtra = editorCore.getContext().getResources() .getDimension(R.dimen.edittext_margin_bottom) * 1.5f; tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Insert); editText.setPadding(30, pTop, 30, pBottom); editText.setBackgroundDrawable( editText.getContext().getResources().getDrawable(R.drawable.block_quote_background)); params.setMargins(0, (int) marginExtra, 0, (int) marginExtra); } editText.setTag(tag); } } catch (Exception e) { } }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void buildLinksSection(Cursor cursor) { // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) findViewById(R.id.links_container); linkContainer.removeAllViews();/* www . j a v a2s. c om*/ // Build links section // the Object can be either a string URL or an Intent List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>(); long currentTimeMillis = UIUtils.getCurrentTime(this); if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) { links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(this))); } // Add session feedback link, if appropriate if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) { links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent())); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(this); int columns = getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Object> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); if (link.first == R.string.session_feedback_submitlink) { mSubmitFeedbackView = linkView; } linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); Intent intent = null; if (link.second instanceof Intent) { intent = (Intent) link.second; } else if (link.second instanceof String) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { findViewById(R.id.session_links_header).setVisibility(View.GONE); findViewById(R.id.links_container).setVisibility(View.GONE); } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void buildLinksSection(Cursor cursor) { final Context context = mRootView.getContext(); // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews();/*from w ww. ja v a 2 s. c om*/ // Build links section // the Object can be either a string URL or an Intent List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>(); long currentTimeMillis = UIUtils.getCurrentTime(context); if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) { links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(context))); } // Add session feedback link, if appropriate if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) { links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent())); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Object> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); if (link.first == R.string.session_feedback_submitlink) { mSubmitFeedbackView = linkView; } linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); Intent intent = null; if (link.second instanceof Intent) { intent = (Intent) link.second; } else if (link.second instanceof String) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } }
From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java
private void buildLinksSection(Cursor cursor) { // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) findViewById(com.saarang.samples.apps.iosched.R.id.links_container); linkContainer.removeAllViews();// w ww.ja va 2 s . co m // Build links section // the Object can be either a string URL or an Intent List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>(); long currentTimeMillis = UIUtils.getCurrentTime(this); if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) { links.add(new Pair<Integer, Object>(com.saarang.samples.apps.iosched.R.string.session_link_livestream, getWatchLiveIntent(this))); } // Add session feedback link, if appropriate if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) { links.add(new Pair<Integer, Object>( com.saarang.samples.apps.iosched.R.string.session_feedback_submitlink, getFeedbackIntent())); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(this); int columns = getResources().getInteger(com.saarang.samples.apps.iosched.R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Object> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate( com.saarang.samples.apps.iosched.R.layout.list_item_session_link, linkContainer, false); if (link.first == com.saarang.samples.apps.iosched.R.string.session_feedback_submitlink) { mSubmitFeedbackView = linkView; } linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); Intent intent = null; if (link.second instanceof Intent) { intent = (Intent) link.second; } else if (link.second instanceof String) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate( com.saarang.samples.apps.iosched.R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } findViewById(com.saarang.samples.apps.iosched.R.id.session_links_header).setVisibility(View.VISIBLE); findViewById(com.saarang.samples.apps.iosched.R.id.links_container).setVisibility(View.VISIBLE); } else { findViewById(com.saarang.samples.apps.iosched.R.id.session_links_header).setVisibility(View.GONE); findViewById(com.saarang.samples.apps.iosched.R.id.links_container).setVisibility(View.GONE); } }
From source file:org.onebusaway.android.ui.ArrivalsListAdapterStyleB.java
@Override protected void initView(final View view, CombinedArrivalInfoStyleB combinedArrivalInfoStyleB) { final ArrivalInfo stopInfo = combinedArrivalInfoStyleB.getArrivalInfoList().get(0); final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); final Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); TextView routeName = (TextView) view.findViewById(R.id.routeName); TextView destination = (TextView) view.findViewById(R.id.routeDestination); // TableLayout that we will fill with TableRows of arrival times TableLayout arrivalTimesLayout = (TableLayout) view.findViewById(R.id.arrivalTimeLayout); arrivalTimesLayout.removeAllViews(); Resources r = view.getResources(); ImageButton starBtn = (ImageButton) view.findViewById(R.id.route_star); starBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton mapImageBtn = (ImageButton) view.findViewById(R.id.mapImageBtn); mapImageBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton routeMoreInfo = (ImageButton) view.findViewById(R.id.route_more_info); routeMoreInfo.setColorFilter(r.getColor(R.color.switch_thumb_normal_material_dark)); starBtn.setImageResource(/* w ww . j a va 2 s . c om*/ stopInfo.isRouteAndHeadsignFavorite() ? R.drawable.focus_star_on : R.drawable.focus_star_off); starBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Show dialog for setting route favorite RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment.Builder( stopInfo.getInfo().getRouteId(), stopInfo.getInfo().getHeadsign()) .setRouteShortName(stopInfo.getInfo().getShortName()) .setRouteLongName(stopInfo.getInfo().getRouteLongName()) .setStopId(stopInfo.getInfo().getStopId()) .setFavorite(!stopInfo.isRouteAndHeadsignFavorite()).build(); dialog.setCallback(new RouteFavoriteDialogFragment.Callback() { @Override public void onSelectionComplete(boolean savedFavorite) { if (savedFavorite) { mFragment.refreshLocal(); } } }); dialog.show(mFragment.getFragmentManager(), RouteFavoriteDialogFragment.TAG); } }); // Setup map mapImageBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showRouteOnMap(stopInfo); } }); // Setup more routeMoreInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(view, stopInfo); } }); routeName.setText(arrivalInfo.getShortName()); destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign())); // Loop through the arrival times and create the TableRows that contains the data for (int i = 0; i < combinedArrivalInfoStyleB.getArrivalInfoList().size(); i++) { final ArrivalInfo arrivalRow = combinedArrivalInfoStyleB.getArrivalInfoList().get(i); final ObaArrivalInfo tempArrivalInfo = arrivalRow.getInfo(); long scheduledTime = tempArrivalInfo.getScheduledArrivalTime(); // Create a new row to be added final TableRow tr = (TableRow) inflater.inflate(R.layout.arrivals_list_tr_template_style_b, null); // Layout and views to inflate from XML templates RelativeLayout layout; TextView scheduleView, estimatedView, statusView; View divider; if (i == 0) { // Use larger styled layout/view for next arrival time layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_large, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_large, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_large, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large, null); } else { // Use smaller styled layout/view for further out times layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_small, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_small, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_small, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_small, null); } // Set arrival times and status in views scheduleView.setText(DateUtils.formatDateTime(context, scheduledTime, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); if (arrivalRow.getPredicted()) { long eta = arrivalRow.getEta(); if (eta == 0) { estimatedView.setText(R.string.stop_info_eta_now); } else { estimatedView.setText(eta + " min"); } } else { estimatedView.setText(R.string.stop_info_eta_unknown); } statusView.setText(arrivalRow.getStatusText()); int colorCode = arrivalRow.getColor(); statusView.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) statusView.getBackground(); d.setColor(context.getResources().getColor(colorCode)); int alpha; if (i == 0) { // Set next arrival alpha = (int) (1.0f * 255); // X percent transparency } else { // Set smaller rows alpha = (int) (.35f * 255); // X percent transparency } d.setAlpha(alpha); // Set padding on status view int pSides = UIUtils.dpToPixels(context, 5); int pTopBottom = UIUtils.dpToPixels(context, 2); statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom); // Add TextViews to layout layout.addView(scheduleView); layout.addView(statusView); layout.addView(estimatedView); // Make sure the TextViews align left/center/right of parent relative layout RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) scheduleView.getLayoutParams(); params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params1.addRule(RelativeLayout.CENTER_VERTICAL); scheduleView.setLayoutParams(params1); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) statusView.getLayoutParams(); params2.addRule(RelativeLayout.CENTER_IN_PARENT); // Give status view a little extra margin int p = UIUtils.dpToPixels(context, 3); params2.setMargins(p, p, p, p); statusView.setLayoutParams(params2); RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) estimatedView.getLayoutParams(); params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params3.addRule(RelativeLayout.CENTER_VERTICAL); estimatedView.setLayoutParams(params3); // Add layout to TableRow tr.addView(layout); // Add the divider, if its not the first row if (i != 0) { int dividerHeight = UIUtils.dpToPixels(context, 1); divider = inflater.inflate(R.layout.arrivals_list_divider_template_style_b, null); divider.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, dividerHeight)); arrivalTimesLayout.addView(divider); } // Add click listener tr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(tr, arrivalRow); } }); // Add TableRow to container layout arrivalTimesLayout.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); } // Show or hide reminder for this trip ContentValues values = null; if (mTripsForStop != null) { values = mTripsForStop.getValues(arrivalInfo.getTripId()); } if (values != null) { String reminderName = values.getAsString(ObaContract.Trips.NAME); TextView reminder = (TextView) view.findViewById(R.id.reminder); if (reminderName.length() == 0) { reminderName = context.getString(R.string.trip_info_noname); } reminder.setText(reminderName); Drawable d = reminder.getCompoundDrawables()[0]; d = DrawableCompat.wrap(d); DrawableCompat.setTint(d.mutate(), view.getResources().getColor(R.color.theme_primary)); reminder.setCompoundDrawables(d, null, null, null); reminder.setVisibility(View.VISIBLE); } else { // Explicitly set reminder to invisible because we might be reusing // this view. View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
private void applyFilter() { if (mAppAdapter != null) { ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter); TextView tvStats = (TextView) findViewById(R.id.tvStats); TextView tvState = (TextView) findViewById(R.id.tvState); // Get settings int userId = Util.getUserId(Process.myUid()); boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false); boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false); boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);//from w w w .ja va 2s.co m boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false); boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true); boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false); boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false); boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true); boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false); String filter = String.format("%s\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b", searchQuery, fUsed, fInternet, fRestriction, fRestrictionNot, fPermission, fOnDemand, fOnDemandNot, fUser, fSystem); pbFilter.setVisibility(ProgressBar.VISIBLE); tvStats.setVisibility(TextView.GONE); // Adjust progress state width RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams(); tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.pbFilter); mAppAdapter.getFilter().filter(filter); } }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);//from w ww . j a v a 2s .c o m setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }
From source file:ir.irani.telecam.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);//from ww w. j av a 2 s .c o m setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.passcode_logo); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText2 = new AnimatingTextView(context); passwordFrameLayout.addView(passwordEditText2); layoutParams = (FrameLayout.LayoutParams) passwordEditText2.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText2.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: passwordEditText2.appendCharacter("0"); break; case 1: passwordEditText2.appendCharacter("1"); break; case 2: passwordEditText2.appendCharacter("2"); break; case 3: passwordEditText2.appendCharacter("3"); break; case 4: passwordEditText2.appendCharacter("4"); break; case 5: passwordEditText2.appendCharacter("5"); break; case 6: passwordEditText2.appendCharacter("6"); break; case 7: passwordEditText2.appendCharacter("7"); break; case 8: passwordEditText2.appendCharacter("8"); break; case 9: passwordEditText2.appendCharacter("9"); break; case 10: passwordEditText2.eraseLastCharacter(); break; } if (passwordEditText2.lenght() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }