List of usage examples for android.support.v4.graphics ColorUtils setAlphaComponent
@ColorInt public static int setAlphaComponent(@ColorInt int color, @IntRange(from = 0x0, to = 0xFF) int alpha)
From source file:com.farmerbb.taskbar.service.DashboardService.java
@SuppressLint("RtlHardcoded") private void drawDashboard() { windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT);// ww w . j a va 2 s. c o m // Initialize views layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.setVisibility(View.GONE); layout.setAlpha(0); SharedPreferences pref = U.getSharedPreferences(this); int width = pref.getInt("dashboard_width", getApplicationContext().getResources().getInteger(R.integer.dashboard_width)); int height = pref.getInt("dashboard_height", getApplicationContext().getResources().getInteger(R.integer.dashboard_height)); boolean isPortrait = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isLandscape = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; if (isPortrait) { columns = height; rows = width; } if (isLandscape) { columns = width; rows = height; } maxSize = columns * rows; int backgroundTint = U.getBackgroundTint(this); int accentColor = U.getAccentColor(this); int accentColorAlt = accentColor; accentColorAlt = ColorUtils.setAlphaComponent(accentColorAlt, Color.alpha(accentColorAlt) / 2); int cellCount = 0; for (int i = 0; i < columns; i++) { LinearLayout layout2 = new LinearLayout(this); layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); layout2.setOrientation(LinearLayout.VERTICAL); for (int j = 0; j < rows; j++) { DashboardCell cellLayout = (DashboardCell) View.inflate(this, R.layout.dashboard, null); cellLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); cellLayout.setBackgroundColor(backgroundTint); cellLayout.setOnClickListener(cellOcl); cellLayout.setOnHoverListener(cellOhl); TextView empty = (TextView) cellLayout.findViewById(R.id.empty); empty.setBackgroundColor(accentColorAlt); empty.setTextColor(accentColor); Bundle bundle = new Bundle(); bundle.putInt("cellId", cellCount); cellLayout.setTag(bundle); cells.put(cellCount, cellLayout); cellCount++; layout2.addView(cellLayout); } layout.addView(layout2); } mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); for (int i = 0; i < maxSize; i++) { int appWidgetId = pref.getInt("dashboard_widget_" + Integer.toString(i), -1); if (appWidgetId != -1) addWidget(appWidgetId, i, false); else if (pref.getBoolean("dashboard_widget_" + Integer.toString(i) + "_placeholder", false)) addPlaceholder(i); } mAppWidgetHost.stopListening(); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(addWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(removeWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_DASHBOARD")); LocalBroadcastManager.getInstance(this).registerReceiver(addWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.ADD_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(removeWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.REMOVE_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_DASHBOARD")); windowManager.addView(layout, params); new Handler().postDelayed(() -> { int paddingSize = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(DashboardService.this)) { case "top_vertical_left": case "bottom_vertical_left": layout.setPadding(paddingSize, 0, 0, 0); break; case "top_left": case "top_right": layout.setPadding(0, paddingSize, 0, 0); break; case "top_vertical_right": case "bottom_vertical_right": layout.setPadding(0, 0, paddingSize, 0); break; case "bottom_left": case "bottom_right": layout.setPadding(0, 0, 0, paddingSize); break; } }, 100); }
From source file:arun.com.chromer.util.ColorUtil.java
@NonNull public static Drawable getRippleDrawableCompat(final @ColorInt int color) { if (Utils.isLollipopAbove()) { return new RippleDrawable(ColorStateList.valueOf(color), null, null); }//from ww w . j a v a 2 s . c o m int translucentColor = ColorUtils.setAlphaComponent(color, 0x44); StateListDrawable stateListDrawable = new StateListDrawable(); int[] states = new int[] { android.R.attr.state_pressed }; stateListDrawable.addState(states, new ColorDrawable(translucentColor)); return stateListDrawable; }
From source file:com.stasbar.knowyourself.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();/*from w w w . ja v a2s. c o m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();/* w w w .jav a2s.co m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();//from w w w .jav a2 s . c o m return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = PreferenceManager.getDefaultSharedPreferences(this) .getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); // final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final TextTime digitalClock = (TextTime) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_ALARM); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();//from w w w .j a va 2 s. c om return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = DataModel.getDataModel().getAlarmVolumeButtonBehavior(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(com.androidinspain.deskclock.R.bool.rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(com.androidinspain.deskclock.R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_info); mContentView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.dismiss); mHintView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.title); final TextClock digitalClock = (TextClock) mContentView .findViewById(com.androidinspain.deskclock.R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView .findViewById(com.androidinspain.deskclock.R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock, false); mCurrentHourColor = ThemeUtils.resolveColor(this, android.R.attr.windowBackground); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:arun.com.chromer.browsing.customtabs.CustomTabs.java
public CustomTabs toolbarColor(@ColorInt int overrideColor) { toolbarColor = ColorUtils.setAlphaComponent(overrideColor, 0xFF); return this; }
From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();/* w ww .j a v a 2 s .com*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD | FLAG_KEEP_SCREEN_ON | FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); // PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); // PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); // wakeLock.acquire(); // // // // KeyguardManager keyguardManager = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); // KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG"); // keyguardLock.disableKeyguard(); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); if (DataModel.getDataModel().getSnoozeByVoice()) { startListening(); } // if (DataModel.getDataModel().getSnoozeByVoice()) { // thisContext = this; // Thread t1 = new Thread(new Runnable() { // public void run() { // mSpeechRecognizerManager = SpeechRecognizerManager.getInstance(thisContext); //new SpeechRecognizerManager(thisContext); // } // }); // t1.start(); // // } }
From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java
int getAlphaColor(int baseColor, float alpha) { return alpha != 1.0f ? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alpha)) : baseColor;//from w w w .j a va 2s.c om }
From source file:com.shopify.buy.ui.ProductDetailsFragmentView.java
private void initializeCheckoutButton() { checkoutButtonContainer = (ViewGroup) findViewById(R.id.checkout_button_container); checkoutButtonContainer.setBackgroundColor(theme.getAccentColor()); Button checkoutButton = (Button) findViewById(R.id.checkout_button); int disabledTextAlpha = 64; // 0.25 * 255 checkoutButton/*from www . ja v a2s . co m*/ .setTextColor( new ColorStateList( new int[][] { new int[] { -android.R.attr.state_enabled }, new int[] { android.R.attr.state_enabled } }, new int[] { ColorUtils.setAlphaComponent(theme.getCheckoutLabelColor(getResources()), disabledTextAlpha), theme.getCheckoutLabelColor(getResources()), })); }