package com.yuji.ef;
+import java.util.List;
+
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Point;
-import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.Gravity;
-import android.view.MotionEvent;
import android.view.View;
-import android.view.View.OnLongClickListener;
-import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
-import android.widget.ScrollView;
+
+import com.yuji.ef.dao.DirNode;
+import com.yuji.ef.dao.FileNode;
+import com.yuji.ef.dao.Node;
public class EverFolderActivity extends Activity /*implements OnTouchListener,
OnLongClickListener*/ {
private IconScrollView scrollView;
private IconImageView target = null;
private IconImageView dest = null;
+ private Node top = null;
private Animation anime;
private int startX;
// target.setImageBitmap(bmp);
// this.target.setOnTouchListener(this);
- int x;
- int y;
- int N = 200;
-
- x = 100;
- y = 0;
- for (int i = 0; i < 4; i++) {
- Bitmap bmp = (i % 2 == 0) ? bmp1 : bmp2;
- createIconImageView(bmp, x, y);
- y += N;
- }
+// int x;
+// int y;
+// int N = 200;
+//
+// x = 100;
+// y = 0;
+// for (int i = 0; i < 4; i++) {
+// Bitmap bmp = (i % 2 == 0) ? bmp1 : bmp2;
+// //createIconImageView(bmp, x, y);
+// createIconImageView(bmp, "TEXT" + i, x, y);
+// y += N;
+// }
+//
+// layout.setMinimumHeight(y * 2 + N);
+ top = new DirNode(null, null);
+
+ Node node;
+ node = new DirNode("\83f\83B\83\8c\83N\83g\83\8a", new LabelIconView(this));
+ top.add(node);
+ node.add(new FileNode("\83t\83@\83C\83\8baaa", new LabelIconView(this)));
+ node.add(new FileNode("\83t\83@\83C\83\8bbb", new LabelIconView(this)));
+ node.add(new FileNode("\83t\83@\83C\83\8bc", new LabelIconView(this)));
+
+ node = new DirNode("\83f\83B\83\8c\83N\83g\83\8aAAA", new LabelIconView(this));
+ top.add(node);
+ node.add(new DirNode("directory qqqq", new LabelIconView(this)));
+ node.add(new FileNode("\83t\83@\83C\83\8bdddddddd", new LabelIconView(this)));
+ node.add(new FileNode("\83t\83@\83C\83\8beee", new LabelIconView(this)));
- layout.setMinimumHeight(y * 2 + N);
+ node = new FileNode("\83t\83@\83C\83\8bzzz", new LabelIconView(this));
+ top.add(node);
+
+ updateList(top);
+ layout.setMinimumHeight(viewY);
} catch (Exception e) {
e.printStackTrace();
}
}
+ private int viewY;
+
+ private void updateList(Node parent){
+ int x = 50;
+ viewY = 30;
+
+ List<Node> list = parent.getChildren();
+ for (Node node : list){
+ updateList(node, x);
+ }
+ }
+
+ private void updateList(Node node, int x){
+ int N = 200;
+ int M = 120;
+
+ LabelIconView view = node.getView();
+ Resources r = getResources();
+ Bitmap bmp = BitmapFactory.decodeResource(r, node.getIconId());
+ createIconImageView(view, bmp, node.getName(), x, viewY);
+
+ viewY += M;
+
+ List<Node> list = node.getChildren();
+ if (list == null){
+ return;
+ }
+ for (Node n : list){
+ updateList(n, x + N);
+ }
+ }
+
+ private void createIconImageView(LabelIconView v, Bitmap bmp, String text, int x, int y) {
+ v.init(x, y, bmp, text);
+
+ android.view.WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+ params.gravity = Gravity.TOP | Gravity.LEFT;
+ params.height = WindowManager.LayoutParams.WRAP_CONTENT;
+ params.width = WindowManager.LayoutParams.WRAP_CONTENT;
+ params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+ params.format = PixelFormat.TRANSLUCENT;
+ params.windowAnimations = 0;
+ params.x = x;
+ params.y = y;
+ v.setLayoutParams(params);
+
+ layout.addView(v);
+ v.layout(x, y, x + v.getWidth(), y + v.getHeight());
+ }
+
+ private void createIconImageView(Bitmap bmp, String text, int x, int y) {
+ LabelIconView v = new LabelIconView(this);
+ v.init(x, y, bmp, text);
+
+ android.view.WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+ params.gravity = Gravity.TOP | Gravity.LEFT;
+ params.height = WindowManager.LayoutParams.WRAP_CONTENT;
+ params.width = WindowManager.LayoutParams.WRAP_CONTENT;
+ params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+ params.format = PixelFormat.TRANSLUCENT;
+ params.windowAnimations = 0;
+ params.x = x;
+ params.y = y;
+ v.setLayoutParams(params);
+
+ layout.addView(v);
+ v.layout(x, y, x + v.getWidth(), y + v.getHeight());
+ }
+
private void createIconImageView(Bitmap bmp, int x, int y) {
IconImageView v = new IconImageView(this);
v.init(x, y);
import android.widget.FrameLayout;
public class IconFrameLayout extends FrameLayout implements OnLongClickListener {
- private IconImageView target = null;
- private IconImageView dest = null;
-
+ private LabelIconView target = null;
+ private LabelIconView dest = null;
+ private List<LabelIconView> list = new ArrayList<LabelIconView>();
+
private Animation anime;
private int startX;
private int startY;
int size = this.getChildCount();
for (int i = 0; i < size; i++) {
- IconImageView vv = (IconImageView) this.getChildAt(i);
+ LabelIconView vv = (LabelIconView) this.getChildAt(i);
int x2 = vv.getInitX();
int y2 = vv.getInitY();
// vv.init(x2, y2);
}
}
- private View getView(int x, int y, View v, List<View> list) {
+ public void addView(LabelIconView child) {
+ super.addView(child);
+ list.add(child);
+ }
+
+ public void removeView(LabelIconView child) {
+ super.removeView(child);
+ list.remove(child);
+ }
+
+ public void moveTop(LabelIconView child){
+ this.removeView(child);
+ this.addView(child);
+ }
+
+ private View getView(int x, int y, View v, List<LabelIconView> list) {
Rect rect = new Rect();
if (v != null) {
x -= dx;
y -= dy;
- // FOO
- List<View> list = new ArrayList<View>();
- int size = this.getChildCount();
- for (int i = 0; i < size; i++) {
- IconImageView v = (IconImageView) this.getChildAt(i);
- list.add(v);
- }
int sx = x + scrollView.getScrollX();
int sy = y + scrollView.getScrollY();
// View v = getView(x, y, target, list);
// if (v == null) {
// return false;
// }
- IconImageView obj = (IconImageView) v;
+ LabelIconView obj = (LabelIconView) v;
+ int size = list.size();
+
if (target == null) {
target = obj;
if (dest == null) {
Rect rect = new Rect();
for (int i = 0; i < size; i++) {
- IconImageView vv = (IconImageView) list.get(i);
+ LabelIconView vv = (LabelIconView) list.get(i);
vv.getHitRect(rect);
if (rect.contains(x, y)) {
dest = vv;
if (target == null) {
return false;
}
- IconImageView v = (IconImageView) target;
+ LabelIconView v = (LabelIconView) target;
v.setAlpha(128);
v.clearColorFilter();
- this.removeView(target);
- this.addView(target);
+ moveTop(target);
longClickFlg = true;
return true;
--- /dev/null
+package com.yuji.ef;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.PorterDuff.Mode;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+public class LabelIconView extends LinearLayout {
+ private boolean isInit = false;
+ private int initX = 0;
+ private int initY = 0;
+
+ private ImageView imageView = null;
+ private TextView textView = null;
+
+ public LabelIconView(Context context) {
+ super(context);
+ }
+
+ public void init(int x, int y, Bitmap bmp, String text) {
+ init(x, y);
+ Context context = this.getContext();
+
+ imageView = new ImageView(context);
+ imageView.setImageBitmap(bmp);
+
+ textView = new TextView(context);
+ textView.setText(text);
+
+ this.addView(imageView);
+ this.addView(textView);
+ }
+
+ public int getInitX() {
+ return initX;
+ }
+
+ public int getInitY() {
+ return initY;
+ }
+
+ public void init(int x, int y) {
+ initX = x;
+ initY = y;
+ }
+
+ public void setAlpha(int alpha) {
+ imageView.setAlpha(alpha);
+ }
+
+ public void setColorFilter(int color, Mode mode) {
+ imageView.setColorFilter(color, mode);
+ }
+
+ public void clearColorFilter() {
+ imageView.clearColorFilter();
+ }
+
+
+}