Skip to content

Commit f99de19

Browse files
committed
[platform] add app image (icon.png)
- make app list show clear where is boundry between apps
1 parent 26da181 commit f99de19

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

app/src/main/java/seven/drawalive/nodebase/NodeBaseApp.java

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package seven.drawalive.nodebase;
22

33
import android.content.Context;
4+
import android.graphics.Bitmap;
5+
import android.graphics.BitmapFactory;
46
import android.util.Log;
57
import android.view.View;
68
import android.widget.ArrayAdapter;
79
import android.widget.Button;
810
import android.widget.EditText;
11+
import android.widget.ImageView;
912
import android.widget.LinearLayout;
1013
import android.widget.Spinner;
1114
import android.widget.TableLayout;
@@ -62,14 +65,40 @@ public void collectAppInformation() {
6265

6366
public void prepareLayout() {
6467
Context context = getContext();
68+
LinearLayout frame = new LinearLayout(context);
69+
frame.setOrientation(LinearLayout.HORIZONTAL);
70+
71+
ImageView image = new ImageView(context);
72+
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(64, 64);
73+
params.setMargins(1, 1, 1, 1);
74+
image.setLayoutParams(params);
75+
image.setMaxHeight(64);
76+
image.setMaxWidth(64);
77+
image.setMinimumHeight(64);
78+
image.setMinimumWidth(64);
79+
try {
80+
File imgfile = new File(_appdir.getAbsolutePath().concat("/icon.png"));
81+
if (imgfile.exists()) {
82+
Bitmap bmp = BitmapFactory.decodeFile(imgfile.getAbsolutePath());
83+
image.setImageBitmap(bmp);
84+
} else {
85+
image.setBackgroundResource(R.drawable.default_icon);
86+
}
87+
} catch (Exception e) {
88+
}
89+
frame.addView(image);
90+
91+
LinearLayout contents = new LinearLayout(context);
92+
contents.setOrientation(LinearLayout.VERTICAL);
93+
6594
TextView label;
6695
label = new TextView(context);
6796
label.setText(String.format("\n=============== App: %s ===", _appdir.getName()));
68-
addView(label);
97+
contents.addView(label);
6998
label = new TextView(context);
7099
label.setText(_readme);
71100
_readme = null; // release memory
72-
addView(label);
101+
contents.addView(label);
73102

74103
TableLayout tbl = new TableLayout(context);
75104
TableRow tbl_r_t = null;
@@ -91,7 +120,7 @@ public void prepareLayout() {
91120
tbl_r_t.addView(_txtParams);
92121
tbl.addView(tbl_r_t);
93122
tbl.setStretchAllColumns(true);
94-
addView(tbl);
123+
contents.addView(tbl);
95124

96125

97126
LinearLayout subview = new LinearLayout(context);
@@ -107,7 +136,10 @@ public void prepareLayout() {
107136
_btnShare.setText("Share");
108137
_btnShare.setEnabled(false);
109138
subview.addView(_btnShare);
110-
addView(subview);
139+
contents.addView(subview);
140+
141+
frame.addView(contents);
142+
addView(frame);
111143
}
112144

113145
public void prepareEvents() {
538 Bytes
Loading

modules/file_upload_download/icon.png

357 Bytes
Loading

0 commit comments

Comments
 (0)