Exemple #1
0
 public void setJavascriptEnabled(boolean jsEnabled) {
   Log.d(L.TAG, "Control bar: Javascript " + (jsEnabled ? "enabled" : "disabled"));
   if (jsToggle.isChecked() != jsEnabled) {
     jsToggle.setOnCheckedChangeListener(null);
     jsToggle.setChecked(jsEnabled);
     jsToggle.setOnCheckedChangeListener(this);
   }
   jsToggle.setEnabled(true);
 }
  private void applyView(String providerNameText, boolean switchOn, String secondRowText) {
    mProviderName.setText(providerNameText);
    if (mSignInSwitch != null && (!mUserChanged)) {
      mSignInSwitch.setOnCheckedChangeListener(null);
      mSignInSwitch.setChecked(switchOn);
      mSignInSwitch.setOnCheckedChangeListener(mCheckedChangeListner);
    }

    if (mLoginName != null) mLoginName.setText(secondRowText);
  }
Exemple #3
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    title = (TextView) findViewById(R.id.title);
    controlPad = (ViewGroup) findViewById(R.id.controlPad);
    progress = (ProgressBar) findViewById(R.id.progress);
    jsToggle = (CompoundButton) this.controlPad.findViewById(R.id.jsToggle);
    jsToggle.setOnCheckedChangeListener(this);

    // Control pad animations
    pullPad = AnimationUtils.loadAnimation(getContext(), R.anim.pull_control_pad);
    pushPad = AnimationUtils.loadAnimation(getContext(), R.anim.push_control_pad);
    pushPad.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            setVisibility(View.INVISIBLE);
            setTitle(null);
          }
        });
  }
  @Override
  public View getView(View convertView) {
    View view;

    if (convertView == null) {
      ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.listview_row_boolean, null);
      TextView label = (TextView) rootView.findViewById(R.id.text_label);

      TrueButtonListener tListener = new TrueButtonListener(dataValue);
      FalseButtonListener fListener = new FalseButtonListener(dataValue);
      NoneButtonListener nListener = new NoneButtonListener(dataValue);

      CompoundButton tButton = (CompoundButton) rootView.findViewById(R.id.true_button);
      CompoundButton fButton = (CompoundButton) rootView.findViewById(R.id.false_button);
      CompoundButton nButton = (CompoundButton) rootView.findViewById(R.id.none_button);

      tButton.setOnCheckedChangeListener(tListener);
      fButton.setOnCheckedChangeListener(fListener);
      nButton.setOnCheckedChangeListener(nListener);

      holder =
          new BooleanRowHolder(label, tListener, fListener, nListener, tButton, fButton, nButton);

      rootView.setTag(holder);
      view = rootView;
    } else {
      view = convertView;
      holder = (BooleanRowHolder) convertView.getTag();
    }

    holder.textLabel.setText(label);

    holder.trueButtonListener.setField(dataValue);
    holder.falseButtonListener.setField(dataValue);
    holder.noneButtonListener.setField(dataValue);

    holder.trueButton.setOnCheckedChangeListener(holder.trueButtonListener);
    holder.falseButton.setOnCheckedChangeListener(holder.falseButtonListener);
    holder.noneButton.setOnCheckedChangeListener(holder.noneButtonListener);

    if (dataValue.getValue().equals(BaseValue.FALSE)) holder.falseButton.setChecked(true);
    else if (dataValue.getValue().equals(BaseValue.TRUE)) holder.trueButton.setChecked(true);
    else if (dataValue.getValue().equals(BaseValue.EMPTY_VALUE)) holder.noneButton.setChecked(true);
    setEditable(editable);

    return view;
  }
  protected void setupListeners() {
    mAmountText.addTextChangedListener(this);
    mTypeButton.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            onTypeChanged(isChecked);
          }
        });
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup c, Bundle s) {
    settings = Settings.getInstance(getActivity());
    View v = inflater.inflate(R.layout.fragment_overview, c, false);
    cn = new ComponentName(getActivity(), AdminReceiver.class);
    dpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);

    toggle = (CompoundButton) v.findViewById(R.id.toggle_admin);
    lockscreenStatus = (TextView) v.findViewById(R.id.lockscreen_status);
    pinPasswordStatus = (TextView) v.findViewById(R.id.pin_password_status);
    keyguardStatus = (TextView) v.findViewById(R.id.keyguard_status);
    warning = v.findViewById(R.id.warning);
    disabledWarning = v.findViewById(R.id.disabled_warning);
    passwordWarning = v.findViewById(R.id.password_warning);

    if (hasPermanentMenuKey()) {
      v.findViewById(R.id.press_menu_for_more).setVisibility(View.VISIBLE);
    }
    toggle.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton c, boolean b) {
            Intent addAdmin = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            if (!b) {
              Context ctx = getActivity();
              if (settings.get(Settings.LOCK_DISABLED) && CryptoUtils.isPasswordSaved(ctx)) {
                dpm.resetPassword(CryptoUtils.getPassword(ctx), 0);
                settings.set(Settings.LOCK_DISABLED, false);
              }
              dpm.removeActiveAdmin(cn);
              disabledWarning.setVisibility(View.VISIBLE);
              warning.setVisibility(View.GONE);

              new Handler()
                  .post(
                      new Runnable() {
                        @Override
                        public void run() {
                          getActivity().supportInvalidateOptionsMenu();
                        }
                      });
            } else {
              addAdmin.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
              addAdmin.putExtra(
                  DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                  getActivity().getString(R.string.admin_add_explanation));
              startActivity(addAdmin);
            }
          }
        });
    return v;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    verify = (CompoundButton) findViewById(R.id.verify);
    verify.setOnCheckedChangeListener(this);

    command = findViewById(R.id.command);
    binding = findViewById(R.id.binding);

    serviceIntent = buildServiceIntent();
  }
  public void applyView(AccountAdapter.AccountSetting accountSetting) {
    // provide name
    String providerNameText = accountSetting.activeUserName;
    if (mShowLongName) providerNameText += '@' + accountSetting.domain;
    mProviderName.setText(providerNameText);
    // switch
    boolean switchOn = false;
    String secondRowText;

    switch (accountSetting.connectionStatus) {
      case ImConnection.LOGGING_IN:
      case ImConnection.SUSPENDING:
      case ImConnection.SUSPENDED:
        switchOn = true;
        secondRowText = getResources().getString(R.string.signing_in_wait);
        break;

      case ImConnection.LOGGED_IN:
        switchOn = true;
        secondRowText = computeSecondRowText(accountSetting);
        break;

      default:
        switchOn = false;
        secondRowText = computeSecondRowText(accountSetting);
        break;
    }

    if (mSignInSwitch != null && (!mUserChanged)) {
      mSignInSwitch.setOnCheckedChangeListener(null);
      mSignInSwitch.setChecked(switchOn);
      mSignInSwitch.setOnCheckedChangeListener(mCheckedChangeListner);
    }
    // login name
    if (mLoginName != null) mLoginName.setText(secondRowText);
  };
  @Override
  public void doInjection(
      Object methodOwner,
      InjectionContext injectionContext,
      Method sourceMethod,
      InjectOnCheckedChangeListener annotation) {
    Class<?>[] argsTypes = new Class<?>[] {CompoundButton.class, boolean.class};
    Method targetMethod =
        getMethod(OnCheckedChangeListener.class, "onCheckedChanged", argsTypes, sourceMethod);
    View view = getViewById(injectionContext.getRootView(), annotation.value());
    checkIsViewAssignable(CompoundButton.class, view.getClass());

    OnCheckedChangeListener onCheckedChangeListener =
        createInvokationProxy(
            OnCheckedChangeListener.class, methodOwner, sourceMethod, targetMethod);
    ((CompoundButton) view).setOnCheckedChangeListener(onCheckedChangeListener);
  }
  public void processCheckChangedListener() {
    Value listener = getMapValue(_keys, CHECK_CHECKED_LISTENER);
    if (!listener.isNull() && listener.isString()) {
      final String base = listener.getString();
      _changeListener =
          new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              String total =
                  String.format("(let ((is-checked %1$s)) %2$s)", (isChecked) ? "1" : "F", base);
              _lispInterpreter.evaluateExpression(total, true);
            }
          };
    }
    if (encapsulated != null)
      ((CompoundButton) encapsulated).setOnCheckedChangeListener(_changeListener);
  }
  private static void bindCompoundButtonValue(
      final View view, final Object target, final Field f2) {
    f2.setAccessible(true);

    Object value = null;
    if (f2.getType().equals(boolean.class) || f2.getType().equals(Boolean.class)) {
      value = ((CompoundButton) view).isChecked();

    } else if (f2.getType().equals(int.class) || f2.getType().equals(Integer.class)) {
      value = ((CompoundButton) view).isChecked() ? 1 : 0;
    }
    if (value != null) {
      try {
        f2.set(target, value);
      } catch (Exception e) {
        Log.e("CleanDroid", e.getMessage(), e);
      }
    }

    ((CompoundButton) view)
        .setOnCheckedChangeListener(
            new OnCheckedChangeListener() {

              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                Object value = null;
                if (f2.getType().equals(boolean.class) || f2.getType().equals(Boolean.class))
                  value = isChecked;
                else if (f2.getType().equals(int.class) || f2.getType().equals(Integer.class))
                  value = isChecked ? 1 : 0;

                if (value != null) {
                  try {
                    f2.set(target, value);
                  } catch (Exception e) {
                    Log.e("CleanDroid", e.getMessage(), e);
                  }
                }
              }
            });
  }
 private void setUpBasicUserInfo(User paramUser)
 {
   g = ((ViewGroup)findViewById(2131493472));
   Context localContext = getContext();
   Object localObject = a(g);
   ((TextView)localObject).setText(a(StringUtils.a(localContext, 2131166901, new Object[] { paramUser.getLocation() }), a));
   ((TextView)localObject).setEnabled(false);
   if (paramUser.getMemberSince() != null)
   {
     localObject = a(g);
     ((TextView)localObject).setId(2131492929);
     ((TextView)localObject).setEnabled(false);
     ((TextView)localObject).setText(a(StringUtils.a(localContext, 2131166902, new Object[] { a(paramUser.getMemberSince()) }), a));
   }
   if (paramUser.isFriend())
   {
     localObject = LayoutInflater.from(localContext).inflate(2130903352, g, false);
     g.addView((View)localObject);
     CompoundButton localCompoundButton = (CompoundButton)((View)localObject).findViewById(2131493923);
     localCompoundButton.setChecked(paramUser.isSendingNotifications());
     localCompoundButton.setOnCheckedChangeListener(new ae(paramUser));
     ((View)localObject).setOnClickListener(new ad(this, localCompoundButton));
     localObject = (SpannableWidget)localObject;
   }
   h = b(g);
   if (AppData.b().m().a(paramUser)) {
     h.setText(localContext.getString(2131166104));
   }
   for (;;)
   {
     h.setOnClickListener(new by(EventIri.ProfileMoreAboutButton, MoreAboutUser.a(localContext, paramUser)));
     paramUser = (SpannableWidget)h;
     if (paramUser != null) {
       paramUser.setRight(true);
     }
     return;
     h.setText(localContext.getString(2131166103, new Object[] { paramUser.getFirstName() }));
   }
 }
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.authorization_requested);

    long requestId = getIntent().getLongExtra(EXTRA_REQUEST_ID, -1);

    if (requestId == -1) throw new IllegalArgumentException();

    this.request = AuthorizationHandlerImpl.getRequest(requestId);

    View content = findViewById(android.R.id.content);

    ViewUtil.setTextViewValue(
        content,
        R.id.requestInfo,
        getString(
            R.string.service_gui_AUTHORIZATION_REQUESTED_INFO, request.contact.getDisplayName()));

    ViewUtil.setTextViewValue(
        content,
        R.id.addToContacts,
        getString(R.string.service_gui_ADD_AUTHORIZED_CONTACT, request.contact.getDisplayName()));

    Spinner contactGroupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

    contactGroupSpinner.setAdapter(new MetaContactGroupAdapter(this));

    CompoundButton addToContactsCb = (CompoundButton) findViewById(R.id.addToContacts);

    addToContactsCb.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateAddToContactsStatus(isChecked);
          }
        });
  }
  /** {@inheritDoc} */
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    inflater.inflate(R.menu.actionbar_toggle_menu, menu);

    // Binds the button
    CompoundButton cBox =
        (CompoundButton)
            menu.findItem(R.id.toggleView).getActionView().findViewById(android.R.id.toggle);
    cBox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton cb, boolean checked) {
            model.setChecked(checked);
          }
        });

    // Set label text
    ((TextView) menu.findItem(R.id.toggleView).getActionView().findViewById(android.R.id.text1))
        .setText(getArguments().getString(ARG_LABEL_TEXT));

    this.menu = menu;
    updateChecked();
  }
