private void onStatusBarTintColorButtonClicked() {
   Intent colorIntent = new Intent(this, ColorPickerActivity.class);
   Bundle bundle = new Bundle();
   bundle.putString("title", getString(R.string.status_bar_tint_text));
   bundle.putString("key", SettingsKeys.STATUS_BAR_TINT);
   String mOldColor = mSettingsHelper.getTintColor(mPackageName, mActivityName, false);
   if (mOldColor == null) mOldColor = mSettingsHelper.getDefaultTint(Tint.STATUS_BAR, false);
   bundle.putString("color", mOldColor);
   colorIntent.putExtras(bundle);
   startActivityForResult(colorIntent, STATUS_BAR_TINT_COLOR_REQUEST);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_application_settings);

    mSettingsHelper = SettingsHelper.getInstance(getApplicationContext());

    Intent i = getIntent();
    parentIntent = i;

    setTitle(i.getStringExtra(Common.EXTRA_KEY_PACKAGE_FRIENDLY_NAME));

    String activityName = i.getStringExtra(Common.EXTRA_KEY_ACTIVITY_NAME);
    TextView currentActivity = (TextView) findViewById(R.id.currentActivity);
    if (!Common.EXTRA_KEY_VALUE_NONE.equals(activityName)) {
      currentActivity.setText(activityName);
      mActivityName = activityName;
    } else {
      currentActivity.setText(R.string.all_activities_title);
    }

    try {
      String packageName = i.getStringExtra(Common.EXTRA_KEY_PACKAGE_NAME);
      if (packageName.equals(PackageNames.LOCKSCREEN_STUB)) {
        mPackageName = packageName;
        if (Utils.hasActionBar())
          getActionBar().setIcon(getResources().getDrawable(R.drawable.ic_lock));
      } else {
        PackageManager pm = getPackageManager();
        ApplicationInfo app = pm.getApplicationInfo(packageName, 0);
        if (Utils.hasActionBar()) getActionBar().setIcon(app.loadIcon(pm));
        mPackageName = app.packageName;
      }
    } catch (NameNotFoundException e) {
      // Close the dialog gracefully, package might have been uninstalled
      finish();
      return;
    }

    if (Utils.hasActionBar()) {
      getActionBar().setDisplayShowCustomEnabled(true);
      getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mStatusBarTint = mSettingsHelper.getTintColor(mPackageName, mActivityName, false);
    if (mStatusBarTint == null)
      mStatusBarTint = mSettingsHelper.getDefaultTint(Tint.STATUS_BAR, false);
    mStatusBarTintButton = (Button) findViewById(R.id.status_bar_tint_button);
    mStatusBarTintButton.setBackgroundColor(
        Color.parseColor(Utils.addHashIfNeeded(mStatusBarTint)));
    mStatusBarTintButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            onStatusBarTintColorButtonClicked();
          }
        });
    mStatusBarIconTint = mSettingsHelper.getIconColors(mPackageName, mActivityName, false);
    if (mStatusBarIconTint == null)
      mStatusBarIconTint = mSettingsHelper.getDefaultTint(Tint.ICON, false);

    mStatusBarIconTintButton = (Button) findViewById(R.id.icon_tint_button);
    mStatusBarIconTintButton.setBackgroundColor(
        Color.parseColor(Utils.addHashIfNeeded(mStatusBarIconTint)));
    mStatusBarIconTintButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            onStatusBarIconTintColorButtonClicked();
          }
        });
    mNavigationBarTint = mSettingsHelper.getNavigationBarTint(mPackageName, mActivityName, false);
    mNavigationBarIconTint =
        mSettingsHelper.getNavigationBarIconTint(mPackageName, activityName, false);

    mNavigationBarTintButton = (Button) findViewById(R.id.navigation_bar_tint_button);
    mNavigationBarIconTintButton = (Button) findViewById(R.id.navigation_bar_icon_tint_button);

    mNavigationBarTintButton.setBackgroundColor(
        Color.parseColor(Utils.addHashIfNeeded(mNavigationBarTint)));
    mNavigationBarTintButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            onNavigationBarTintButtonClicked();
          }
        });

    mNavigationBarIconTintButton.setBackgroundColor(
        Color.parseColor(Utils.addHashIfNeeded(mNavigationBarIconTint)));
    mNavigationBarIconTintButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            onNavigationBarIconTintButtonClicked();
          }
        });

    mResetToAutoDetectButton = (Button) findViewById(R.id.reset_to_auto_detect_button);
    mResetToAutoDetectButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            resetToAutoDetect();
          }
        });

    mLinkPanelsCheckbox = (CheckBox) findViewById(R.id.link_panels_checkbox);
    mLinkPanelsCheckbox.setChecked(mSettingsHelper.shouldLinkPanels(mPackageName, mActivityName));
    mLinkPanelsCheckbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSettingsHelper.setShouldLinkPanels(mPackageName, mActivityName, isChecked);
          }
        });

    mReactToActionBarCheckbox = (CheckBox) findViewById(R.id.react_actionbar_checkbox);
    mReactToActionBarCheckbox.setChecked(
        mSettingsHelper.shouldReactToActionBar(mPackageName, mActivityName));
    mReactToActionBarCheckbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSettingsHelper.setShouldReactToActionBar(mPackageName, mActivityName, isChecked);
          }
        });

    mReverseTintActionBarChedkbox = (CheckBox) findViewById(R.id.reverse_tint_actionbar_checkbox);
    mReverseTintActionBarChedkbox.setChecked(
        mSettingsHelper.shouldReverseTintAbColor(mPackageName));
    mReverseTintActionBarChedkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSettingsHelper.setShouldReverseTintActionBar(mPackageName, mActivityName, isChecked);
          }
        });

    if (mActivityName != null) findViewById(R.id.package_specifc_options).setVisibility(View.GONE);
  }