* #24533 New Contact List, with data model
* #23415 general refactoring
diff --git a/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java b/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java
new file mode 100644
index 0000000..6938759
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java
@@ -0,0 +1,88 @@
+package com.savoirfairelinux.sflphone.views;
+
+import android.content.Context;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+
+import com.savoirfairelinux.sflphone.R;
+
+public class ClearableEditText extends RelativeLayout {
+ LayoutInflater inflater = null;
+ EditText edit_text;
+ Button btn_clear;
+
+ public ClearableEditText(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ // TODO Auto-generated constructor stub
+ initViews();
+ }
+
+ public ClearableEditText(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ // TODO Auto-generated constructor stub
+ initViews();
+ }
+
+ public ClearableEditText(Context context) {
+ super(context);
+ // TODO Auto-generated constructor stub
+ initViews();
+ }
+
+ void initViews() {
+ inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ inflater.inflate(R.layout.clearable_edit_text, this, true);
+ edit_text = (EditText) findViewById(R.id.clearable_edit);
+ btn_clear = (Button) findViewById(R.id.clearable_button_clear);
+ btn_clear.setVisibility(RelativeLayout.INVISIBLE);
+ clearText();
+ showHideClearButton();
+ }
+
+ void clearText() {
+ btn_clear.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ edit_text.setText("");
+ }
+ });
+ }
+
+ void showHideClearButton() {
+ edit_text.addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // TODO Auto-generated method stub
+ if (s.length() > 0)
+ btn_clear.setVisibility(RelativeLayout.VISIBLE);
+ else
+ btn_clear.setVisibility(RelativeLayout.INVISIBLE);
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+
+ public Editable getText() {
+ Editable text = edit_text.getText();
+ return text;
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/views/TACGridView.java b/src/com/savoirfairelinux/sflphone/views/TACGridView.java
new file mode 100644
index 0000000..38c2fc6
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/views/TACGridView.java
@@ -0,0 +1,48 @@
+package com.savoirfairelinux.sflphone.views;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.GridView;
+
+public class TACGridView extends GridView {
+
+ public TACGridView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ }
+
+ public TACGridView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public TACGridView(Context context) {
+ super(context);
+ }
+
+ boolean expanded = false;
+
+ public boolean isExpanded() {
+ return expanded;
+ }
+
+ public void setExpanded(boolean expanded) {
+ this.expanded = expanded;
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (isExpanded()) {
+ // Calculate entire height by providing a very large height hint.
+ // But do not use the highest 2 bits of this integer; those are
+ // reserved for the MeasureSpec mode.
+ int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
+ super.onMeasure(widthMeasureSpec, expandSpec);
+
+ android.view.ViewGroup.LayoutParams params = getLayoutParams();
+ params.height = getMeasuredHeight();
+ } else {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
+}