package com.android.systemui.quicksettings; import android.content.Context; import android.os.PowerManager; import android.os.SystemClock; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import com.android.systemui.R; import com.android.systemui.statusbar.phone.QuickSettingsController; import com.android.systemui.statusbar.phone.QuickSettingsContainerView; public class SleepScreenTile extends QuickSettingsTile { private PowerManager pm; public SleepScreenTile(Context context, LayoutInflater inflater, QuickSettingsContainerView container, QuickSettingsController qsc) { super(context, inflater, container, qsc); mDrawable = R.drawable.ic_qs_sleep; mLabel = mContext.getString(R.string.quick_settings_screen_sleep); pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mOnClick = new OnClickListener() { @Override public void onClick(View v) { pm.goToSleep(SystemClock.uptimeMillis()); } }; mOnLongClick = new OnLongClickListener() { @Override public boolean onLongClick(View v) { startSettingsActivity("android.settings.DISPLAY_SETTINGS"); return true; } }; } }