use of android.app.Activity in project MaterialShowcaseView by deano2390.
the class MaterialShowcaseView method setTarget.
/**
* Tells us about the "Target" which is the view we want to anchor to.
* We figure out where it is on screen and (optionally) how big it is.
* We also figure out whether to place our content and dismiss button above or below it.
*
* @param target
*/
public void setTarget(Target target) {
mTarget = target;
// update dismiss button state
updateDismissButton();
if (mTarget != null) {
/**
* If we're on lollipop then make sure we don't draw over the nav bar
*/
if (!mRenderOverNav && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mBottomMargin = getSoftButtonsBarSizePort((Activity) getContext());
FrameLayout.LayoutParams contentLP = (LayoutParams) getLayoutParams();
if (contentLP != null && contentLP.bottomMargin != mBottomMargin)
contentLP.bottomMargin = mBottomMargin;
}
// apply the target position
Point targetPoint = mTarget.getPoint();
Rect targetBounds = mTarget.getBounds();
setPosition(targetPoint);
// now figure out whether to put content above or below it
int height = getMeasuredHeight();
int midPoint = height / 2;
int yPos = targetPoint.y;
int radius = Math.max(targetBounds.height(), targetBounds.width()) / 2;
if (mShape != null) {
mShape.updateTarget(mTarget);
radius = mShape.getHeight() / 2;
}
if (yPos > midPoint) {
// target is in lower half of screen, we'll sit above it
mContentTopMargin = 0;
mContentBottomMargin = (height - yPos) + radius + mShapePadding;
mGravity = Gravity.BOTTOM;
} else {
// target is in upper half of screen, we'll sit below it
mContentTopMargin = yPos + radius + mShapePadding;
mContentBottomMargin = 0;
mGravity = Gravity.TOP;
}
}
applyLayoutParams();
}
use of android.app.Activity in project MyDiary by erttyy8821.
the class ScreenHelper method getScreenHeight.
public static int getScreenHeight(Context context) {
DisplayMetrics metrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
return metrics.heightPixels;
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class SelectActionModeCallback method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch(item.getItemId()) {
case android.R.id.cut:
mWebView.cutSelection();
mode.finish();
break;
case android.R.id.copy:
mWebView.copySelection();
mode.finish();
break;
case android.R.id.paste:
mWebView.pasteFromClipboard();
mode.finish();
break;
case com.android.internal.R.id.share:
String selection = mWebView.getSelection();
Browser.sendString(mWebView.getContext(), selection);
mode.finish();
break;
case com.android.internal.R.id.select_all:
mWebView.selectAll();
break;
case com.android.internal.R.id.find:
String sel = mWebView.getSelection();
mode.finish();
mWebView.showFindDialog(sel, false);
break;
case com.android.internal.R.id.websearch:
mode.finish();
Intent i = new Intent(Intent.ACTION_WEB_SEARCH);
i.putExtra(SearchManager.EXTRA_NEW_SEARCH, true);
i.putExtra(SearchManager.QUERY, mWebView.getSelection());
if (!(mWebView.getContext() instanceof Activity)) {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
mWebView.getContext().startActivity(i);
break;
default:
return false;
}
return true;
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class LinearLayoutEditTextsTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final Activity activity = getActivity();
mChild = activity.findViewById(R.id.editText1);
mContainer = activity.findViewById(R.id.layout);
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class EffectsVideoCapture method testBackEffectsVideoCapture.
@LargeTest
public void testBackEffectsVideoCapture() throws Exception {
Instrumentation inst = getInstrumentation();
Intent intent = new Intent();
intent.setClass(getInstrumentation().getTargetContext(), CameraEffectsRecordingSample.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("OUTPUT_FILENAME", Environment.getExternalStorageDirectory().toString() + "/CameraEffectsRecordingTest.mp4");
Activity act = inst.startActivitySync(intent);
captureVideos("Back Camera Video Capture\n", inst);
act.finish();
// Verification
File file = new File(Environment.getExternalStorageDirectory(), "CameraEffectsRecordingTest.mp4");
Uri uri = Uri.fromFile(file);
verify(getActivity(), uri);
}
Aggregations