Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
46545a7
My profile activity introduced
oguzkocer Nov 17, 2015
ad59f58
Link added to me page for the my profile activity
oguzkocer Nov 17, 2015
2fb87f1
My profile labels added
oguzkocer Nov 18, 2015
ef28245
Dividers added to my profile page
oguzkocer Nov 18, 2015
04519ba
My profile page now uses the correct text view & font
oguzkocer Nov 18, 2015
f004610
Basic input dialog added to my profile for first name
oguzkocer Nov 19, 2015
cae4632
My profile refactored and the labels are added in, the dialog is now …
oguzkocer Nov 23, 2015
e04a0b1
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 3, 2015
5735b59
First name, last name and about me added to Account model
oguzkocer Dec 3, 2015
d671ba7
Fixed getter/setters for new properties
oguzkocer Dec 3, 2015
0c72234
First name, last name and about me db migration added
oguzkocer Dec 3, 2015
3a770a8
Updating account settings separated from the main call
oguzkocer Dec 4, 2015
b3d6623
Fetching account settings and updating UI
oguzkocer Dec 4, 2015
c4cd55f
Added a callback to /me/settings call to update the my profile screen
oguzkocer Dec 4, 2015
86b0fe4
DialogUtils introduced
oguzkocer Dec 5, 2015
0101534
Use DialogUtils for editing first name in My Profile
oguzkocer Dec 5, 2015
2e47efc
All labels in My Profile screen is now editable
oguzkocer Dec 5, 2015
9f9cb12
Adds the ability to add hint to input dialog
oguzkocer Dec 6, 2015
a83e7b2
Use updateLabel method, so the visibility of labels are correctly set
oguzkocer Dec 6, 2015
ed1f445
Save button added to my profile screen
oguzkocer Dec 6, 2015
f157e77
Possible NPE fixed in Account model
oguzkocer Dec 6, 2015
5142cbd
Save button updates the account settings
oguzkocer Dec 6, 2015
75de500
Progress dialog added for save action
oguzkocer Dec 7, 2015
b6289d6
Account settings icon added
oguzkocer Dec 8, 2015
6da2856
Me settings icon renamed as my profile icon
oguzkocer Dec 8, 2015
4215f4d
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 10, 2015
a77e56c
Track my profile and account settings events
oguzkocer Dec 10, 2015
6615849
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 15, 2015
a5c24e9
Unescape html for my profile labels
oguzkocer Dec 15, 2015
2589d1f
Show the initial text in my profile dialogs as selected
oguzkocer Dec 15, 2015
3f3b9ad
Fixed a bug where you couldn't delete your my profile labels
oguzkocer Dec 15, 2015
0bd01f5
Fixed a bug where the display name wouldn't be updated in the db afte…
oguzkocer Dec 15, 2015
197d61e
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 16, 2015
e04a89a
Hide my profile row when not logged in with WordPress.com
oguzkocer Dec 16, 2015
d5a3328
Save button removed from My Profile page
oguzkocer Dec 16, 2015
855b485
Posting account settings now accepts the params instead of certain fi…
oguzkocer Dec 16, 2015
d77e214
When you update labels in my profile, it'll silently update the server
oguzkocer Dec 16, 2015
dafb905
Change the capitilization for the my profile labels
oguzkocer Dec 16, 2015
1fb9464
Check if finishing for my profile activity for success callback
oguzkocer Dec 17, 2015
5de8502
Use StringUtils.notNullStr() for new account model properties
oguzkocer Dec 17, 2015
219f8fd
Set My Profile's title in the manifest
oguzkocer Dec 17, 2015
5e4dca4
Use TextUtils.isEmpty() instead of manual null & empty check
oguzkocer Dec 17, 2015
13b388a
Remove unnecessary usage of 'org.wordpress.android.' in some places
oguzkocer Dec 17, 2015
316b394
My Profile dialog is now cancelable
oguzkocer Dec 17, 2015
a5e201c
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 17, 2015
2fe452f
MyProfileActivity moved to prefs package
oguzkocer Dec 18, 2015
d0fe00b
Instead of using callbacks, use EventBus to update UI for my profile …
oguzkocer Dec 18, 2015
90505d3
Me screen shows the updated information when navigated in
oguzkocer Dec 18, 2015
43c8df6
Me screen icons updated with gridicons counterparts
oguzkocer Dec 18, 2015
ba913a0
Display name field defaults to username
oguzkocer Dec 18, 2015
b974355
My profile view is wrapped inside of a ScrollView
oguzkocer Dec 18, 2015
5a02a14
xxxhdpi icons for /me moved to future folder
oguzkocer Dec 18, 2015
e06e762
Merge remote-tracking branch 'origin/develop' into feature/my-profile
oguzkocer Dec 21, 2015
a7a51ac
Account.RestParam enum refactored to use constructors
oguzkocer Dec 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@
android:theme="@style/CalypsoTheme"
android:windowSoftInputMode="stateHidden"/>

