Permalink
Browse files

ver1.1.0

- new: sort items
- new: image cache
- bugfix: crash when launched from apps feed
- bugfix: no response when tapped logo on action bar
  • Loading branch information...
1 parent ddf661a commit 91644b3fb7e01289f4c866a0330d623eef2f0de8 @kazuyayokoyama committed Feb 14, 2012
View
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kazuyayokoyama.android.apps.todobento"
- android:versionCode="1"
- android:versionName="1.0.0">
+ android:versionCode="2"
+ android:versionName="1.1.0">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:background="#FFFFFF">
- <com.kazuyayokoyama.android.apps.todobento.ui.widget.SortableListView android:id="@id/android:list"
+ <leoliang.tasks365.DraggableListView android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@@ -148,18 +148,6 @@ synchronized public TodoListItem getTodoListItem(String uuid) {
return null;
}
- synchronized public void sortTodoList(int positionFrom, int positionTo) {
- TodoListItem item = mBento.bento.todoList.get(positionFrom);
-
- if (positionFrom < positionTo) {
- mBento.bento.todoList.add(positionTo, item);
- mBento.bento.todoList.remove(positionFrom);
- } else if (positionFrom > positionTo) {
- mBento.bento.todoList.remove(positionFrom);
- mBento.bento.todoList.add(positionTo, item);
- }
- }
-
synchronized public int getTodoListCount() {
return mBento.bento.todoList.size();
}
@@ -189,10 +177,7 @@ synchronized public Bitmap getTodoBitmap(DbFeed dbFeed, String todoUuid,
}
c.close();
- // dummy
- if (bitmap == null) {
- bitmap = BitmapHelper.getDummyBitmap(targetWidth, targetHeight);
- } else {
+ if (bitmap != null) {
bitmap = BitmapHelper.getResizedBitmap(bitmap, targetWidth, targetHeight, degrees);
}
@@ -290,6 +275,18 @@ synchronized public void updateTodo(TodoListItem updateItem, String htmlMsg) {
pushUpdate(htmlMsg);
}
+ synchronized public void sortTodoList(int positionFrom, int positionTo) {
+ TodoListItem item = mBento.bento.todoList.get(positionFrom);
+
+ if (positionFrom < positionTo) {
+ mBento.bento.todoList.add(positionTo, item);
+ mBento.bento.todoList.remove(positionFrom);
+ } else if (positionFrom > positionTo) {
+ mBento.bento.todoList.remove(positionFrom);
+ mBento.bento.todoList.add(positionTo, item);
+ }
+ }
+
synchronized public void sortTodoCompleted(String htmlMsg) {
pushUpdate(htmlMsg);
}
@@ -73,6 +73,7 @@ public void onListItemClick(ListView l, View v, int position, long id) {
// Intent
Intent intent = new Intent(getActivity(), TodoListActivity.class);
+ intent.putExtra(TodoListActivity.EXTRA_LAUNCHED_FROM_BENTO_LIST, true);
startActivity(intent);
}
@@ -33,6 +33,7 @@
import com.kazuyayokoyama.android.apps.todobento.R;
import com.kazuyayokoyama.android.apps.todobento.io.BentoManager;
+import com.kazuyayokoyama.android.apps.todobento.util.ImageCache;
public class HomeActivity extends FragmentActivity {
public static final String EXTRA_TODO = "com.kazuyayokoyama.android.apps.todobento.extra.EXTRA_TODO";
@@ -61,7 +62,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (bInstalled) {
goMusubi();
} else {
- goMarket();
+ goMusubiOnMarket();
}
} else {
@@ -75,30 +76,40 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
mMusubi = Musubi.getInstance(this);
- // get version code
- int versionCode = 0;
- try {
- PackageInfo packageInfo = getPackageManager().getPackageInfo(
- "com.kazuyayokoyama.android.apps.todobento", PackageManager.GET_META_DATA);
- versionCode = packageInfo.versionCode;
- } catch (NameNotFoundException e) {
- e.printStackTrace();
+ // Check iif this activity launched from apps feed
+ if (mMusubi == null || mMusubi.getObj() == null || mMusubi.getObj().getSubfeed() == null) {
+ // go to market
+ goMarket();
+
+ } else {
+
+ // get version code
+ int versionCode = 0;
+ try {
+ PackageInfo packageInfo = getPackageManager().getPackageInfo(
+ "com.kazuyayokoyama.android.apps.todobento", PackageManager.GET_META_DATA);
+ versionCode = packageInfo.versionCode;
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ new TodoListAsyncTask(this, (Uri) intent.getParcelableExtra(Musubi.EXTRA_FEED_URI), versionCode).execute();
}
-
- new TodoListAsyncTask(this, (Uri) intent.getParcelableExtra(Musubi.EXTRA_FEED_URI), versionCode).execute();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_TODO_LIST) {
mManager.fin();
+ ImageCache.clearCache();
finish();
} else if (requestCode == REQUEST_BENTO_LIST) {
if (resultCode == Activity.RESULT_OK) {
goTodoList();
} else {
mManager.fin();
+ ImageCache.clearCache();
finish();
}
}
@@ -116,7 +127,7 @@ private void goTodoList() {
startActivityForResult(intent, REQUEST_TODO_LIST);
}
- private void goMarket() {
+ private void goMusubiOnMarket() {
AlertDialog.Builder marketDialog = new AlertDialog.Builder(this)
.setTitle(R.string.market_dialog_title)
.setMessage(R.string.market_dialog_text)
@@ -154,7 +165,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
startActivity(intent);
finish();
} catch (Exception e) {
- goMarket();
+ goMusubiOnMarket();
}
}
})
@@ -166,6 +177,14 @@ public void onClick(DialogInterface dialog, int whichButton) {
});
musubiDialog.create().show();
}
+
+ private void goMarket() {
+ // Go to Market
+ Uri uri = Uri.parse("market://details?id=com.kazuyayokoyama.android.apps.todobento");
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(intent);
+ finish();
+ }
private class TodoListAsyncTask extends AsyncTask<Void, Void, Boolean> {
private BentoManager mManager = BentoManager.getInstance();
@@ -30,19 +30,24 @@
import com.kazuyayokoyama.android.apps.todobento.ui.TodoListFragment.OnBentoSelectedListener;
public class TodoListActivity extends FragmentActivity implements OnBentoSelectedListener {
+ public static final String EXTRA_LAUNCHED_FROM_BENTO_LIST = "launched_from_bento_list";
+
//private static final String TAG = "TodoListActivity";
private BentoManager mManager = BentoManager.getInstance();
private TodoListFragment mTodoListFragment;
+ private boolean mLaunchedFromBentoList = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_todo_list);
+
+ mLaunchedFromBentoList = getIntent().hasExtra(EXTRA_LAUNCHED_FROM_BENTO_LIST);
final ActionBar actionBar = getSupportActionBar();
// set defaults for logo & home up
- actionBar.setDisplayHomeAsUpEnabled(false);
+ actionBar.setDisplayHomeAsUpEnabled(mLaunchedFromBentoList);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setTitle(mManager.getBentoListItem().bento.name.toString());
@@ -68,7 +73,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
- finish();
+ if (mLaunchedFromBentoList) {
+ finish();
+ }
return true;
default:
return mTodoListFragment.onOptionsItemSelected(item);
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.util.UUID;
+import leoliang.tasks365.DraggableListView;
+import leoliang.tasks365.DraggableListView.DropListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -65,7 +67,7 @@
private BentoManager mManager = BentoManager.getInstance();
private TodoListItemAdapter mListAdapter = null;
- private SortableListView mListView = null;
+ private DraggableListView mListView = null;
private boolean mSorted = false;
private OnBentoSelectedListener mListener;
@@ -76,10 +78,25 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View root = inflater.inflate(R.layout.fragment_todo_list, container, false);
// ListView
- mListView = (SortableListView) root.findViewById(android.R.id.list);
- mListView.setDragListener(new DragListener());
- mListView.setSortable(false);
+ mListView = (DraggableListView) root.findViewById(android.R.id.list);
mListView.setFastScrollEnabled(true);
+ mListView.setDropListener(new DropListener() {
+ @Override
+ public void drop(int from, int to) {
+ if (from == to) {
+ return;
+ }
+
+ // sort
+ StringBuilder msg = new StringBuilder(
+ getString(R.string.feed_msg_sorted, mManager.getLocalName()));
+ String htmlMsg = UIUtils.getHtmlString(mManager.getBentoListItem().bento.name, msg.toString());
+ mManager.sortTodoList(from, to);
+ mManager.sortTodoCompleted(htmlMsg);
+
+ refreshView();
+ }
+ });
return root;
}
@@ -16,6 +16,7 @@
package com.kazuyayokoyama.android.apps.todobento.ui;
+import leoliang.tasks365.DraggableListView;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -31,8 +32,8 @@
import com.kazuyayokoyama.android.apps.todobento.R;
import com.kazuyayokoyama.android.apps.todobento.io.BentoManager;
-import com.kazuyayokoyama.android.apps.todobento.ui.widget.SortableListView;
import com.kazuyayokoyama.android.apps.todobento.util.BitmapHelper;
+import com.kazuyayokoyama.android.apps.todobento.util.ImageCache;
import com.kazuyayokoyama.android.apps.todobento.util.UIUtils;
public class TodoListItemAdapter extends ArrayAdapter<TodoListItem> {
@@ -43,16 +44,16 @@
private BentoManager mManager = BentoManager.getInstance();
private LayoutInflater mInflater;
private int mDraggingPosition = -1;
- private SortableListView mSortableListView = null;
+ private DraggableListView mDraggableListView = null;
private Context mContext = null;
public TodoListItemAdapter(Context context, int resourceId,
- SortableListView listView) {
+ DraggableListView listView) {
super(context, resourceId);
mContext = context;
mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mSortableListView = listView;
+ mDraggableListView = listView;
}
@Override
@@ -100,7 +101,7 @@ public void onClick(View view) {
item.modContactId = mManager.getLocalContactId();
CharSequence baseMsg;
- Resources rsrc = mSortableListView.getResources();
+ Resources rsrc = mDraggableListView.getResources();
if (item.bDone) {
if (item.title.length() > 0) {
baseMsg = rsrc.getString(R.string.feed_msg_done, mManager.getLocalName(), item.title);
@@ -155,9 +156,9 @@ public void onClick(View view) {
holder.imageView.setImageBitmap(
BitmapHelper.getDummyBitmap(IMG_WIDTH, IMG_HEIGHT));
- ImageGetTask task = new ImageGetTask(holder.imageView);
- task.execute(item.uuid);
- /*
+ //ImageGetTask task = new ImageGetTask(holder.imageView);
+ //task.execute(item.uuid);
+
Bitmap bitmap = ImageCache.getImage(item.uuid);
if (bitmap == null) {
holder.imageView.setImageBitmap(
@@ -168,7 +169,7 @@ public void onClick(View view) {
holder.imageView.setImageBitmap(bitmap);
holder.imageView.setVisibility(View.VISIBLE);
}
- */
+
} catch (Exception e) {
e.printStackTrace();
}
@@ -218,7 +219,7 @@ protected Bitmap doInBackground(String... params) {
try {
Bitmap bitmap = mManager.getTodoBitmap(params[0], IMG_WIDTH, IMG_HEIGHT, 0);
if (bitmap != null) {
- //ImageCache.setImage(params[0], bitmap);
+ ImageCache.setImage(params[0], bitmap);
}
return bitmap;
} catch (Exception e) {
Oops, something went wrong. Retry.

0 comments on commit 91644b3

Please sign in to comment.