2012-05-30 Santiago Munin <burnin1@gmail.com>

* src/pandroid_event_viewer/pandorafms/EventList.java: Removed unused methods and added two that will set images to the left of some textviews.
	* res/layout/item_list_event_extended.xml: Refactored some linear layouts with textviews and imageviews. Now, it is a single textview with an image on the left.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6365 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
santimunin 2012-05-30 11:40:24 +00:00
parent d0831d8d37
commit e9a8e26a7e
3 changed files with 190 additions and 181 deletions

View File

@ -1,6 +1,11 @@
2012-05-30 Santiago Munín <burnin1@gmail.com>
* src/pandroid_event_viewer/pandorafms/EventList.java: Removed unused methods and added two that will set images to the left of some textviews.
* res/layout/item_list_event_extended.xml: Refactored some linear layouts with textviews and imageviews. Now, it is a single textview with an image on the left.
2012-05-29 Santiago Munín <burnin1@gmail.com> 2012-05-29 Santiago Munín <burnin1@gmail.com>
*src/pandrod_event_viewer/pandorafms/EventList.java: Now tags are links to their urls (if have). * src/pandrod_event_viewer/pandorafms/EventList.java: Now tags are links to their urls (if have).
2012-05-25 Santiago Munín <burning1@gmail.com> 2012-05-25 Santiago Munín <burning1@gmail.com>

View File

@ -14,116 +14,80 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
--> -->
<TableLayout <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_height="fill_parent" android:background="#FFFFFF" >
android:background="#FFFFFF"
> <TableRow
<TableRow> android:layout_width="wrap_content"
<TextView android:layout_height="wrap_content" >
android:textColor="#000"
android:text="@string/severity_label_str" <TextView
android:paddingRight="5dip" android:layout_width="wrap_content"
/> android:layout_height="wrap_content"
<LinearLayout android:paddingRight="5dip"
android:layout_width="fill_parent" android:text="@string/severity_label_str"
android:layout_height="wrap_content" android:textColor="#000" />
android:orientation="horizontal"
> <TextView
<ImageView android:id="@+id/severity_text"
android:layout_weight="0" android:layout_width="wrap_content"
android:id="@+id/img_severity" android:layout_height="wrap_content"
android:layout_width="0dp" android:drawablePadding="5dp"
android:layout_height="wrap_content" android:text=""
android:layout_gravity="center" android:textColor="#000" />
android:contentDescription="@string/img_severity" </TableRow>
android:paddingRight="5dp"
/> <TableRow>
<TextView
android:id="@+id/severity_text" <TextView
android:textColor="#000" android:paddingRight="5dip"
android:text="" android:text="@string/type_label_str"
android:layout_width="wrap_content" android:textColor="#000" />
android:layout_height="wrap_content"
/> <TextView
</LinearLayout> android:id="@+id/type_text"
</TableRow> android:layout_width="wrap_content"
<TableRow> android:layout_height="wrap_content"
<TextView android:drawablePadding="5dp"
android:textColor="#000" android:text=""
android:text="@string/type_label_str" android:textColor="#000" />
android:paddingRight="5dip" </TableRow>
/>
<LinearLayout <TableRow
android:layout_width="fill_parent" android:id="@+id/row_agent"
android:layout_height="wrap_content" android:visibility="gone" >
android:orientation="horizontal"
> <TextView
<ImageView android:paddingRight="5dip"
android:layout_weight="0" android:text="@string/agent_label_str"
android:id="@+id/img_type" android:textColor="#000" />
android:layout_width="0dp"
android:layout_height="wrap_content" <TextView
android:layout_gravity="center" android:id="@+id/agent_text"
android:contentDescription="@string/img_type" android:text=""
android:paddingRight="0dp" android:textColor="#000" />
/> </TableRow>
<TextView
android:id="@+id/type_text" <TableRow>
android:textColor="#000"
android:text="" <TextView
android:layout_width="wrap_content" android:paddingRight="5dip"
android:layout_height="wrap_content" android:text="@string/group_label_str"
/> android:textColor="#000" />
</LinearLayout>
</TableRow> <TextView
<TableRow android:id="@+id/group_text"
android:id="@+id/row_agent" android:layout_width="wrap_content"
android:visibility="gone" android:layout_height="wrap_content"
> android:layout_weight="1"
<TextView android:drawablePadding="5dp"
android:textColor="#000" android:text="@string/all_str"
android:text="@string/agent_label_str" android:textColor="#000" />
android:paddingRight="5dip" </TableRow>
/> <!--
<TextView <TableRow>
android:id="@+id/agent_text"
android:textColor="#000"
android:text=""
/>
</TableRow>
<TableRow>
<TextView
android:textColor="#000"
android:text="@string/group_label_str"
android:paddingRight="5dip"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:layout_weight="0"
android:id="@+id/img_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/img_group"
android:paddingRight="5dp"
/>
<TextView
android:layout_weight="1"
android:id="@+id/group_text"
android:textColor="#000"
android:text="@string/all_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</TableRow>
<!--<TableRow>
<TextView <TextView
android:textColor="#000" android:textColor="#000"
android:text="Count" android:text="Count"
@ -133,53 +97,54 @@
android:textColor="#000" android:textColor="#000"
android:text="1" android:text="1"
/> />
</TableRow>-->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:textColor="#000"
android:text="@string/comments_label_str"
android:paddingRight="5dip"
/>
<TextView
android:id="@+id/comments_text"
android:textColor="#000"
android:text="@string/empty"
android:singleLine="false"
android:layout_width="wrap_content"
/>
</TableRow> </TableRow>
<TableRow> -->
<TextView
android:textColor="#000" <TableRow
android:text="@string/tags_label_str" android:layout_width="fill_parent"
android:paddingRight="5dip" android:layout_height="wrap_content" >
/>
<TextView <TextView
android:id="@+id/tags_text" android:paddingRight="5dip"
android:textColor="#000" android:text="@string/comments_label_str"
android:text="@string/empty" android:textColor="#000" />
android:linksClickable="true"
<TextView
android:id="@+id/comments_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:text="@string/empty"
android:textColor="#000" />
</TableRow>
<TableRow>
<TextView
android:paddingRight="5dip"
android:text="@string/tags_label_str"
android:textColor="#000" />
<TextView
android:id="@+id/tags_text"
android:linksClickable="true"
android:text="@string/empty"
android:textColor="#000" />
</TableRow>
<TableRow android:gravity="right" >
<Button
android:id="@+id/validate_button_extended"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/validate_event_button_str" />
<TextView
android:id="@+id/validate_event_label"
android:text="@string/validate_event_label_str"
android:textColor="#000"
android:textStyle="bold"
android:visibility="gone" />
</TableRow>
/>
</TableRow>
<TableRow
android:gravity="right"
>
<Button
android:id="@+id/validate_button_extended"
android:text="@string/validate_event_button_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/validate_event_label"
android:textColor="#000"
android:textStyle="bold"
android:visibility="gone"
android:text="@string/validate_event_label_str"
/>
</TableRow>
</TableLayout> </TableLayout>

