Example usage for android.view View FOCUS_DOWN

List of usage examples for android.view View FOCUS_DOWN

Introduction

In this page you can find the example usage for android.view View FOCUS_DOWN.

Prototype

int FOCUS_DOWN

To view the source code for android.view View FOCUS_DOWN.

Click Source Link

Document

Use with #focusSearch(int) .

Usage

From source file:net.oremland.rss.reader.fragments.BrowserFragment.java

private void initializeViews(Bundle savedInstanceState) {
    if (savedInstanceState == null && getContext() != null) {
        boolean isTablet = getContext().getResources().getBoolean(R.bool.isTablet);
        WebSettings.ZoomDensity zoomDensity = isTablet ? WebSettings.ZoomDensity.MEDIUM
                : WebSettings.ZoomDensity.FAR;

        WebView description = (WebView) getView().findViewById(R.id.description);
        description.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        description.getSettings().setJavaScriptEnabled(true);
        description.getSettings().setPluginState(WebSettings.PluginState.ON);
        description.getSettings().setDefaultTextEncodingName("utf-8");
        description.getSettings().setLoadWithOverviewMode(true);
        description.getSettings().setDefaultZoom(zoomDensity);
        description.getSettings().setSupportZoom(true);
        description.getSettings().setBuiltInZoomControls(true);
        description.requestFocus(View.FOCUS_DOWN);
        description.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
        description.getSettings().setUseWideViewPort(isTablet);
        description.setWebChromeClient(this.getWebChromeClient());
        description.setWebViewClient(this.getWebViewClient());
    }//ww w .ja  v a  2 s .com
}

From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java

private void run_tts_test() {
    SpannableStringBuilder ssb = new SpannableStringBuilder(textInfo.getText());
    ssb.append(_context.getString(R.string.setup_tts_test));
    ssb.append('\n');
    ssb.append(_context.getString(R.string.setup_tts_engine));
    textInfo.setText(ssb);/*from  www .j  a v  a2 s .c  o m*/
    svMyview.fullScroll(View.FOCUS_DOWN);
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    getActivity().startActivityFromFragment(SetupFragment.this, checkIntent, 3);
}

From source file:nl.meta.mobile.chat.MobileChatActivity.java

/**
 * This method adds a new TextView with the message to the chatbox.
 * /*w  w  w  .j a v  a  2 s. com*/
 * @param message
 *            The message to be added.
 */
private void addMessageToChat(String message) {
    TextView tv = new TextView(this);
    tv.setText(message);
    llMessages.addView(tv);
    // Scroll to the end
    svMessages.fullScroll(View.FOCUS_DOWN);
}

From source file:com.azure.webapi.LoginManager.java

/**
 * Creates the UI for the interactive authentication process
 * // w  w  w.j ava2  s  .c  om
 * @param provider
 *            The provider used for the authentication process
 * @param startUrl
 *            The initial URL for the authentication process
 * @param endUrl
 *            The final URL for the authentication process
 * @param context
 *            The context used to create the authentication dialog
 * @param callback
 *            Callback to invoke when the authentication process finishes
 */
protected void showLoginUI(MobileServiceAuthenticationProvider provider, final String startUrl,
        final String endUrl, final Context context, LoginUIOperationCallback callback) {
    if (startUrl == null || startUrl == "") {
        throw new IllegalArgumentException("startUrl can not be null or empty");
    }

    if (endUrl == null || endUrl == "") {
        throw new IllegalArgumentException("endUrl can not be null or empty");
    }

    if (context == null) {
        throw new IllegalArgumentException("context can not be null");
    }

    final LoginUIOperationCallback externalCallback = callback;
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    // Create the Web View to show the login page
    final WebView wv = new WebView(context);
    builder.setTitle("Connecting to a service");
    builder.setCancelable(true);
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
        }
    });

    // Set cancel button's action
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
            wv.destroy();
        }
    });

    wv.getSettings().setJavaScriptEnabled(true);

    wv.requestFocus(View.FOCUS_DOWN);
    wv.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            int action = event.getAction();
            if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
                if (!view.hasFocus()) {
                    view.requestFocus();
                }
            }

            return false;
        }
    });

    // Create a LinearLayout and add the WebView to the Layout
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(wv);

    // Add a dummy EditText to the layout as a workaround for a bug
    // that prevents showing the keyboard for the WebView on some devices
    EditText dummyEditText = new EditText(context);
    dummyEditText.setVisibility(View.GONE);
    layout.addView(dummyEditText);

    // Add the layout to the dialog
    builder.setView(layout);

    final AlertDialog dialog = builder.create();

    wv.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // If the URL of the started page matches with the final URL
            // format, the login process finished
            if (isFinalUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(url, null);
                }

                dialog.dismiss();
            }

            super.onPageStarted(view, url, favicon);
        }

        // Checks if the given URL matches with the final URL's format
        private boolean isFinalUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(endUrl);
        }

        // Checks if the given URL matches with the start URL's format
        private boolean isStartUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(startUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (isStartUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(null, new MobileServiceException(
                            "Logging in with the selected authentication provider is not enabled"));
                }

                dialog.dismiss();
            }
        }
    });

    wv.loadUrl(startUrl);
    dialog.show();
}

