Ejemplo n.º 1
0
 public void attachContainer() {
   if (!mAttached) {
     mAttached = true;
     setupContainer();
     refreshContainer();
     mSettingsObserver.observe();
   }
 }
Ejemplo n.º 2
0
  public HoloClock(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mHandler = new Handler();
    SettingsObserver settingsObserver = new SettingsObserver(mHandler);
    settingsObserver.observe();

    updateSettings();
  }
 public LockTaskNotify(Context context) {
   mContext = context;
   mAccessibilityManager =
       (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
   mHandler = new H();
   SettingsObserver observer = new SettingsObserver(mHandler);
   observer.observe();
   mHasNavigationBar = context.getResources().getBoolean(R.bool.config_showNavigationBar);
 }
  @Override
  public void init(Context c, int style) {
    super.init(c, style);

    SharedPreferences shared =
        mContext.getSharedPreferences(KEY_USER_TIMEOUT, Context.MODE_PRIVATE);
    storedUserTimeout = shared.getInt("timeout", FALLBACK_SCREEN_TIMEOUT_VALUE);
    mObserver = new SettingsObserver(mHandler);
    mObserver.observe();
  }
  NotificationManagerService(
      Context context, StatusBarManagerService statusBar, LightsService lights) {
    super();
    mContext = context;
    mAm = ActivityManagerNative.getDefault();
    mSound = new NotificationPlayer(TAG);
    mSound.setUsesWakeLock(context);
    mToastQueue = new ArrayList<ToastRecord>();
    mHandler = new WorkerHandler();

    mStatusBar = statusBar;
    statusBar.setNotificationCallbacks(mNotificationCallbacks);

    mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS);
    mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION);

    Resources resources = mContext.getResources();
    mDefaultNotificationColor =
        resources.getColor(com.android.internal.R.color.config_defaultNotificationColor);
    mDefaultNotificationLedOn =
        resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOn);
    mDefaultNotificationLedOff =
        resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOff);

    // Don't start allowing notifications until the setup wizard has run once.
    // After that, including subsequent boots, init with notifications turned on.
    // This works on the first boot because the setup wizard will toggle this
    // flag at least once and we'll go back to 0 after that.
    if (0
        == Settings.Secure.getInt(
            mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0)) {
      mDisabledNotifications = StatusBarManager.DISABLE_NOTIFICATION_ALERTS;
    }

    // register for various Intents
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    mContext.registerReceiver(mIntentReceiver, filter);
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    pkgFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    pkgFilter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
    pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
    pkgFilter.addDataScheme("package");
    mContext.registerReceiver(mIntentReceiver, pkgFilter);
    IntentFilter sdFilter = new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mContext.registerReceiver(mIntentReceiver, sdFilter);

    SettingsObserver observer = new SettingsObserver(mHandler);
    observer.observe();
  }
  public DockBatteryController(Context context) {
    mContext = context;
    mHandler = new Handler();

    SettingsObserver settingsObserver = new SettingsObserver(mHandler);
    settingsObserver.observe();
    updateSettings();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    context.registerReceiver(this, filter);
  }
  /** Initialize the receivers and initiate the first NTP request */
  public void systemReady() {
    registerForTelephonyIntents();
    registerForAlarms();
    registerForConnectivityIntents();

    mThread = new HandlerThread(TAG);
    mThread.start();
    mHandler = new MyHandler(mThread.getLooper());
    // Check the network time on the new thread
    mHandler.obtainMessage(EVENT_POLL_NETWORK_TIME).sendToTarget();

    mSettingsObserver = new SettingsObserver(mHandler, EVENT_AUTO_TIME_CHANGED);
    mSettingsObserver.observe(mContext);
  }
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    init();
    mBatteryGroup = (ViewGroup) findViewById(R.id.battery_combo);
    mBatteryIcon = (ImageView) findViewById(R.id.battery);
    mBatteryText = (TextView) findViewById(R.id.battery_text);
    mBatteryCenterText = (TextView) findViewById(R.id.battery_text_center);
    mBatteryTextOnly = (TextView) findViewById(R.id.battery_text_only);
    addIconView(mBatteryIcon);

    SettingsObserver settingsObserver = new SettingsObserver(new Handler());
    settingsObserver.observe();
    updateSettings(); // to initialize values
  }
  public BrightnessSlider(Context context) {
    mContext = context;
    mView = View.inflate(mContext, R.layout.brightness_slider, null);

    mControl = (ToggleSlider) mView.findViewById(R.id.brightness);

    mScreenBrightnessDim =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_screenBrightnessDim);

    boolean automaticAvailable =
        context
            .getResources()
            .getBoolean(com.android.internal.R.bool.config_automatic_brightness_available);
    mPower = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));

    if (automaticAvailable) {
      int automatic;
      try {
        automatic =
            Settings.System.getInt(
                mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
      } catch (SettingNotFoundException snfe) {
        automatic = 0;
      }
      mControl.setChecked(automatic != 0);
    } else {
      mControl.setChecked(false);
      // control.hideToggle();
    }

    int value;
    try {
      value =
          Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
    } catch (SettingNotFoundException ex) {
      value = MAXIMUM_BACKLIGHT;
    }

    mControl.setMax(MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
    mControl.setValue(value - mScreenBrightnessDim);

    mControl.setOnChangedListener(this);

    SettingsObserver so = new SettingsObserver(new Handler());
    so.observe();
  }
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    mObserver.observe();

    mWifiGroup = (ViewGroup) findViewById(R.id.wifi_combo);
    mWifi = (ImageView) findViewById(R.id.wifi_signal);
    mWifiActivity = (ImageView) findViewById(R.id.wifi_inout);
    mMobileGroup = (ViewGroup) findViewById(R.id.mobile_combo);
    mMobile = (ImageView) findViewById(R.id.mobile_signal);
    mMobileActivity = (ImageView) findViewById(R.id.mobile_inout);
    mMobileType = (ImageView) findViewById(R.id.mobile_type);
    mSpacer = findViewById(R.id.spacer);
    mAirplane = (ImageView) findViewById(R.id.airplane);

    apply();
  }