<!--Me activities-->
<activity
android:name=".ui.prefs.MyProfileActivity"
android:label="@string/my_profile"
android:theme="@style/CalypsoTheme" />

<!-- Services -->
<service
android:name=".ui.posts.services.PostUploadService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class WordPressDB {
public static final String COLUMN_NAME_VIDEO_PRESS_SHORTCODE = "videoPressShortcode";
public static final String COLUMN_NAME_UPLOAD_STATE = "uploadState";

private static final int DATABASE_VERSION = 38;
private static final int DATABASE_VERSION = 39;

private static final String CREATE_TABLE_BLOGS = "create table if not exists accounts (id integer primary key autoincrement, "
+ "url text, blogName text, username text, password text, imagePlacement text, centerThumbnail boolean, fullSizeImage boolean, maxImageWidth text, maxImageWidthId integer);";
Expand Down Expand Up @@ -380,6 +380,9 @@ public WordPressDB(Context ctx) {
case 37:
resetThemeTable();
currentVersion++;
case 38:
AccountTable.migrationAddFirstNameLastNameAboutMeFields(db);
currentVersion++;
}
db.setVersion(DATABASE_VERSION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public static void migrationAddEmailAddressField(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + ACCOUNT_TABLE + " ADD email TEXT DEFAULT '';");
}

public static void migrationAddFirstNameLastNameAboutMeFields(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + ACCOUNT_TABLE + " ADD first_name TEXT DEFAULT '';");
db.execSQL("ALTER TABLE " + ACCOUNT_TABLE + " ADD last_name TEXT DEFAULT '';");
db.execSQL("ALTER TABLE " + ACCOUNT_TABLE + " ADD about_me TEXT DEFAULT '';");
}

private static void dropTables(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + ACCOUNT_TABLE);
}
Expand All @@ -59,6 +65,9 @@ public static void save(Account account, SQLiteDatabase database) {
values.put("visible_site_count", account.getVisibleSiteCount());
values.put("access_token", account.getAccessToken());
values.put("email", account.getEmail());
values.put("first_name", account.getFirstName());
values.put("last_name", account.getLastName());
values.put("about_me", account.getAboutMe());
database.insertWithOnConflict(ACCOUNT_TABLE, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}

Expand All @@ -84,6 +93,9 @@ private static Account getAccountByLocalId(long localId) {
account.setVisibleSiteCount(c.getInt(c.getColumnIndex("visible_site_count")));
account.setAccessToken(c.getString(c.getColumnIndex("access_token")));
account.setEmail(c.getString(c.getColumnIndex("email")));
account.setFirstName(c.getString(c.getColumnIndex("first_name")));
account.setLastName(c.getString(c.getColumnIndex("last_name")));
account.setAboutMe(c.getString(c.getColumnIndex("about_me")));
}
return account;
} finally {
Expand Down
64 changes: 64 additions & 0 deletions WordPress/src/main/java/org/wordpress/android/models/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
import org.wordpress.android.WordPress;
import org.wordpress.android.datasets.AccountTable;
import org.wordpress.android.datasets.ReaderUserTable;
import org.wordpress.android.ui.prefs.PrefsEvents;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;

import java.util.Map;

import de.greenrobot.event.EventBus;

/**
* Class for managing logged in user informations.
*/
Expand Down Expand Up @@ -37,6 +42,48 @@ public void onErrorResponse(VolleyError volleyError) {
WordPress.getRestClientUtilsV1_1().get("me", listener, errorListener);
}

public void fetchAccountSettings() {
com.wordpress.rest.RestRequest.Listener listener = new RestRequest.Listener() {
@Override
public void onResponse(JSONObject jsonObject) {
if (jsonObject != null) {
updateAccountSettingsFromRestResponse(jsonObject);
save();
EventBus.getDefault().post(new PrefsEvents.MyProfileDetailsChanged());
}
}
};

RestRequest.ErrorListener errorListener = new RestRequest.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.API, volleyError);
}
};

