use of android.view.MotionEvent in project FloatingStickies by MohammadAdib.
the class Window method getSystemDecorations.
/**
* Returns the system window decorations if the implementation sets
* {@link #FLAG_DECORATION_SYSTEM}.
* <p/>
* <p/>
* The system window decorations support hiding, closing, moving, and
* resizing.
*
* @return The frame view containing the system window decorations.
*/
@SuppressWarnings("deprecation")
private View getSystemDecorations() {
final View decorations = mLayoutInflater.inflate(R.layout.system_window_decorators, null);
try {
ImageView icon = (ImageView) decorations.findViewById(R.id.addIV);
icon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new Thread(mContext.getAddRunnable(id)).start();
}
});
// close
ImageView close = (ImageView) decorations.findViewById(R.id.closeIV);
close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = StandOutWindow.getCloseIntent(mContext, mContext.getWindow(id).cls, id);
mContext.startService(intent);
}
});
// close
ImageView drop = (ImageView) decorations.findViewById(R.id.dropIV);
drop.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PopupWindow dropDown = getDropDownList();
dropDown.showAsDropDown(v);
}
});
// move
View titlebar = decorations.findViewById(R.id.titlebar);
titlebar.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// handle dragging to move
boolean consumed = mContext.onTouchHandleMove(id, Window.this, v, event);
return consumed;
}
});
// resize
View corner = decorations.findViewById(R.id.corner);
corner.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// handle dragging to move
boolean consumed = mContext.onTouchHandleResize(id, Window.this, v, event);
return consumed;
}
});
// set window appearance and behavior based on flags
if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
// hide.setVisibility(View.VISIBLE);
}
if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_CLOSE_DISABLE)) {
close.setVisibility(View.GONE);
}
if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_MOVE_DISABLE)) {
titlebar.setOnTouchListener(null);
}
if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_RESIZE_DISABLE)) {
corner.setVisibility(View.GONE);
}
} catch (Exception e) {
}
return decorations;
}
use of android.view.MotionEvent in project NewPipe by TeamNewPipe.
the class VideoItemDetailFragment method updateInfo.
private void updateInfo(final StreamInfo info) {
Activity a = getActivity();
RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detail_text_content_layout);
final TextView videoTitleView = (TextView) activity.findViewById(R.id.detail_video_title_view);
TextView uploaderView = (TextView) activity.findViewById(R.id.detail_uploader_view);
TextView viewCountView = (TextView) activity.findViewById(R.id.detail_view_count_view);
TextView thumbsUpView = (TextView) activity.findViewById(R.id.detail_thumbs_up_count_view);
TextView thumbsDownView = (TextView) activity.findViewById(R.id.detail_thumbs_down_count_view);
TextView uploadDateView = (TextView) activity.findViewById(R.id.detail_upload_date_view);
TextView descriptionView = (TextView) activity.findViewById(R.id.detail_description_view);
RecyclerView nextStreamView = (RecyclerView) activity.findViewById(R.id.detail_next_stream_content);
RelativeLayout nextVideoRootFrame = (RelativeLayout) activity.findViewById(R.id.detail_next_stream_root_layout);
TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title);
Button backgroundButton = (Button) activity.findViewById(R.id.detail_stream_thumbnail_window_background_button);
View thumbnailView = activity.findViewById(R.id.detail_thumbnail_view);
View topView = activity.findViewById(R.id.detailTopView);
Button channelButton = (Button) activity.findViewById(R.id.channel_button);
// prevents a crash if the activity/fragment was already left when the response came
if (channelButton != null) {
progressBar.setVisibility(View.GONE);
if (info.next_video != null) {
// todo: activate this function or remove it
nextStreamView.setVisibility(View.GONE);
} else {
nextStreamView.setVisibility(View.GONE);
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
}
textContentLayout.setVisibility(View.VISIBLE);
if (android.os.Build.VERSION.SDK_INT < 18) {
playVideoButton.setVisibility(View.VISIBLE);
} else {
ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
playArrowView.setVisibility(View.VISIBLE);
}
if (!showNextStreamItem) {
nextVideoRootFrame.setVisibility(View.GONE);
similarTitle.setVisibility(View.GONE);
}
videoTitleView.setText(info.title);
topView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
View extra = activity.findViewById(R.id.detailExtraView);
if (extra.getVisibility() == View.VISIBLE) {
extra.setVisibility(View.GONE);
arrow.setImageResource(R.drawable.arrow_down);
} else {
extra.setVisibility(View.VISIBLE);
arrow.setImageResource(R.drawable.arrow_up);
}
}
return true;
}
});
// Since newpipe is designed to work even if certain information is not available,
// the UI has to react on missing information.
videoTitleView.setText(info.title);
if (!info.uploader.isEmpty()) {
uploaderView.setText(info.uploader);
} else {
activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
}
if (info.view_count >= 0) {
viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
} else {
viewCountView.setVisibility(View.GONE);
}
if (info.dislike_count >= 0) {
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
} else {
thumbsDownView.setVisibility(View.INVISIBLE);
activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
}
if (info.like_count >= 0) {
thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
} else {
thumbsUpView.setVisibility(View.GONE);
activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
thumbsDownView.setVisibility(View.GONE);
activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
}
if (!info.upload_date.isEmpty()) {
uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
} else {
uploadDateView.setVisibility(View.GONE);
}
if (!info.description.isEmpty()) {
descriptionView.setText(Html.fromHtml(info.description));
} else {
descriptionView.setVisibility(View.GONE);
}
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
// parse streams
Vector<VideoStream> streamsToUse = new Vector<>();
for (VideoStream i : info.video_streams) {
if (useStream(i, streamsToUse)) {
streamsToUse.add(i);
}
}
textContentLayout.setVisibility(View.VISIBLE);
if (info.next_video == null) {
activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
}
if (info.related_streams != null && !info.related_streams.isEmpty()) {
initSimilarVideos(info);
} else {
activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
}
setupActionBarHandler(info);
if (autoPlayEnabled) {
playVideo(info);
}
if (android.os.Build.VERSION.SDK_INT < 18) {
playVideoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playVideo(info);
}
});
}
backgroundButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playVideo(info);
}
});
//todo: make backgroundButton handle this
thumbnailView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playVideo(info);
}
});
if (info.channel_url != null && info.channel_url != "") {
channelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NavStack.getInstance().openChannelActivity(getActivity(), info.channel_url, info.service_id);
}
});
} else {
channelButton.setVisibility(Button.GONE);
}
initThumbnailViews(info);
}
}
use of android.view.MotionEvent in project android_frameworks_base by ParanoidAndroid.
the class NotificationPanel method onInterceptTouchEvent.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
MotionEvent cancellation = MotionEvent.obtain(ev);
cancellation.setAction(MotionEvent.ACTION_CANCEL);
boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) || super.onInterceptTouchEvent(ev);
if (intercept) {
latestItems.onInterceptTouchEvent(cancellation);
}
return intercept;
}
use of android.view.MotionEvent in project android_frameworks_base by ParanoidAndroid.
the class StatusBarWindowView method onInterceptTouchEvent.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
boolean intercept = false;
if (mNotificationPanel.isFullyExpanded() && mScrollView.getVisibility() == View.VISIBLE) {
intercept = mExpandHelper.onInterceptTouchEvent(ev);
}
if (!intercept) {
super.onInterceptTouchEvent(ev);
}
if (intercept) {
MotionEvent cancellation = MotionEvent.obtain(ev);
cancellation.setAction(MotionEvent.ACTION_CANCEL);
latestItems.onInterceptTouchEvent(cancellation);
cancellation.recycle();
}
return intercept;
}
use of android.view.MotionEvent in project android_frameworks_base by ParanoidAndroid.
the class TouchExplorer method sendTouchExplorationGestureStartAndHoverEnterIfNeeded.
/**
* Sends the enter events if needed. Such events are hover enter and touch explore
* gesture start.
*
* @param policyFlags The policy flags associated with the event.
*/
private void sendTouchExplorationGestureStartAndHoverEnterIfNeeded(int policyFlags) {
MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
if (event != null && event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
final int pointerIdBits = event.getPointerIdBits();
sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
sendMotionEvent(event, MotionEvent.ACTION_HOVER_ENTER, pointerIdBits, policyFlags);
}
}
Aggregations