Search in sources :

Example 1 with CMHardwareManager

use of cyanogenmod.hardware.CMHardwareManager in project android_frameworks_base by ResurrectionRemix.

the class VibratorService method updateVibratorIntensity.

private void updateVibratorIntensity() {
    final CMHardwareManager hardware = CMHardwareManager.getInstance(mContext);
    final int intensity = CMSettings.Secure.getIntForUser(mContext.getContentResolver(), CMSettings.Secure.VIBRATOR_INTENSITY, hardware.getVibratorDefaultIntensity(), UserHandle.USER_CURRENT);
    hardware.setVibratorIntensity(intensity);
}
Also used : CMHardwareManager(cyanogenmod.hardware.CMHardwareManager)

Example 2 with CMHardwareManager

use of cyanogenmod.hardware.CMHardwareManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VibratorIntensity method onBindDialogView.

@Override
protected void onBindDialogView(final View view) {
    super.onBindDialogView(view);
    mSeekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
    mValueText = (TextView) view.findViewById(R.id.value);
    mWarningText = (TextView) view.findViewById(R.id.warning_text);
    // Read the current value in case user wants to dismiss his changes
    final CMHardwareManager hardware = CMHardwareManager.getInstance(getContext());
    mOriginalValue = hardware.getVibratorIntensity();
    mWarningValue = hardware.getVibratorWarningIntensity();
    mMinValue = hardware.getVibratorMinIntensity();
    mMaxValue = hardware.getVibratorMaxIntensity();
    mDefaultValue = hardware.getVibratorDefaultIntensity();
    final String message = getContext().getResources().getString(R.string.vibrator_intensity_dialog_warning, intensityToPercent(mMinValue, mMaxValue, mWarningValue));
    mWarningText.setText(message);
    if (mWarningValue <= 0) {
        mWarningText.setVisibility(View.GONE);
    }
    final Drawable progressDrawable = mSeekBar.getProgressDrawable();
    if (progressDrawable instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressDrawable;
        mProgressDrawable = ld.findDrawableByLayerId(android.R.id.progress);
    }
    mProgressThumb = mSeekBar.getThumb();
    mRedFilter = new LightingColorFilter(Color.BLACK, getContext().getResources().getColor(android.R.color.holo_red_light));
    mSeekBar.setOnSeekBarChangeListener(this);
    mSeekBar.setMax(mMaxValue - mMinValue);
    mSeekBar.setProgress(mOriginalValue - mMinValue);
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter) CMHardwareManager(cyanogenmod.hardware.CMHardwareManager)

Example 3 with CMHardwareManager

use of cyanogenmod.hardware.CMHardwareManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VibratorIntensity method setVibratorIntensity.

private void setVibratorIntensity(final int intensity) {
    final CMHardwareManager hardware = CMHardwareManager.getInstance(getContext());
    hardware.setVibratorIntensity(intensity);
}
Also used : CMHardwareManager(cyanogenmod.hardware.CMHardwareManager)

Example 4 with CMHardwareManager

use of cyanogenmod.hardware.CMHardwareManager in project android_frameworks_base by crdroidandroid.

the class VibratorService method systemReady.

public void systemReady() {
    mIm = mContext.getSystemService(InputManager.class);
    mSettingObserver = new SettingsObserver(mH);
    mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
    mPowerManagerInternal.registerLowPowerModeObserver(new PowerManagerInternal.LowPowerModeListener() {

        @Override
        public void onLowPowerModeChanged(boolean enabled) {
            updateInputDeviceVibrators();
        }
    });
    final CMHardwareManager hardware = CMHardwareManager.getInstance(mContext);
    if (hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) {
        mContext.getContentResolver().registerContentObserver(CMSettings.Secure.getUriFor(CMSettings.Secure.VIBRATOR_INTENSITY), true, mSettingObserver, UserHandle.USER_ALL);
        updateVibratorIntensity();
    }
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES), true, mSettingObserver, UserHandle.USER_ALL);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updateInputDeviceVibrators();
            updateVibratorIntensity();
        }
    }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mH);
    updateInputDeviceVibrators();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PowerManagerInternal(android.os.PowerManagerInternal) Intent(android.content.Intent) InputManager(android.hardware.input.InputManager) BroadcastReceiver(android.content.BroadcastReceiver) CMHardwareManager(cyanogenmod.hardware.CMHardwareManager)

Example 5 with CMHardwareManager

use of cyanogenmod.hardware.CMHardwareManager in project android_frameworks_base by crdroidandroid.

the class VibratorService method updateVibratorIntensity.

private void updateVibratorIntensity() {
    final CMHardwareManager hardware = CMHardwareManager.getInstance(mContext);
    final int intensity = CMSettings.Secure.getIntForUser(mContext.getContentResolver(), CMSettings.Secure.VIBRATOR_INTENSITY, hardware.getVibratorDefaultIntensity(), UserHandle.USER_CURRENT);
    hardware.setVibratorIntensity(intensity);
}
Also used : CMHardwareManager(cyanogenmod.hardware.CMHardwareManager)

Aggregations

CMHardwareManager (cyanogenmod.hardware.CMHardwareManager)7 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 InputManager (android.hardware.input.InputManager)2 PowerManagerInternal (android.os.PowerManagerInternal)2 LightingColorFilter (android.graphics.LightingColorFilter)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1