View File

@ -34,6 +34,8 @@ import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
@ -68,7 +70,6 @@ public class EventList extends ListActivity {
// private HashMap<Integer, Boolean> openedItem; // private HashMap<Integer, Boolean> openedItem;
private HashMap<String, Bitmap> imgGroups; private HashMap<String, Bitmap> imgGroups;
private HashMap<String, Bitmap> imgSeverity;
private HashMap<String, Bitmap> imgType; private HashMap<String, Bitmap> imgType;
private BroadcastReceiver onBroadcast; private BroadcastReceiver onBroadcast;
@ -78,7 +79,6 @@ public class EventList extends ListActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.imgGroups = new HashMap<String, Bitmap>(); this.imgGroups = new HashMap<String, Bitmap>();
this.imgSeverity = new HashMap<String, Bitmap>();
this.imgType = new HashMap<String, Bitmap>(); this.imgType = new HashMap<String, Bitmap>();
Intent i = getIntent(); Intent i = getIntent();
@ -226,7 +226,7 @@ public class EventList extends ListActivity {
* @return A bitmap of that image * @return A bitmap of that image
*/ */
private Bitmap downloadImage(String fileUrl) { private Bitmap downloadImage(String fileUrl) {
Log.i(TAG, "Downloading image"); Log.i(TAG, "Downloading image: " + fileUrl);
URL myFileUrl = null; URL myFileUrl = null;
try { try {
@ -243,7 +243,12 @@ public class EventList extends ListActivity {
return null; return null;
} }
// TODO comment /**
* Sets the group image on event list.
* @param view Parent view.
* @param group_icon Group icon.
* @param id Group's ImageView id.
*/
private void setImageGroup(View view, String group_icon, int id) { private void setImageGroup(View view, String group_icon, int id) {
ImageView imgview = (ImageView) view.findViewById(id); ImageView imgview = (ImageView) view.findViewById(id);
Bitmap img; Bitmap img;
@ -272,8 +277,13 @@ public class EventList extends ListActivity {
} }
} }
// TODO comment /**
public void setImageType(View view, String url, int id) { * Sets type's image on event list.
* @param view
* @param url
* @param id
*/
private void setImageType(View view, String url, int id) {
ImageView imgview = (ImageView) view.findViewById(id); ImageView imgview = (ImageView) view.findViewById(id);
Bitmap img = null; Bitmap img = null;
@ -293,23 +303,54 @@ public class EventList extends ListActivity {
} }
// TODO comment // TODO comment
private void setTextViewImage(View view, String url, int id) {
public void setImageSeverity(View view, String url, int id) { TextView tview = (TextView) view.findViewById(id);
ImageView imgview = (ImageView) view.findViewById(id);
Bitmap img = null; Bitmap img = null;
if (this.imgSeverity.containsKey(url)) { if (this.imgType.containsKey(url)) {
img = this.imgSeverity.get(url); img = this.imgType.get(url);
} else { } else {
img = this.downloadImage(url); img = this.downloadImage(url);
if (img != null) { if (img != null) {
this.imgSeverity.put(url, img); this.imgType.put(url, img);
} }
} }
if (img != null) { if (img != null) {
imgview.setImageBitmap(img); Drawable d = new BitmapDrawable(img);
d.setBounds(0, 0, 16, 16);
tview.setCompoundDrawables(d, null, null, null);
}
}
// TODO comment
private void setTextViewGroupImage(View view, String group_icon, int id) {
TextView tview = (TextView) view.findViewById(id);
Bitmap img = null;
if (this.imgGroups.containsKey(group_icon)) {
img = this.imgGroups.get(group_icon);
} else {
SharedPreferences preferences = getApplicationContext()
.getSharedPreferences(
getApplicationContext().getString(
R.string.const_string_preferences),
Activity.MODE_PRIVATE);
String url = preferences.getString("url", "");
img = this.downloadImage(url + "/images/groups_small/" + group_icon
+ ".png");
if (img != null) {
this.imgGroups.put(group_icon, img);
}
}
if (img != null) {
Drawable d = new BitmapDrawable(img);
d.setBounds(0, 0, 16, 16);
tview.setCompoundDrawables(d, null, null, null);
} }
} }
@ -350,7 +391,6 @@ public class EventList extends ListActivity {
public MyAdapter(Context c, PandroidEventviewerActivity object) { public MyAdapter(Context c, PandroidEventviewerActivity object) {
mContext = c; mContext = c;
this.object = object; this.object = object;
showLoadingEvents = false; showLoadingEvents = false;
} }
@ -502,7 +542,6 @@ public class EventList extends ListActivity {
tagText += parts[0]; tagText += parts[0];
} }
} }
// TODO ask miguel (links are not returned)
text.setText(Html.fromHtml(tagText)); text.setText(Html.fromHtml(tagText));
text.setMovementMethod(LinkMovementMethod.getInstance()); text.setMovementMethod(LinkMovementMethod.getInstance());
} }
@ -518,12 +557,12 @@ public class EventList extends ListActivity {
.findViewById(R.id.group_text); .findViewById(R.id.group_text);
text.setText(item.group_name); text.setText(item.group_name);
if (item.group_icon.length() != 0) if (item.group_icon.length() != 0)
setImageGroup(viewEventExtended, item.group_icon, setTextViewGroupImage(viewEventExtended,
R.id.img_group); item.group_icon, R.id.group_text);
} else { } else {
// ALL // ALL
setImageGroup(viewEventExtended, "world", setTextViewGroupImage(viewEventExtended, "world",
R.id.img_group); R.id.group_text);
} }
if (item.agent_name.length() != 0) { if (item.agent_name.length() != 0) {
@ -543,8 +582,8 @@ public class EventList extends ListActivity {
} }
if (item.description_image.length() != 0) if (item.description_image.length() != 0)
setImageType(viewEventExtended, item.description_image, setTextViewImage(viewEventExtended,
R.id.img_type); item.description_image, R.id.type_text);
text = (TextView) viewEventExtended text = (TextView) viewEventExtended
.findViewById(R.id.type_text); .findViewById(R.id.type_text);
text.setText(eventType2Text(item.event_type)); text.setText(eventType2Text(item.event_type));
@ -555,8 +594,8 @@ public class EventList extends ListActivity {
text.setText(item.criticity_name); text.setText(item.criticity_name);
if (item.criticity_image.length() != 0) if (item.criticity_image.length() != 0)
setImageType(viewEventExtended, setTextViewImage(viewEventExtended,
item.criticity_image, R.id.img_severity); item.criticity_image, R.id.severity_text);
} }
// Set the open and close the extended info event row // Set the open and close the extended info event row