use of android.widget.PopupWindow in project platform_frameworks_base by android.
the class DecorView method createStandaloneActionMode.
private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
endOnGoingFadeAnimation();
cleanupPrimaryActionMode();
// cleanupPrimaryActionMode() invocation above.
if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
if (mWindow.isFloating()) {
// Use the action bar theme.
final TypedValue outValue = new TypedValue();
final Resources.Theme baseTheme = mContext.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
final Context actionBarContext;
if (outValue.resourceId != 0) {
final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
actionBarTheme.setTo(baseTheme);
actionBarTheme.applyStyle(outValue.resourceId, true);
actionBarContext = new ContextThemeWrapper(mContext, 0);
actionBarContext.getTheme().setTo(actionBarTheme);
} else {
actionBarContext = mContext;
}
mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
mPrimaryActionModePopup.setWidth(MATCH_PARENT);
actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
mPrimaryActionModeView.setContentHeight(height);
mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
mShowPrimaryActionModePopup = new Runnable() {
public void run() {
mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
endOnGoingFadeAnimation();
if (shouldAnimatePrimaryActionModeView()) {
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
mFadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mPrimaryActionModeView.setVisibility(VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mPrimaryActionModeView.setAlpha(1f);
mFadeAnim = null;
}
});
mFadeAnim.start();
} else {
mPrimaryActionModeView.setAlpha(1f);
mPrimaryActionModeView.setVisibility(VISIBLE);
}
}
};
} else {
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
if (stub != null) {
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
mPrimaryActionModePopup = null;
}
}
}
if (mPrimaryActionModeView != null) {
mPrimaryActionModeView.killMode();
ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
return mode;
}
return null;
}
use of android.widget.PopupWindow in project FloatingStickies by MohammadAdib.
the class Window method getDropDownList.
public PopupWindow getDropDownList() {
final List<DropDownListItem> items = new ArrayList<DropDownListItem>();
items.add(new DropDownListItem("Copy", new Runnable() {
@Override
public void run() {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(getText());
}
}));
items.add(new DropDownListItem("Paste", new Runnable() {
@Override
public void run() {
try {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
setText(getText() + clipboard.getText().toString());
} catch (Exception e) {
}
}
}));
items.add(new DropDownListItem("Share", new Runnable() {
@Override
public void run() {
// Share
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Floating Stickies");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getText());
mContext.startActivity(Intent.createChooser(sharingIntent, "Share Sticky").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}));
// turn item list into views in PopupWindow
LinearLayout list = new LinearLayout(mContext);
list.setOrientation(LinearLayout.VERTICAL);
ScrollView scroller = new ScrollView(mContext);
scroller.addView(list);
final PopupWindow dropDown = new PopupWindow(scroller, StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.WRAP_CONTENT, true);
for (final DropDownListItem item : items) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup listItem = (ViewGroup) inflater.inflate(R.layout.drop_down_list_item, null);
list.addView(listItem);
TextView textView = (TextView) listItem.findViewById(R.id.text);
textView.setText(item.text);
listItem.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dropDown.dismiss();
item.action.run();
}
});
}
return dropDown;
}
use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.
the class Util method showPopup.
public static PopupWindow showPopup(Activity act, int nLayout, boolean bDropDown, View vAnchor, int offsetX, int offsetY) {
final PopupWindow pw = new PopupWindow(act);
LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(nLayout, null, false);
pw.setContentView(v);
pw.setFocusable(true);
pw.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
pw.setOutsideTouchable(true);
pw.setTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
if (bDropDown)
pw.showAsDropDown(vAnchor, offsetX, offsetY);
else
pw.showAtLocation(vAnchor.getRootView(), Gravity.NO_GRAVITY, offsetX, offsetY);
return pw;
}
use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.
the class ProfileFragment 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) {
int nLayout = m_bOtherProfile ? R.layout.profile_settings : R.layout.profile_settings2;
final PopupWindow pw = Util.showPopup(getActivity(), nLayout, true, btnSettings, 5, 5);
View v = pw.getContentView();
Button btn = (Button) v.findViewById(R.id.btn_filter_all);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
m_currentActType = ActivityFragment.ACTIVITY_TYPE_ALL;
pw.dismiss();
getProfileInfo(false);
}
});
btn = (Button) v.findViewById(R.id.btn_filter_updates);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
m_currentActType = ActivityFragment.ACTIVITY_TYPE_UPDATES;
getProfileInfo(false);
pw.dismiss();
}
});
btn = (Button) v.findViewById(R.id.btn_add_remove_friend);
if (btn != null) {
btn.setBackgroundResource(m_bFriend ? R.drawable.friend_remove_button_background : R.drawable.friend_add_button_background);
btn.setText(m_bFriend ? "Remove from friends" : "Add to friends");
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AddOrRemoveFriend(m_bFriend, m_playerTsid);
m_bFriend = !m_bFriend;
pw.dismiss();
}
});
}
}
});
}
use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.
the class ActivityFragment method initTopMenu.
private void initTopMenu() {
m_btnFilter = (Button) m_root.findViewById(R.id.btnFilter);
m_btnFilter.setVisibility(View.VISIBLE);
m_btnNewUpdate = (Button) m_root.findViewById(R.id.btnNewUpdate);
m_btnNewUpdate.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
FlurryAgent.logEvent("Activity - 'Compose' button pressed");
composeNotes();
}
});
m_btnFilter.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
final PopupWindow pw = Util.showPopup(getActivity(), R.layout.filter_menu, true, m_btnFilter, 5, 5);
View v = pw.getContentView();
Button btn = (Button) v.findViewById(R.id.btn_filter_all);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
m_currentActType = ACTIVITY_TYPE_ALL;
pw.dismiss();
getActivity(false);
}
});
btn = (Button) v.findViewById(R.id.btn_filter_updates);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
m_currentActType = ACTIVITY_TYPE_UPDATES;
pw.dismiss();
getActivity(false);
}
});
btn = (Button) v.findViewById(R.id.btn_filter_requests);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
m_currentActType = ACTIVITY_TYPE_REQUESTS;
pw.dismiss();
getActivity(false);
}
});
}
});
}
Aggregations