List of usage examples for android.view Gravity LEFT
int LEFT
To view the source code for android.view Gravity LEFT.
Click Source Link
From source file:com.oonhee.oojs.inappbrowser.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from www.j a v a2s .c o m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { closeDialog(); } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); back.setText("<"); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); forward.setText(">"); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); close.setText(buttonLabel); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new AmazonWebView(cordova.getActivity()); CordovaActivity app = (CordovaActivity) cordova.getActivity(); cordova.getFactory().initializeWebView(inAppWebView, 0x00FF00, false, null); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); AmazonWebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); AmazonWebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(com.amazon.android.webkit.AmazonWebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { AmazonCookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { AmazonCookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.grepsound.activities.MainActivity.java
@Override public void showSettings() { if (!mDrawerIsLocked) mDrawerLayout.closeDrawer(Gravity.LEFT); mDrawerToggle.setDrawerIndicatorEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDetailsFragment = new SettingsSlidingFragment(); switchFragments();/* ww w .j av a 2 s. co m*/ }
From source file:com.doubleTwist.drawerlib.ADrawerLayout.java
protected void layoutView(View v, int l, int t, int r, int b) { LayoutParams params = (LayoutParams) v.getLayoutParams(); Rect bounds = new Rect(); Rect boundsWithoutPeek = new Rect(); int gravity = params.gravity; switch (gravity) { case Gravity.RIGHT: if (DEBUG) Log.d(TAG, "gravity: right"); bounds.left = r - v.getMeasuredWidth() - mPeekSize.right; bounds.top = t;// w w w .ja v a 2 s . com bounds.right = r - mPeekSize.right; bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(mPeekSize.right, 0); mMinScrollX = -bounds.width(); break; case Gravity.TOP: if (DEBUG) Log.d(TAG, "gravity: top"); bounds.left = l; bounds.top = t + mPeekSize.top; bounds.right = v.getMeasuredWidth(); bounds.bottom = t + v.getMeasuredHeight() + mPeekSize.top; v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(0, -mPeekSize.top); mMaxScrollY = bounds.height(); break; case Gravity.BOTTOM: if (DEBUG) Log.d(TAG, "gravity: bottom"); bounds.left = l; bounds.top = b - v.getMeasuredHeight() - mPeekSize.bottom; bounds.right = l + v.getMeasuredWidth(); bounds.bottom = b - mPeekSize.bottom; v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(0, mPeekSize.bottom); mMinScrollY = -bounds.height(); break; case Gravity.LEFT: if (DEBUG) Log.d(TAG, "gravity: left"); bounds.left = l + mPeekSize.left; bounds.top = t; bounds.right = l + v.getMeasuredWidth() + mPeekSize.left; bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); mMaxScrollX = bounds.width(); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(-mPeekSize.left, 0); break; default: if (DEBUG) Log.d(TAG, "gravity: default"); bounds.left = l; bounds.top = t; bounds.right = l + v.getMeasuredWidth(); bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); break; } if (DEBUG) { Log.d(TAG, " == VIEW LAYOUT == " + v.toString()); Log.d(TAG, "bounds: " + bounds.left + "," + bounds.top + "," + bounds.right + "," + bounds.bottom); } if (mLayoutBounds.containsKey(v)) mLayoutBounds.remove(v); mLayoutBounds.put(v, bounds); if (mLayoutBoundsWithoutPeek.containsKey(v)) mLayoutBoundsWithoutPeek.remove(v); mLayoutBoundsWithoutPeek.put(v, boundsWithoutPeek); }
From source file:com.spydiko.rotationmanager.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: // Refresh button // if(AppSpecificOrientation.LOG) Log.d(TAG, "action_settings"); packageManager = getPackageManager(); UpdateData updateData = new UpdateData(); this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) updateData.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); else/*from w ww .j av a 2s . c om*/ updateData.execute((Void[]) null); // if(AppSpecificOrientation.LOG) Log.d(TAG, "execute"); lv.setAdapter(adapter); break; case R.id.itemToggleService: // Play - Stop Service // if(AppSpecificOrientation.LOG) Log.d(TAG, "entered"); if (AppSpecificOrientation.isServiceRunning()) { item.setTitle(R.string.titleServiceStop); // item.setIcon(android.R.drawable.ic_media_play); stopService(new Intent(this, NewOrieService.class)); AppSpecificOrientation.setServiceRunning(false); // if(AppSpecificOrientation.LOG) Log.d(TAG, "if"); // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(R.drawable.ic_off_button_rotation_manager); } else { item.setTitle(R.string.titleServiceStart); // item.setIcon(android.R.drawable.ic_media_pause); startService(new Intent(this, NewOrieService.class)); Toast toast = Toast.makeText(this, getString(R.string.notification_text), Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); toast.show(); // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(R.drawable.ic_on_button_rotation_manager); // if(AppSpecificOrientation.LOG) Log.d(TAG, "else"); } break; case R.id.setOnBoot: // Set broadcast receiver on or off if (AppSpecificOrientation.getBoot()) { item.setChecked(false); AppSpecificOrientation.setBoot(false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(android.R.drawable.button_onoff_indicator_off); // if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to false"); } else { item.setChecked(true); AppSpecificOrientation.setBoot(true); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(android.R.drawable.button_onoff_indicator_on); // if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to true"); } break; case R.id.howTo: // Open How To Activity startActivityForResult((new Intent(this, HowToActivity.class)), 1); break; case R.id.about: // Open About Activity startActivityForResult((new Intent(this, AboutActivity.class)), 1); break; case R.id.donate: startActivity(new Intent(this, DonateActivity.class)); break; case R.id.permNotification: if (AppSpecificOrientation.isPermNotification()) { item.setChecked(false); AppSpecificOrientation.setPermNotification(false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(android.R.drawable.button_onoff_indicator_off); // if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to false"); if (AppSpecificOrientation.isServiceRunning()) startService(new Intent(this, NewOrieService.class)); } else { item.setChecked(true); AppSpecificOrientation.setPermNotification(true); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) item.setIcon(android.R.drawable.button_onoff_indicator_on); // if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to true"); if (AppSpecificOrientation.isServiceRunning()) startService(new Intent(this, NewOrieService.class)); } break; case R.id.license: startActivity(new Intent(this, License.class)); break; case android.R.id.home: menu.toggle(); return true; } return true; }
From source file:com.google.blockly.android.ToolboxFragment.java
/** * @return Computed {@link Rotation} constant for {@link #mRotateTabs} and {@link #mTabEdge}. *//*from w ww.j ava 2 s . co m*/ @Rotation.Enum private int getLabelRotation() { if (!mRotateTabs) { return Rotation.NONE; } switch (mTabEdge) { case Gravity.LEFT: return Rotation.COUNTER_CLOCKWISE; case Gravity.RIGHT: return Rotation.CLOCKWISE; case Gravity.TOP: return Rotation.NONE; case Gravity.BOTTOM: return Rotation.NONE; case GravityCompat.START: return Rotation.ADAPTIVE_COUNTER_CLOCKWISE; case GravityCompat.END: return Rotation.ADAPTIVE_CLOCKWISE; default: throw new IllegalArgumentException("Invalid tabEdge: " + mTabEdge); } }
From source file:com.dk.view.FolderDrawerLayout.java
/** * Sets the title of the drawer with the given gravity. * <p>/* ww w . ja va2s . c o m*/ * When accessibility is turned on, this is the title that will be used to * identify the drawer to the active accessibility service. * * @param edgeGravity * Gravity.LEFT, RIGHT, START or END. Expresses which drawer to * set the title for. * @param title * The title for the drawer. */ public void setDrawerTitle(int edgeGravity, CharSequence title) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { mTitleLeft = title; } else if (absGravity == Gravity.RIGHT) { mTitleRight = title; } }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * /*from www .j ava2 s.c o m*/ * @param edgeGravity * Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. */ public int getDrawerLockMode(int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); switch (absGravity) { case Gravity.LEFT: return mLockModeLeft; case Gravity.RIGHT: return mLockModeRight; case Gravity.TOP: return mLockModeTop; case Gravity.BOTTOM: return mLockModeBottom; default: return LOCK_MODE_UNLOCKED; } }
From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable provided must have a * nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer * instead of the drawable provided.//from w ww . j a va 2s . com * * <p>Note that for better support for both left-to-right and right-to-left layout * directions, a drawable for RTL layout (in additional to the one in LTR layout) can be * defined with a resource qualifier "ldrtl" for API 17 and above with the gravity * {@link GravityCompat#START}. Alternatively, for API 23 and above, the drawable can * auto-mirrored such that the drawable will be mirrored in RTL layout.</p> * * @param shadowDrawable Shadow drawable to use at the edge of a drawer * @param gravity Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering callbacks, * setting states, etc. properly. */ if (SET_DRAWER_SHADOW_FROM_ELEVATION) { // No op. Drawer shadow will come from setting an elevation on the drawer. return; } if ((gravity & GravityCompat.START) == GravityCompat.START) { mShadowStart = shadowDrawable; } else if ((gravity & GravityCompat.END) == GravityCompat.END) { mShadowEnd = shadowDrawable; } else if ((gravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; } else if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; } else { return; } resolveShadowDrawables(); invalidate(); }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *///from w w w. j a v a2 s . c o m @LockMode public int getDrawerLockMode(@EdgeGravity int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { return mLockModeLeft; } else if (absGravity == Gravity.RIGHT) { return mLockModeRight; } return LOCK_MODE_UNLOCKED; }
From source file:com.dk.view.FolderDrawerLayout.java
/** * Returns the title of the drawer with the given gravity. * /*from w w w.j ava 2 s . c o m*/ * @param edgeGravity * Gravity.LEFT, RIGHT, START or END. Expresses which drawer to * return the title for. * @return The title of the drawer, or null if none set. * @see #setDrawerTitle(int, CharSequence) */ public CharSequence getDrawerTitle(int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { return mTitleLeft; } else if (absGravity == Gravity.RIGHT) { return mTitleRight; } return null; }