WordPress.getRestClientUtilsV1_1().get("me/settings", listener, errorListener);
}

public void postAccountSettings(Map<String, String> params) {
com.wordpress.rest.RestRequest.Listener listener = new RestRequest.Listener() {
@Override
public void onResponse(JSONObject jsonObject) {
if (jsonObject != null) {
updateAccountSettingsFromRestResponse(jsonObject);
save();
}
}
};

RestRequest.ErrorListener errorListener = new RestRequest.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.API, volleyError);
}
};

WordPress.getRestClientUtilsV1_1().post("me/settings", params, null, listener, errorListener);
}

public void signout() {
init();
Expand All @@ -46,4 +93,21 @@ public void signout() {
public void save() {
AccountTable.save(this);
}

public enum RestParam {
FIRST_NAME("first_name"),
LAST_NAME("last_name"),
DISPLAY_NAME("display_name"),
ABOUT_ME("description");

private String description;

RestParam(String description) {
this.description = description;
}

public static String toString(RestParam param) {
return param.description;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class AccountModel {
private int mVisibleSiteCount;
private String mAccessToken;
private String mEmail;
private String mFirstName;
private String mLastName;
private String mAboutMe;

public AccountModel() {
init();
Expand All @@ -33,6 +36,9 @@ public void init() {
mVisibleSiteCount = 0;
mAccessToken = "";
mEmail = "";
mFirstName = "";
mLastName = "";
mAboutMe = "";
}

public void updateFromRestResponse(JSONObject json) {
Expand All @@ -47,6 +53,13 @@ public void updateFromRestResponse(JSONObject json) {
mEmail = json.optString("email");
}

public void updateAccountSettingsFromRestResponse(JSONObject json) {
mFirstName = json.optString("first_name");
mLastName = json.optString("last_name");
mDisplayName = json.optString("display_name");
mAboutMe = json.optString("description");
}

public long getUserId() {
return mUserId;
}
Expand Down Expand Up @@ -130,4 +143,28 @@ public void setEmail(String email) {
public String getEmail() {
return StringUtils.notNullStr(mEmail);
}

public String getFirstName() {
return StringUtils.notNullStr(mFirstName);
}

public void setFirstName(String firstName) {
mFirstName = firstName;
}

public String getLastName() {
return StringUtils.notNullStr(mLastName);
}

public void setLastName(String lastName) {
mLastName = lastName;
}

public String getAboutMe() {
return StringUtils.notNullStr(mAboutMe);
}

public void setAboutMe(String aboutMe) {
mAboutMe = aboutMe;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.wordpress.android.ui.accounts.SignInActivity;
import org.wordpress.android.ui.comments.CommentsActivity;
import org.wordpress.android.ui.main.SitePickerActivity;
import org.wordpress.android.ui.prefs.MyProfileActivity;
import org.wordpress.android.ui.media.MediaBrowserActivity;
import org.wordpress.android.ui.media.WordPressMediaUtils;
import org.wordpress.android.ui.posts.EditPostActivity;
Expand Down Expand Up @@ -172,8 +173,15 @@ public static void addMedia(Activity activity) {
WordPressMediaUtils.launchPictureLibrary(activity);
}

public static void viewMyProfile(Context context) {
Intent intent = new Intent(context, MyProfileActivity.class);
AnalyticsUtils.trackWithCurrentBlogDetails(AnalyticsTracker.Stat.OPENED_MY_PROFILE);
slideInFromRight(context, intent);
}

public static void viewAccountSettings(Activity activity) {
Intent intent = new Intent(activity, SettingsActivity.class);
AnalyticsUtils.trackWithCurrentBlogDetails(AnalyticsTracker.Stat.OPENED_ACCOUNT_SETTINGS);
slideInFromRightForResult(activity, intent, RequestCodes.ACCOUNT_SETTINGS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import org.wordpress.android.models.Account;
import org.wordpress.android.models.AccountHelper;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.prefs.PrefsEvents;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.HelpshiftHelper.Tag;
import org.wordpress.android.widgets.WPNetworkImageView;

import java.lang.ref.WeakReference;

import de.greenrobot.event.EventBus;

public class MeFragment extends Fragment {
private static final String IS_DISCONNECTING = "IS_DISCONNECTING";

Expand All @@ -36,6 +39,7 @@ public class MeFragment extends Fragment {
private TextView mDisplayNameTextView;
private TextView mUsernameTextView;
private TextView mLoginLogoutTextView;
private View mMyProfileView;
private View mNotificationsView;
private View mNotificationsDividerView;
private ProgressDialog mDisconnectProgressDialog;
Expand All @@ -54,12 +58,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mDisplayNameTextView = (TextView) rootView.findViewById(R.id.me_display_name);
mUsernameTextView = (TextView) rootView.findViewById(R.id.me_username);
mLoginLogoutTextView = (TextView) rootView.findViewById(R.id.me_login_logout_text_view);
mMyProfileView = rootView.findViewById(R.id.row_my_profile);
mNotificationsView = rootView.findViewById(R.id.row_notifications);
mNotificationsDividerView = rootView.findViewById(R.id.me_notifications_divider);

addDropShadowToAvatar();
refreshAccountDetails();

mMyProfileView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ActivityLauncher.viewMyProfile(getActivity());
}
});

rootView.findViewById(R.id.row_settings).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -108,6 +120,19 @@ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}

@Override
public void onStop() {
EventBus.getDefault().unregister(this);
super.onStop();
}

@Override
public void onResume() {
super.onResume();
refreshAccountDetails();
EventBus.getDefault().register(this);
}

@Override
public void onDestroy() {
if (mDisconnectProgressDialog != null) {
Expand Down Expand Up @@ -141,6 +166,7 @@ private void refreshAccountDetails() {
mDisplayNameTextView.setVisibility(View.VISIBLE);
mUsernameTextView.setVisibility(View.VISIBLE);
mAvatarFrame.setVisibility(View.VISIBLE);
mMyProfileView.setVisibility(View.VISIBLE);
mNotificationsView.setVisibility(View.VISIBLE);
mNotificationsDividerView.setVisibility(View.VISIBLE);

Expand All @@ -161,6 +187,7 @@ private void refreshAccountDetails() {
mDisplayNameTextView.setVisibility(View.GONE);
mUsernameTextView.setVisibility(View.GONE);
mAvatarFrame.setVisibility(View.GONE);
mMyProfileView.setVisibility(View.GONE);
mNotificationsView.setVisibility(View.GONE);
mNotificationsDividerView.setVisibility(View.GONE);
mLoginLogoutTextView.setText(R.string.me_connect_to_wordpress_com);
Expand Down Expand Up @@ -227,4 +254,8 @@ protected void onPostExecute(Void aVoid) {
mDisconnectProgressDialog = null;
}
}

public void onEventMainThread(PrefsEvents.MyProfileDetailsChanged event) {
refreshAccountDetails();
}
}
Loading