Skip to content

Commit fc3409d

Browse files
committed
0.0.4
1. add control function for log level setting. 2. re-made the table of the main screen for performance.
1 parent 8ec5f1d commit fc3409d

18 files changed

Lines changed: 1014 additions & 412 deletions

AndroidManifest.xml

100644100755
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0'?>
2-
<manifest xmlns:a='http://schemas.android.com/apk/res/android' package='com.zeerd.dltviewer' a:versionCode='0' a:versionName='0.0.3'>
2+
<manifest xmlns:a='http://schemas.android.com/apk/res/android' package='com.zeerd.dltviewer' a:versionCode='0' a:versionName='0.0.4'>
33
<uses-permission a:name='android.permission.INTERNET'/>
44
<uses-permission a:name='android.permission.WRITE_EXTERNAL_STORAGE'/>
55
<uses-permission a:name="android.permission.ACCESS_WIFI_STATE" />
@@ -16,6 +16,12 @@
1616
a:name="android.support.PARENT_ACTIVITY"
1717
a:value=".MainActivity" />
1818
</activity>
19+
<activity a:name=".ControlActivity"
20+
a:parentActivityName=".MainActivity" >
21+
<meta-data
22+
a:name="android.support.PARENT_ACTIVITY"
23+
a:value=".MainActivity" />
24+
</activity>
1925
<activity a:name=".HelpActivity"
2026
a:parentActivityName=".MainActivity" >
2127
<meta-data

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,3 @@ So I use some special way to build this project.
4444
[Android table column width 50 / 50](https://stackoverflow.com/questions/22383932/android-table-column-width-50-50)
4545

4646
[How can I read a text file in Android?](https://stackoverflow.com/questions/12421814/how-can-i-read-a-text-file-in-android)
47-
48-

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ echo "Compiling..."
2121
install -d obj
2222
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/SettingActivity.java
2323
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/HelpActivity.java
24+
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/ControlActivity.java
25+
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/LogRow.java
26+
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/LogTableAdapter.java
2427
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/MainActivity.java
2528
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/R.java
2629

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* @licence app begin@
3+
*
4+
* This Source Code Form is subject to the terms of the
5+
* Mozilla Public License (MPL), v. 2.0.
6+
* If a copy of the MPL was not distributed with this file,
7+
* You can obtain one at http://mozilla.org/MPL/2.0/.
8+
*
9+
* @licence end@
10+
*/
11+
12+
package com.zeerd.dltviewer;
13+
14+
import android.app.Activity;
15+
import android.os.Bundle;
16+
import android.util.Log;
17+
import android.view.View;
18+
import android.widget.EditText;
19+
import android.widget.TextView;
20+
import android.widget.Toast;
21+
22+
import com.zeerd.dltviewer.R;
23+
24+
public class ControlActivity extends Activity {
25+
26+
private static final String TAG = "DLT-Viewer";
27+
private static final String [] langurage ={"off","fatal","error","warn","info","debug","Verbose"};
28+
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.control);
33+
34+
}
35+
36+
public void setSpecialLogLevel(View v) {
37+
EditText apid = (EditText)ControlActivity.this.findViewById(R.id.special_apid);
38+
EditText ctid = (EditText)ControlActivity.this.findViewById(R.id.special_ctid);
39+
EditText lvl = (EditText)ControlActivity.this.findViewById(R.id.special_level);
40+
41+
setLevel(
42+
apid.getText().toString(),
43+
ctid.getText().toString(),
44+
Integer.parseInt(lvl.getText().toString())
45+
);
46+
Toast.makeText(getBaseContext(),
47+
"Set the level of ["
48+
+ apid.getText().toString()
49+
+ ":"
50+
+ ctid.getText().toString()
51+
+ "] to be "
52+
+ lvl.getText().toString(),
53+
Toast.LENGTH_LONG).show();
54+
}
55+
56+
public void setDefaultLogLevel(View v) {
57+
EditText lvl = (EditText)ControlActivity.this.findViewById(R.id.default_level);
58+
String sLvl = lvl.getText().toString();
59+
setDefaultLevel(Integer.parseInt(sLvl));
60+
61+
Toast.makeText(getBaseContext(),
62+
"Set the default level to be "
63+
+ lvl.getText().toString(),
64+
Toast.LENGTH_LONG).show();
65+
}
66+
67+
public void returnControl(View v) {
68+
finish();
69+
}
70+
71+
static {
72+
System.loadLibrary("dlt-jnicallback");
73+
}
74+
public native void setDefaultLevel(int level);
75+
public native void setAllLevel(int level);
76+
public native void setLevel(String apid, String ctid, int level);
77+
78+
}
Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
1-
package com.zeerd.dltviewer;
2-
3-
import android.app.Activity;
4-
import android.content.pm.PackageInfo;
5-
import android.content.pm.PackageManager.NameNotFoundException;
6-
import android.os.Bundle;
7-
import android.util.Log;
8-
import android.view.View;
9-
import android.widget.TextView;
10-
11-
import com.zeerd.dltviewer.R;
12-
13-
public class HelpActivity extends Activity {
14-
15-
private static final String TAG = "DLT-Viewer";
16-
17-
@Override
18-
protected void onCreate(Bundle savedInstanceState) {
19-
super.onCreate(savedInstanceState);
20-
setContentView(R.layout.help);
21-
22-
try {
23-
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
24-
((TextView)HelpActivity.this.findViewById(R.id.name)).setText("DLT-Viewer Android " + packageInfo.versionName);
25-
} catch (NameNotFoundException e) {
26-
((TextView)HelpActivity.this.findViewById(R.id.name)).setText("DLT-Viewer Android");
27-
}
28-
}
29-
30-
public void returnHelp(View v) {
31-
finish();
32-
}
1+
/*
2+
* @licence app begin@
3+
*
4+
* This Source Code Form is subject to the terms of the
5+
* Mozilla Public License (MPL), v. 2.0.
6+
* If a copy of the MPL was not distributed with this file,
7+
* You can obtain one at http://mozilla.org/MPL/2.0/.
8+
*
9+
* @licence end@
10+
*/
11+
12+
package com.zeerd.dltviewer;
13+
14+
import android.app.Activity;
15+
import android.content.pm.PackageInfo;
16+
import android.content.pm.PackageManager.NameNotFoundException;
17+
import android.os.Bundle;
18+
import android.util.Log;
19+
import android.view.View;
20+
import android.widget.TextView;
21+
22+
import com.zeerd.dltviewer.R;
23+
24+
public class HelpActivity extends Activity {
25+
26+
private static final String TAG = "DLT-Viewer";
27+
28+
@Override
29+
protected void onCreate(Bundle savedInstanceState) {
30+
super.onCreate(savedInstanceState);
31+
setContentView(R.layout.help);
32+
33+
try {
34+
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
35+
((TextView)HelpActivity.this.findViewById(R.id.name)).setText("DLT-Viewer Android " + packageInfo.versionName);
36+
} catch (NameNotFoundException e) {
37+
((TextView)HelpActivity.this.findViewById(R.id.name)).setText("DLT-Viewer Android");
38+
}
39+
}
40+
41+
public void returnHelp(View v) {
42+
finish();
43+
}
3344
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* @licence app begin@
3+
*
4+
* This Source Code Form is subject to the terms of the
5+
* Mozilla Public License (MPL), v. 2.0.
6+
* If a copy of the MPL was not distributed with this file,
7+
* You can obtain one at http://mozilla.org/MPL/2.0/.
8+
*
9+
* @licence end@
10+
*/
11+
12+
package com.zeerd.dltviewer;
13+
14+
import java.util.ArrayList;
15+
import java.util.List;
16+
17+
public class LogRow {
18+
19+
private String[] column = new String[6];
20+
21+
public LogRow(
22+
String timestamp,
23+
String ecuid,
24+
String apid,
25+
String ctid,
26+
String subtype,
27+
String payload) {
28+
29+
super();
30+
this.column[0] = timestamp;
31+
this.column[1] = ecuid;
32+
this.column[2] = apid;
33+
this.column[3] = ctid;
34+
this.column[4] = subtype;
35+
this.column[5] = payload;
36+
}
37+
38+
public String getColumn(int index) {
39+
return column[index];
40+
}
41+
public void setColumn(int index, String str) {
42+
this.column[index] = str;
43+
}
44+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* @licence app begin@
3+
*
4+
* This Source Code Form is subject to the terms of the
5+
* Mozilla Public License (MPL), v. 2.0.
6+
* If a copy of the MPL was not distributed with this file,
7+
* You can obtain one at http://mozilla.org/MPL/2.0/.
8+
*
9+
* @licence end@
10+
*/
11+
12+
package com.zeerd.dltviewer;
13+
14+
import java.util.List;
15+
16+
import android.app.Activity;
17+
import android.util.Log;
18+
import android.view.LayoutInflater;
19+
import android.view.View;
20+
import android.view.ViewGroup;
21+
import android.widget.BaseAdapter;
22+
import android.widget.TextView;
23+
24+
public class LogTableAdapter extends BaseAdapter {
25+
private Activity activity;
26+
private List<LogRow> rows;
27+
private static final String TAG = "DLT-Viewer";
28+
29+
public LogTableAdapter(Activity activity, List<LogRow> rows) {
30+
super();
31+
this.activity = activity;
32+
this.rows = rows;
33+
}
34+
35+
@Override
36+
public int getCount() {
37+
return rows.size();
38+
}
39+
40+
@Override
41+
public Object getItem(int position) {
42+
return rows.get(position);
43+
}
44+
45+
@Override
46+
public long getItemId(int position) {
47+
// TODO Auto-generated method stub
48+
return 0;
49+
}
50+
51+
@Override
52+
public View getView(int position, View convertView, ViewGroup parent) {
53+
54+
if (convertView == null) {
55+
LayoutInflater inflater = activity.getLayoutInflater();
56+
convertView = inflater.inflate(R.layout.log_row, null);
57+
}
58+
TextView col1 = (TextView) convertView.findViewById(R.id.log_timestamp);
59+
TextView col2 = (TextView) convertView.findViewById(R.id.log_ecuid);
60+
TextView col3 = (TextView) convertView.findViewById(R.id.log_apid);
61+
TextView col4 = (TextView) convertView.findViewById(R.id.log_ctid);
62+
TextView col5 = (TextView) convertView.findViewById(R.id.log_subtype);
63+
TextView col6 = (TextView) convertView.findViewById(R.id.log_payload);
64+
65+
String timestamp = rows.get(position).getColumn(0);
66+
String subtype = rows.get(position).getColumn(4);
67+
68+
int len = timestamp.length();
69+
String new_timestamp = timestamp.substring(0, len-4) + "." + timestamp.substring(len-4, len);
70+
Log.i(TAG, timestamp+" vs "+new_timestamp);
71+
col1.setText(new_timestamp);
72+
col2.setText(rows.get(position).getColumn(1));
73+
col3.setText(rows.get(position).getColumn(2));
74+
col4.setText(rows.get(position).getColumn(3));
75+
col5.setText(subtype);
76+
col6.setText(rows.get(position).getColumn(5));
77+
78+
if(subtype.equals("error") || subtype.equals("fatal")) {
79+
col1.setBackgroundResource(R.drawable.border_red);
80+
col2.setBackgroundResource(R.drawable.border_red);
81+
col3.setBackgroundResource(R.drawable.border_red);
82+
col4.setBackgroundResource(R.drawable.border_red);
83+
col5.setBackgroundResource(R.drawable.border_red);
84+
col6.setBackgroundResource(R.drawable.border_red);
85+
}
86+
else if(subtype.equals("warn")) {
87+
col1.setBackgroundResource(R.drawable.border_yellow);
88+
col2.setBackgroundResource(R.drawable.border_yellow);
89+
col3.setBackgroundResource(R.drawable.border_yellow);
90+
col4.setBackgroundResource(R.drawable.border_yellow);
91+
col5.setBackgroundResource(R.drawable.border_yellow);
92+
col6.setBackgroundResource(R.drawable.border_yellow);
93+
}
94+
else {
95+
col1.setBackgroundResource(R.drawable.border);
96+
col2.setBackgroundResource(R.drawable.border);
97+
col3.setBackgroundResource(R.drawable.border);
98+
col4.setBackgroundResource(R.drawable.border);
99+
col5.setBackgroundResource(R.drawable.border);
100+
col6.setBackgroundResource(R.drawable.border);
101+
}
102+
103+
return convertView;
104+
}
105+
}

0 commit comments

Comments
 (0)