/*
 * Copyright 2015 Red Hat, Inc. and/or its affiliates
 * and other contributors as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.hawkular.client.android.fragment;

import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;

import org.hawkular.client.android.R;

import butterknife.BindString;

public final class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
    @BindString(R.string.settings_key_account)
    String accountKey;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);

        setUpSettings();

        setUpListeners();
    }

    private void setUpSettings() {
        addPreferencesFromResource(R.xml.settings);
    }

    private void setUpListeners() {
        findPreference(accountKey).setOnPreferenceClickListener(this);
    }

    @Override
    public boolean onPreferenceClick(Preference preference) {
        if (accountKey.equals(preference.getKey())) {
            tearDownAuthorization();
        }

        return true;
    }

    private void tearDownAuthorization() {
        getActivity().finish();
    }
}

@@ -819,32 +819,58 @@
 ferenceFragment;
+%0Aimport android.view.View;
 %0A%0Aimport org.haw
@@ -924,16 +924,48 @@
 dString;
+%0Aimport butterknife.ButterKnife;
 %0A%0Apublic
@@ -1225,24 +1225,50 @@
 te(state);%0A%0A
+        setUpBindings();%0A%0A
         setU
@@ -1306,32 +1306,222 @@
 eners();%0A    %7D%0A%0A
+    private void setUpBindings() %7B%0A        ButterKnife.bind(this, getParentView());%0A    %7D%0A%0A    private View getParentView() %7B%0A        return getActivity().getWindow().getDecorView();%0A    %7D%0A%0A
     private void
@@ -1957,24 +1957,24 @@
 ization() %7B%0A
-
         getA
@@ -1998,11 +1998,205 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void onDestroyView() %7B%0A        super.onDestroyView();%0A%0A        tearDownBindings();%0A    %7D%0A%0A    private void tearDownBindings() %7B%0A        ButterKnife.unbind(this);%0A    %7D
 %0A%7D%0A

Fix settings.