// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FilterObject.java
// public class FilterObject {
// 	
// 	public static final int FILTER_TYPE_NONE = 0;			// This means that filter is not available
// 	public static final int FILTER_TYPE_ALL = 1;			// Every item should pass this filter
// 	public static final int FILTER_TYPE_NOTIFICATION = 2;
// 	public static final int FILTER_TYPE_MESSAGING = 3;
// 	public static final int FILTER_TYPE_FEED = 4;
// 	public static final int FILTER_TYPE_EMERGENCY = 5;
// 	public static final int FILTER_TYPE_PACKAGE_NAME = 6;
// 	
// 	public static final int MATCHING_TYPE_NONE = 0;			// This means that matching type is not available
// 	public static final int MATCHING_TYPE_WHOLE_WORD = 1;
// 	public static final int MATCHING_TYPE_START_WITH = 2;
// 	public static final int MATCHING_TYPE_END_WITH = 3;
// 	public static final int MATCHING_TYPE_PART_OF = 4;
// 	
// 	public static final int REPLACE_TYPE_NONE = 0;		// This means that replace type is not available
// 	public static final int REPLACE_TYPE_ALL = 1;		// replace all
// 	public static final int REPLACE_TYPE_SAME_PART = 2;	// replace only same part
// 	
// 	public static final int ICON_TYPE_NONE_CODE = 0xf0;
// 	
// 	
// 	public int mId = -1;					// ID : matching with database primary key
// 	public int mType = FILTER_TYPE_NONE;			// Filter type : defines target object
// 	public int mIconType = 0;
// 	public int mCompareType = MATCHING_TYPE_NONE;	// Matching conditions: whole word, start with, end with, part of
// 	public int mReplaceType = REPLACE_TYPE_NONE;	// Replace methods : Replace all, Replace same part only
// 	public String mOriginalString = null;	// Original string
// 	public String mReplaceString = null;	// String to be shown on remote device
// 	
// 	
// 	public void copyTo(FilterObject target) {
// 		target.mId = this.mId;
// 		target.mType = this.mType;
// 		target.mIconType = this.mIconType;
// 		target.mCompareType = this.mCompareType;
// 		target.mReplaceType = this.mReplaceType;
// 		target.mOriginalString = new String(this.mOriginalString);
// 		target.mReplaceString = new String(this.mReplaceString);
// 	}
// 	
// }
// 
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java
// public class Logs {
// 	
// 	private static final String TAG = "RetroWatch";
// 	public static boolean mIsEnabled = true;
// 	
// 	
// 	public static void v(String msg) {
// 		if(mIsEnabled) {
// 			Log.v(TAG, msg);
// 		}
// 	}
// 	
// 	public static void v(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.v(tag, msg);
// 		}
// 	}
// 	
// 	public static void d(String msg) {
// 		if(mIsEnabled) {
// 			Log.d(TAG, msg);
// 		}
// 	}
// 	
// 	public static void d(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.d(tag, msg);
// 		}
// 	}
// 	
// 	public static void e(String msg) {
// 		if(mIsEnabled) {
// 			Log.e(TAG, msg);
// 		}
// 	}
// 	
// 	public static void e(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.e(tag, msg);
// 		}
// 	}
// 	
// 	public static void i(String msg) {
// 		if(mIsEnabled) {
// 			Log.e(TAG, msg);
// 		}
// 	}
// 	
// 	public static void i(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.e(tag, msg);
// 		}
// 	}
// 	
// }


import java.util.ArrayList;
import com.hardcopy.retrowatchle.contents.objects.FilterObject;
import com.hardcopy.retrowatchle.utils.Logs;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
/*
 * Copyright (C) 2014 The Retro Watch - Open source smart watch 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.hardcopy.retrowatchle;




/**
 * This fragment shows user defined message filters.
 */
public class FiltersFragment extends Fragment implements OnClickListener, IAdapterListener {

	private static final String TAG = "FiltersFragment";
	
	// Context
	private Context mContext = null;
	private IFragmentListener mFragmentListener;
	
	// View
	private ListView mListFilter = null;
	private FiltersAdapter mFiltersAdapter = null;
	private Spinner mSpinnerFilterType = null;
	private Spinner mSpinnerCompareType = null;
	private Spinner mSpinnerReplaceType = null;
	private Spinner mSpinnerIconType = null;
	private EditText mEditOrigin = null;
	private EditText mEditReplace = null;
	private Button mButtonDelete = null;
	private Button mButtonAdd = null;
	private Button mButtonNew = null;
	
