List of usage examples for android.widget FrameLayout setOnTouchListener
public void setOnTouchListener(OnTouchListener l)
From source file:at.wada811.android.library.demos.view.FlickActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flick); FrameLayout container = (FrameLayout) findViewById(R.id.container); container.setOnTouchListener(new FlickTouchListener(this)); container.setOnClickListener(new OnClickListener() { @Override/*from ww w . jav a 2 s. c om*/ public void onClick(View v) { LogUtils.d(); AndroidUtils.showToast(self, "onClick"); } }); }
From source file:fr.norips.ar.ARMuseum.ARMuseumActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Calls ARActivity's ctor, abstract class of ARBaseLib setContentView(R.layout.main);//from ww w . j a v a2s . co m FrameLayout f = (FrameLayout) findViewById(R.id.mainLayout); f.setOnTouchListener(new OnSwipeTouchListener(ARMuseumActivity.this) { public void onSwipeTop() { } public void onSwipeRight() { ConfigHolder.getInstance().nextPage(); } public void onSwipeLeft() { ConfigHolder.getInstance().previousPage(); } public void onSwipeBottom() { } }); }
From source file:com.horaapps.leafpic.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); FrameLayout root = (FrameLayout) findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override//from w w w . j ava 2 s .c o m public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { //view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event); } }); root.setBackgroundColor(R.color.md_black_1000); shutterView = findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); mediaController = new KeyCompatibleMediaController(this); mediController_anchor = findViewById(R.id.media_player_anchor); mediaController.setAnchorView(mediController_anchor); mediaController.setPaddingRelative(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this)); toolbar = (Toolbar) findViewById(R.id.toolbar); initUI(); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) CookieHandler.setDefault(defaultCookieManager); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
/** * @param view Instance of flashcard.xml *//*from w ww . ja va 2s . com*/ public Flashcard(View view, OnCardAnsweredListener listener) { mListener = listener; mView = view; mQuestion = (StyledMarkdownView) view.findViewById(R.id.question); mAnswer = (StyledMarkdownView) view.findViewById(R.id.answer); mCardView = (CardView) view.findViewById(R.id.card); mButtonBar = view.findViewById(R.id.button_bar); mCorrectButton = (Button) view.findViewById(R.id.correct_button); mWrongButton = (Button) view.findViewById(R.id.wrong_button); mContext = mView.getContext(); // Load colors int[] attrs = { android.R.attr.textColorSecondary, android.R.attr.textColorPrimary }; TypedArray ta = mView.getContext().obtainStyledAttributes(R.style.AppTheme, attrs); sDeactivatedTextColor = colorToCSSString(ta.getColor(0, 0)); sDefaultTextColor = colorToCSSString(ta.getColor(1, 0)); ta.recycle(); sGreenTextColor = colorToCSSString(ContextCompat.getColor(mContext, R.color.green)); mQuestionColor = sDefaultTextColor; mAnswerColor = sGreenTextColor; // Make question visible mQuestion.setAlpha(1.0f); mAnswer.setAlpha(0.0f); // Setup WebViews WebSettings settings = mQuestion.getSettings(); settings.setDefaultFontSize(mFontSize); settings.setLoadsImagesAutomatically(true); settings.setGeolocationEnabled(false); settings.setAllowFileAccess(false); settings.setDisplayZoomControls(false); settings.setNeedInitialFocus(false); settings.setSupportZoom(false); settings.setSaveFormData(false); settings.setJavaScriptEnabled(true); mQuestion.setHorizontalScrollBarEnabled(false); mQuestion.setVerticalScrollBarEnabled(false); settings = mAnswer.getSettings(); settings.setDefaultFontSize(mFontSize); settings.setLoadsImagesAutomatically(true); settings.setGeolocationEnabled(false); settings.setAllowFileAccess(false); settings.setDisplayZoomControls(false); settings.setNeedInitialFocus(false); settings.setSupportZoom(false); settings.setSaveFormData(false); settings.setJavaScriptEnabled(true); mAnswer.setHorizontalScrollBarEnabled(false); mAnswer.setVerticalScrollBarEnabled(false); // Hack to disable text selection in WebViews mQuestion.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View v) { return true; } }); mAnswer.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View v) { return true; } }); // Card should "turn" on click final FrameLayout questionLayout = (FrameLayout) view.findViewById(R.id.question_layout); questionLayout.setClickable(true); questionLayout.setOnTouchListener(mTurnCardListener); mQuestion.setOnTouchListener(mTurnCardListener); mAnswer.setOnTouchListener(mTurnCardListener); // Deactivate card when user answers it mCorrectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deactivateCard(true); mListener.onCardAnswered(mCard, true); } }); mWrongButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deactivateCard(false); mListener.onCardAnswered(mCard, false); } }); // Limit card width to 400dp ViewTreeObserver observer = mCardView.getViewTreeObserver(); final int width480dp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, view.getContext().getResources().getDisplayMetrics()); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { if (mCardView.getWidth() > width480dp) { ViewGroup.LayoutParams layoutParams = mCardView.getLayoutParams(); layoutParams.width = width480dp; mCardView.setLayoutParams(layoutParams); mCardView.requestLayout(); return false; } return true; } }); }
From source file:android.support.v7.internal.widget.ActivityChooserView.java
/** * Create a new instance.//from ww w . ja v a 2 s . co m * * @param context The application environment. * @param attrs A collection of attributes. * @param defStyle The default style to apply to this view. */ public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView, defStyle, 0); mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable); attributesArray.recycle(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.abc_activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image); final FrameLayout expandButton = (FrameLayout) findViewById(R.id.expand_activities_button); expandButton.setOnClickListener(mCallbacks); expandButton.setOnTouchListener(new ListPopupWindow.ForwardingListener(expandButton) { @Override public ListPopupWindow getPopup() { return getListPopupWindow(); } @Override protected boolean onForwardingStarted() { showPopup(); return true; } @Override protected boolean onForwardingStopped() { dismissPopup(); return true; } }); mExpandActivityOverflowButton = expandButton; mExpandActivityOverflowButtonImage = (ImageView) expandButton.findViewById(R.id.image); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); mAdapter = new ActivityChooserViewAdapter(); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); updateAppearance(); } }); Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); }
From source file:org.telegram.ui.SessionsActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("SessionsTitle", R.string.SessionsTitle)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*from w w w. j ava 2s . c om*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); emptyLayout = new LinearLayout(context); emptyLayout.setOrientation(LinearLayout.VERTICAL); emptyLayout.setGravity(Gravity.CENTER); //emptyLayout.setBackgroundResource(R.drawable.greydivider_bottom); emptyLayout.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight())); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.devices); emptyLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; imageView.setLayoutParams(layoutParams2); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setText(LocaleController.getString("NoOtherSessions", R.string.NoOtherSessions)); emptyLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.topMargin = AndroidUtilities.dp(16); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER; textView.setLayoutParams(layoutParams2); textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); textView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0); textView.setText(LocaleController.getString("NoOtherSessionsInfo", R.string.NoOtherSessionsInfo)); emptyLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.topMargin = AndroidUtilities.dp(14); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER; textView.setLayoutParams(layoutParams2); FrameLayout progressView = new FrameLayout(context); frameLayout.addView(progressView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); progressView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); listView.setEmptyView(progressView); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == terminateAllSessionsRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage( LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (getParentActivity() == null) { return; } if (error == null && response instanceof TLRPC.TL_boolTrue) { Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT); toast.show(); } else { Toast toast = Toast .makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT); toast.show(); } finishFragment(); } }); UserConfig.registeredForPush = false; UserConfig.saveConfig(false); MessagesController.getInstance().registerForPush(UserConfig.pushString); ConnectionsManager.getInstance() .setUserId(UserConfig.getClientUserId()); } }); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i >= otherSessionsStartRow && i < otherSessionsEndRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("TerminateSessionQuestion", R.string.TerminateSessionQuestion)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int option) { final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog .setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); final TLRPC.TL_authorization authorization = sessions .get(i - otherSessionsStartRow); TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization(); req.hash = authorization.hash; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } if (error == null) { sessions.remove(authorization); updateRows(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } } }); } }); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } }); return fragmentView; }
From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java
@Override public void onPreviewInitialized(FrameLayout preview) { preview.addView(mRoundedOverlay);// w w w .j a v a2 s . c om preview.addView(mCameraInstructions); preview.addView(mCapturePreview, mCapturePreviewParams); preview.addView(mSaveButton, mSaveButtonParams); preview.addView(mShareButton, mShareButtonParams); preview.setOnTouchListener(MainActivity.this); }
From source file:info.tellmetime.TellmetimeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tellmetime); mDensity = getResources().getDisplayMetrics().density; mScreenWidth = getResources().getDisplayMetrics().widthPixels; mScreenHeight = getResources().getDisplayMetrics().heightPixels; mShorterEdge = Math.min(mScreenWidth, mScreenHeight); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); mBacklightLight = getResources().getColor(R.color.backlight_light); mBacklightDark = getResources().getColor(R.color.backlight_dark); // Restore background and highlight colors from saved values or set defaults. mSettings = getSharedPreferences("PREFS", Context.MODE_PRIVATE); mHighlightColor = mSettings.getInt(HIGHLIGHT, Color.WHITE); mBacklightColor = mSettings.getInt(BACKLIGHT, mBacklightLight); mBackgroundColor = mSettings.getInt(BACKGROUND, getResources().getColor(R.color.background)); mBackgroundMode = mSettings.getInt(BACKGROUND_MODE, MODE_BACKGROUND_SOLID); mHighlightPosition = mSettings.getFloat(POSITION, 0.0f); mMinutesSize = mSettings.getInt(MINUTES_SIZE, 36); isNightMode = mSettings.getBoolean(NIGHTMODE, false); // Dim the navigation bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) getWindow().getDecorView().setSystemUiVisibility(isNightMode ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0); mSurface = (RelativeLayout) findViewById(R.id.surface); mSurface.setBackgroundColor(mBackgroundColor); resizeClock();//ww w . jav a 2s . c o m Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); // Set typeface of all items in the clock to Roboto and dim each one and drop shadow on them. final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); tv.setTypeface(mTypefaceBold); tv.setTextColor(mBacklightColor); tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } // Set Roboto font on TextView where it isn't default. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { Typeface mTypefaceItalic = Typeface.createFromAsset(getAssets(), "Roboto-CondensedItalic.ttf"); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.info_background)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.info_image)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.labelHighlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_light)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_dark)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_highlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelMinutes)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m1)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m2)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m3)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m4)).setTypeface(mTypefaceBold); } FrameLayout mTouchZone = (FrameLayout) findViewById(R.id.touchZone); mTouchZone.setOnTouchListener(this); mTouchZone.setBackgroundColor( getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent)); mBackgroundImage = (ImageView) findViewById(R.id.background_image); switchBackgroundMode(mBackgroundMode); RelativeLayout mPanel = (RelativeLayout) findViewById(R.id.panel); mPanel.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.delayedHide(4000); return true; } }); mHider = new PanelHider(mPanel, this); Spinner spinnerBackgroundMode = (Spinner) findViewById(R.id.spinnerBackgroundMode); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.backgrounds_modes, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerBackgroundMode.setAdapter(adapter); spinnerBackgroundMode.setOnItemSelectedListener(this); spinnerBackgroundMode.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.showNoAutoHide(); return false; } }); spinnerBackgroundMode.setSelection(mBackgroundMode); mSeekBarHighlight = (SeekBar) findViewById(R.id.highlightValue); mSeekBarHighlight.setOnSeekBarChangeListener(this); // Draw rainbow gradient on #mSeekBarHighlight and set position. drawRainbow(); if (mBacklightColor == mBacklightLight) ((RadioButton) findViewById(R.id.radio_backlight_light)).setChecked(true); else if (mBacklightColor == mBacklightDark) ((RadioButton) findViewById(R.id.radio_backlight_dark)).setChecked(true); else ((RadioButton) findViewById(R.id.radio_backlight_highlight)).setChecked(true); SeekBar mSeekBarMinutes = (SeekBar) findViewById(R.id.minutesSize); mSeekBarMinutes.setOnSeekBarChangeListener(this); mSeekBarMinutes.setProgress(mMinutesSize); mHider.hideNow(); Color.colorToHSV(mBackgroundColor, mHSV); mHSV[1] = 1.0f; //Trigger initial tick. mClockAlgorithm.tickTock(); // Schedule the clock algorithm to tick every round minute. Calendar time = Calendar.getInstance(); time.set(Calendar.MILLISECOND, 0); time.set(Calendar.SECOND, 0); time.add(Calendar.MINUTE, 1); Timer timer = new Timer(); timer.schedule(mClockTask, time.getTime(), 60 * 1000); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSurface.setAlpha(0.0f); mSurface.animate().alpha(1.0f).setDuration(1500); } // If it is first run, hint to user that panel is available. if (!mSettings.contains(HIGHLIGHT)) showToast(R.string.info_first_run); }
From source file:com.waz.zclient.ui.cursor.CursorToolbar.java
private void createItems() { LayoutInflater inflater = LayoutInflater.from(getContext()); int diameter = getResources().getDimensionPixelSize(R.dimen.cursor__menu_button__diameter); int rightMargin; /*/*from w ww. j a v a 2 s. c o m*/ As long as 4 mainItems are shown in the toolbar, they are spread out equally in phone */ rightMargin = CursorUtils.getMarginBetweenCursorButtons(getContext()); CursorIconButton cursorIconButton; for (int i = 0; i < cursorItems.size(); i++) { final CursorMenuItem item = cursorItems.get(i); final FrameLayout buttonContainer = new FrameLayout(getContext()); buttonContainer.setId(item.resId); cursorIconButton = (CursorIconButton) inflater.inflate(R.layout.cursor__item, this, false); cursorIconButton.setText(item.glyphResId); cursorIconButton .setPressedBackgroundColor(ContextCompat.getColor(getContext(), R.color.light_graphite)); switch (item) { case CAMERA: cursorIconButtonCamera = cursorIconButton; break; case AUDIO_MESSAGE: cursorIconButtonAudio = cursorIconButton; break; } if (item == CursorMenuItem.DUMMY) { cursorIconButton.initTextColor(ContextCompat.getColor(getContext(), R.color.transparent)); cursorIconButton .setPressedBackgroundColor(ContextCompat.getColor(getContext(), R.color.transparent)); cursorIconButton.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.transparent)); } buttonContainer.setTag(item); buttonContainer.setLongClickable(true); buttonContainer.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { CursorMenuItem item = (CursorMenuItem) view.getTag(); touchedButtonContainer = buttonContainer; if (callback != null && item == CursorMenuItem.AUDIO_MESSAGE) { callback.onMotionEvent(item, motionEvent); } detector.onTouchEvent(motionEvent); return false; } }); FrameLayout.LayoutParams paramsButton = new FrameLayout.LayoutParams(diameter, diameter); paramsButton.gravity = Gravity.CENTER; buttonContainer.addView(cursorIconButton, paramsButton); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(buttonWidth, ViewGroup.LayoutParams.MATCH_PARENT); if (i < cursorItems.size() - 1) { params.rightMargin = rightMargin; } addView(buttonContainer, params); } }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
private View getView(List<AppEntry> list, int position) { View convertView = View.inflate(this, R.layout.icon, null); final AppEntry entry = list.get(position); final SharedPreferences pref = U.getSharedPreferences(this); ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); ImageView imageView2 = (ImageView) convertView.findViewById(R.id.shortcut_icon); imageView.setImageDrawable(entry.getIcon(this)); imageView2.setBackgroundColor(/* ww w. j a v a 2 s. c o m*/ pref.getInt("accent_color", getResources().getInteger(R.integer.translucent_white))); String taskbarPosition = U.getTaskbarPosition(this); if (pref.getBoolean("shortcut_icon", true)) { boolean shouldShowShortcutIcon; if (taskbarPosition.contains("vertical")) shouldShowShortcutIcon = position >= list.size() - numOfPinnedApps; else shouldShowShortcutIcon = position < numOfPinnedApps; if (shouldShowShortcutIcon) imageView2.setVisibility(View.VISIBLE); } if (taskbarPosition.equals("bottom_right") || taskbarPosition.equals("top_right")) { imageView.setRotationY(180); imageView2.setRotationY(180); } FrameLayout layout = (FrameLayout) convertView.findViewById(R.id.entry); layout.setOnClickListener(view -> U.launchApp(TaskbarService.this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(TaskbarService.this), null, true, false)); layout.setOnLongClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); return true; }); layout.setOnGenericMotionListener((view, motionEvent) -> { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); } if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true)) view.setBackgroundColor(0); return false; }); if (pref.getBoolean("visual_feedback", true)) { layout.setOnHoverListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) { int accentColor = U.getAccentColor(TaskbarService.this); accentColor = ColorUtils.setAlphaComponent(accentColor, Color.alpha(accentColor) / 2); v.setBackgroundColor(accentColor); } if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) v.setBackgroundColor(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) v.setPointerIcon(PointerIcon.getSystemIcon(TaskbarService.this, PointerIcon.TYPE_DEFAULT)); return false; }); layout.setOnTouchListener((v, event) -> { v.setAlpha( event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE ? 0.5f : 1); return false; }); } return convertView; }