Ejemplo n.º 11
0
 public void setListening(boolean listening) {
   if (mListening == listening) return;
   mListening = listening;
   for (TileRecord r : mRecords) {
     r.tile.setListening(mListening);
   }
   mFooter.setListening(mListening);
   if (mListening) {
     refreshAllTiles();
     mSettingsObserver.observe();
   } else {
     mSettingsObserver.unobserve();
   }
   if (listening && showBrightnessSlider()) {
     mBrightnessController.registerCallbacks();
   } else {
     mBrightnessController.unregisterCallbacks();
   }
 }
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    mSettingsObserver.observe();
    mDoubleTapGesture =
        new GestureDetector(
            mContext,
            new GestureDetector.SimpleOnGestureListener() {
              @Override
              public boolean onDoubleTap(MotionEvent e) {
                PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
                Log.d(TAG, "Gesture!!");
                if (pm != null) pm.goToSleep(e.getEventTime());
                else Log.d(TAG, "getSystemService returned null PowerManager");

                return true;
              }
            });

    // We really need to be able to animate while window animations are going on
    // so that activities may be started asynchronously from panel animations
    final ViewRootImpl root = getViewRootImpl();
    if (root != null) {
      root.setDrawDuringWindowsAnimating(true);
    }

    // We need to ensure that our window doesn't suffer from overdraw which would normally
    // occur if our window is translucent. Since we are drawing the whole window anyway with
    // the scrim, we don't need the window to be cleared in the beginning.
    if (mService.isScrimSrcModeEnabled()) {
      IBinder windowToken = getWindowToken();
      WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
      lp.token = windowToken;
      setLayoutParams(lp);
      WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
      setWillNotDraw(false);
    } else {
      setWillNotDraw(!DEBUG);
    }
  }
  public KeyButtonView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyButtonView, defStyle, 0);

    mCode = a.getInteger(R.styleable.KeyButtonView_keyCode, 0);

    mSupportsLongpress = a.getBoolean(R.styleable.KeyButtonView_keyRepeat, true);

    setDrawingAlpha(mQuiescentAlpha);

    a.recycle();

    setClickable(true);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    setBackground(new KeyButtonRipple(context, this));
    mPm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

    SettingsObserver settingsObserver = new SettingsObserver(new Handler());
    settingsObserver.observe();
  }
Ejemplo n.º 14
0
 public void updateResources() {
   final Resources res = mContext.getResources();
   final int columns = Math.max(1, useFourColumns());
   mCellHeight = res.getDimensionPixelSize(R.dimen.qs_tile_height);
   if (mUseFourColumns) {
     mCellWidth = (int) (mCellHeight * TILE_ASPECT_SMALL);
   } else {
     mCellWidth = (int) (mCellHeight * TILE_ASPECT);
   }
   mLargeCellHeight = res.getDimensionPixelSize(R.dimen.qs_dual_tile_height);
   mLargeCellWidth = (int) (mLargeCellHeight * TILE_ASPECT);
   mPanelPaddingBottom = res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom);
   mDualTileUnderlap = res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
   mBrightnessPaddingTop = res.getDimensionPixelSize(R.dimen.qs_brightness_padding_top);
   if (mColumns != columns) {
     mColumns = columns;
     postInvalidate();
   }
   if (mListening) {
     refreshAllTiles();
     mSettingsObserver.observe();
   }
   updateDetailText();
 }
 public void onBootPhaseAppsCanStart() {
   mSettingsObserver.observe();
 }