use of android.widget.FrameLayout in project ViewPagerIndicator by LuckyJayce.
the class LazyFragment method onCreateView.
@Deprecated
protected final void onCreateView(Bundle savedInstanceState) {
super.onCreateView(savedInstanceState);
this.savedInstanceState = savedInstanceState;
Bundle bundle = getArguments();
if (bundle != null) {
isLazyLoad = bundle.getBoolean(INTENT_BOOLEAN_LAZYLOAD, isLazyLoad);
}
//为什么不直接getUserVisibleHint();而是通过自己存isVisibleToUserState变量判断
//因为v4的25的版本 已经调用 setUserVisibleHint(true),结果到这里getUserVisibleHint是false
// (ps:看了FragmentManager源码Fragment被重新创建有直接赋值isVisibleToUser不知道是不是那里和之前v4有改动的地方)
//所以我默认VISIBLE_STATE_NOTSET,之前没有调用setUserVisibleHint方法,就用系统的getUserVisibleHint,否则就用setUserVisibleHint后保存的值
//总之就是调用了setUserVisibleHint 就使用setUserVisibleHint的值
boolean isVisibleToUser;
if (isVisibleToUserState == VISIBLE_STATE_NOTSET) {
isVisibleToUser = getUserVisibleHint();
} else {
isVisibleToUser = isVisibleToUserState == VISIBLE_STATE_VISIABLE;
}
if (isLazyLoad) {
if (isVisibleToUser && !isInit) {
isInit = true;
onCreateViewLazy(savedInstanceState);
} else {
LayoutInflater layoutInflater = inflater;
if (layoutInflater == null) {
layoutInflater = LayoutInflater.from(getApplicationContext());
}
layout = new FrameLayout(layoutInflater.getContext());
View view = getPreviewLayout(layoutInflater, layout);
if (view != null) {
layout.addView(view);
}
layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
super.setContentView(layout);
}
} else {
isInit = true;
onCreateViewLazy(savedInstanceState);
}
}
use of android.widget.FrameLayout in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ActivityOnResumeHook method afterHookedMethod.
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Activity activity = (Activity) param.thisObject;
String packageName = activity.getPackageName();
String activityName = activity.getLocalClassName();
Intent activityIntent = activity.getIntent();
mSettingsHelper.reload();
if (mSettingsHelper.getBoolean(SettingsKeys.TOAST_ACTIVITY_NAMES, false)) {
String tosatText = mResources.getString(R.string.toast_text_package_name, packageName);
tosatText += "\n";
tosatText += mResources.getString(R.string.toast_text_activity_name, activityName);
Toast.makeText(activity, tosatText, Toast.LENGTH_SHORT).show();
}
if (!mSettingsHelper.isEnabled(packageName, activityName))
return;
if (activityIntent != null && (activityIntent.getFlags() & FLAG_FLOATING_WINDOW) == FLAG_FLOATING_WINDOW)
return;
// From Xposed SwipeBack by PeterCxy
// https://github.com/LOSP/SwipeBack/blob/master/src/us/shandian/mod/swipeback/hook/ModSwipeBack.java
int isFloating = getStaticIntField(findClass("com.android.internal.R.styleable", null), "Window_windowIsFloating");
if (activity.getWindow().getWindowStyle().getBoolean(isFloating, false))
return;
if (mSettingsHelper.getBoolean(SettingsKeys.ALLOW_API_CHANGES, true)) {
PackageManager pm = activity.getPackageManager();
ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if (info.metaData != null) {
Bundle metadata = info.metaData;
if (metadata.containsKey(StatusBarTintApi.METADATA_OVERRIDE_COLORS)) {
return;
}
}
}
String statusBarTint = mSettingsHelper.getTintColor(packageName, activityName, true);
String iconTint = mSettingsHelper.getIconColors(packageName, activityName, true);
String navigationBarTint = mSettingsHelper.getNavigationBarTint(packageName, activityName, false);
String navBarIconTint = mSettingsHelper.getNavigationBarIconTint(packageName, activityName, false);
boolean overridingStatusBar = false;
boolean overridingNavBar = false;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && mSettingsHelper.shouldRespectKitKatApi()) {
int flags = activity.getWindow().getAttributes().flags;
if ((flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) {
log("Activity has status bar transclucency, overriding color to 66000000");
statusBarTint = KK_TRANSPARENT_COLOR_STRING;
overridingStatusBar = true;
}
if ((flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) {
log("Activity has nav bar transclucency, overriding color to 66000000");
navigationBarTint = KK_TRANSPARENT_COLOR_STRING;
overridingNavBar = true;
}
}
int navigationBarTintColor = 0;
int navigationBarIconTintColor = 0;
try {
navigationBarTintColor = Color.parseColor(Utils.addHashIfNeeded(navigationBarTint));
} catch (Throwable t) {
}
try {
navigationBarIconTintColor = Color.parseColor(Utils.addHashIfNeeded(navBarIconTint));
} catch (Throwable t) {
}
int color = 0;
int actionBarTextColor = -2;
boolean colorHandled = false;
if (Utils.hasActionBar() && !overridingStatusBar) {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
// If it's not showing, we shouldn't detect it.
if (actionBar.isShowing()) {
FrameLayout container = (FrameLayout) XposedHelpers.getObjectField(actionBar, "mContainerView");
if (container != null) {
Drawable backgroundDrawable = (Drawable) XposedHelpers.getObjectField(container, "mBackground");
if (backgroundDrawable != null) {
try {
color = Utils.getMainColorFromActionBarDrawable(backgroundDrawable);
colorHandled = true;
if (!mSettingsHelper.shouldAlwaysReverseTint() && mSettingsHelper.shouldReverseTintAbColor(packageName)) {
actionBar.setBackgroundDrawable(new IgnoredColorDrawable(color));
}
} catch (IllegalArgumentException e) {
}
container.invalidate();
}
try {
TextView mTitleView = (TextView) getObjectField(getObjectField(container, "mActionBarView"), "mTitleView");
if (mTitleView != null) {
if (mTitleView.getVisibility() == View.VISIBLE) {
actionBarTextColor = mTitleView.getCurrentTextColor();
}
}
} catch (Throwable t) {
}
}
}
}
}
int statusBarTintColor = color;
int iconTintColor;
if (statusBarTint != null) {
try {
statusBarTintColor = Color.parseColor(statusBarTint);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
int defaultNormal = mSettingsHelper.getDefaultTint(Tint.ICON);
int invertedIconTint = mSettingsHelper.getDefaultTint(Tint.ICON_INVERTED);
if (iconTint == null) {
if (actionBarTextColor != -2) {
iconTintColor = actionBarTextColor;
} else {
iconTintColor = Utils.getIconColorForColor(statusBarTintColor, defaultNormal, invertedIconTint, mSettingsHelper.getHsvMax());
}
} else {
iconTintColor = Color.parseColor(iconTint);
}
Intent intent = new Intent(StatusBarTintApi.INTENT_CHANGE_COLOR_NAME);
if (statusBarTint != null)
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT, statusBarTintColor);
if (iconTint != null)
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_ICON_TINT, iconTintColor);
if (colorHandled == true) {
if (!intent.hasExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT))
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT, overridingStatusBar ? KITKAT_TRANSPARENT_COLOR : color);
if (!intent.hasExtra(StatusBarTintApi.KEY_STATUS_BAR_ICON_TINT))
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_ICON_TINT, overridingStatusBar ? Color.WHITE : iconTintColor);
}
/* We failed to get a colour, fall back to the defaults */
if (!intent.hasExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT))
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT, overridingStatusBar ? KITKAT_TRANSPARENT_COLOR : mSettingsHelper.getDefaultTint(Tint.STATUS_BAR));
if (!intent.hasExtra(StatusBarTintApi.KEY_STATUS_BAR_ICON_TINT))
intent.putExtra(StatusBarTintApi.KEY_STATUS_BAR_ICON_TINT, overridingStatusBar ? Color.WHITE : defaultNormal);
intent.putExtra(StatusBarTintApi.KEY_NAVIGATION_BAR_TINT, overridingNavBar ? KITKAT_TRANSPARENT_COLOR : navigationBarTintColor);
intent.putExtra(StatusBarTintApi.KEY_NAVIGATION_BAR_ICON_TINT, overridingNavBar ? Color.WHITE : navigationBarIconTintColor);
intent.putExtra("time", System.currentTimeMillis());
intent.putExtra("link_panels", mSettingsHelper.shouldLinkPanels(packageName, null));
if (mSettingsHelper.shouldAlwaysReverseTint() && mSettingsHelper.shouldReverseTintAbColor(packageName)) {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null && actionBar.isShowing()) {
// Reverse tint
actionBar.setBackgroundDrawable(new IgnoredColorDrawable(intent.getIntExtra(StatusBarTintApi.KEY_STATUS_BAR_TINT, -1)));
}
}
activity.sendBroadcast(intent);
}
use of android.widget.FrameLayout in project FloatingStickies by MohammadAdib.
the class StandOutWindow method onTouchHandleMove.
@SuppressWarnings("deprecation")
public boolean onTouchHandleMove(final int id, final Window window, View view, MotionEvent event) {
try {
StandOutLayoutParams params = window.getLayoutParams();
// how much you have to move in either direction in order for the
// gesture to be a move and not tap
int totalDeltaX = window.touchInfo.lastX - window.touchInfo.firstX;
int totalDeltaY = window.touchInfo.lastY - window.touchInfo.firstY;
Animation mFadeOut = AnimationUtils.loadAnimation(this, R.anim.dock);
final Animation mFadeOut2 = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
final Animation mFadeIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
final Animation mFadeIn2 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation mFadeInG = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
final Animation mFadeOutG = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
final View win = window.findViewById(R.id.window);
final ImageView dockIcon = (ImageView) window.findViewById(R.id.preview);
final ImageView dockGlow = (ImageView) window.findViewById(R.id.dockglow);
final Drawable drawable = getResources().getDrawable(R.drawable.pencil);
FrameLayout body = (FrameLayout) window.findViewById(R.id.body);
dockIcon.setImageDrawable(getResources().getDrawable((Integer) body.getTag()));
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
window.touchInfo.lastX = (int) event.getRawX();
window.touchInfo.lastY = (int) event.getRawY();
window.touchInfo.firstX = window.touchInfo.lastX;
window.touchInfo.firstY = window.touchInfo.lastY;
break;
case MotionEvent.ACTION_MOVE:
int deltaX = (int) event.getRawX() - window.touchInfo.lastX;
int deltaY = (int) event.getRawY() - window.touchInfo.lastY;
window.touchInfo.lastX = (int) event.getRawX();
window.touchInfo.lastY = (int) event.getRawY();
if (window.touchInfo.moving || Math.abs(totalDeltaX) >= params.threshold || Math.abs(totalDeltaY) >= params.threshold) {
window.touchInfo.moving = true;
// if window is moveable
if (Utils.isSet(window.flags, StandOutFlags.FLAG_BODY_MOVE_ENABLE)) {
// update the position of the window
if (event.getPointerCount() == 1) {
params.x += deltaX;
params.y += deltaY;
}
window.edit().setPosition(params.x, params.y).commit();
if (window.getWidth() < mWindowManager.getDefaultDisplay().getWidth()) {
if (params.x > 0 && window.touchEdge && window.fullSize) {
dockGlow.startAnimation(mFadeOutG);
dockGlow.setVisibility(View.GONE);
window.touchEdge = false;
}
if (params.x > pxFromDp(8)) {
window.touchEdge = false;
// Attempt at undocking.
if (!window.fullSize) {
window.fullSize = true;
undocking = true;
dockIcon.setVisibility(View.GONE);
mFadeOut2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d("FloatingFolder", "Animation started");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Log.d("FloatingFolder", "Animation ended");
// post so that screenshot
// is
// invisible
// before anything else
// happens
dockIcon.post(new Runnable() {
@Override
public void run() {
StandOutLayoutParams params = window.getLayoutParams();
Drawable drawable = dockIcon.getDrawable();
dockIcon.setImageDrawable(null);
params.y = params.y - window.dockH / 2 + drawable.getIntrinsicHeight() / 2;
params.width = window.dockW;
params.height = window.dockH;
updateViewLayout(id, params);
win.setVisibility(View.VISIBLE);
gracePeriod = System.currentTimeMillis();
win.startAnimation(mFadeIn2);
undocking = false;
}
});
}
});
gracePeriod = System.currentTimeMillis();
dockIcon.startAnimation(mFadeOut2);
}
} else {
if (!window.touchEdge && params.x <= 0) {
dockGlow.setVisibility(View.VISIBLE);
dockGlow.startAnimation(mFadeInG);
window.touchEdge = true;
}
}
}
} else {
window.edit().setPosition(params.x, params.y).commit();
}
}
break;
case MotionEvent.ACTION_UP:
if (window.fullSize && window.getWidth() < mWindowManager.getDefaultDisplay().getWidth()) {
// Attempt at docking
if (params.x <= 0 && !undocking) {
window.dockH = window.getHeight();
window.dockW = window.getWidth();
window.fullSize = false;
mFadeOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
dockGlow.setVisibility(View.GONE);
win.setVisibility(View.GONE);
// post so that the folder is invisible
// before
// anything else happens
dockIcon.post(new Runnable() {
@Override
public void run() {
StandOutLayoutParams params = window.getLayoutParams();
params.y = params.y + params.height / 2 - pxFromDp(40) / 2;
params.width = pxFromDp(40);
params.height = pxFromDp(40);
updateViewLayout(id, params);
dockIcon.setVisibility(View.VISIBLE);
dockIcon.startAnimation(mFadeIn);
}
});
}
});
gracePeriod = System.currentTimeMillis();
win.startAnimation(mFadeOut);
}
window.touchInfo.moving = false;
onMove(id, window, view, event);
break;
}
if (!window.fullSize && params.x > 0 && params.x <= pxFromDp(8)) {
window.edit().setPosition(0, params.y).commit();
}
// bring to front on tap
boolean tap = Math.abs(totalDeltaX) < params.threshold && Math.abs(totalDeltaY) < params.threshold;
if (tap) {
StandOutWindow.this.bringToFront(id);
}
}
} catch (Exception e) {
}
return true;
}
use of android.widget.FrameLayout in project material-dialogs by afollestad.
the class DialogInit method init.
@SuppressWarnings("ConstantConditions")
@UiThread
public static void init(final MaterialDialog dialog) {
final MaterialDialog.Builder builder = dialog.builder;
// Set cancelable flag and dialog background color
dialog.setCancelable(builder.cancelable);
dialog.setCanceledOnTouchOutside(builder.canceledOnTouchOutside);
if (builder.backgroundColor == 0) {
builder.backgroundColor = DialogUtils.resolveColor(builder.context, R.attr.md_background_color, DialogUtils.resolveColor(dialog.getContext(), R.attr.colorBackgroundFloating));
}
if (builder.backgroundColor != 0) {
GradientDrawable drawable = new GradientDrawable();
drawable.setCornerRadius(builder.context.getResources().getDimension(R.dimen.md_bg_corner_radius));
drawable.setColor(builder.backgroundColor);
dialog.getWindow().setBackgroundDrawable(drawable);
}
// Retrieve color theme attributes
if (!builder.positiveColorSet) {
builder.positiveColor = DialogUtils.resolveActionTextColorStateList(builder.context, R.attr.md_positive_color, builder.positiveColor);
}
if (!builder.neutralColorSet) {
builder.neutralColor = DialogUtils.resolveActionTextColorStateList(builder.context, R.attr.md_neutral_color, builder.neutralColor);
}
if (!builder.negativeColorSet) {
builder.negativeColor = DialogUtils.resolveActionTextColorStateList(builder.context, R.attr.md_negative_color, builder.negativeColor);
}
if (!builder.widgetColorSet) {
builder.widgetColor = DialogUtils.resolveColor(builder.context, R.attr.md_widget_color, builder.widgetColor);
}
// Retrieve default title/content colors
if (!builder.titleColorSet) {
final int titleColorFallback = DialogUtils.resolveColor(dialog.getContext(), android.R.attr.textColorPrimary);
builder.titleColor = DialogUtils.resolveColor(builder.context, R.attr.md_title_color, titleColorFallback);
}
if (!builder.contentColorSet) {
final int contentColorFallback = DialogUtils.resolveColor(dialog.getContext(), android.R.attr.textColorSecondary);
builder.contentColor = DialogUtils.resolveColor(builder.context, R.attr.md_content_color, contentColorFallback);
}
if (!builder.itemColorSet) {
builder.itemColor = DialogUtils.resolveColor(builder.context, R.attr.md_item_color, builder.contentColor);
}
// Retrieve references to views
dialog.title = (TextView) dialog.view.findViewById(R.id.md_title);
dialog.icon = (ImageView) dialog.view.findViewById(R.id.md_icon);
dialog.titleFrame = dialog.view.findViewById(R.id.md_titleFrame);
dialog.content = (TextView) dialog.view.findViewById(R.id.md_content);
dialog.recyclerView = (RecyclerView) dialog.view.findViewById(R.id.md_contentRecyclerView);
dialog.checkBoxPrompt = (CheckBox) dialog.view.findViewById(R.id.md_promptCheckbox);
// Button views initially used by checkIfStackingNeeded()
dialog.positiveButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultPositive);
dialog.neutralButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultNeutral);
dialog.negativeButton = (MDButton) dialog.view.findViewById(R.id.md_buttonDefaultNegative);
// Don't allow the submit button to not be shown for input dialogs
if (builder.inputCallback != null && builder.positiveText == null) {
builder.positiveText = builder.context.getText(android.R.string.ok);
}
// Set up the initial visibility of action buttons based on whether or not text was set
dialog.positiveButton.setVisibility(builder.positiveText != null ? View.VISIBLE : View.GONE);
dialog.neutralButton.setVisibility(builder.neutralText != null ? View.VISIBLE : View.GONE);
dialog.negativeButton.setVisibility(builder.negativeText != null ? View.VISIBLE : View.GONE);
// Set up the focus of action buttons
dialog.positiveButton.setFocusable(true);
dialog.neutralButton.setFocusable(true);
dialog.negativeButton.setFocusable(true);
if (builder.positiveFocus) {
dialog.positiveButton.requestFocus();
}
if (builder.neutralFocus) {
dialog.neutralButton.requestFocus();
}
if (builder.negativeFocus) {
dialog.negativeButton.requestFocus();
}
// Setup icon
if (builder.icon != null) {
dialog.icon.setVisibility(View.VISIBLE);
dialog.icon.setImageDrawable(builder.icon);
} else {
Drawable d = DialogUtils.resolveDrawable(builder.context, R.attr.md_icon);
if (d != null) {
dialog.icon.setVisibility(View.VISIBLE);
dialog.icon.setImageDrawable(d);
} else {
dialog.icon.setVisibility(View.GONE);
}
}
// Setup icon size limiting
int maxIconSize = builder.maxIconSize;
if (maxIconSize == -1) {
maxIconSize = DialogUtils.resolveDimension(builder.context, R.attr.md_icon_max_size);
}
if (builder.limitIconToDefaultSize || DialogUtils.resolveBoolean(builder.context, R.attr.md_icon_limit_icon_to_default_size)) {
maxIconSize = builder.context.getResources().getDimensionPixelSize(R.dimen.md_icon_max_size);
}
if (maxIconSize > -1) {
dialog.icon.setAdjustViewBounds(true);
dialog.icon.setMaxHeight(maxIconSize);
dialog.icon.setMaxWidth(maxIconSize);
dialog.icon.requestLayout();
}
// Setup divider color in case content scrolls
if (!builder.dividerColorSet) {
final int dividerFallback = DialogUtils.resolveColor(dialog.getContext(), R.attr.md_divider);
builder.dividerColor = DialogUtils.resolveColor(builder.context, R.attr.md_divider_color, dividerFallback);
}
dialog.view.setDividerColor(builder.dividerColor);
// Setup title and title frame
if (dialog.title != null) {
dialog.setTypeface(dialog.title, builder.mediumFont);
dialog.title.setTextColor(builder.titleColor);
dialog.title.setGravity(builder.titleGravity.getGravityInt());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ResourceType
dialog.title.setTextAlignment(builder.titleGravity.getTextAlignment());
}
if (builder.title == null) {
dialog.titleFrame.setVisibility(View.GONE);
} else {
dialog.title.setText(builder.title);
dialog.titleFrame.setVisibility(View.VISIBLE);
}
}
// Setup content
if (dialog.content != null) {
dialog.content.setMovementMethod(new LinkMovementMethod());
dialog.setTypeface(dialog.content, builder.regularFont);
dialog.content.setLineSpacing(0f, builder.contentLineSpacingMultiplier);
if (builder.linkColor == null) {
dialog.content.setLinkTextColor(DialogUtils.resolveColor(dialog.getContext(), android.R.attr.textColorPrimary));
} else {
dialog.content.setLinkTextColor(builder.linkColor);
}
dialog.content.setTextColor(builder.contentColor);
dialog.content.setGravity(builder.contentGravity.getGravityInt());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ResourceType
dialog.content.setTextAlignment(builder.contentGravity.getTextAlignment());
}
if (builder.content != null) {
dialog.content.setText(builder.content);
dialog.content.setVisibility(View.VISIBLE);
} else {
dialog.content.setVisibility(View.GONE);
}
}
// Setup prompt checkbox
if (dialog.checkBoxPrompt != null) {
dialog.checkBoxPrompt.setText(builder.checkBoxPrompt);
dialog.checkBoxPrompt.setChecked(builder.checkBoxPromptInitiallyChecked);
dialog.checkBoxPrompt.setOnCheckedChangeListener(builder.checkBoxPromptListener);
dialog.setTypeface(dialog.checkBoxPrompt, builder.regularFont);
dialog.checkBoxPrompt.setTextColor(builder.contentColor);
MDTintHelper.setTint(dialog.checkBoxPrompt, builder.widgetColor);
}
// Setup action buttons
dialog.view.setButtonGravity(builder.buttonsGravity);
dialog.view.setButtonStackedGravity(builder.btnStackedGravity);
dialog.view.setStackingBehavior(builder.stackingBehavior);
boolean textAllCaps;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
textAllCaps = DialogUtils.resolveBoolean(builder.context, android.R.attr.textAllCaps, true);
if (textAllCaps) {
textAllCaps = DialogUtils.resolveBoolean(builder.context, R.attr.textAllCaps, true);
}
} else {
textAllCaps = DialogUtils.resolveBoolean(builder.context, R.attr.textAllCaps, true);
}
MDButton positiveTextView = dialog.positiveButton;
dialog.setTypeface(positiveTextView, builder.mediumFont);
positiveTextView.setAllCapsCompat(textAllCaps);
positiveTextView.setText(builder.positiveText);
positiveTextView.setTextColor(builder.positiveColor);
dialog.positiveButton.setStackedSelector(dialog.getButtonSelector(DialogAction.POSITIVE, true));
dialog.positiveButton.setDefaultSelector(dialog.getButtonSelector(DialogAction.POSITIVE, false));
dialog.positiveButton.setTag(DialogAction.POSITIVE);
dialog.positiveButton.setOnClickListener(dialog);
dialog.positiveButton.setVisibility(View.VISIBLE);
MDButton negativeTextView = dialog.negativeButton;
dialog.setTypeface(negativeTextView, builder.mediumFont);
negativeTextView.setAllCapsCompat(textAllCaps);
negativeTextView.setText(builder.negativeText);
negativeTextView.setTextColor(builder.negativeColor);
dialog.negativeButton.setStackedSelector(dialog.getButtonSelector(DialogAction.NEGATIVE, true));
dialog.negativeButton.setDefaultSelector(dialog.getButtonSelector(DialogAction.NEGATIVE, false));
dialog.negativeButton.setTag(DialogAction.NEGATIVE);
dialog.negativeButton.setOnClickListener(dialog);
dialog.negativeButton.setVisibility(View.VISIBLE);
MDButton neutralTextView = dialog.neutralButton;
dialog.setTypeface(neutralTextView, builder.mediumFont);
neutralTextView.setAllCapsCompat(textAllCaps);
neutralTextView.setText(builder.neutralText);
neutralTextView.setTextColor(builder.neutralColor);
dialog.neutralButton.setStackedSelector(dialog.getButtonSelector(DialogAction.NEUTRAL, true));
dialog.neutralButton.setDefaultSelector(dialog.getButtonSelector(DialogAction.NEUTRAL, false));
dialog.neutralButton.setTag(DialogAction.NEUTRAL);
dialog.neutralButton.setOnClickListener(dialog);
dialog.neutralButton.setVisibility(View.VISIBLE);
// Setup list dialog stuff
if (builder.listCallbackMultiChoice != null) {
dialog.selectedIndicesList = new ArrayList<>();
}
if (dialog.recyclerView != null) {
if (builder.adapter == null) {
// Determine list type
if (builder.listCallbackSingleChoice != null) {
dialog.listType = MaterialDialog.ListType.SINGLE;
} else if (builder.listCallbackMultiChoice != null) {
dialog.listType = MaterialDialog.ListType.MULTI;
if (builder.selectedIndices != null) {
dialog.selectedIndicesList = new ArrayList<>(Arrays.asList(builder.selectedIndices));
builder.selectedIndices = null;
}
} else {
dialog.listType = MaterialDialog.ListType.REGULAR;
}
builder.adapter = new DefaultRvAdapter(dialog, MaterialDialog.ListType.getLayoutForType(dialog.listType));
} else if (builder.adapter instanceof MDAdapter) {
// Notify simple list adapter of the dialog it belongs to
((MDAdapter) builder.adapter).setDialog(dialog);
}
}
// Setup progress dialog stuff if needed
setupProgressDialog(dialog);
// Setup input dialog stuff if needed
setupInputDialog(dialog);
// Setup custom views
if (builder.customView != null) {
((MDRootLayout) dialog.view.findViewById(R.id.md_root)).noTitleNoPadding();
FrameLayout frame = (FrameLayout) dialog.view.findViewById(R.id.md_customViewFrame);
dialog.customViewFrame = frame;
View innerView = builder.customView;
if (innerView.getParent() != null) {
((ViewGroup) innerView.getParent()).removeView(innerView);
}
if (builder.wrapCustomViewInScroll) {
/* Apply the frame padding to the content, this allows the ScrollView to draw it's
over scroll glow without clipping */
final Resources r = dialog.getContext().getResources();
final int framePadding = r.getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
final ScrollView sv = new ScrollView(dialog.getContext());
int paddingTop = r.getDimensionPixelSize(R.dimen.md_content_padding_top);
int paddingBottom = r.getDimensionPixelSize(R.dimen.md_content_padding_bottom);
sv.setClipToPadding(false);
if (innerView instanceof EditText) {
// Setting padding to an EditText causes visual errors, set it to the parent instead
sv.setPadding(framePadding, paddingTop, framePadding, paddingBottom);
} else {
// Setting padding to scroll view pushes the scroll bars out, don't do it if not necessary (like above)
sv.setPadding(0, paddingTop, 0, paddingBottom);
innerView.setPadding(framePadding, 0, framePadding, 0);
}
sv.addView(innerView, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
innerView = sv;
}
frame.addView(innerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
// Setup user listeners
if (builder.showListener != null) {
dialog.setOnShowListener(builder.showListener);
}
if (builder.cancelListener != null) {
dialog.setOnCancelListener(builder.cancelListener);
}
if (builder.dismissListener != null) {
dialog.setOnDismissListener(builder.dismissListener);
}
if (builder.keyListener != null) {
dialog.setOnKeyListener(builder.keyListener);
}
// Setup internal show listener
dialog.setOnShowListenerInternal();
// Other internal initialization
dialog.invalidateList();
dialog.setViewInternal(dialog.view);
dialog.checkIfListInitScroll();
// Min height and max width calculations
WindowManager wm = dialog.getWindow().getWindowManager();
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
final int windowWidth = size.x;
final int windowHeight = size.y;
final int windowVerticalPadding = builder.context.getResources().getDimensionPixelSize(R.dimen.md_dialog_vertical_margin);
final int windowHorizontalPadding = builder.context.getResources().getDimensionPixelSize(R.dimen.md_dialog_horizontal_margin);
final int maxWidth = builder.context.getResources().getDimensionPixelSize(R.dimen.md_dialog_max_width);
final int calculatedWidth = windowWidth - (windowHorizontalPadding * 2);
dialog.view.setMaxHeight(windowHeight - windowVerticalPadding * 2);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = Math.min(maxWidth, calculatedWidth);
dialog.getWindow().setAttributes(lp);
}
use of android.widget.FrameLayout in project phonegap-facebook-plugin by Wizcorp.
the class WebDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
spinner = new ProgressDialog(getContext());
spinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
spinner.setMessage(getContext().getString(R.string.com_facebook_loading));
spinner.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
dismiss();
}
});
requestWindowFeature(Window.FEATURE_NO_TITLE);
contentFrameLayout = new FrameLayout(getContext());
// First calculate how big the frame layout should be
calculateSize();
getWindow().setGravity(Gravity.CENTER);
// resize the dialog if the soft keyboard comes up
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
/* Create the 'x' image, but don't add to the contentFrameLayout layout yet
* at this point, we only need to know its drawable width and height
* to place the webview
*/
createCrossImage();
/* Now we know 'x' drawable width and height,
* layout the webview and add it the contentFrameLayout layout
*/
int crossWidth = crossImageView.getDrawable().getIntrinsicWidth();
setUpWebView(crossWidth / 2 + 1);
/* Finally add the 'x' image to the contentFrameLayout layout and
* add contentFrameLayout to the Dialog view
*/
contentFrameLayout.addView(crossImageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setContentView(contentFrameLayout);
}
Aggregations