use of android.view.ViewGroup.LayoutParams in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class EmptyTextSettings method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mEmpty = new TextView(getContext());
mEmpty.setGravity(Gravity.CENTER);
TypedValue value = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, value, true);
mEmpty.setTextAppearance(value.resourceId);
((ViewGroup) view.findViewById(android.R.id.list_container)).addView(mEmpty, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
setEmptyView(mEmpty);
}
use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.
the class KeyboardView method showKey.
private void showKey(final int keyIndex) {
final PopupWindow previewPopup = mPreviewPopup;
final Key[] keys = mKeys;
if (keyIndex < 0 || keyIndex >= mKeys.length)
return;
Key key = keys[keyIndex];
if (key.icon != null) {
mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon);
mPreviewText.setText(null);
} else {
mPreviewText.setCompoundDrawables(null, null, null, null);
mPreviewText.setText(getPreviewText(key));
if (key.label.length() > 1 && key.codes.length < 2) {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
} else {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
mPreviewText.setTypeface(Typeface.DEFAULT);
}
}
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
final int popupHeight = mPreviewHeight;
LayoutParams lp = mPreviewText.getLayoutParams();
if (lp != null) {
lp.width = popupWidth;
lp.height = popupHeight;
}
if (!mPreviewCentered) {
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
} else {
// TODO: Fix this if centering is brought back
mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
mPopupPreviewY = -mPreviewText.getMeasuredHeight();
}
mHandler.removeMessages(MSG_REMOVE_PREVIEW);
getLocationInWindow(mCoordinates);
// Offset may be zero
mCoordinates[0] += mMiniKeyboardOffsetX;
// Offset may be zero
mCoordinates[1] += mMiniKeyboardOffsetY;
// Set the preview background state
mPreviewText.getBackground().setState(key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
mPopupPreviewX += mCoordinates[0];
mPopupPreviewY += mCoordinates[1];
// If the popup cannot be shown above the key, put it on the side
getLocationOnScreen(mCoordinates);
if (mPopupPreviewY + mCoordinates[1] < 0) {
// the right, offset by enough to see at least one key to the left/right.
if (key.x + key.width <= getWidth() / 2) {
mPopupPreviewX += (int) (key.width * 2.5);
} else {
mPopupPreviewX -= (int) (key.width * 2.5);
}
mPopupPreviewY += popupHeight;
}
if (previewPopup.isShowing()) {
previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight);
} else {
previewPopup.setWidth(popupWidth);
previewPopup.setHeight(popupHeight);
previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY);
}
mPreviewText.setVisibility(VISIBLE);
}
use of android.view.ViewGroup.LayoutParams in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothSettings method resetBarSize.
private void resetBarSize(float titleTextSize, int actionBarHeight, int switchBarHeight) {
Activity activity = getActivity();
DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
int titleId = Resources.getSystem().getIdentifier("action_bar", "id", "android");
Toolbar toolbar = (Toolbar) activity.getWindow().findViewById(titleId);
TextView title = null;
if (toolbar != null) {
LayoutParams layoutParams = toolbar.getLayoutParams();
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, actionBarHeight, displayMetrics);
for (int i = 0; i < toolbar.getChildCount(); ++i) {
if (toolbar.getChildAt(i) instanceof TextView) {
title = (TextView) toolbar.getChildAt(i);
}
Toolbar.LayoutParams childLayoutParams = (Toolbar.LayoutParams) toolbar.getChildAt(i).getLayoutParams();
childLayoutParams.gravity = Gravity.CENTER_VERTICAL;
}
}
if (title != null)
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, titleTextSize);
if (mSwitchBar != null) {
LayoutParams layoutParams = mSwitchBar.getLayoutParams();
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, switchBarHeight, displayMetrics);
}
}
use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.
the class Dialog method dispatchPopulateAccessibilityEvent.
@Override
public boolean dispatchPopulateAccessibilityEvent(@NonNull AccessibilityEvent event) {
event.setClassName(getClass().getName());
event.setPackageName(mContext.getPackageName());
LayoutParams params = getWindow().getAttributes();
boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT);
event.setFullScreen(isFullScreen);
return false;
}
use of android.view.ViewGroup.LayoutParams in project newsrob by marianokamp.
the class DashboardListActivity method initialize.
private void initialize(Intent i) {
dbQuery = UIHelper.createDBQueryFromIntentExtras(getEntryManager(), i);
Cursor c = getEntryManager().getDashboardContentCursor(dbQuery);
startManagingCursor(c);
final int readIndicator = getEntryManager().isLightColorSchemeSelected() ? R.drawable.read_indicator : R.drawable.read_indicator_dark;
sca = new SimpleCursorAdapter(this, R.layout.dashboard_list_row, c, new String[] { "_id", "frequency", "sum_unread_freq" }, new int[] { R.id.item_title, R.id.item_count, R.id.unread });
sca.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, final Cursor cursor, int columnIndex) {
if (columnIndex == 2) {
TextView tv = (TextView) view;
boolean containsUnread = cursor.getInt(2) > 0;
tv.setBackgroundResource(containsUnread ? readIndicator : R.drawable.read_indicator_invisible);
return true;
} else if (columnIndex == 1) {
final View itemCount = view;
View.OnClickListener itemCountClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
final String stringValueOfTag = v.getTag(R.id.view_position).toString();
final int position = Integer.valueOf(stringValueOfTag);
onListItemClick(getListView(), v, position, -99l);
final Drawable d = getResources().getDrawable(entryManager.isLightColorSchemeSelected() ? R.drawable.count_list_item : R.drawable.count_list_item_dark);
LayoutParams lp = v.getLayoutParams();
lp.height = v.getHeight();
v.setLayoutParams(lp);
v.setBackgroundDrawable(d);
}
};
view.setTag(R.id.view_position, cursor.getPosition());
itemCount.setOnClickListener(itemCountClickListener);
}
return false;
}
});
setListAdapter(sca);
if (!getEntryManager().isLicenseAccepted())
showDialog(DIALOG_SHOW_LICENSE);
else {
if (getEntryManager().getDaysInstalled() >= 3 && getEntryManager().shouldAskForUsageDataCollectionPermission())
showDialog(DIALOG_SHOW_USAGE_DATA_COLLECTION);
// Skip this activity when now labels are displayed
if (sca.getCount() == 1 && i.getBooleanExtra("skip", true)) {
Intent intent = new Intent(this, FeedListActivity.class);
UIHelper.addExtrasFromDBQuery(intent, dbQuery);
startActivity(intent);
if (!isTaskRoot())
finish();
}
}
}
Aggregations