示例#1
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    mZenButtons = (SegmentedButtons) findViewById(R.id.zen_buttons);
    mZenButtons.addButton(
        R.string.interruption_level_none, R.drawable.ic_zen_none, Global.ZEN_MODE_NO_INTERRUPTIONS);
    mZenButtons.addButton(
        R.string.interruption_level_priority,
        R.drawable.ic_zen_important,
        Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
    mZenButtons.addButton(
        R.string.interruption_level_all, R.drawable.ic_zen_all, Global.ZEN_MODE_OFF);
    mZenButtons.setCallback(mZenButtonsCallback);

    final ViewGroup zenButtonsContainer = (ViewGroup) findViewById(R.id.zen_buttons_container);
    zenButtonsContainer.setLayoutTransition(newLayoutTransition(null));

    mZenSubhead = findViewById(R.id.zen_subhead);

    mZenSubheadCollapsed = (TextView) findViewById(R.id.zen_subhead_collapsed);
    mZenSubheadCollapsed.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setExpanded(true);
          }
        });
    Interaction.register(mZenSubheadCollapsed, mInteractionCallback);

    mZenSubheadExpanded = (TextView) findViewById(R.id.zen_subhead_expanded);
    Interaction.register(mZenSubheadExpanded, mInteractionCallback);

    mMoreSettings = findViewById(R.id.zen_more_settings);
    mMoreSettings.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            fireMoreSettings();
          }
        });
    Interaction.register(mMoreSettings, mInteractionCallback);

    mZenConditions = (LinearLayout) findViewById(R.id.zen_conditions);
    for (int i = 0; i < mMaxConditions; i++) {
      mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false));
    }

    setLayoutTransition(newLayoutTransition(mTransitionHelper));
  }
示例#2
0
  private void updateWidgets() {
    if (mTransitionHelper.isTransitioning()) {
      mTransitionHelper.pendingUpdateWidgets();
      return;
    }
    final int zen = getSelectedZen(Global.ZEN_MODE_OFF);
    final boolean zenOff = zen == Global.ZEN_MODE_OFF;
    final boolean zenImportant = zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
    final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS;
    final boolean expanded = !mHidden && mExpanded;

    mZenButtons.setVisibility(mHidden ? GONE : VISIBLE);
    mZenSubhead.setVisibility(!mHidden && !zenOff ? VISIBLE : GONE);
    mZenSubheadExpanded.setVisibility(expanded ? VISIBLE : GONE);
    mZenSubheadCollapsed.setVisibility(!expanded ? VISIBLE : GONE);
    mMoreSettings.setVisibility(zenImportant && expanded ? VISIBLE : GONE);
    mZenConditions.setVisibility(!zenOff && expanded ? VISIBLE : GONE);

    if (zenNone) {
      mZenSubheadExpanded.setText(R.string.zen_no_interruptions_with_warning);
      mZenSubheadCollapsed.setText(mExitConditionText);
    } else if (zenImportant) {
      mZenSubheadExpanded.setText(R.string.zen_important_interruptions);
      mZenSubheadCollapsed.setText(mExitConditionText);
    }
    mZenSubheadExpanded.setTextColor(
        zenNone && mPrefs.isNoneDangerous() ? mSubheadWarningColor : mSubheadColor);
  }
示例#3
0
 @Override
 public void onSelected(final Object value) {
   if (value != null && mZenButtons.isShown()) {
     if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + value);
     AsyncTask.execute(
         new Runnable() {
           @Override
           public void run() {
             mController.setZen((Integer) value);
           }
         });
   }
 }
示例#4
0
 private void handleUpdateZen(int zen) {
   if (mSessionZen != -1 && mSessionZen != zen) {
     setExpanded(zen != Global.ZEN_MODE_OFF);
     mSessionZen = zen;
   }
   mZenButtons.setSelectedValue(zen);
   updateWidgets();
   handleUpdateConditions();
   if (mExpanded) {
     final Condition selected = getSelectedCondition();
     if (!Objects.equals(mExitCondition, selected)) {
       select(selected);
     }
   }
 }
示例#5
0
 private int getSelectedZen(int defValue) {
   final Object zen = mZenButtons.getSelectedValue();
   return zen != null ? (Integer) zen : defValue;
 }
示例#6
0
 public void showSilentHint() {
   if (DEBUG) Log.d(mTag, "showSilentHint");
   if (mZenButtons == null || mZenButtons.getChildCount() == 0) return;
   final View noneButton = mZenButtons.getChildAt(0);
   mIconPulser.start(noneButton);
 }
示例#7
0
 public void updateLocale() {
   mZenButtons.updateLocale();
 }