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;
}
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);
}
}
});
}
}
}
}
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;
}
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);
}
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);
}
Aggregations