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>
|
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>
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/severity_label_str"
|
android:layout_height="wrap_content"
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/severity_label_str"
|
||||||
<LinearLayout
|
android:textColor="#000" />
|
||||||
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
|
<TextView
|
||||||
android:id="@+id/severity_text"
|
android:id="@+id/severity_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text=""
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
android:drawablePadding="5dp"
|
||||||
</LinearLayout>
|
android:text=""
|
||||||
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/type_label_str"
|
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/type_label_str"
|
||||||
<LinearLayout
|
android:textColor="#000" />
|
||||||
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
|
<TextView
|
||||||
android:id="@+id/type_text"
|
android:id="@+id/type_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text=""
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
android:drawablePadding="5dp"
|
||||||
</LinearLayout>
|
android:text=""
|
||||||
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:id="@+id/row_agent"
|
android:id="@+id/row_agent"
|
||||||
android:visibility="gone"
|
android:visibility="gone" >
|
||||||
>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/agent_label_str"
|
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/agent_label_str"
|
||||||
|
android:textColor="#000" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/agent_text"
|
android:id="@+id/agent_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text=""
|
android:text=""
|
||||||
/>
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/group_label_str"
|
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/group_label_str"
|
||||||
<LinearLayout
|
android:textColor="#000" />
|
||||||
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
|
<TextView
|
||||||
android:layout_weight="1"
|
|
||||||
android:id="@+id/group_text"
|
android:id="@+id/group_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/all_str"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
android:layout_weight="1"
|
||||||
</LinearLayout>
|
android:drawablePadding="5dp"
|
||||||
|
android:text="@string/all_str"
|
||||||
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<!--<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>
|
||||||
|
-->
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" >
|
||||||
>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/comments_label_str"
|
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/comments_label_str"
|
||||||
|
android:textColor="#000" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/comments_text"
|
android:id="@+id/comments_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/empty"
|
|
||||||
android:singleLine="false"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
/>
|
android:singleLine="false"
|
||||||
|
android:text="@string/empty"
|
||||||
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/tags_label_str"
|
|
||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
/>
|
android:text="@string/tags_label_str"
|
||||||
|
android:textColor="#000" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tags_text"
|
android:id="@+id/tags_text"
|
||||||
android:textColor="#000"
|
|
||||||
android:text="@string/empty"
|
|
||||||
android:linksClickable="true"
|
android:linksClickable="true"
|
||||||
|
android:text="@string/empty"
|
||||||
/>
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow
|
|
||||||
android:gravity="right"
|
<TableRow android:gravity="right" >
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/validate_button_extended"
|
android:id="@+id/validate_button_extended"
|
||||||
android:text="@string/validate_event_button_str"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
android:text="@string/validate_event_button_str" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/validate_event_label"
|
android:id="@+id/validate_event_label"
|
||||||
|
android:text="@string/validate_event_label_str"
|
||||||
android:textColor="#000"
|
android:textColor="#000"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:visibility="gone"
|
android:visibility="gone" />
|
||||||
android:text="@string/validate_event_label_str"
|
|
||||||
/>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue