use of android.widget.PopupWindow in project Etar-Calendar by Etar-Group.
the class DayView method init.
private void init(Context context) {
setFocusable(true);
// Allow focus in touch mode so that we can do keyboard shortcuts
// even after we've entered touch mode.
setFocusableInTouchMode(true);
setClickable(true);
setOnCreateContextMenuListener(this);
mFirstDayOfWeek = Utils.getFirstDayOfWeek(context);
mCurrentTime = new Time(Utils.getTimeZone(context, mTZUpdater));
long currentTime = System.currentTimeMillis();
mCurrentTime.set(currentTime);
mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff);
String theme = Utils.getTheme(context);
if (theme.equals("dark")) {
mWeek_todayColor = mResources.getColor(R.color.week_today_dark);
mWeek_saturdayColor = mResources.getColor(R.color.week_saturday_dark);
mWeek_sundayColor = mResources.getColor(R.color.week_sunday_dark);
mCalendarDateBannerTextColor = mResources.getColor(R.color.calendar_date_banner_text_color_dark);
mFutureBgColorRes = mResources.getColor(R.color.calendar_future_bg_color_dark);
mBgColor = mResources.getColor(R.color.calendar_hour_background_dark);
mCalendarHourLabelColor = mResources.getColor(R.color.calendar_hour_label_dark);
mCalendarGridAreaSelected = mResources.getColor(R.color.calendar_grid_area_selected_dark);
mCalendarGridLineInnerHorizontalColor = mResources.getColor(R.color.calendar_grid_line_inner_horizontal_color_dark);
mCalendarGridLineInnerVerticalColor = mResources.getColor(R.color.calendar_grid_line_inner_vertical_color_dark);
mPressedColor = mResources.getColor(R.color.pressed_dark);
mClickedColor = mResources.getColor(R.color.day_event_clicked_background_color_dark);
mEventTextColor = mResources.getColor(R.color.calendar_event_text_color_dark);
mMoreEventsTextColor = mResources.getColor(R.color.month_event_other_color_dark);
} else {
mWeek_todayColor = mResources.getColor(R.color.week_today);
mWeek_saturdayColor = mResources.getColor(R.color.week_saturday);
mWeek_sundayColor = mResources.getColor(R.color.week_sunday);
mCalendarDateBannerTextColor = mResources.getColor(R.color.calendar_date_banner_text_color);
mFutureBgColorRes = mResources.getColor(R.color.calendar_future_bg_color);
mBgColor = mResources.getColor(R.color.calendar_hour_background);
mCalendarGridAreaSelected = mResources.getColor(R.color.calendar_grid_area_selected);
mCalendarGridLineInnerHorizontalColor = mResources.getColor(R.color.calendar_grid_line_inner_horizontal_color);
mCalendarGridLineInnerVerticalColor = mResources.getColor(R.color.calendar_grid_line_inner_vertical_color);
mCalendarHourLabelColor = mResources.getColor(R.color.calendar_hour_label);
mPressedColor = mResources.getColor(R.color.pressed);
mClickedColor = mResources.getColor(R.color.day_event_clicked_background_color);
mEventTextColor = mResources.getColor(R.color.calendar_event_text_color);
mMoreEventsTextColor = mResources.getColor(R.color.month_event_other_color);
}
mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE);
mEventTextPaint.setTextAlign(Paint.Align.LEFT);
mEventTextPaint.setAntiAlias(true);
int gridLineColor = mResources.getColor(R.color.calendar_grid_line_highlight_color);
Paint p = mSelectionPaint;
p.setColor(gridLineColor);
p.setStyle(Style.FILL);
p.setAntiAlias(false);
p = mPaint;
p.setAntiAlias(true);
// Allocate space for 2 weeks worth of weekday names so that we can
// easily start the week display at any week day.
mDayStrs = new String[14];
// Also create an array of 2-letter abbreviations.
mDayStrs2Letter = new String[14];
for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
int index = i - Calendar.SUNDAY;
// e.g. Tue for Tuesday
mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM);
mDayStrs[index + 7] = mDayStrs[index];
// e.g. Tu for Tuesday
mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT);
// If we don't have 2-letter day strings, fall back to 1-letter.
if (mDayStrs2Letter[index].equals(mDayStrs[index])) {
mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST);
}
mDayStrs2Letter[index + 7] = mDayStrs2Letter[index];
}
// Figure out how much space we need for the 3-letter abbrev names
// in the worst case.
p.setTextSize(DATE_HEADER_FONT_SIZE);
p.setTypeface(mBold);
String[] dateStrs = { " 28", " 30" };
mDateStrWidth = computeMaxStringWidth(0, dateStrs, p);
p.setTextSize(DAY_HEADER_FONT_SIZE);
mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p);
p.setTextSize(HOURS_TEXT_SIZE);
p.setTypeface(null);
handleOnResume();
String[] timeStrs = { "12 AM", "12 PM", "22:00" };
p.setTextSize(HOURS_TEXT_SIZE);
mHoursWidth = HOURS_MARGIN + computeMaxStringWidth(mHoursWidth, timeStrs, p);
GRID_LINE_LEFT_MARGIN = mHoursWidth;
LayoutInflater inflater;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mPopupView = inflater.inflate(R.layout.bubble_event, null);
mPopupView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mPopup = new PopupWindow(context);
mPopup.setContentView(mPopupView);
Resources.Theme dialogTheme = getResources().newTheme();
dialogTheme.applyStyle(android.R.style.Theme_Dialog, true);
TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
mPopup.setBackgroundDrawable(ta.getDrawable(0));
ta.recycle();
// Enable touching the popup window
mPopupView.setOnClickListener(this);
// Catch long clicks for creating a new event
setOnLongClickListener(this);
mBaseDate = new Time(Utils.getTimeZone(context, mTZUpdater));
long millis = System.currentTimeMillis();
mBaseDate.set(millis);
mEarliestStartHour = new int[mNumDays];
mHasAllDayEvent = new boolean[mNumDays];
// mLines is the array of points used with Canvas.drawLines() in
// drawGridBackground() and drawAllDayEvents(). Its size depends
// on the max number of lines that can ever be drawn by any single
// drawLines() call in either of those methods.
final int maxGridLines = // max horizontal lines we might draw
(24 + 1) + // max vertical lines we might draw
(mNumDays + 1);
mLines = new float[maxGridLines * 4];
}
use of android.widget.PopupWindow in project android_frameworks_base by AOSPA.
the class FloatingToolbar method createPopupWindow.
private static PopupWindow createPopupWindow(ViewGroup content) {
ViewGroup popupContentHolder = new LinearLayout(content.getContext());
PopupWindow popupWindow = new PopupWindow(popupContentHolder);
// TODO: Use .setLayoutInScreenEnabled(true) instead of .setClippingEnabled(false)
// unless FLAG_LAYOUT_IN_SCREEN has any unintentional side-effects.
popupWindow.setClippingEnabled(false);
popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL);
popupWindow.setAnimationStyle(0);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
content.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
popupContentHolder.addView(content);
return popupWindow;
}
use of android.widget.PopupWindow in project ABPlayer by winkstu.
the class MediaController method initFloatingWindow.
private void initFloatingWindow() {
mWindow = new PopupWindow(mContext);
mWindow.setFocusable(true);
mWindow.setBackgroundDrawable(null);
mWindow.setOutsideTouchable(true);
}
use of android.widget.PopupWindow in project WordPress-Android by wordpress-mobile.
the class MediaBrowserActivity method setupAddMenuPopup.
/** Setup the popup that allows you to add new media from camera, video camera or local files **/
private void setupAddMenuPopup() {
String capturePhoto = getString(R.string.media_add_popup_capture_photo);
String captureVideo = getString(R.string.media_add_popup_capture_video);
String pickPhotoFromGallery = getString(R.string.select_photo);
String pickVideoFromGallery = getString(R.string.select_video);
String[] items = new String[] { capturePhoto, captureVideo, pickPhotoFromGallery, pickVideoFromGallery };
@SuppressLint("InflateParams") View menuView = getLayoutInflater().inflate(R.layout.actionbar_add_media, null, false);
final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.actionbar_add_media_cell, items);
ListView listView = (ListView) menuView.findViewById(R.id.actionbar_add_media_listview);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
adapter.notifyDataSetChanged();
if (position == 0) {
MediaBrowserActivity enclosingActivity = MediaBrowserActivity.this;
WordPressMediaUtils.launchCamera(enclosingActivity, BuildConfig.APPLICATION_ID, enclosingActivity);
} else if (position == 1) {
WordPressMediaUtils.launchVideoCamera(MediaBrowserActivity.this);
} else if (position == 2) {
WordPressMediaUtils.launchPictureLibrary(MediaBrowserActivity.this);
} else if (position == 3) {
WordPressMediaUtils.launchVideoLibrary(MediaBrowserActivity.this);
}
mAddMediaPopup.dismiss();
}
});
int width = getResources().getDimensionPixelSize(R.dimen.action_bar_spinner_width);
mAddMediaPopup = new PopupWindow(menuView, width, ViewGroup.LayoutParams.WRAP_CONTENT, true);
mAddMediaPopup.setBackgroundDrawable(new ColorDrawable());
}
use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.
the class UnlearnFragment method setupSettings.
private void setupSettings() {
final Button btnSettings = (Button) m_root.findViewById(R.id.btnSettings);
btnSettings.setVisibility(View.VISIBLE);
btnSettings.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
final PopupWindow pw = Util.showPopup(getActivity(), R.layout.skill_settings, true, btnSettings, 5, 5);
View v = pw.getContentView();
Button btn = (Button) v.findViewById(R.id.btn_learning);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
pw.dismiss();
((HomeScreen) getActivity()).setCurrentFragmentSkills();
}
});
btn = (Button) v.findViewById(R.id.btn_unlearning);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
pw.dismiss();
((HomeScreen) getActivity()).setCurrentFragmentUnlearn();
}
});
}
});
}
Aggregations