Exemple #15
0
 @Override
 public void onCreate(final Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   mPrefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
   final boolean filter_enabled = mPrefs.getBoolean(PREFERENCE_KEY_ENABLE_FILTER, false);
   setContentView(new FrameLayout(this));
   mActionBar = getSupportActionBar();
   mActionBar.setDisplayShowTitleEnabled(false);
   mActionBar.setDisplayHomeAsUpEnabled(true);
   mActionBar.setDisplayShowCustomEnabled(true);
   mActionBar.setCustomView(R.layout.actionbar_filters);
   final View view = mActionBar.getCustomView();
   mSpinner = (Spinner) view.findViewById(R.id.navigate);
   mToggle = (CompoundButton) view.findViewById(R.id.toggle);
   mToggle.setOnCheckedChangeListener(this);
   mToggle.setChecked(filter_enabled);
   mAdapter = new ArrayAdapter<TabSpec>(this, R.layout.spinner_item_white_text);
   mAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
   mAdapter.add(new TabSpec(FilteredUsersFragment.class, getString(R.string.users)));
   mAdapter.add(new TabSpec(FilteredKeywordsFragment.class, getString(R.string.keywords)));
   mAdapter.add(new TabSpec(FilteredSourcesFragment.class, getString(R.string.sources)));
   mSpinner.setAdapter(mAdapter);
   mSpinner.setOnItemSelectedListener(this);
 }
 @SuppressWarnings("ConstantConditions")
 public static void setEventListener(
     Object handler,
     ViewFinder finder,
     DoubleKeyValueMap<Object, Annotation, Method> value_annotation_method_map) {
   for (Object value : value_annotation_method_map.getFirstKeys()) {
     ConcurrentHashMap<Annotation, Method> annotation_method_map =
         value_annotation_method_map.get(value);
     for (Annotation annotation : annotation_method_map.keySet()) {
       try {
         Method method = annotation_method_map.get(annotation);
         if (annotation.annotationType().equals(OnClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnLongClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnLongClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnFocusChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnFocusChangeListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnKey.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnKeyListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnTouch.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnTouchListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnItemClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((AdapterView<?>) view)
               .setOnItemClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnItemLongClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((AdapterView<?>) view)
               .setOnItemLongClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnChildClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnChildClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupCollapse.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupCollapseListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupExpand.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupExpandListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnCheckedChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           if (view instanceof RadioGroup) {
             ((RadioGroup) view)
                 .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method));
           } else if (view instanceof CompoundButton) {
             ((CompoundButton) view)
                 .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method));
           }
         } else if (annotation.annotationType().equals(OnPreferenceClick.class)) {
           Preference preference = finder.findPreference(value.toString());
           if (preference == null) break;
           preference.setOnPreferenceClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnPreferenceChange.class)) {
           Preference preference = finder.findPreference(value.toString());
           if (preference == null) break;
           preference.setOnPreferenceChangeListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnTabChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((TabHost) view).setOnTabChangedListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnScrollChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.getViewTreeObserver()
               .addOnScrollChangedListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnScrollStateChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnScrollStateChanged.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnScroll.class)) {
               method1 = a_m_map.get(a);
             }
           }
           ((AbsListView) view)
               .setOnScrollListener(new ViewCommonEventListener(handler, method0, method1));
         } else if (annotation.annotationType().equals(OnItemSelected.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnItemSelected.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnNothingSelected.class)) {
               method1 = a_m_map.get(a);
             }
           }
           ((AdapterView<?>) view)
               .setOnItemSelectedListener(new ViewCommonEventListener(handler, method0, method1));
         } else if (annotation.annotationType().equals(OnProgressChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null, method2 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnProgressChanged.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnStartTrackingTouch.class)) {
               method1 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnStopTrackingTouch.class)) {
               method2 = a_m_map.get(a);
             }
           }
           ((SeekBar) view)
               .setOnSeekBarChangeListener(
                   new ViewCommonEventListener(handler, method0, method1, method2));
         }
       } catch (Throwable e) {
         LogUtils.e(e.getMessage(), e);
       }
     }
   }
 }
  public void init(Cursor c, boolean showLongName) {

    mShowLongName = showLongName;

    mProviderIdColumn = c.getColumnIndexOrThrow(Imps.Provider._ID);

    mSignInSwitch = (CompoundButton) findViewById(R.id.statusSwitch);
    mProviderName = (TextView) findViewById(R.id.providerName);
    mLoginName = (TextView) findViewById(R.id.loginName);
    mChatView = (TextView) findViewById(R.id.conversations);

    mBtnSettings = (ImageView) findViewById(R.id.btnSettings);

    mActiveAccountIdColumn = c.getColumnIndexOrThrow(Imps.Provider.ACTIVE_ACCOUNT_ID);
    mActiveAccountUserNameColumn = c.getColumnIndexOrThrow(Imps.Provider.ACTIVE_ACCOUNT_USERNAME);
    mAccountPresenceStatusColumn = c.getColumnIndexOrThrow(Imps.Provider.ACCOUNT_PRESENCE_STATUS);
    mAccountConnectionStatusColumn =
        c.getColumnIndexOrThrow(Imps.Provider.ACCOUNT_CONNECTION_STATUS);

    if (mSignInSwitch != null) {
      mProviderName.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {

              Intent intent = new Intent(getContext(), NewChatActivity.class);
              intent.putExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, mAccountId);
              getContext().startActivity(intent);
            }
          });

      mLoginName.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {

              Intent intent = new Intent(getContext(), NewChatActivity.class);
              intent.putExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, mAccountId);
              getContext().startActivity(intent);
            }
          });

      mSignInSwitch.setOnCheckedChangeListener(mCheckedChangeListner);

      if (mBtnSettings != null) {
        mBtnSettings.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {

                Intent intent =
                    new Intent(
                        Intent.ACTION_EDIT,
                        ContentUris.withAppendedId(Imps.Account.CONTENT_URI, mAccountId));
                intent.addCategory(ImApp.IMPS_CATEGORY);
                mActivity.startActivity(intent);
              }
            });
      }
    }

    /*
    mStatusSwitch.setOnClickListener(new OnClickListener (){

        @Override
        public void onClick(View v) {

            if (mStatusSwitch.isChecked())
                mSignInManager.signIn(mAccountId);
            else
                mSignInManager.signOut(mAccountId);

        }

    });*/
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    setTextViewValue(
        view.findViewById(R.id.infoStatusRow),
        R.id.statusLabelName,
        getString(R.string.label_effect_name),
        0);

    setTextViewValue(
        view.findViewById(R.id.infoStateRow),
        R.id.stateMainLabel,
        getString(R.string.state_label_header_start),
        0);
    setTextViewValue(
        view.findViewById(R.id.infoStateRow2),
        R.id.stateMainLabel,
        getString(R.string.state_label_header_end),
        0);

    setTextViewValue(
        view.findViewById(R.id.infoPeriodRow),
        R.id.nameValueNameText,
        getString(R.string.effect_info_period_name),
        0);
    setTextViewValue(
        view.findViewById(R.id.infoDurationRow),
        R.id.nameValueNameText,
        getString(R.string.effect_info_pulse_duration),
        0);
    setTextViewValue(
        view.findViewById(R.id.infoCountRow),
        R.id.nameValueNameText,
        getString(R.string.effect_info_count_name),
        0);

    // second presets button
    Button presetsButton2 =
        (Button) view.findViewById(R.id.infoStateRow2).findViewById(R.id.stateButton);
    presetsButton2.setTag(STATE2_ITEM_TAG);
    presetsButton2.setClickable(true);
    presetsButton2.setOnClickListener(this);

    TextView periodName =
        (TextView) view.findViewById(R.id.infoPeriodRow).findViewById(R.id.nameValueNameText);
    periodName.setTag(R.id.infoPeriodRow);
    periodName.setClickable(true);
    periodName.setOnClickListener(this);

    TextView periodValue =
        (TextView) view.findViewById(R.id.infoPeriodRow).findViewById(R.id.nameValueValueText);
    periodValue.setTag(R.id.infoPeriodRow);
    periodValue.setClickable(true);
    periodValue.setOnClickListener(this);

    TextView durationName =
        (TextView) view.findViewById(R.id.infoDurationRow).findViewById(R.id.nameValueNameText);
    durationName.setTag(R.id.infoDurationRow);
    durationName.setClickable(true);
    durationName.setOnClickListener(this);

    TextView durationValue =
        (TextView) view.findViewById(R.id.infoDurationRow).findViewById(R.id.nameValueValueText);
    durationValue.setTag(R.id.infoDurationRow);
    durationValue.setClickable(true);
    durationValue.setOnClickListener(this);

    TextView countName =
        (TextView) view.findViewById(R.id.infoCountRow).findViewById(R.id.nameValueNameText);
    countName.setTag(R.id.infoCountRow);
    countName.setClickable(true);
    countName.setOnClickListener(this);

    TextView countValue =
        (TextView) view.findViewById(R.id.infoCountRow).findViewById(R.id.nameValueValueText);
    countValue.setTag(R.id.infoCountRow);
    countValue.setClickable(true);
    countValue.setOnClickListener(this);

    View currentStateRow =
        view.findViewById(R.id.infoStateRow).findViewById(R.id.startWithCurrentStateRow);
    currentStateRow.setVisibility(View.VISIBLE);

    CompoundButton currentStateRowTick =
        (CompoundButton) currentStateRow.findViewById(R.id.startWithCurrentStateTick);
    currentStateRowTick.setClickable(true);
    currentStateRowTick.setOnClickListener(this);
    currentStateRowTick.setOnCheckedChangeListener(this);
    currentStateRowTick.setChecked(pendingPulseEffect.startWithCurrent);

    // state adapter
    stateAdapter2 =
        new LampStateViewAdapter(
            view.findViewById(R.id.infoStateRow2),
            STATE2_ITEM_TAG,
            getColorTempMin(),
            getColorTempSpan(),
            this);

    initLampState();

    updateInfoFields(
        pendingPulseEffect.name,
        getPendingLampState(0),
        LampCapabilities.allCapabilities,
        pendingPulseEffect.uniformity);

    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();

    mAccBuffer = new ArrayBlockingQueue<>(Globals.ACCELEROMETER_BUFFER_CAPACITY);

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);

    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);

    mAsyncTask = new OnSensorChangedTask();
    mAsyncTask.execute();

    stepsView = (TextView) findViewById(R.id.stepCount);
    activityView = (TextView) findViewById(R.id.activity_type);
    calView = (TextView) findViewById(R.id.calCount);
    distView = (TextView) findViewById(R.id.distCount);
    seekBar_height = (SeekBar) findViewById(R.id.height);
    heightPrint = (TextView) findViewById(R.id.heightInput);
    height = seekBar_height.getProgress() + 130;
    heightPrint.setText(height + "cm");

    seekBar_weight = (SeekBar) findViewById(R.id.weight);
    weightPrint = (TextView) findViewById(R.id.weightInput);
    weight = seekBar_weight.getProgress() + 50;
    weightPrint.setText(weight + "kg");

    seekBar_height.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          int progress = 0;

          @Override
          public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            progress = progresValue;
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            height = seekBar.getProgress() + 130;
            heightPrint.setText(height + "cm");
          }
        });

    seekBar_weight.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          int progress = 0;

          @Override
          public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            progress = progresValue;
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            weight = seekBar.getProgress() + 50;
            weightPrint.setText(weight + "kg");
          }
        });

    // Set the buttons and the text accordingly
    accelButton = (ToggleButton) findViewById(R.id.MonitorButton);
    accelButton.setChecked(isAccelRunning);
    accelButton.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton btn, boolean isChecked) {
            if (!isAccelRunning) {
              startAccelerometer();
              accelButton.setChecked(true);
            } else {
              stopAccelerometer();
              accelButton.setChecked(false);
            }
          }
        });
  }