List of usage examples for android.widget TextView setOnTouchListener
public void setOnTouchListener(OnTouchListener l)
From source file:org.anhonesteffort.flock.EditAutoRenewActivity.java
private void handleDisableForm() { Log.d(TAG, "handleDisableForm()"); Button verifyAndSaveButton = (Button) findViewById(R.id.button_verify_and_save); EditText cardExpirationView = (EditText) findViewById(R.id.card_expiration); EditText cardNumberView = (EditText) findViewById(R.id.card_number); TextView cardCVCView = (TextView) findViewById(R.id.card_cvc); cardNumberView.setFocusable(false);/*from w w w .j av a 2 s . c o m*/ cardNumberView.setFocusableInTouchMode(false); cardExpirationView.setFocusable(false); cardExpirationView.setFocusableInTouchMode(false); cardCVCView.setFocusable(false); cardCVCView.setFocusableInTouchMode(false); cardNumberView.setText(""); cardExpirationView.setText(""); cardCVCView.setText(""); cardNumberView.setOnTouchListener(null); cardExpirationView.setOnTouchListener(null); cardCVCView.setOnTouchListener(null); verifyAndSaveButton.setText(R.string.button_save); verifyAndSaveButton.setOnClickListener(null); }
From source file:org.anhonesteffort.flock.EditAutoRenewActivity.java
private void handleInitFormForViewingSuccess() { Log.d(TAG, "handleInitFormForViewingSuccess()"); Button verifyAndSaveButton = (Button) findViewById(R.id.button_verify_and_save); EditText cardNumberView = (EditText) findViewById(R.id.card_number); EditText cardExpirationView = (EditText) findViewById(R.id.card_expiration); TextView cardCVCView = (TextView) findViewById(R.id.card_cvc); handleEnableForm();/*w ww . j a v a2 s .c om*/ cardNumberView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) handleInitFormForEditing(); return false; } }); cardExpirationView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) handleInitFormForEditing(); return false; } }); cardCVCView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) handleInitFormForEditing(); return false; } }); if (StringUtils.isEmpty(cardNumberView.getText().toString())) cardNumberView.setText("**** **** **** " + cardInformation.get().getCardLastFour()); if (StringUtils.isEmpty(cardExpirationView.getText().toString())) cardExpirationView.setText(cardInformation.get().getCardExpiration()); cardCVCView.setText(""); verifyAndSaveButton.setText(R.string.button_save); verifyAndSaveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSaveAutoRenewAndFinish(true); } }); }
From source file:dcheungaa.procal.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mainActivities.add(this); try {/*from www . j a v a 2 s.com*/ fx50Parser = new Fx50ParserCallable(); } catch (Exception e) { System.out.println("Fx50 Parser failed to initiate: " + e.getMessage()); } this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context = this; InputHandler.setContext(this); views.put("drawer", (DrawerLayout) findViewById(R.id.drawer_layout)); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, ((DrawerLayout) views.get("drawer")), R.string.navigation_drawer_open, R.string.navigation_drawer_close); ((DrawerLayout) views.get("drawer")).setDrawerListener(toggle); toggle.syncState(); // //DrawerLayout.LayoutParams lp =(android.support.v4.widget.DrawerLayout.LayoutParams) drawer.getLayoutParams(); //lp.setMargins(0,200,0,200); //drawer.setLayoutParams(lp); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); views.put("resultDisplay", findViewById(R.id.resultDisplay)); //Set font TextView inquiryDisplay = (TextView) findViewById(R.id.inquiryDisplay); TextView matrixDisplay = (TextView) findViewById(R.id.matrixDisplay); views.put("matrixDisplay", matrixDisplay); views.put("inquiryDisplay", inquiryDisplay); final Typeface FONT_FX50 = Typeface.createFromAsset(getAssets(), "fonts/Fx50.otf"); matrixDisplay.setTypeface(FONT_FX50); TextView cursor = (TextView) findViewById(R.id.tv_cursor); views.put("cursor", (TextView) findViewById(R.id.tv_cursor)); cursor.setTypeface(FONT_FX50); //keypad gen final InputStream inSKey = getResources().openRawResource(R.raw.keypad); Display display = getWindowManager().getDefaultDisplay(); RelativeLayout cm = (RelativeLayout) findViewById(R.id.content_main); LinearLayout lls = (LinearLayout) findViewById(R.id.llScreen); llKeyPad = (LinearLayout) findViewById(R.id.llKeyPad); Resources resources = getResources(); keyPad = new KeyPad_init(this, resources, inSKey, display, cm, lls, llKeyPad); call_load = true; horizontalScrollView = (HorizontalScrollView) findViewById(R.id.llHoriScrollView); matrixDisplay.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { System.out.print("Pressed Boss\n"); if (event.getAction() == MotionEvent.ACTION_UP) { if (!CursorHandler.cursorVisible && DisplayModeHandler.displayMode) { CursorHandler.cursorVisible = true; CursorHandler.blinkCursor(); DisplayModeHandler.displayMode = false; InputHandler.updateMatrixDisplay(); } if (!InputHandler.error) CursorHandler.locateCursorPos((int) event.getX()); InputHandler.error = false; } return true; } }); CursorHandler.blinkCursor(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { System.out.println("Requesting writing permission"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1234); } } if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { System.out.println("Requesting reading permission"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 1235); } } Point size = new Point(); display.getSize(size); screenWidth = size.x; screenHeight = size.y; //hide VAR keypad svVar = (ScrollView) findViewById(R.id.svVar); svVar.setVisibility(View.INVISIBLE); svVar.setPadding(0, 0, 0, 0); svVar.setBackgroundResource(R.drawable.popup_container); svVar.setElevation(16f); LinearLayout llVar = (LinearLayout) findViewById(R.id.llVarPad); llVar.setElevation(32f); llVar.setBackgroundColor(context.getResources().getColor(R.color.colorPrimaryDarker)); varPad = new KeyPad_init(this, resources, display, llVar); final InputStream inSCmd = getResources().openRawResource(R.raw.programming_keys); svCmd = (ScrollView) findViewById(R.id.svCmd); svCmd.setVisibility(View.INVISIBLE); svCmd.setPadding(0, 0, 0, 0); svCmd.setBackgroundResource(R.drawable.popup_container); svCmd.setElevation(16f); LinearLayout llCmd = (LinearLayout) findViewById(R.id.llCmdPad); llCmd.setElevation(32f); llCmd.setBackgroundColor(context.getResources().getColor(R.color.colorAccentDarker)); cmdPad = new KeyPad_init(this, resources, inSCmd, display, llCmd, "", "COMMAND"); final InputStream inSConst = getResources().openRawResource(R.raw.constant_keypad); svConst = (ScrollView) findViewById(R.id.svConst); svConst.setVisibility(View.INVISIBLE); svConst.setPadding(0, 0, 0, 0); svConst.setBackgroundResource(R.drawable.popup_container); svConst.setElevation(16f); LinearLayout llConst = (LinearLayout) findViewById(R.id.llConstPad); llConst.setElevation(32f); llConst.setBackgroundColor(context.getResources().getColor(R.color.colorSecondaryDarker)); constPad = new KeyPad_init(this, resources, inSConst, display, llConst, "&", "CONSTANT"); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
From source file:com.cssweb.android.base.QuoteGridActivity.java
private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);//from www .j a v a 2s . c o m //??4? if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) { if (this.mPaint.measureText(paramString) > textWeight) localTextView.setTextSize(13); } if (n2 == paramInt2) { String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString; localTextView.setText(str); } else { localTextView.setText(paramString); } localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); //touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(false); if (paramInt4 == 0 && paramInt3 >= 0) {// localTextView.setGravity(Gravity.CENTER); int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; //localTextView.setWidth(i8+20); } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; //localTextView.setWidth(i8+20); } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } // if ((paramInt3 == j) && (paramInt4 == l)) { // int i13 = this.residTitleScrollCol[l]; // localDrawable = localResources.getDrawable(i13); // localTextView.setTextColor(paramInt1); // localTextView.setBackgroundDrawable(localDrawable); // paramLinearLayout.addView(localTextView); // return; // } }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow();/*from w ww . j a va 2s .c o m*/ window.setWindowAnimations(R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; containerView.setBackgroundDrawable(shadowDrawable); containerView.setPadding(backgroundPaddingLeft, (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft, (applyBottomPadding ? AndroidUtilities.dp(8) : 0)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); container.addView(containerView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM)); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } else { int topOffset = 0; if (title != null) { TextView titleView = new TextView(getContext()); titleView.setLines(1); titleView.setSingleLine(true); titleView.setText(title); titleView.setTextColor(0xff757575); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8)); titleView.setGravity(Gravity.CENTER_VERTICAL); containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); titleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 48; } if (items != null) { FrameLayout rowLayout = null; int lastRowLayoutNum = 0; for (int a = 0; a < items.length; a++) { BottomSheetCell cell = new BottomSheetCell(getContext(), 0); cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0); containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0)); topOffset += 48; cell.setTag(a); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissWithButtonClick((Integer) v.getTag()); } }); itemViews.add(cell); } } } WindowManager.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.TOP | Gravity.LEFT; params.dimAmount = 0; params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params); }
From source file:kr.wdream.ui.ActionBar.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow();// ww w . j a v a 2s . c o m window.setWindowAnimations(kr.wdream.storyshop.R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; containerView.setBackgroundDrawable(shadowDrawable); containerView.setPadding(backgroundPaddingLeft, (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft, (applyBottomPadding ? AndroidUtilities.dp(8) : 0)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); container.addView(containerView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM)); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } else { int topOffset = 0; if (title != null) { TextView titleView = new TextView(getContext()); titleView.setLines(1); titleView.setSingleLine(true); titleView.setText(title); titleView.setTextColor(0xff757575); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8)); titleView.setGravity(Gravity.CENTER_VERTICAL); containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); titleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 48; } if (items != null) { FrameLayout rowLayout = null; int lastRowLayoutNum = 0; for (int a = 0; a < items.length; a++) { BottomSheetCell cell = new BottomSheetCell(getContext(), 0); cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0); containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0)); topOffset += 48; cell.setTag(a); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissWithButtonClick((Integer) v.getTag()); } }); itemViews.add(cell); } } } WindowManager.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.TOP | Gravity.LEFT; params.dimAmount = 0; params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params); }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow();//from w w w . j av a 2 s .c om window.setWindowAnimations(R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; containerView.setBackgroundDrawable(shadowDrawable); containerView.setPadding(backgroundPaddingLeft, (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft, (applyBottomPadding ? AndroidUtilities.dp(8) : 0)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); container.addView(containerView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM)); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } else { int topOffset = 0; if (title != null) { TextView titleView = new TextView(getContext()); titleView.setTypeface(FontManager.instance().getTypeface()); titleView.setLines(1); titleView.setSingleLine(true); titleView.setText(title); titleView.setTextColor(0xff757575); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8)); titleView.setGravity(Gravity.CENTER_VERTICAL); containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); titleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 48; } if (items != null) { FrameLayout rowLayout = null; int lastRowLayoutNum = 0; for (int a = 0; a < items.length; a++) { BottomSheetCell cell = new BottomSheetCell(getContext(), 0); cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0); containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0)); topOffset += 48; cell.setTag(a); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissWithButtonClick((Integer) v.getTag()); } }); itemViews.add(cell); } } } WindowManager.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.TOP | Gravity.LEFT; params.dimAmount = 0; params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params); }
From source file:org.anhonesteffort.flock.EditAutoRenewActivity.java
private void handleInitFormAsAutoRenewDisabled() { Log.d(TAG, "handleInitFormFormAsAutoRenewDisabled()"); Button verifyAndSaveButton = (Button) findViewById(R.id.button_verify_and_save); EditText cardExpirationView = (EditText) findViewById(R.id.card_expiration); EditText cardNumberView = (EditText) findViewById(R.id.card_number); TextView cardCVCView = (TextView) findViewById(R.id.card_cvc); cardNumberView.setFocusable(false);/*from w w w . j a va 2 s. co m*/ cardNumberView.setFocusableInTouchMode(false); cardExpirationView.setFocusable(false); cardExpirationView.setFocusableInTouchMode(false); cardCVCView.setFocusable(false); cardCVCView.setFocusableInTouchMode(false); cardNumberView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) ((CheckBox) findViewById(R.id.checkbox_enable_auto_renew)).setChecked(true); return false; } }); cardExpirationView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) ((CheckBox) findViewById(R.id.checkbox_enable_auto_renew)).setChecked(true); return false; } }); cardCVCView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) ((CheckBox) findViewById(R.id.checkbox_enable_auto_renew)).setChecked(true); return false; } }); cardNumberView.setText(""); cardExpirationView.setText(""); cardCVCView.setText(""); verifyAndSaveButton.setText(R.string.button_save); verifyAndSaveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSaveAutoRenewAndFinish(false); } }); }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (backgroundColor == 0) { backgroundColor = darkTheme ? 0xFF424242 : 0xFFFFFFFF; }/*from w w w.ja v a 2 s. c om*/ if (titleTextColor == 0) { titleTextColor = darkTheme ? 0xB3FFFFFF : 0x8A000000; } if (itemTextColor == 0) { itemTextColor = darkTheme ? 0xFFFFFFFF : 0xDE000000; } if (iconColor == 0) { iconColor = darkTheme ? 0xFFFFFFFF : 0x8A000000; } if (itemSelector == 0) { itemSelector = darkTheme ? R.drawable.selectable_dark : R.drawable.selectable_light; } Window window = getWindow(); window.setWindowAnimations(R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; if (Build.VERSION.SDK_INT >= 16) { containerView.setBackground(shadowDrawable); } else { containerView.setBackgroundDrawable(shadowDrawable); } containerView.setPadding(0, backgroundPaddingTop, 0, Utils.dp(getContext(), 8)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); containerView.setBackgroundColor(backgroundColor); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; containerView.setLayoutParams(params); container.addView(containerView, 0); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) containerView.getLayoutParams(); params1.width = ViewGroup.LayoutParams.MATCH_PARENT; params1.height = ViewGroup.LayoutParams.WRAP_CONTENT; params1.gravity = Gravity.START | Gravity.TOP; containerView.addView(customView, params1); } else { int topOffset = 0; if (titleText != null) { TextView titleTextView = new TextView(getContext()); titleTextView.setLines(1); titleTextView.setMaxLines(1); titleTextView.setSingleLine(true); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setGravity(Gravity.CENTER_VERTICAL); FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, Utils.dp(getContext(), 56)); params0.gravity = Gravity.START | Gravity.TOP; params0.leftMargin = Utils.dp(getContext(), 16); params0.rightMargin = Utils.dp(getContext(), 16); titleTextView.setLayoutParams(params0); containerView.addView(titleTextView); titleTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 56; } BottomSheetAdapter adapter = new BottomSheetAdapter(); if (mItems != null || mItemsRes != null) { if (contentType == LIST) { FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params2.topMargin = Utils.dp(getContext(), topOffset); ListView listView = new ListView(getContext()); listView.setSelector(itemSelector); listView.setDividerHeight(0); listView.setAdapter(adapter); listView.setDrawSelectorOnTop(true); listView.setVerticalScrollBarEnabled(false); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); listView.setLayoutParams(params2); containerView.addView(listView); } else if (contentType == GRID) { FrameLayout.LayoutParams params3 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); GridView gridView = new GridView(getContext()); gridView.setSelector(itemSelector); gridView.setAdapter(adapter); gridView.setNumColumns(3); gridView.setVerticalScrollBarEnabled(false); gridView.setVerticalSpacing(Utils.dp(getContext(), 16)); gridView.setPadding(Utils.dp(getContext(), 0), Utils.dp(getContext(), topOffset + 8), Utils.dp(getContext(), 0), Utils.dp(getContext(), 16)); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); gridView.setLayoutParams(params3); containerView.addView(gridView); } if (mItems != null) { for (int a = 0; a < mItems.length; a++) { items.add(new Item(mItems[a], mIcons != null ? mIcons[a] : 0)); } } else { for (int a = 0; a < mItemsRes.length; a++) { items.add(new Item(getContext().getText(mItemsRes[a]), mIcons != null ? mIcons[a] : 0)); } } adapter.notifyDataSetChanged(); } } WindowManager.LayoutParams params4 = window.getAttributes(); params4.width = ViewGroup.LayoutParams.MATCH_PARENT; params4.gravity = Gravity.TOP | Gravity.START; params4.dimAmount = 0; params4.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params4.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params4.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params4); }
From source file:com.android.leanlauncher.Workspace.java
private void addAllAppsIcon() { // Add the Apps button LayoutInflater inflater = LayoutInflater.from(getContext()); TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mWorkspace, false); Drawable d = getResources().getDrawable(R.drawable.all_apps_button_icon); Utilities.resizeIconDrawable(d); allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(getResources().getString(R.string.all_apps_button_label)); mLauncher.setAllAppsButton(allAppsButton); allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); allAppsButton.setOnClickListener(mLauncher); CellLayout.LayoutParams lp = new CellLayout.LayoutParams((mWorkspace.getCountX() - 1) / 2, mWorkspace.getCountY() - 1, 1, 1); lp.canReorder = false;//w ww.j a va 2s.c o m mWorkspace.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true); }