	// Data
	private FilterObject mCurrentFilterObject = null;
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FilterObject.java
// public class FilterObject {
// 	
// 	public static final int FILTER_TYPE_NONE = 0;			// This means that filter is not available
// 	public static final int FILTER_TYPE_ALL = 1;			// Every item should pass this filter
// 	public static final int FILTER_TYPE_NOTIFICATION = 2;
// 	public static final int FILTER_TYPE_MESSAGING = 3;
// 	public static final int FILTER_TYPE_FEED = 4;
// 	public static final int FILTER_TYPE_EMERGENCY = 5;
// 	public static final int FILTER_TYPE_PACKAGE_NAME = 6;
// 	
// 	public static final int MATCHING_TYPE_NONE = 0;			// This means that matching type is not available
// 	public static final int MATCHING_TYPE_WHOLE_WORD = 1;
// 	public static final int MATCHING_TYPE_START_WITH = 2;
// 	public static final int MATCHING_TYPE_END_WITH = 3;
// 	public static final int MATCHING_TYPE_PART_OF = 4;
// 	
// 	public static final int REPLACE_TYPE_NONE = 0;		// This means that replace type is not available
// 	public static final int REPLACE_TYPE_ALL = 1;		// replace all
// 	public static final int REPLACE_TYPE_SAME_PART = 2;	// replace only same part
// 	
// 	public static final int ICON_TYPE_NONE_CODE = 0xf0;
// 	
// 	
// 	public int mId = -1;					// ID : matching with database primary key
// 	public int mType = FILTER_TYPE_NONE;			// Filter type : defines target object
// 	public int mIconType = 0;
// 	public int mCompareType = MATCHING_TYPE_NONE;	// Matching conditions: whole word, start with, end with, part of
// 	public int mReplaceType = REPLACE_TYPE_NONE;	// Replace methods : Replace all, Replace same part only
// 	public String mOriginalString = null;	// Original string
// 	public String mReplaceString = null;	// String to be shown on remote device
// 	
// 	
// 	public void copyTo(FilterObject target) {
// 		target.mId = this.mId;
// 		target.mType = this.mType;
// 		target.mIconType = this.mIconType;
// 		target.mCompareType = this.mCompareType;
// 		target.mReplaceType = this.mReplaceType;
// 		target.mOriginalString = new String(this.mOriginalString);
// 		target.mReplaceString = new String(this.mReplaceString);
// 	}
// 	
// }
// 
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java
// public class Logs {
// 	
// 	private static final String TAG = "RetroWatch";
// 	public static boolean mIsEnabled = true;
// 	
// 	
// 	public static void v(String msg) {
// 		if(mIsEnabled) {
// 			Log.v(TAG, msg);
// 		}
// 	}
// 	
// 	public static void v(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.v(tag, msg);
// 		}
// 	}
// 	
// 	public static void d(String msg) {
// 		if(mIsEnabled) {
// 			Log.d(TAG, msg);
// 		}
// 	}
// 	
// 	public static void d(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.d(tag, msg);
// 		}
// 	}
// 	
// 	public static void e(String msg) {
// 		if(mIsEnabled) {
// 			Log.e(TAG, msg);
// 		}
// 	}
// 	
// 	public static void e(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.e(tag, msg);
// 		}
// 	}
// 	
// 	public static void i(String msg) {
// 		if(mIsEnabled) {
// 			Log.e(TAG, msg);
// 		}
// 	}
// 	
// 	public static void i(String tag, String msg) {
// 		if(mIsEnabled) {
// 			Log.e(tag, msg);
// 		}
// 	}
// 	
// }


// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/FiltersFragment.java
import java.util.ArrayList;
import com.hardcopy.retrowatchle.contents.objects.FilterObject;
import com.hardcopy.retrowatchle.utils.Logs;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;

/*
 * Copyright (C) 2014 The Retro Watch - Open source smart watch 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.hardcopy.retrowatchle;




/**
 * This fragment shows user defined message filters.
 */
public class FiltersFragment extends Fragment implements OnClickListener, IAdapterListener {

	private static final String TAG = "FiltersFragment";
	
	// Context
	private Context mContext = null;
	private IFragmentListener mFragmentListener;
	
	// View
	private ListView mListFilter = null;
	private FiltersAdapter mFiltersAdapter = null;
	private Spinner mSpinnerFilterType = null;
	private Spinner mSpinnerCompareType = null;
	private Spinner mSpinnerReplaceType = null;
	private Spinner mSpinnerIconType = null;
	private EditText mEditOrigin = null;
	private EditText mEditReplace = null;
	private Button mButtonDelete = null;
	private Button mButtonAdd = null;
	private Button mButtonNew = null;
	
	// Data
	private FilterObject mCurrentFilterObject = null;
	private ArrayList<FilterObject> mFiltersCache = null;