From source file:com.wubydax.dbeditor.TableValuesFragment.java

private void showDialog(final String key, final String value, final int position) {
    @SuppressLint("InflateParams")
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_layout, null, false);
    TextView keyText = (TextView) view.findViewById(R.id.textKey);
    final EditText editText = (EditText) view.findViewById(R.id.valueEditText);
    final ScrollView scroll = (ScrollView) view.findViewById(R.id.ScrollView1);
    if (value.matches("\\d+(?:\\.\\d+)?")) {
        editText.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        editText.setSingleLine(true);/*  w w  w . j a v a 2  s.  c o  m*/
    } else {
        editText.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        editText.setHint(getResources().getString(R.string.enter_string));
    }
    keyText.setText(key);
    editText.setText(value);
    editText.setSelection(editText.getText().length());
    scroll.post(new Runnable() {
        @Override
        public void run() {
            scroll.fullScroll(View.FOCUS_DOWN);
        }
    });
    new AlertDialog.Builder(getActivity()).setTitle(getResources().getString(R.string.change_value))
            .setView(view).setNegativeButton(android.R.string.cancel, null)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String newValue = editText.getText().toString();
                    boolean isGranted = Settings.System.canWrite(getActivity());
                    if (!isGranted) {
                        Intent grantPermission = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
                        startActivity(grantPermission);
                    } else {
                        switch (mTableName) {
                        case "system":
                            Settings.System.putString(getActivity().getContentResolver(), key, newValue);
                            break;
                        case "global":
                            Settings.Global.putString(getActivity().getContentResolver(), key, newValue);
                            break;
                        case "secure":
                            Settings.Secure.putString(getActivity().getContentResolver(), key, newValue);
                            break;
                        }
                        mList.get(position).value = newValue;
                    }
                    mRecyclerView.getAdapter().notifyDataSetChanged();
                }
            }).show();
}

From source file:com.commonsware.android.mrp.PlaybackFragment.java

private void logToTranscript(String msg) {
    if (client != null) {
        String sessionId = client.getSessionId();

        if (sessionId != null) {
            msg = "(" + sessionId + ") " + msg;
        }/*from w w w  . jav  a2 s . c  o m*/
    }

    transcript.setText(transcript.getText().toString() + msg + "\n");
    scroll.fullScroll(View.FOCUS_DOWN);
}

From source file:com.air.mobilebrowser.BrowserActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ttsPlayer = new TTSPlayer(this);

    // Allow for out-of-band additions to thread queue (mainly for cleanup)
    mHandler = new Handler();

    // Prevents user from taking screenshots. 
    getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Load layout
    mWebView = new AIRWebView(this, this);
    mWebView.requestFocus(View.FOCUS_DOWN);

    setContentView(R.layout.activity_browser);
    FrameLayout layout = (FrameLayout) findViewById(R.id.sec_webview);
    layout.addView(((AIRWebView) mWebView).getLayout());

    // Initialize device monitoring 
    mDeviceStatus = new DeviceStatus(this, this);
    mDeviceStatus.registerReceivers(this);

    // By default, lock to landscape
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    mDeviceStatus.lockedOrientation = "landscape";

    // Configure the webview 
    configureWebView(mWebView);//from   w w  w  .  ja v  a  2s  .  co m

    // Configure Debug Console
    if (mIsDebugEnabled) {
        findViewById(R.id.slidingDrawer1).setVisibility(View.VISIBLE);
        findViewById(R.id.addressBarWrapper).setVisibility(View.VISIBLE);

        findViewById(R.id.goButton).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                String url = ((EditText) findViewById(R.id.address_bar)).getText().toString();
                mWebView.loadUrl(url);
            }
        });
    }

    // Load the content 
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    String url = preferences.getString("pref_default_url", getString(R.string.url_default_location));

    // For testing, uncomment the following line to use a custom url: 

    // Check for Internet connectivity
    if (mDeviceStatus.connectivity == DeviceStatus.CONNECTIVITY_CONNECTED) {
        mWebView.loadUrl(url);
    } else {
        mWebView.loadUrl("about:none");
    }

    // Register BroadcastListener for service intents
    mSBReceiver = new SBReceiver(this);
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_black_logtag)));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_micmutechanged)));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_keyboardchange)));
    // add receiver for bluetooth keyboard connection/disconnection events
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));

    IntentFilter testFilter = new IntentFilter(Intent.CATEGORY_HOME);

    super.getApplicationContext().registerReceiver(mSBReceiver, testFilter);

    // Get AudioManger
    mAudioManager = (AudioManager) super.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);

    // Configure JS Command Processing
    configureJSCmdHandling();

    // Begin monitoring for focus change. 
    startService(new Intent(getApplicationContext(), ActivityWatchService.class));
}

From source file:com.ultramegasoft.flavordex2.util.EntryFormHelper.java

/**
 * Set up the autocomplete for the maker field.
 *//*from w  ww.  ja  v a 2 s.  co  m*/
