List of usage examples for android.view KeyEvent getAction
public final int getAction()
From source file:pt.hive.cameo.activities.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // saves a reference to the current instance under the self variable // so that it may be used by any clojure method final LoginActivity self = this; // tries to retrieve the extras set of parameters from the intent // and in case they exist, tries to retrieve the login path (parameter) Bundle extras = this.getIntent().getExtras(); if (extras != null) { this.loginPath = extras.getString("LOGIN_PATH"); this.logoId = extras.getInt("LOGO_ID"); }/*from w w w. ja va2s .c om*/ // removes the title bar from the window (improves readability) // and then sets the login layout on it (starts the layout) this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.setContentView(R.layout.login); // in case we've received a valid logo identifier the logo image must be // updated with the associated resource (customized view) if (this.logoId != 0) { Drawable logoResource = this.getResources().getDrawable(this.logoId); ImageView logo = (ImageView) this.findViewById(R.id.logo); logo.setImageDrawable(logoResource); } // retrieves the password edit text field and updates it to the // sans serif typeface and then updates the transformation method EditText password = (EditText) this.findViewById(R.id.password); password.setTypeface(Typeface.SANS_SERIF); password.setTransformationMethod(new PasswordTransformationMethod()); password.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { self.login(); } return false; } }); // retrieves the reference to the various button in the current activity // and registers the current instance as the click listener Button signIn = (Button) findViewById(R.id.sign_in); signIn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { self.login(); } }); }
From source file:com.mstar.tv.tvplayer.philips.option.OptionThirdFragment.java
public void updateView(String data, int dataPositon) { vseekbar_title.setText(data);/*from ww w. j a v a 2 s. co m*/ switch (dataPositon) { case 0: currentIndex = K_TvPictureManager.getInstance().K_getPCHPos(); Log.v(TAG, "=========hpos===currentIndex=" + currentIndex); break; case 1: currentIndex = K_TvPictureManager.getInstance().K_getPCVPos(); Log.v(TAG, "=========vpos===currentIndex=" + currentIndex); break; case 2: currentIndex = K_TvPictureManager.getInstance().K_getPCClock(); Log.v(TAG, "=========clock===currentIndex=" + currentIndex); break; case 3: currentIndex = K_TvPictureManager.getInstance().K_getPCPhase(); Log.v(TAG, "=========phase===currentIndex=" + currentIndex); break; default: break; } seekBar.setProgress(currentIndex); progressVal.setText(String.valueOf(seekBar.getProgress())); up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted); down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted); final int flag = dataPositon; seekBar.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View arg0, int keyCode, KeyEvent keyevent) { if (keyevent.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: seekBar.incrementProgressBy(1); progressVal.setText(String.valueOf(seekBar.getProgress())); up_img.setBackgroundResource(R.drawable.slider_arrow_up_pressed); down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted); updateSeekbarData(flag, seekBar); return true; case KeyEvent.KEYCODE_DPAD_DOWN: seekBar.incrementProgressBy(-1); progressVal.setText(String.valueOf(seekBar.getProgress())); up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted); down_img.setBackgroundResource(R.drawable.slider_arrow_down_pressed); updateSeekbarData(flag, seekBar); return true; case KeyEvent.KEYCODE_DPAD_LEFT: getActivity().onKeyDown(keyCode, keyevent); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: return true; default: break; } } return false; } }); }
From source file:com.irccloud.android.ActionEditText.java
@Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (mDrawerLayout != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { mDrawerLayout.closeDrawers();// ww w.ja v a2 s . co m } return super.onKeyPreIme(keyCode, event); }
From source file:org.yaawp.hmi.activities.CustomActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i(TAG, "onKeyDown( KeyCode=" + keyCode + " KeyEvent=" + event.getAction()); boolean status = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == lastKeyCode && event.getDownTime() - lastPressedTime < Const.DOUBLE_PRESS_HK_BACK_PERIOD) { status = onKeyTwiceDown(event.getKeyCode(), event); } else {//from w w w . j ava 2 s. com lastPressedTime = event.getDownTime(); lastKeyCode = event.getKeyCode(); status = onKeyOnceDown(keyCode, event); } } else { status = super.onKeyDown(keyCode, event); } return status; }
From source file:com.farmerbb.taskbar.activity.DashboardActivity.java
@Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { event.getKeyCode();//from w w w . j av a 2s .c om return true; } return super.dispatchKeyShortcutEvent(event); }
From source file:com.mobshep.mobileshepherd.UDataLeakage.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.udl_layout); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w ww . java 2 s . c om*/ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); String destinationDir = "/data/data/" + getPackageName() + "/files/"; String destinationPath = destinationDir + "Tue Jul 08 172618 EDT 2014"; File f = new File(destinationPath); if (!f.exists()) { File directory = new File(destinationDir); directory.mkdirs(); //assets members.db -> /databases/ try { copyKey(getBaseContext().getAssets().open("Tue Jul 08 172618 EDT 2014"), new FileOutputStream(destinationPath)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } ListView noteList = (ListView) findViewById(R.id.noteList); final EditText miniNote = (EditText) findViewById(R.id.miniNote); final ArrayList<String> noteItems = new ArrayList<String>(); final ArrayAdapter<String> arrayAdapter; arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, noteItems); noteList.setAdapter(arrayAdapter); miniNote.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER) || keyCode == KeyEvent.KEYCODE_ENTER) { String Log = miniNote.getText().toString(); logDetails(Log); noteItems.add(0, miniNote.getText().toString()); arrayAdapter.notifyDataSetChanged(); miniNote.setText(""); miniNote.setTextColor(Color.WHITE); return true; } return false; } } ); }
From source file:com.smoothsync.smoothsetup.microfragments.appspecificpassword.AppSpecificWebviewFragment.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (mWebView.canGoBack()) { // user went back a step mWebView.goBack();// w w w.j a va2s . c o m } else { // the user cancelled the authorization flow new FragmentEnvironment<>(this).host().execute(getActivity(), new BackTransition()); } } return true; } return false; }
From source file:net.zorgblub.typhon.activity.ReadingActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); if (action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK && isDrawerOpen()) { closeNavigationDrawer();/*from www . j a v a2 s. c o m*/ return true; } if (readingFragment.dispatchKeyEvent(event)) { return true; } return super.dispatchKeyEvent(event); }
From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }/* w ww .j a v a2 s .c om*/ if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8347337366")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hibhailal458@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:com.hitesh_sahu.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//w ww . ja va 2 s . c o m if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8888813275")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hiteshkrsahu@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }