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:
parent
d0831d8d37
commit
e9a8e26a7e
|
@ -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>
|
||||
|
||||
*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>
|
||||
|
||||
|
|
|
@ -14,116 +14,80 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
-->
|
||||
<TableLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="#FFFFFF"
|
||||
>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#000"
|
||||
android:text="@string/severity_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_severity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/img_severity"
|
||||
android:paddingRight="5dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/severity_text"
|
||||
android:textColor="#000"
|
||||
android:text=""
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#000"
|
||||
android:text="@string/type_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_type"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/img_type"
|
||||
android:paddingRight="0dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/type_text"
|
||||
android:textColor="#000"
|
||||
android:text=""
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:id="@+id/row_agent"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView
|
||||
android:textColor="#000"
|
||||
android:text="@string/agent_label_str"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<TextView
|
||||
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>
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="#FFFFFF" >
|
||||
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/severity_label_str"
|
||||
android:textColor="#000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/severity_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:text=""
|
||||
android:textColor="#000" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/type_label_str"
|
||||
android:textColor="#000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/type_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:text=""
|
||||
android:textColor="#000" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/row_agent"
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/agent_label_str"
|
||||
android:textColor="#000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/agent_text"
|
||||
android:text=""
|
||||
android:textColor="#000" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/group_label_str"
|
||||
android:textColor="#000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/group_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawablePadding="5dp"
|
||||
android:text="@string/all_str"
|
||||
android:textColor="#000" />
|
||||
</TableRow>
|
||||
<!--
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#000"
|
||||
android:text="Count"
|
||||
|
@ -133,53 +97,54 @@
|
|||
android:textColor="#000"
|
||||
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>
|
||||
<TextView
|
||||
android:textColor="#000"
|
||||
android:text="@string/tags_label_str"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tags_text"
|
||||
android:textColor="#000"
|
||||
android:text="@string/empty"
|
||||
android:linksClickable="true"
|
||||
-->
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/comments_label_str"
|
||||
android:textColor="#000" />
|
||||
|
||||
<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>
|
|
@ -34,6 +34,8 @@ import android.content.res.Configuration;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -68,7 +70,6 @@ public class EventList extends ListActivity {
|
|||
|
||||
// private HashMap<Integer, Boolean> openedItem;
|
||||
private HashMap<String, Bitmap> imgGroups;
|
||||
private HashMap<String, Bitmap> imgSeverity;
|
||||
private HashMap<String, Bitmap> imgType;
|
||||
|
||||
private BroadcastReceiver onBroadcast;
|
||||
|
@ -78,7 +79,6 @@ public class EventList extends ListActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.imgGroups = new HashMap<String, Bitmap>();
|
||||
this.imgSeverity = new HashMap<String, Bitmap>();
|
||||
this.imgType = new HashMap<String, Bitmap>();
|
||||
|
||||
Intent i = getIntent();
|
||||
|
@ -226,7 +226,7 @@ public class EventList extends ListActivity {
|
|||
* @return A bitmap of that image
|
||||
*/
|
||||
private Bitmap downloadImage(String fileUrl) {
|
||||
Log.i(TAG, "Downloading image");
|
||||
Log.i(TAG, "Downloading image: " + fileUrl);
|
||||
URL myFileUrl = null;
|
||||
|
||||
try {
|
||||
|
@ -243,7 +243,12 @@ public class EventList extends ListActivity {
|
|||
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) {
|
||||
ImageView imgview = (ImageView) view.findViewById(id);
|
||||
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);
|
||||
Bitmap img = null;
|
||||
|
||||
|
@ -293,23 +303,54 @@ public class EventList extends ListActivity {
|
|||
}
|
||||
|
||||
// TODO comment
|
||||
|
||||
public void setImageSeverity(View view, String url, int id) {
|
||||
ImageView imgview = (ImageView) view.findViewById(id);
|
||||
private void setTextViewImage(View view, String url, int id) {
|
||||
TextView tview = (TextView) view.findViewById(id);
|
||||
Bitmap img = null;
|
||||
|
||||
if (this.imgSeverity.containsKey(url)) {
|
||||
img = this.imgSeverity.get(url);
|
||||
if (this.imgType.containsKey(url)) {
|
||||
img = this.imgType.get(url);
|
||||
} else {
|
||||
img = this.downloadImage(url);
|
||||
|
||||
if (img != null) {
|
||||
this.imgSeverity.put(url, img);
|
||||
this.imgType.put(url, img);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
mContext = c;
|
||||
|
||||
this.object = object;
|
||||
showLoadingEvents = false;
|
||||
}
|
||||
|
@ -502,7 +542,6 @@ public class EventList extends ListActivity {
|
|||
tagText += parts[0];
|
||||
}
|
||||
}
|
||||
// TODO ask miguel (links are not returned)
|
||||
text.setText(Html.fromHtml(tagText));
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
@ -518,12 +557,12 @@ public class EventList extends ListActivity {
|
|||
.findViewById(R.id.group_text);
|
||||
text.setText(item.group_name);
|
||||
if (item.group_icon.length() != 0)
|
||||
setImageGroup(viewEventExtended, item.group_icon,
|
||||
R.id.img_group);
|
||||
setTextViewGroupImage(viewEventExtended,
|
||||
item.group_icon, R.id.group_text);
|
||||
} else {
|
||||
// ALL
|
||||
setImageGroup(viewEventExtended, "world",
|
||||
R.id.img_group);
|
||||
setTextViewGroupImage(viewEventExtended, "world",
|
||||
R.id.group_text);
|
||||
}
|
||||
|
||||
if (item.agent_name.length() != 0) {
|
||||
|
@ -543,8 +582,8 @@ public class EventList extends ListActivity {
|
|||
}
|
||||
|
||||
if (item.description_image.length() != 0)
|
||||
setImageType(viewEventExtended, item.description_image,
|
||||
R.id.img_type);
|
||||
setTextViewImage(viewEventExtended,
|
||||
item.description_image, R.id.type_text);
|
||||
text = (TextView) viewEventExtended
|
||||
.findViewById(R.id.type_text);
|
||||
text.setText(eventType2Text(item.event_type));
|
||||
|
@ -555,8 +594,8 @@ public class EventList extends ListActivity {
|
|||
text.setText(item.criticity_name);
|
||||
|
||||
if (item.criticity_image.length() != 0)
|
||||
setImageType(viewEventExtended,
|
||||
item.criticity_image, R.id.img_severity);
|
||||
setTextViewImage(viewEventExtended,
|
||||
item.criticity_image, R.id.severity_text);
|
||||
}
|
||||
|
||||
// Set the open and close the extended info event row
|
||||
|
|
Loading…
Reference in New Issue