From e65cfe3a7c96ae553a7a4e39d3bd99c1291fd458 Mon Sep 17 00:00:00 2001 From: jruesga Date: Sat, 22 Sep 2012 19:08:23 +0200 Subject: Some renames --- res/drawable/holo_selector_nofocusable.xml | 25 ---- res/drawable/holo_selector_nonfocusable.xml | 25 ++++ res/layout/bookmarks_item.xml | 2 +- res/layout/navigation_view_details_item.xml | 4 +- res/layout/navigation_view_icons_item.xml | 4 +- res/layout/navigation_view_simple_item.xml | 4 +- res/layout/search_item.xml | 4 +- .../explorer/adapters/SearchResultAdapter.java | 6 +- .../explorer/ui/widgets/NoFocusableButtonItem.java | 74 ---------- .../ui/widgets/NonFocusableButtonItem.java | 74 ++++++++++ .../explorer/ui/widgets/RelevanceView.java | 155 +++++++++++++++++++++ .../explorer/ui/widgets/RelevanceWidget.java | 155 --------------------- .../widgets/TransparentNoFocusableButtonItem.java | 71 ---------- .../widgets/TransparentNonFocusableButtonItem.java | 71 ++++++++++ 14 files changed, 337 insertions(+), 337 deletions(-) delete mode 100644 res/drawable/holo_selector_nofocusable.xml create mode 100644 res/drawable/holo_selector_nonfocusable.xml delete mode 100644 src/com/cyanogenmod/explorer/ui/widgets/NoFocusableButtonItem.java create mode 100644 src/com/cyanogenmod/explorer/ui/widgets/NonFocusableButtonItem.java create mode 100644 src/com/cyanogenmod/explorer/ui/widgets/RelevanceView.java delete mode 100644 src/com/cyanogenmod/explorer/ui/widgets/RelevanceWidget.java delete mode 100644 src/com/cyanogenmod/explorer/ui/widgets/TransparentNoFocusableButtonItem.java create mode 100644 src/com/cyanogenmod/explorer/ui/widgets/TransparentNonFocusableButtonItem.java diff --git a/res/drawable/holo_selector_nofocusable.xml b/res/drawable/holo_selector_nofocusable.xml deleted file mode 100644 index e5ea90e4..00000000 --- a/res/drawable/holo_selector_nofocusable.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/res/drawable/holo_selector_nonfocusable.xml b/res/drawable/holo_selector_nonfocusable.xml new file mode 100644 index 00000000..e5ea90e4 --- /dev/null +++ b/res/drawable/holo_selector_nonfocusable.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout/bookmarks_item.xml b/res/layout/bookmarks_item.xml index 3625f4d6..5e879afe 100644 --- a/res/layout/bookmarks_item.xml +++ b/res/layout/bookmarks_item.xml @@ -28,7 +28,7 @@ android:paddingLeft="@dimen/extra_margin" android:src="@null" /> - - - - - - - - - implements O TextView mTvName; TextView mTvParentDir; ImageButton mBtMenu; - RelevanceWidget mWgRelevance; + RelevanceView mWgRelevance; } /** @@ -222,7 +222,7 @@ public class SearchResultAdapter extends ArrayAdapter implements O viewHolder.mTvParentDir = (TextView)v.findViewById(RESOURCE_ITEM_PARENT_DIR); viewHolder.mBtMenu = (ImageButton)v.findViewById(RESOURCE_ITEM_MENU); viewHolder.mBtMenu.setOnClickListener(this); - viewHolder.mWgRelevance = (RelevanceWidget)v.findViewById(RESOURCE_ITEM_RELEVANCE); + viewHolder.mWgRelevance = (RelevanceView)v.findViewById(RESOURCE_ITEM_RELEVANCE); v.setTag(viewHolder); } diff --git a/src/com/cyanogenmod/explorer/ui/widgets/NoFocusableButtonItem.java b/src/com/cyanogenmod/explorer/ui/widgets/NoFocusableButtonItem.java deleted file mode 100644 index eca59b2d..00000000 --- a/src/com/cyanogenmod/explorer/ui/widgets/NoFocusableButtonItem.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.cyanogenmod.explorer.ui.widgets; - -import android.content.Context; -import android.util.AttributeSet; - -import com.cyanogenmod.explorer.R; - -/** - * A class that represents a button from an action bar that can't gain focus. - */ -public class NoFocusableButtonItem extends ButtonItem { - - /** - * Constructor of NoFocusableButtonItem. - * - * @param context The current context - */ - public NoFocusableButtonItem(Context context) { - super(context); - init(); - } - - /** - * Constructor of NoFocusableButtonItem. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public NoFocusableButtonItem(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - /** - * Constructor of NoFocusableButtonItem. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - * @param defStyle The default style to apply to this view. If 0, no style - * will be applied (beyond what is included in the theme). This may - * either be an attribute resource, whose value will be retrieved - * from the current theme, or an explicit style resource. - */ - public NoFocusableButtonItem(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(); - } - - /** - * Method that initializes the widget. - */ - private void init() { - //Remove focus - setBackgroundResource(R.drawable.holo_selector_nofocusable); - setFocusable(false); - setFocusableInTouchMode(false); - } -} diff --git a/src/com/cyanogenmod/explorer/ui/widgets/NonFocusableButtonItem.java b/src/com/cyanogenmod/explorer/ui/widgets/NonFocusableButtonItem.java new file mode 100644 index 00000000..ab91677f --- /dev/null +++ b/src/com/cyanogenmod/explorer/ui/widgets/NonFocusableButtonItem.java @@ -0,0 +1,74 @@ +/* + * 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.cyanogenmod.explorer.ui.widgets; + +import android.content.Context; +import android.util.AttributeSet; + +import com.cyanogenmod.explorer.R; + +/** + * A class that represents a button from an action bar that can't gain focus. + */ +public class NonFocusableButtonItem extends ButtonItem { + + /** + * Constructor of NonFocusableButtonItem. + * + * @param context The current context + */ + public NonFocusableButtonItem(Context context) { + super(context); + init(); + } + + /** + * Constructor of NonFocusableButtonItem. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + */ + public NonFocusableButtonItem(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + /** + * Constructor of NonFocusableButtonItem. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + * @param defStyle The default style to apply to this view. If 0, no style + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. + */ + public NonFocusableButtonItem(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + /** + * Method that initializes the widget. + */ + private void init() { + //Remove focus + setBackgroundResource(R.drawable.holo_selector_nonfocusable); + setFocusable(false); + setFocusableInTouchMode(false); + } +} diff --git a/src/com/cyanogenmod/explorer/ui/widgets/RelevanceView.java b/src/com/cyanogenmod/explorer/ui/widgets/RelevanceView.java new file mode 100644 index 00000000..89cb9a10 --- /dev/null +++ b/src/com/cyanogenmod/explorer/ui/widgets/RelevanceView.java @@ -0,0 +1,155 @@ +/* + * 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.cyanogenmod.explorer.ui.widgets; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.os.Looper; +import android.util.AttributeSet; +import android.view.View; + +import com.cyanogenmod.explorer.R; + +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; + +/** + * A widget for display a relevance widget. + */ +public class RelevanceView extends View { + + private final Paint mBorderPaint = new Paint(); + private final Paint mRelevancePaint = new Paint(); + private float mRelevance; + + private Map mColors; + + /** + * Constructor of RelevanceView. + * + * @param context The current context + */ + public RelevanceView(Context context) { + super(context); + init(); + } + + /** + * Constructor of RelevanceView. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + */ + public RelevanceView(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + /** + * Constructor of RelevanceView. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + * @param defStyle The default style to apply to this view. If 0, no style + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. + */ + public RelevanceView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + /** + * Method that initializes the view. This method loads all the necessary + * information and create an appropriate layout for the view + */ + private void init() { + //Configure the paints + float density = getResources().getDisplayMetrics().density; + this.mBorderPaint.setColor(getResources().getColor(R.color.relevance_border)); + this.mBorderPaint.setStrokeWidth((1 * density) + 0.5f); + this.mRelevancePaint.setColor(Color.TRANSPARENT); + + //Create the color map + this.mColors = new TreeMap(); + this.mColors.put(Integer.valueOf(25), + new Integer(getResources().getColor(R.color.relevance_percentil_25))); + this.mColors.put(Integer.valueOf(50), + new Integer(getResources().getColor(R.color.relevance_percentil_50))); + this.mColors.put(Integer.valueOf(75), + new Integer(getResources().getColor(R.color.relevance_percentil_75))); + this.mColors.put(Integer.valueOf(100), + new Integer(getResources().getColor(R.color.relevance_percentil_100))); + + //Relevance is 0 until is sets + this.mRelevance = 0.0f; + } + + /** + * Set the relevance of the widget. + * + * @param relevance the mRelevance to set + */ + public void setRelevance(float relevance) { + this.mRelevance = relevance; + if (relevance < 0) { + this.mRelevance = 0.0f; + } + if (relevance > 100) { + this.mRelevance = 100.0f; + } + + //Change the color of the relevance depending on his percentage + Iterator it = this.mColors.keySet().iterator(); + while (it.hasNext()) { + Integer key = it.next(); + if (this.mRelevance <= key.intValue()) { + this.mRelevancePaint.setColor(this.mColors.get(key).intValue()); + break; + } + } + + //Invalidate the widget for drawing again + if (Looper.getMainLooper().getThread() == Thread.currentThread()) { + invalidate(); + } else { + postInvalidate(); + } + } + + @Override + protected void onDraw(Canvas canvas) { + int w = getMeasuredWidth(); + int h = getMeasuredHeight(); + + //Draw the relevance + canvas.drawRect(0, 0, (this.mRelevance * w / 100), h, this.mRelevancePaint); + + //Draw the border + canvas.drawLine(0, 0, w, 0, this.mBorderPaint); + canvas.drawLine(w, 0, w, h, this.mBorderPaint); + canvas.drawLine(w, h, 0, h, this.mBorderPaint); + canvas.drawLine(0, h, 0, 0, this.mBorderPaint); + } + + + +} diff --git a/src/com/cyanogenmod/explorer/ui/widgets/RelevanceWidget.java b/src/com/cyanogenmod/explorer/ui/widgets/RelevanceWidget.java deleted file mode 100644 index dcb108a0..00000000 --- a/src/com/cyanogenmod/explorer/ui/widgets/RelevanceWidget.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.cyanogenmod.explorer.ui.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.os.Looper; -import android.util.AttributeSet; -import android.view.View; - -import com.cyanogenmod.explorer.R; - -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; - -/** - * A widget for display a relevance widget. - */ -public class RelevanceWidget extends View { - - private final Paint mBorderPaint = new Paint(); - private final Paint mRelevancePaint = new Paint(); - private float mRelevance; - - private Map mColors; - - /** - * Constructor of RelevanceWidget. - * - * @param context The current context - */ - public RelevanceWidget(Context context) { - super(context); - init(); - } - - /** - * Constructor of RelevanceWidget. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public RelevanceWidget(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - /** - * Constructor of RelevanceWidget. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - * @param defStyle The default style to apply to this view. If 0, no style - * will be applied (beyond what is included in the theme). This may - * either be an attribute resource, whose value will be retrieved - * from the current theme, or an explicit style resource. - */ - public RelevanceWidget(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(); - } - - /** - * Method that initializes the view. This method loads all the necessary - * information and create an appropriate layout for the view - */ - private void init() { - //Configure the paints - float density = getResources().getDisplayMetrics().density; - this.mBorderPaint.setColor(getResources().getColor(R.color.relevance_border)); - this.mBorderPaint.setStrokeWidth((1 * density) + 0.5f); - this.mRelevancePaint.setColor(Color.TRANSPARENT); - - //Create the color map - this.mColors = new TreeMap(); - this.mColors.put(Integer.valueOf(25), - new Integer(getResources().getColor(R.color.relevance_percentil_25))); - this.mColors.put(Integer.valueOf(50), - new Integer(getResources().getColor(R.color.relevance_percentil_50))); - this.mColors.put(Integer.valueOf(75), - new Integer(getResources().getColor(R.color.relevance_percentil_75))); - this.mColors.put(Integer.valueOf(100), - new Integer(getResources().getColor(R.color.relevance_percentil_100))); - - //Relevance is 0 until is sets - this.mRelevance = 0.0f; - } - - /** - * Set the relevance of the widget. - * - * @param relevance the mRelevance to set - */ - public void setRelevance(float relevance) { - this.mRelevance = relevance; - if (relevance < 0) { - this.mRelevance = 0.0f; - } - if (relevance > 100) { - this.mRelevance = 100.0f; - } - - //Change the color of the relevance depending on his percentage - Iterator it = this.mColors.keySet().iterator(); - while (it.hasNext()) { - Integer key = it.next(); - if (this.mRelevance <= key.intValue()) { - this.mRelevancePaint.setColor(this.mColors.get(key).intValue()); - break; - } - } - - //Invalidate the widget for drawing again - if (Looper.getMainLooper().getThread() == Thread.currentThread()) { - invalidate(); - } else { - postInvalidate(); - } - } - - @Override - protected void onDraw(Canvas canvas) { - int w = getMeasuredWidth(); - int h = getMeasuredHeight(); - - //Draw the relevance - canvas.drawRect(0, 0, (this.mRelevance * w / 100), h, this.mRelevancePaint); - - //Draw the border - canvas.drawLine(0, 0, w, 0, this.mBorderPaint); - canvas.drawLine(w, 0, w, h, this.mBorderPaint); - canvas.drawLine(w, h, 0, h, this.mBorderPaint); - canvas.drawLine(0, h, 0, 0, this.mBorderPaint); - } - - - -} diff --git a/src/com/cyanogenmod/explorer/ui/widgets/TransparentNoFocusableButtonItem.java b/src/com/cyanogenmod/explorer/ui/widgets/TransparentNoFocusableButtonItem.java deleted file mode 100644 index 894394c3..00000000 --- a/src/com/cyanogenmod/explorer/ui/widgets/TransparentNoFocusableButtonItem.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.cyanogenmod.explorer.ui.widgets; - -import android.content.Context; -import android.util.AttributeSet; - -/** - * A class that represents a button from an action bar that can't gain focus - * without background. - */ -public class TransparentNoFocusableButtonItem extends NoFocusableButtonItem { - - /** - * Constructor of TransparentNoFocusableButtonItem. - * - * @param context The current context - */ - public TransparentNoFocusableButtonItem(Context context) { - super(context); - init(); - } - - /** - * Constructor of TransparentNoFocusableButtonItem. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public TransparentNoFocusableButtonItem(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - /** - * Constructor of TransparentNoFocusableButtonItem. - * - * @param context The current context - * @param attrs The attributes of the XML tag that is inflating the view. - * @param defStyle The default style to apply to this view. If 0, no style - * will be applied (beyond what is included in the theme). This may - * either be an attribute resource, whose value will be retrieved - * from the current theme, or an explicit style resource. - */ - public TransparentNoFocusableButtonItem(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(); - } - - /** - * Method that initializes the widget. - */ - private void init() { - //Remove focus - setBackground(null); - } -} diff --git a/src/com/cyanogenmod/explorer/ui/widgets/TransparentNonFocusableButtonItem.java b/src/com/cyanogenmod/explorer/ui/widgets/TransparentNonFocusableButtonItem.java new file mode 100644 index 00000000..bb099d7a --- /dev/null +++ b/src/com/cyanogenmod/explorer/ui/widgets/TransparentNonFocusableButtonItem.java @@ -0,0 +1,71 @@ +/* + * 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.cyanogenmod.explorer.ui.widgets; + +import android.content.Context; +import android.util.AttributeSet; + +/** + * A class that represents a button from an action bar that can't gain focus + * without background. + */ +public class TransparentNonFocusableButtonItem extends NonFocusableButtonItem { + + /** + * Constructor of TransparentNonFocusableButtonItem. + * + * @param context The current context + */ + public TransparentNonFocusableButtonItem(Context context) { + super(context); + init(); + } + + /** + * Constructor of TransparentNonFocusableButtonItem. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + */ + public TransparentNonFocusableButtonItem(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + /** + * Constructor of TransparentNonFocusableButtonItem. + * + * @param context The current context + * @param attrs The attributes of the XML tag that is inflating the view. + * @param defStyle The default style to apply to this view. If 0, no style + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. + */ + public TransparentNonFocusableButtonItem(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + /** + * Method that initializes the widget. + */ + private void init() { + //Remove focus + setBackground(null); + } +} -- cgit v1.2.3