Search in sources :

Example 21 with Activity

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();
}
Also used : Rect(android.graphics.Rect) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 22 with Activity

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;
}
Also used : Activity(android.app.Activity) DisplayMetrics(android.util.DisplayMetrics)

Example 23 with Activity

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;
}
Also used : Activity(android.app.Activity) Intent(android.content.Intent)

Example 24 with Activity

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);
}
Also used : Activity(android.app.Activity)

Example 25 with Activity

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);
}
Also used : Instrumentation(android.app.Instrumentation) Activity(android.app.Activity) Intent(android.content.Intent) File(java.io.File) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

Activity (android.app.Activity)1138 View (android.view.View)200 Test (org.junit.Test)166 Intent (android.content.Intent)162 TextView (android.widget.TextView)83 ArrayList (java.util.ArrayList)62 Bundle (android.os.Bundle)53 Context (android.content.Context)51 ViewGroup (android.view.ViewGroup)48 DialogInterface (android.content.DialogInterface)44 AlertDialog (android.app.AlertDialog)41 Robolectric.buildActivity (org.robolectric.Robolectric.buildActivity)40 ImageView (android.widget.ImageView)36 Twitter (twitter4j.Twitter)35 LayoutInflater (android.view.LayoutInflater)34 AppCompatActivity (android.support.v7.app.AppCompatActivity)32 DisplayMetrics (android.util.DisplayMetrics)32 FrameLayout (android.widget.FrameLayout)28 Robolectric.setupActivity (org.robolectric.Robolectric.setupActivity)28 FragmentActivity (android.support.v4.app.FragmentActivity)27