Search in sources :

Example 21 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method prepareHaloNotification.

public void prepareHaloNotification(NotificationData.Entry entry, StatusBarNotification notification, boolean update) {
    Notification notif = notification.getNotification();
    // Get the remote view
    try {
        if (!update) {
            ViewGroup mainView = (ViewGroup) notif.contentView.apply(mContext, null, mOnClickHandler);
            if (mainView instanceof FrameLayout) {
                entry.haloContent = mainView.getChildAt(1);
                mainView.removeViewAt(1);
            } else {
                entry.haloContent = mainView;
            }
        } else {
            notif.contentView.reapply(mContext, entry.haloContent, mOnClickHandler);
        }
    } catch (Exception e) {
        // Non uniform content?
        android.util.Log.d("PARANOID", "   Non uniform content?");
    }
    // Construct the round icon
    final float haloSize = Settings.System.getFloat(mContext.getContentResolver(), Settings.System.HALO_SIZE, 1.0f);
    int iconSize = (int) (mContext.getResources().getDimensionPixelSize(R.dimen.halo_bubble_size) * haloSize);
    int smallIconSize = (int) (mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size) * haloSize);
    int largeIconWidth = notif.largeIcon != null ? (int) (notif.largeIcon.getWidth() * haloSize) : 0;
    int largeIconHeight = notif.largeIcon != null ? (int) (notif.largeIcon.getHeight() * haloSize) : 0;
    Bitmap roundIcon = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(roundIcon);
    canvas.drawARGB(0, 0, 0, 0);
    // halo-bubble, we'll use that one and cut it round
    if (notif.largeIcon != null && largeIconWidth >= iconSize / 2) {
        Paint smoothingPaint = new Paint();
        smoothingPaint.setAntiAlias(true);
        smoothingPaint.setFilterBitmap(true);
        smoothingPaint.setDither(true);
        canvas.drawCircle(iconSize / 2, iconSize / 2, iconSize / 2.3f, smoothingPaint);
        smoothingPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
        final int newWidth = iconSize;
        final int newHeight = iconSize * largeIconWidth / largeIconHeight;
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(notif.largeIcon, newWidth, newHeight, true);
        canvas.drawBitmap(scaledBitmap, null, new Rect(0, 0, iconSize, iconSize), smoothingPaint);
    } else {
        try {
            Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(notification.getPackageName(), notification.getUser(), notif.icon, notif.iconLevel, notif.number, notif.tickerText));
            if (icon == null)
                icon = mContext.getPackageManager().getApplicationIcon(notification.getPackageName());
            int margin = (iconSize - smallIconSize) / 2;
            icon.setBounds(margin, margin, iconSize - margin, iconSize - margin);
            icon.draw(canvas);
        } catch (Exception e) {
        // NameNotFoundException
        }
    }
    entry.roundIcon = roundIcon;
}
Also used : Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Paint(android.graphics.Paint) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) ActivityNotFoundException(android.content.ActivityNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) FrameLayout(android.widget.FrameLayout) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 22 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindow method installDecor.

private void installDecor() {
    if (mDecor == null) {
        mDecor = generateDecor();
        mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        mDecor.setIsRootNamespace(true);
        if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
            mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
        }
    }
    if (mContentParent == null) {
        mContentParent = generateLayout(mDecor);
        // Set up decor part of UI to ignore fitsSystemWindows if appropriate.
        mDecor.makeOptionalFitsSystemWindows();
        mTitleView = (TextView) findViewById(com.android.internal.R.id.title);
        if (mTitleView != null) {
            mTitleView.setLayoutDirection(mDecor.getLayoutDirection());
            if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) {
                View titleContainer = findViewById(com.android.internal.R.id.title_container);
                if (titleContainer != null) {
                    titleContainer.setVisibility(View.GONE);
                } else {
                    mTitleView.setVisibility(View.GONE);
                }
                if (mContentParent instanceof FrameLayout) {
                    ((FrameLayout) mContentParent).setForeground(null);
                }
            } else {
                mTitleView.setText(mTitle);
            }
        } else {
            mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
            if (mActionBar != null) {
                mActionBar.setWindowCallback(getCallback());
                if (mActionBar.getTitle() == null) {
                    mActionBar.setWindowTitle(mTitle);
                }
                final int localFeatures = getLocalFeatures();
                if ((localFeatures & (1 << FEATURE_PROGRESS)) != 0) {
                    mActionBar.initProgress();
                }
                if ((localFeatures & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) {
                    mActionBar.initIndeterminateProgress();
                }
                boolean splitActionBar = false;
                final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
                if (splitWhenNarrow) {
                    splitActionBar = getContext().getResources().getBoolean(com.android.internal.R.bool.split_action_bar_is_narrow);
                } else {
                    splitActionBar = getWindowStyle().getBoolean(com.android.internal.R.styleable.Window_windowSplitActionBar, false);
                }
                final ActionBarContainer splitView = (ActionBarContainer) findViewById(com.android.internal.R.id.split_action_bar);
                if (splitView != null) {
                    mActionBar.setSplitView(splitView);
                    mActionBar.setSplitActionBar(splitActionBar);
                    mActionBar.setSplitWhenNarrow(splitWhenNarrow);
                    final ActionBarContextView cab = (ActionBarContextView) findViewById(com.android.internal.R.id.action_context_bar);
                    cab.setSplitView(splitView);
                    cab.setSplitActionBar(splitActionBar);
                    cab.setSplitWhenNarrow(splitWhenNarrow);
                } else if (splitActionBar) {
                    Log.e(TAG, "Requested split action bar with " + "incompatible window decor! Ignoring request.");
                }
                // Post the panel invalidate for later; avoid application onCreateOptionsMenu
                // being called in the middle of onCreate or similar.
                mDecor.post(new Runnable() {

                    public void run() {
                        // Invalidate if the panel menu hasn't been created before this.
                        PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
                        if (!isDestroyed() && (st == null || st.menu == null)) {
                            invalidatePanelMenu(FEATURE_ACTION_BAR);
                        }
                    }
                });
            }
        }
    }
}
Also used : ActionBarContainer(com.android.internal.widget.ActionBarContainer) FrameLayout(android.widget.FrameLayout) ActionBarContextView(com.android.internal.widget.ActionBarContextView) MenuView(com.android.internal.view.menu.MenuView) ImageView(android.widget.ImageView) View(android.view.View) ActionBarView(com.android.internal.widget.ActionBarView) TextView(android.widget.TextView) ActionBarContextView(com.android.internal.widget.ActionBarContextView)

