/* Copyright 2016 Braden Farmer
 *
 * 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 com.farmerbb.taskbar.fragment;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;

import com.farmerbb.taskbar.R;
import com.farmerbb.taskbar.util.U;

public class FreeformModeFragment extends SettingsFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        finishedLoadingPrefs = false;

        super.onActivityCreated(savedInstanceState);

        // Add preferences
        addPreferencesFromResource(R.xml.pref_freeform_hack);

        AppCompatActivity activity = (AppCompatActivity) getActivity();
        activity.setTitle(R.string.pref_header_freeform);
        ActionBar actionBar = activity.getSupportActionBar();
        if(actionBar != null)
            actionBar.setDisplayHomeAsUpEnabled(true);

        finishedLoadingPrefs = true;
    }


    @Override
    public void onResume() {
        super.onResume();

        if(showReminderToast) {
            showReminderToast = false;

            ((CheckBoxPreference) findPreference("freeform_hack")).setChecked(hasFreeformSupport());

            if(hasFreeformSupport())
                U.showToastLong(getActivity(), R.string.reboot_required);
        }
    }
}

@@ -628,16 +628,58 @@
 gment;%0A%0A
+import android.content.SharedPreferences;%0A
 import a
@@ -1219,24 +1219,588 @@
 orm_hack);%0A%0A
+        SharedPreferences pref = U.getSharedPreferences(getActivity());%0A        if(!pref.getBoolean(%22freeform_hack_override%22, false)) %7B%0A            pref.edit()%0A                    .putBoolean(%22freeform_hack%22, hasFreeformSupport())%0A                    .putBoolean(%22freeform_hack_override%22, true)%0A                    .apply();%0A        %7D%0A%0A        findPreference(%22freeform_hack%22).setOnPreferenceClickListener(this);%0A        findPreference(%22freeform_mode_help%22).setOnPreferenceClickListener(this);%0A%0A        bindPreferenceSummaryToValue(findPreference(%22window_size%22));%0A%0A
         AppC

Fix freeform mode settings page