// Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorSettingsDialog.java
// public class ColorSettingsDialog extends AlertDialog implements
// 		ColorPickerView.OnColorChangedListener {
// 
// 	private ColorPickerView mColorPicker;
// 
// 	private ColorPanelView mOldColor;
// 	private ColorPanelView mNewColor;
// 	private EditText mHexColor;
// 	private Button mHexButton;
// 
// 	private LayoutInflater mInflater;
// 	private OnColorChangedListener mListener;
// 
// 	public ColorSettingsDialog(Context context, int initialColor, final String defColor) {
// 		super(context);
// 		getWindow().setFormat(PixelFormat.RGBA_8888);
// 		// To fight color banding.
// 		setUp(initialColor, defColor);
// 	}
// 
// 	private void setUp(int color, final String defColor) {
//         mInflater = (LayoutInflater) getContext()
//                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 
//         View layout = mInflater.inflate(R.layout.dialog_colorpicker, null);
// 
//         mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
//         mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
//         mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
//         mHexColor = (EditText) layout.findViewById(R.id.current_hex_text);
// 
//         mColorPicker.setOnColorChangedListener(this);
//         mOldColor.setColor(color);
//         mColorPicker.setColor(color, true);
// 
//         mHexButton = (Button) layout.findViewById(R.id.color_apply);
//         mHexButton.setOnClickListener(new View.OnClickListener(){
//         	@Override
//         	public void onClick(View v) {
//         		try{
//         			int color = Color.parseColor("#" + mHexColor.getText().toString());
//         			mColorPicker.setColor(color);
//         			colorChange(color);
//         		}catch(Exception e){
//         			mHexColor.setText("FFFFFF");
//         		}
//         	}
//         });
// 
//         setView(layout);
//     }
// 
// 	@Override
// 	public void onColorChanged(int color) {
// 		colorChange(color);
// 	}
// 
// 	private void colorChange(int color){
// 		mNewColor.setColor(color);
// 		mHexColor.setText(Integer.toHexString(color).toUpperCase(Locale.ENGLISH).substring(2));
// 		if (mListener != null) {
// 			mListener.onColorChanged(color);
// 		}
// 	}
// 
// 	public void setAlphaSliderVisible(boolean visible) {
// 		mColorPicker.setAlphaSliderVisible(visible);
// 	}
// 
// 	public String getColorString() {
// 		return Integer.toHexString(mColorPicker.getColor());
// 	}
// 
// 	public int getColor() {
// 		return mColorPicker.getColor();
// 	}
// 
// }


import android.view.View;
import android.widget.ImageView;
import com.zst.xposed.halo.floatingwindow3.R;
import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorSettingsDialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.AttributeSet;
/*
 * Copyright (C) 2013 XuiMod
 * Copyright (C) 2012 The CyanogenMod Project
 * 
 * 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.zst.xposed.halo.floatingwindow3.prefs;




public class ColorPicker extends Preference implements OnPreferenceClickListener {
	
	SharedPreferences mPref;
	ImageView mColorBox;
	Resources mRes;
	String mDefaultColor;

	public ColorPicker(Context context, AttributeSet attrs) {
		super(context, attrs);
		
		mDefaultColor = attrs.getAttributeValue(null, "defaultValue");
	}

	@Override
	protected void onBindView(View view) {
		super.onBindView(view);		
		mColorBox = (ImageView) view.findViewById(android.R.id.icon);
		mPref = getPreferenceManager().getSharedPreferences();
		mRes = getContext().getResources();
		setOnPreferenceClickListener(this);
		refreshColorBox();
	}

	@Override
	public boolean onPreferenceClick(Preference arg0) {
		final ColorSettingsDialog d = new ColorSettingsDialog(getContext(), getColor(), mDefaultColor);
// Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorSettingsDialog.java
// public class ColorSettingsDialog extends AlertDialog implements
// 		ColorPickerView.OnColorChangedListener {
// 
// 	private ColorPickerView mColorPicker;
// 
// 	private ColorPanelView mOldColor;
// 	private ColorPanelView mNewColor;
// 	private EditText mHexColor;
// 	private Button mHexButton;
// 
// 	private LayoutInflater mInflater;
// 	private OnColorChangedListener mListener;
// 
// 	public ColorSettingsDialog(Context context, int initialColor, final String defColor) {
// 		super(context);
// 		getWindow().setFormat(PixelFormat.RGBA_8888);
// 		// To fight color banding.
// 		setUp(initialColor, defColor);
// 	}
// 
// 	private void setUp(int color, final String defColor) {
//         mInflater = (LayoutInflater) getContext()
//                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 
//         View layout = mInflater.inflate(R.layout.dialog_colorpicker, null);
// 
//         mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
//         mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
//         mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
//         mHexColor = (EditText) layout.findViewById(R.id.current_hex_text);
// 
//         mColorPicker.setOnColorChangedListener(this);
//         mOldColor.setColor(color);
//         mColorPicker.setColor(color, true);
// 
//         mHexButton = (Button) layout.findViewById(R.id.color_apply);
//         mHexButton.setOnClickListener(new View.OnClickListener(){
//         	@Override
//         	public void onClick(View v) {
//         		try{
//         			int color = Color.parseColor("#" + mHexColor.getText().toString());
//         			mColorPicker.setColor(color);
//         			colorChange(color);
//         		}catch(Exception e){
//         			mHexColor.setText("FFFFFF");
//         		}
//         	}
//         });
// 
//         setView(layout);
//     }
// 
// 	@Override
// 	public void onColorChanged(int color) {
// 		colorChange(color);
// 	}
// 
// 	private void colorChange(int color){
// 		mNewColor.setColor(color);
// 		mHexColor.setText(Integer.toHexString(color).toUpperCase(Locale.ENGLISH).substring(2));
// 		if (mListener != null) {
// 			mListener.onColorChanged(color);
// 		}
// 	}
// 
// 	public void setAlphaSliderVisible(boolean visible) {
// 		mColorPicker.setAlphaSliderVisible(visible);
// 	}
// 
// 	public String getColorString() {
// 		return Integer.toHexString(mColorPicker.getColor());
// 	}
// 
// 	public int getColor() {
// 		return mColorPicker.getColor();
// 	}
// 
// }


// Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/ColorPicker.java
import android.view.View;
import android.widget.ImageView;
import com.zst.xposed.halo.floatingwindow3.R;
import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorSettingsDialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.AttributeSet;

/*
 * Copyright (C) 2013 XuiMod
 * Copyright (C) 2012 The CyanogenMod Project
 * 
 * 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.zst.xposed.halo.floatingwindow3.prefs;




public class ColorPicker extends Preference implements OnPreferenceClickListener {
	
	SharedPreferences mPref;
	ImageView mColorBox;
	Resources mRes;
	String mDefaultColor;

	public ColorPicker(Context context, AttributeSet attrs) {
		super(context, attrs);
		
		mDefaultColor = attrs.getAttributeValue(null, "defaultValue");
	}

	@Override
	protected void onBindView(View view) {
		super.onBindView(view);		
		mColorBox = (ImageView) view.findViewById(android.R.id.icon);
		mPref = getPreferenceManager().getSharedPreferences();
		mRes = getContext().getResources();
		setOnPreferenceClickListener(this);
		refreshColorBox();
	}

	@Override
	public boolean onPreferenceClick(Preference arg0) {
		final ColorSettingsDialog d = new ColorSettingsDialog(getContext(), getColor(), mDefaultColor);
		final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {