Added display of basic profile for user.

This commit is contained in:
RyanBateman 2012-07-05 13:01:25 -04:00
parent 386e18da71
commit 523d45236e
12 changed files with 307 additions and 54 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#00000000"
android:centerColor="#FFFFFFFF"
android:endColor="#00000000"
android:angle="0" />
</shape>

View file

@ -4,15 +4,22 @@
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/profile_details"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<fragment
android:name="com.newsblur.fragment.ProfileActivityFragment"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_below="@id/profile_details"/>
<View
android:layout_width="fill_parent"
android:layout_height="8dip"
android:layout_alignParentTop="true"
android:background="@drawable/orangeline_shadow" />
<FrameLayout
android:id="@+id/profile_details"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/darkgray" >
</LinearLayout>

View file

@ -2,54 +2,90 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white">
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="20dp">
<ImageView
android:id="@+id/profile_picture"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="@string/description_profile_picture"
android:src="@drawable/person"
android:background="@color/darkgray"
android:padding="10dp"
android:scaleType="fitCenter" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="USER PROFILE NAME"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/profile_picture"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_margin="20dp"
android:background="@color/darkgray"
android:contentDescription="@string/description_profile_picture"
android:scaleType="center"
android:src="@drawable/person" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="20dp"
android:layout_weight="1"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="@color/lightorange"
android:textStyle="bold"/>
<TextView
android:text="bio"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textStyle="italic"
android:textColor="@color/lightgray" />
android:gravity="center_vertical" >
<TextView
android:id="@+id/profile_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/lightorange"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/profile_bio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profile_username"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:textColor="@color/lightgray"
android:textSize="12dp"
android:textStyle="italic" />
<ImageView
android:id="@+id/profile_location_icon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_below="@id/profile_bio"
android:layout_marginRight="5dp"
android:contentDescription="@string/profile_location_icon"
android:scaleType="fitCenter"
android:src="@drawable/location_icon" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/profile_location_icon"
android:layout_below="@id/profile_bio"
android:layout_toRightOf="@id/profile_location_icon"
android:id="@+id/profile_location"
android:textColor="@color/lightgray"
android:textSize="12dp" />
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/lightgray" />
<include
android:layout_width="fill_parent"
layout="@layout/profile_user_statistics" />
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/lightgray" />
</LinearLayout>

View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/lightgray"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/profile_followingcount"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="@color/darkgray"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/profile_followercount"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="@color/darkgray"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/profile_sharedcount"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="@color/darkgray"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:id="@+id/profile_subscribercount"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="@color/darkgray"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="3dp"
android:text="@string/profile_following"
android:textAllCaps="true"
android:textColor="@color/darkgray"
android:textSize="11dp" />
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="3dp"
android:text="@string/profile_followers"
android:textAllCaps="true"
android:textColor="@color/darkgray"
android:textSize="11dp" />
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="3dp"
android:text="@string/profile_shared"
android:textAllCaps="true"
android:textColor="@color/darkgray"
android:textSize="11dp" />
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="3dp"
android:text="@string/profile_subscribers"
android:textAllCaps="true"
android:textColor="@color/darkgray"
android:textSize="11dp" />
</TableRow>
</TableLayout>

View file

@ -26,5 +26,10 @@
<string name="menu_refresh">Refresh</string>
<string name="profile">Profile</string>
<string name="profile_location_icon">Location icon</string>
<string name="profile_following">following</string>
<string name="profile_followers">followers</string>
<string name="profile_shared">shared</string>
<string name="profile_subscribers">subscribers</string>
</resources>

View file

@ -0,0 +1,18 @@
package com.newsblur.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.newsblur.R;
public class ProfileActivityFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_profileactivity, null);
}
}

View file

@ -1,24 +1,49 @@
package com.newsblur.fragment;
import com.newsblur.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.newsblur.R;
import com.newsblur.domain.UserProfile;
import com.newsblur.util.PrefsUtil;
public class ProfileDetailsFragment extends Fragment {
UserProfile user;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
user = PrefsUtil.getUserDetails(getActivity());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_profiledetails, null);
TextView username = (TextView) v.findViewById(R.id.profile_username);
username.setText(user.username);
TextView bio = (TextView) v.findViewById(R.id.profile_bio);
bio.setText(user.bio);
TextView location = (TextView) v.findViewById(R.id.profile_location);
location.setText(user.location);
TextView sharedCount = (TextView) v.findViewById(R.id.profile_sharedcount);
sharedCount.setText("" + user.sharedStoriesCount);
TextView followerCount = (TextView) v.findViewById(R.id.profile_followercount);
followerCount.setText("" + user.followerCount);
TextView followingCount = (TextView) v.findViewById(R.id.profile_followingcount);
followingCount.setText("" + user.followingCount);
TextView subscriberCount = (TextView) v.findViewById(R.id.profile_subscribercount);
subscriberCount.setText("" + user.numberOfSubscribers);
return v;
}

View file

@ -32,12 +32,33 @@ public class PrefsUtil {
edit.putString(PrefConstants.USER_POPULAR_PUBLISHERS, profile.popularPublishers);
edit.putInt(PrefConstants.USER_SHARED_STORIES_COUNT, profile.sharedStoriesCount);
edit.putInt(PrefConstants.USER_STORIES_LAST_MONTH, profile.storiesLastMonth);
edit.putInt(PrefConstants.USER_STORIES_LAST_MONTH, profile.storiesLastMonth);
edit.putInt(PrefConstants.USER_SUBSCRIBER_COUNT, profile.subscriptionCount);
edit.putString(PrefConstants.USER_USERNAME, profile.username);
edit.putString(PrefConstants.USER_WEBSITE, profile.website);
edit.commit();
}
public static UserProfile getUserDetails(final Context context) {
UserProfile user = new UserProfile();
final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
user.averageStoriesPerMonth = preferences.getInt(PrefConstants.USER_AVERAGE_STORIES_PER_MONTH, 0);
user.bio = preferences.getString(PrefConstants.USER_BIO, null);
user.feedAddress = preferences.getString(PrefConstants.USER_FEED_ADDRESS, null);
user.feedTitle = preferences.getString(PrefConstants.USER_FEED_TITLE, null);
user.followerCount = preferences.getInt(PrefConstants.USER_FOLLOWER_COUNT, 0);
user.followingCount = preferences.getInt(PrefConstants.USER_FOLLOWING_COUNT, 0);
user.id = preferences.getString(PrefConstants.USER_ID, null);
user.location = preferences.getString(PrefConstants.USER_LOCATION, null);
user.photoService = preferences.getString(PrefConstants.USER_PHOTO_SERVICE, null);
user.photoUrl = preferences.getString(PrefConstants.USER_PHOTO_URL, null);
user.popularPublishers = preferences.getString(PrefConstants.USER_POPULAR_PUBLISHERS, null);
user.sharedStoriesCount = preferences.getInt(PrefConstants.USER_SHARED_STORIES_COUNT, 0);
user.storiesLastMonth = preferences.getInt(PrefConstants.USER_STORIES_LAST_MONTH, 0);
user.subscriptionCount = preferences.getInt(PrefConstants.USER_SUBSCRIBER_COUNT, 0);
user.username = preferences.getString(PrefConstants.USER_USERNAME, null);
user.website = preferences.getString(PrefConstants.USER_WEBSITE, null);
return user;
}
}