private void setupMakersAutoComplete() {
    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(mFragment.getContext(),
            R.layout.simple_dropdown_item_2line, null,
            new String[] { Tables.Makers.NAME, Tables.Makers.LOCATION },
            new int[] { android.R.id.text1, android.R.id.text2 }, 0);

    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        @Override
        public Cursor runQuery(CharSequence constraint) {
            final Uri uri;
            if (TextUtils.isEmpty(constraint)) {
                uri = Tables.Makers.CONTENT_URI;
            } else {
                uri = Uri.withAppendedPath(Tables.Makers.CONTENT_FILTER_URI_BASE,
                        Uri.encode(constraint.toString()));
            }

            final Bundle args = new Bundle();
            args.putParcelable("uri", uri);

            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mFragment.getLoaderManager().restartLoader(LOADER_MAKERS, args, EntryFormHelper.this);
                }
            });

            return adapter.getCursor();
        }
    });

    mTxtMaker.setAdapter(adapter);

    // fill in maker and origin fields with a suggestion
    mTxtMaker.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Cursor cursor = (Cursor) parent.getItemAtPosition(position);
            cursor.moveToPosition(position);

            final String name = cursor.getString(cursor.getColumnIndex(Tables.Makers.NAME));
            final String origin = cursor.getString(cursor.getColumnIndex(Tables.Makers.LOCATION));
            mTxtMaker.setText(name);
            mTxtOrigin.setText(origin);

            // skip origin field
            mTxtOrigin.focusSearch(View.FOCUS_DOWN).requestFocus();
        }
    });
}

From source file:com.bangalore.barcamp.activity.WebViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);/*w w w  .ja v a 2  s  .  com*/
    mDrawerToggle = BCBFragmentUtils.setupActionBar(this, BCBConsts.BARCAMP_BANGALORE);
    webView = (WebView) findViewById(R.id.webView);
    WebSettings websettings = webView.getSettings();
    websettings.setJavaScriptEnabled(true);
    webView.setClickable(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
            }
            super.onPageStarted(view, url, favicon);
        }

        private void setUserDetails(String url) {
            Intent newIntent = new Intent(WebViewActivity.this, MainFragmentActivity.class);
            newIntent.setData(Uri.parse(url));
            startActivity(newIntent);
            String id = newIntent.getData().getQueryParameter("id");
            String sid = newIntent.getData().getQueryParameter("sid");
            Log.e("data", "id: " + id + " sid: " + sid);
            BCBSharedPrefUtils.setUserData(getApplicationContext(), id, sid);
            BCBSharedPrefUtils.setScheduleUpdated(WebViewActivity.this, true);
            finish();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            findViewById(R.id.linearLayout2).setVisibility(View.GONE);
            webView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            showDialog(SHOW_ERROR_DIALOG);
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
                Tracker t = ((BarcampBangalore) getApplication()).getTracker();

                // Send a screen view.
                t.send(new HitBuilders.EventBuilder().setCategory("ui_action").setAction("button")
                        .setLabel("Login Success").build());

            }
            super.onLoadResource(view, url);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
                Tracker t = ((BarcampBangalore) getApplication()).getTracker();

                // Send a screen view.
                t.send(new HitBuilders.EventBuilder().setCategory("ui_action").setAction("button")
                        .setLabel("Login Success").build());
                return true;

            }
            if (url.equals(getIntent().getStringExtra(URL))) {
                return true;
            } else if (getIntent().getBooleanExtra(ENABLE_LOGIN, false)) {
                return false;
            }
            Log.e("Action", url);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
            return true;
        }

    });

    String url = getIntent().getStringExtra(URL);
    webView.loadUrl(url);

    Tracker t = ((BarcampBangalore) getApplication()).getTracker();

    // Set screen name.
    t.setScreenName(this.getClass().getName() + url);

    // Send a screen view.
    t.send(new HitBuilders.AppViewBuilder().build());

    // ActionBar actionbar = (ActionBar) findViewById(R.id.actionBar1);
    // actionbar.addAction(new Action() {
    //
    // @Override
    // public void performAction(View arg0) {
    // findViewById(R.id.linearLayout2).setVisibility(View.VISIBLE);
    // webView.setVisibility(View.GONE);
    // webView.reload();
    // }
    //
    // @Override
    // public int getDrawable() {
    // return R.drawable.refresh;
    // }
    // }, 0);

    webView.requestFocus(View.FOCUS_DOWN);

    BCBFragmentUtils.addNavigationActions(this);
    supportInvalidateOptionsMenu();

}

From source file:com.jtechme.apphub.privileged.views.InstallConfirmActivity.java

public void onClick(View v) {
    if (v == mOk) {
        if (mOkCanInstall || mScrollView == null) {
            setResult(RESULT_OK, intent);
            finish();//from   ww  w . ja  v a2s .  c o m
        } else {
            mScrollView.pageScroll(View.FOCUS_DOWN);
        }
    } else if (v == mCancel) {
        setResult(RESULT_CANCELED, intent);
        finish();
    }
}