Java Code Examples for android.widget.Button#requestFocus()

The following examples show how to use android.widget.Button#requestFocus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_backup, container, false);

    view.findViewById(R.id.btnRestoreBackup).setOnClickListener(this);
    Button btnSaveBackup = view.findViewById(R.id.btnSaveBackup);
    btnSaveBackup.setOnClickListener(this);
    btnSaveBackup.requestFocus();
    etFilePath = view.findViewById(R.id.etPathBackup);
    PathVars pathVars = PathVars.getInstance(view.getContext());
    pathBackup = pathVars.getDefaultBackupPath();
    etFilePath.setText(pathBackup);
    etFilePath.setOnClickListener(this);
    appDataDir = pathVars.getAppDataDir();

    return view;
}
 
Example 2
Source File: KeyboardShortcutDialogPreference.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
  super.showDialog(state);
  AlertDialog alertDialog = (AlertDialog) getDialog();
  if (alertDialog == null) {
    return;
  }

  View clear = alertDialog.findViewById(R.id.clear);
  clear.setOnClickListener(clearButtonClickListener);
  alertDialog
      .getButton(DialogInterface.BUTTON_POSITIVE)
      .setOnClickListener(okButtonClickListener);
  alertDialog.setOnKeyListener(this);

  Button okButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
  okButton.setFocusableInTouchMode(true);
  okButton.requestFocus();

  setKeyEventSource(getKeyEventSourceForCurrentKeyComboModel());
}
 
Example 3
Source File: HelpActivity.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);

    etLogsPath = findViewById(R.id.etLogsPath);
    etLogsPath.setOnClickListener(this);
    Button btnSaveLogs = findViewById(R.id.btnSaveLogs);
    btnSaveLogs.setOnClickListener(this);
    btnSaveLogs.requestFocus();
    SwitchCompat swRootCommandsLog = findViewById(R.id.swRootCommandsLog);
    swRootCommandsLog.setChecked(new PrefManager(this).getBoolPref("swRootCommandsLog"));
    swRootCommandsLog.setOnCheckedChangeListener(this);

    Handler mHandler = new Handler();

    PathVars pathVars = PathVars.getInstance(this);
    appDataDir = pathVars.getAppDataDir();
    busyboxPath = pathVars.getBusyboxPath();
    pathToSaveLogs = pathVars.getDefaultBackupPath();
    iptables = pathVars.getIptablesPath();
    appUID = new PrefManager(this).getStrPref("appUID");

    br = new HelpActivityReceiver(mHandler, appDataDir, pathToSaveLogs);

    modulesStatus = ModulesStatus.getInstance();

    if (modulesStatus.isRootAvailable()) {
        IntentFilter intentFilter = new IntentFilter(RootExecService.COMMAND_RESULT);
        LocalBroadcastManager.getInstance(this).registerReceiver(br, intentFilter);
    }

}
 
Example 4
Source File: LocalBackupStorageSetupFragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    Button selectDirButton = findViewById(R.id.button_lbs_select_dir);
    selectDirButton.setOnClickListener(v -> selectBackupDir());
    selectDirButton.requestFocus(); //TV fix
}
 
Example 5
Source File: ConnectActivity.java    From Android-Remote with GNU General Public License v3.0 5 votes vote down vote up
private void initializeUi() {
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    // Get the Layoutelements
    mBtnConnect = (Button) findViewById(R.id.btnConnect);
    mBtnConnect.setOnClickListener(oclConnect);
    mBtnConnect.requestFocus();

    mBtnClementine = (ImageButton) findViewById(R.id.btnClementineIcon);
    mBtnClementine.setOnClickListener(oclClementine);

    // Setup the animation for the Clementine icon
    mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
    mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
    mAlphaDown.setDuration(ANIMATION_DURATION);
    mAlphaUp.setDuration(ANIMATION_DURATION);
    mAlphaDown.setFillAfter(true);
    mAlphaUp.setFillAfter(true);
    mAlphaUp.setAnimationListener(mAnimationListener);
    mAlphaDown.setAnimationListener(mAnimationListener);
    mAnimationCancel = false;

    // Ip and Autoconnect
    mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
    mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mEtIp.setThreshold(3);

    // Get old ip and auto-connect from shared prefences
    mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
    mEtIp.setSelection(mEtIp.length());

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.select_dialog_item, mKnownIps.toArray(new String[0]));
    mEtIp.setAdapter(adapter);

    // Get the last auth code
    mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}
 
Example 6
Source File: TalkBackKeyboardShortcutPreferencesActivity.java    From talkback with Apache License 2.0 4 votes vote down vote up
private static void focusCancelButton(AlertDialog alertDialog) {
  Button cancelButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
  cancelButton.setFocusableInTouchMode(true);
  cancelButton.requestFocus();
}