Started working on new layout for people view

pull/14/head
Sam Bosley 12 years ago
parent b62e1755f1
commit 47f736d17a

@ -58,6 +58,10 @@ public final class User extends RemoteModel {
public static final LongProperty REMOTE_ID = new LongProperty(
TABLE, REMOTE_ID_PROPERTY_NAME);
/** Friendship status */
public static final StringProperty STATUS = new StringProperty(
TABLE, "status");
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(User.class);
@ -70,6 +74,7 @@ public final class User extends RemoteModel {
defaultValues.put(NAME.name, "");
defaultValues.put(EMAIL.name, "");
defaultValues.put(PICTURE.name, "");
defaultValues.put(STATUS.name, "");
}
@Override
@ -77,6 +82,12 @@ public final class User extends RemoteModel {
return defaultValues;
}
public static final String STATUS_PENDING = "pending";
public static final String STATUS_OTHER_PENDING = "other_pending";
public static final String STATUS_FRIENDS = "friends";
public static final String STATUS_IGNORED = "ignored";
public static final String STATUS_BLOCKED = "blocked";
// --- data access boilerplate
public User() {

@ -1426,6 +1426,7 @@ public final class ActFmSyncService {
model.setValue(User.NAME, json.optString("name"));
model.setValue(User.EMAIL, json.optString("email"));
model.setValue(User.PICTURE, json.optString("picture"));
model.setValue(User.STATUS, json.optString("status"));
}
public static void jsonFromUser(JSONObject json, User model) throws JSONException {

@ -9,6 +9,7 @@ import android.content.Intent;
import android.support.v4.view.Menu;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.timsu.astrid.R;
@ -21,6 +22,7 @@ import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.helper.ProgressBarSyncResultCallback;
import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.service.ThemeService;
@ -41,6 +43,10 @@ public class PersonViewFragment extends TaskListFragment {
@Autowired ActFmPreferenceService actFmPreferenceService;
private AsyncImageView userImage;
private TextView userName;
private TextView userSubtitle;
private User user;
@Override
@ -50,6 +56,13 @@ public class PersonViewFragment extends TaskListFragment {
user = userDao.fetch(extras.getLong(EXTRA_USER_ID_LOCAL), User.PROPERTIES);
}
((TextView) getView().findViewById(android.R.id.empty)).setText(getEmptyDisplayString());
if (user != null) {
userImage.setUrl(user.getValue(User.PICTURE));
userName.setText(user.getDisplayName());
} else {
getView().findViewById(R.id.user_header).setVisibility(View.GONE);
}
}
@Override
@ -67,6 +80,24 @@ public class PersonViewFragment extends TaskListFragment {
}
@Override
protected void setUpUiComponents() {
super.setUpUiComponents();
userImage = (AsyncImageView) getView().findViewById(R.id.user_image);
userName = (TextView) getView().findViewById(R.id.user_name);
userSubtitle = (TextView) getView().findViewById(R.id.user_subtitle);
}
@Override
protected View getListBody(ViewGroup root) {
ViewGroup parent = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.task_list_body_user, root, false);
View taskListView = super.getListBody(parent);
parent.addView(taskListView);
return parent;
}
@Override
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
if(actFmPreferenceService.isLoggedIn()) {

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="100">
<RelativeLayout
android:id="@+id/user_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:background="#ff0000">
<com.todoroo.astrid.helper.AsyncImageView
android:id="@+id/user_image"
android:layout_height="45dip"
android:layout_width="45dip"
android:scaleType="fitCenter"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/user_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/user_image"
android:layout_alignTop="@id/user_image"
android:text="USER NAME"/>
<TextView
android:id="@+id/user_subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/user_name"
android:layout_toRightOf="@id/user_image"
android:text="Some text goes here. Blah blah blah bleeeeeeeep."/>
</RelativeLayout>
<!-- List body goes here -->
</LinearLayout>

@ -330,6 +330,13 @@ public class Database extends AbstractDatabase {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
case 25: try {
database.execSQL("ALTER TABLE " + User.TABLE.name + " ADD " +
User.STATUS.accept(visitor, null));
} catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
return true;
}

Loading…
Cancel
Save