List of usage examples for android.widget RelativeLayout setEnabled
@RemotableViewMethod public void setEnabled(boolean enabled)
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override @TargetApi(11)/*www . ja va 2 s. c o m*/ public void onCreate(Bundle icicle) { super.onCreate(icicle); if (!InstallMosh.isInstallStarted()) { new InstallMosh(this); } configureStrictMode(); hardKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; hardKeyboard = hardKeyboard && !Build.MODEL.contains("Transformer"); this.setContentView(R.layout.act_console); BugSenseHandler.setup(this, "d27a12dc"); clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); prefs = PreferenceManager.getDefaultSharedPreferences(this); // hide action bar if requested by user try { ActionBar actionBar = getActionBar(); if (!prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { actionBar.hide(); } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); } catch (NoSuchMethodError error) { Log.w(TAG, "Android sdk version pre 11. Not touching ActionBar."); } // hide status bar if requested by user if (prefs.getBoolean(PreferenceConstants.FULLSCREEN, false)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } // TODO find proper way to disable volume key beep if it exists. setVolumeControlStream(AudioManager.STREAM_MUSIC); // handle requested console from incoming intent requested = getIntent().getData(); inflater = LayoutInflater.from(this); flip = (ViewFlipper) findViewById(R.id.console_flip); empty = (TextView) findViewById(android.R.id.empty); stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group); stringPromptInstructions = (TextView) findViewById(R.id.console_password_instructions); stringPrompt = (EditText) findViewById(R.id.console_password); stringPrompt.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP) return false; if (keyCode != KeyEvent.KEYCODE_ENTER) return false; // pass collected password down to current terminal String value = stringPrompt.getText().toString(); PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return false; helper.setResponse(value); // finally clear password for next user stringPrompt.setText(""); updatePromptVisible(); return true; } }); booleanPromptGroup = (RelativeLayout) findViewById(R.id.console_boolean_group); booleanPrompt = (TextView) findViewById(R.id.console_prompt); booleanYes = (Button) findViewById(R.id.console_prompt_yes); booleanYes.setOnClickListener(new OnClickListener() { public void onClick(View v) { PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return; helper.setResponse(Boolean.TRUE); updatePromptVisible(); } }); booleanNo = (Button) findViewById(R.id.console_prompt_no); booleanNo.setOnClickListener(new OnClickListener() { public void onClick(View v) { PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return; helper.setResponse(Boolean.FALSE); updatePromptVisible(); } }); // preload animations for terminal switching slide_left_in = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); slide_left_out = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); slide_right_in = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slide_right_out = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed); fade_stay_hidden = AnimationUtils.loadAnimation(this, R.anim.fade_stay_hidden); // Preload animation for keyboard button keyboard_fade_in = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_in); keyboard_fade_out = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_out); inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final RelativeLayout keyboardGroup = (RelativeLayout) findViewById(R.id.keyboard_group); if (Build.MODEL.contains("Transformer") && getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY && prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { keyboardGroup.setEnabled(false); keyboardGroup.setVisibility(View.INVISIBLE); } mKeyboardButton = (ImageView) findViewById(R.id.button_keyboard); mKeyboardButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); keyboardGroup.setVisibility(View.GONE); } }); final ImageView symButton = (ImageView) findViewById(R.id.button_sym); symButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.showCharPickerDialog(terminal); keyboardGroup.setVisibility(View.GONE); } }); mInputButton = (ImageView) findViewById(R.id.button_input); mInputButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView ctrlButton = (ImageView) findViewById(R.id.button_ctrl); ctrlButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.metaPress(TerminalKeyListener.META_CTRL_ON); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView escButton = (ImageView) findViewById(R.id.button_esc); escButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.sendEscape(); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); // detect fling gestures to switch between terminals final GestureDetector detect = new GestureDetector(new ICBSimpleOnGestureListener(this)); flip.setLongClickable(true); flip.setOnTouchListener(new ICBOnTouchListener(this, keyboardGroup, detect)); }