import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class EverFolderActivity extends BaseActivity {
private enum ScreenStatus {
- Normal, AddNode, RenameNode
+ Normal, AddNode, DeleteNode, RenameNode
};
private LinearLayout msgLayout;
private BitmapCacheFactory bitmapFactory = BitmapCacheFactory.getInstance();
private Node top = null;
private int indent = 0;
+ private int bmpPaddingLeft;
+ private int bmpWidth;
private int viewY;
private boolean lock = false;
private boolean isInit = true;
}
}
};
- private int bmpPaddingLeft;
@Override
public void onCreate(Bundle savedInstanceState) {
msgEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
- String text = s.toString();
- msgOkButton.setEnabled(text.length() > 0);
+ if (status != ScreenStatus.DeleteNode) {
+ String text = s.toString();
+ msgOkButton.setEnabled(text.length() > 0);
+ } else {
+ msgOkButton.setEnabled(true);
+ }
}
public void beforeTextChanged(CharSequence s, int start,
msgOkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- msgOkButtonOnClick();
+ msgOkButtonOnClick(v);
}
});
msgCancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- msgCancelOnClick();
+ msgCancelOnClick(v);
}
});
bitmapFactory.init(this);
Node node = new DirNode(null, null);
- Bitmap bmp = bitmapFactory.get(node.getStatusIconId());
+ Bitmap bmp = null;
+ bmp = bitmapFactory.get(node.getStatusIconId());
bmpPaddingLeft = bmp.getWidth();
+ bmp = bitmapFactory.get(node.getIconId());
+ bmpWidth = bmp.getWidth();
+
+ float fSize = 48 * (1 / 2.0f);
+ leftButton.setTextSize(fSize);
+ rightButton.setTextSize(fSize);
} catch (Exception e) {
// TODO
e.printStackTrace();
public boolean onMenuOpened(int featureId, Menu menu) {
boolean ret = super.onMenuOpened(featureId, menu);
+ // #29304
+ if (menu == null){
+ return false;
+ }
+
MenuItem item;
boolean cutButtonFlag = false;
}
private void selectMenuDelete() {
- FolderUtil util = FolderUtil.getInstance();
- LabelIconView target = layout.getSelectedTarget();
- long id = target.getNodeId();
- NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
- Node node = dao.searchById(id);
- if (node != null) {
- util.deleteNode(node);
- // TODO 三角マークも消さないといけないのでは
- layout.removeView(target);
- updateList();
- setStatus();
- }
+ setStatus(ScreenStatus.DeleteNode);
}
private void selectMenuRename() {
}
private void updateList(Node parent) {
- viewY = 30;
+ viewY = 10;
// List<Node> list = parent.getChildren();
// for (Node node : list){
// }
updateList(parent, 0);
layout.setMinimumHeight(viewY);
- layout.invalidate();
- }
-
+
+ scrollView.invalidate();
+
+// layout.invalidate();
+
+// this.runOnUiThread(new Runnable() {
+// @Override
+// public void run() {
+// // ビューを再描画し,UI上で画像変更を反映
+// scrollView.invalidate();
+// }
+// });
+ }
+
private void updateList(Node node, int depth) {
- int N = 100;
- int M = 80;
- int x = N * (depth - indent) + 50;
+ int N = (int) (bmpWidth * 0.6);
+ int M = (int) (bmpWidth * 1.2);
+ int x = N * (depth - indent);
if (depth - indent >= 0
&& !(depth - indent == 0 && node instanceof FileNode)) {
// }
view.setNodeId(node.getId());
}
- ScaleUtil scaleUtil = ScaleUtil.getInstance();
- viewY += M * scaleUtil.getScaledDensity();
+ viewY += M;
if (node.getStatus() != Node.Status.OPEN) {
return;
NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
for (Long id : idList) {
Node n = dao.searchById(id);
+ if (n == null){
+ // TODO
+ continue;
+ }
+ if (n instanceof DirNode){
+ DirNode d = (DirNode)n;
+ if (isNoteBook(d) && !d.isSelected()){
+ continue;
+ }
+ }
list.add(n);
}
Collections.sort(list, nodeComparator);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// updateList();
// setStatus();
+ NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
+ if (dao.isEmpty()) {
+ finish();
+ }
isInit = true;
}
@Override
protected void onStart() {
super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
+ if (dao.isEmpty()) {
+ if (isInit) {
+ Intent intent = new Intent(this,
+ (Class<?>) SettingActivity.class);
+ startActivityForResult(intent, 0);
+
+ isInit = false;
+ } else {
+ finish();
+ isInit = true;
+ }
+ }
LockDao lockDao = (LockDao) LockDao.getInstance();
lock = lockDao.lock(this, Constant.LOCK_UPDATE_NOTE);
// }
// }
- private void msgOkButtonOnClick() {
+ private void msgOkButtonOnClick(View v) {
FolderUtil util = FolderUtil.getInstance();
LabelIconView target = layout.getSelectedTarget();
NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
DirNode node = new DirNode(text, null);
util.addDirNode(parent, node);
}
+ layout.setCutTarget(null, false);
+ } else if (status == ScreenStatus.DeleteNode) {
+ long id = target.getNodeId();
+ Node node = dao.searchById(id);
+ if (node != null) {
+ util.deleteNode(node);
+ layout.removeView(target);
+ }
+ layout.setCutTarget(null, false);
} else if (status == ScreenStatus.RenameNode) {
long id = target.getNodeId();
Node node = dao.searchById(id);
dao.updateName(node, text);
}
+ layout.setCutTarget(null, false);
}
+
+ closeIME(v);
+
layout.clearTarget();
updateList();
setStatus(ScreenStatus.Normal);
}
- private void msgCancelOnClick() {
+ private void msgCancelOnClick(View v) {
+ closeIME(v);
+
setStatus(ScreenStatus.Normal);
}
+ private void closeIME(View v){
+ InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(v.getWindowToken(),0);
+ }
+
public void execute(long srcId, long dstId) {
try {
removeAllNodeView();
dao.addChildrenIdNT(dst, src.getId());
} else if (dst instanceof FileNode) {
// dp.add(src.getId());
- dao.updateParentNT(src, dst.getId());
+ dao.updateParentNT(src, dp.getId());
dao.addChildrenIdNT(dp, src.getId());
}
NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
Node node = dao.searchById(id);
+ if (!isFileNode(node)) {
+ return;
+ }
String guid = node.getGuid();
EvernoteIntentUtil util = EvernoteIntentUtil.getInstance();
leftButton.setEnabled(false);
rightButton.setEnabled(false);
+ } else if (status == ScreenStatus.DeleteNode) {
+ msgLayout.setVisibility(View.VISIBLE);
+ msgEditText.setVisibility(View.GONE);
+ msgButtonLayout.setVisibility(View.VISIBLE);
+ confirmMsg.setText(getString(R.string.mainDeleteMsg));
+
+ layout.setElabledTouchEvent(false);
+ leftButton.setEnabled(false);
+ rightButton.setEnabled(false);
} else if (status == ScreenStatus.RenameNode) {
msgLayout.setVisibility(View.VISIBLE);
msgEditText.setVisibility(View.VISIBLE);