Example 23 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class TabletTicker method makeWindow.

private ViewGroup makeWindow() {
    final Resources res = mContext.getResources();
    final FrameLayout view = new FrameLayout(mContext);
    final int width = res.getDimensionPixelSize(R.dimen.notification_ticker_width);
    int windowFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    if (CLICKABLE_TICKER) {
        windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    } else {
        windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    }
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, mLargeIconHeight, WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, windowFlags, PixelFormat.TRANSLUCENT);
    lp.gravity = Gravity.BOTTOM | Gravity.END;
    //        lp.windowAnimations = com.android.internal.R.style.Animation_Toast;
    mLayoutTransition = new LayoutTransition();
    mLayoutTransition.addTransitionListener(this);
    view.setLayoutTransition(mLayoutTransition);
    lp.setTitle("NotificationTicker");
    view.setLayoutParams(lp);
    return view;
}
Also used : FrameLayout(android.widget.FrameLayout) Resources(android.content.res.Resources) LayoutTransition(android.animation.LayoutTransition) WindowManager(android.view.WindowManager)

Example 24 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class TextureViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContent = new FrameLayout(this);
    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(this);
    mTextureView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Bitmap b = mTextureView.getBitmap(800, 800);
            BufferedOutputStream out = null;
            try {
                File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
                out = new BufferedOutputStream(new FileOutputStream(dump));
                b.compress(Bitmap.CompressFormat.PNG, 100, out);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
            }
        }
    });
    Button button = new Button(this);
    button.setText("Remove/Add");
    button.setOnClickListener(new View.OnClickListener() {

        private boolean mAdded = true;

        @Override
        public void onClick(View v) {
            if (mAdded) {
                mContent.removeView(mTextureView);
            } else {
                mContent.addView(mTextureView);
            }
            mAdded = !mAdded;
        }
    });
    mContent.addView(mTextureView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    mContent.addView(button, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
    setContentView(mContent);
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) TextureView(android.view.TextureView) View(android.view.View) Bitmap(android.graphics.Bitmap) Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) FileOutputStream(java.io.FileOutputStream) TextureView(android.view.TextureView) BufferedOutputStream(java.io.BufferedOutputStream) File(java.io.File)

Example 25 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class ThinPatchesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout layout = new FrameLayout(this);
    PatchView b = new PatchView(this);
    b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    layout.addView(b);
    layout.setBackgroundColor(0xffffffff);
    setContentView(layout);
}
Also used : FrameLayout(android.widget.FrameLayout)

Aggregations

FrameLayout (android.widget.FrameLayout)619 View (android.view.View)238 TextView (android.widget.TextView)136 ViewGroup (android.view.ViewGroup)125 ImageView (android.widget.ImageView)93 LinearLayout (android.widget.LinearLayout)89 ListView (android.widget.ListView)54 AdapterView (android.widget.AdapterView)47 Button (android.widget.Button)44 LayoutInflater (android.view.LayoutInflater)42 Bitmap (android.graphics.Bitmap)40 LayoutParams (android.view.ViewGroup.LayoutParams)37 AbsListView (android.widget.AbsListView)37 Context (android.content.Context)34 Activity (android.app.Activity)25 Intent (android.content.Intent)25 TextureView (android.view.TextureView)25 ColorDrawable (android.graphics.drawable.ColorDrawable)23 FileOutputStream (java.io.FileOutputStream)23 Drawable (android.graphics.drawable.Drawable)20