diff --git a/app/src/main/java/com/hapramp/preferences/HaprampPreferenceManager.java b/app/src/main/java/com/hapramp/preferences/HaprampPreferenceManager.java index 95a2c07a..1410f803 100644 --- a/app/src/main/java/com/hapramp/preferences/HaprampPreferenceManager.java +++ b/app/src/main/java/com/hapramp/preferences/HaprampPreferenceManager.java @@ -2,6 +2,7 @@ import android.content.Context; import android.content.SharedPreferences; +import android.util.Log; import com.google.gson.Gson; import com.hapramp.main.HapRampMain; @@ -182,7 +183,8 @@ public void saveCurrentUserFollowings(ArrayList followings) { Set set = new HashSet(); set.addAll(followings); editor.putStringSet("followings", set); - editor.apply(); + editor.commit(); + Log.d("UserInfo","saving followings "+set.toString()); } public Set getFollowingsSet() { diff --git a/app/src/main/java/com/hapramp/ui/activity/ParticipateEditorActivity.java b/app/src/main/java/com/hapramp/ui/activity/ParticipateEditorActivity.java index 49afc97e..7a0e0a45 100644 --- a/app/src/main/java/com/hapramp/ui/activity/ParticipateEditorActivity.java +++ b/app/src/main/java/com/hapramp/ui/activity/ParticipateEditorActivity.java @@ -21,6 +21,7 @@ import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; import android.view.View; +import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -103,6 +104,9 @@ public class ParticipateEditorActivity extends AppCompatActivity implements Edit TextView submissionInfo; @BindView(R.id.auto_hashtags_text) TextView autoHashtagsText; + @BindView(R.id.attach_link_check) + CheckBox attachLinkCheckBox; + private ProgressDialog progressDialog; private String title; private String generated_permalink; @@ -307,6 +311,11 @@ private void sendPostToSteemBlockChain() { showPublishingProgressDialog(true, "Publishing..."); SteemPostCreator steemPostCreator = new SteemPostCreator(); steemPostCreator.setSteemPostCreatorCallback(this); + if(attachLinkCheckBox.isChecked()) { + //add competition link + String url = String.format(getString(R.string.contest_structure), mCompetitionTitle, mCompetitionId); + body = body + url; + } //add footer body = body + Constants.COMPETITION_FOOTER; steemPostCreator.createPost(body, title, imageLinks, tags, generated_permalink); diff --git a/app/src/main/java/com/hapramp/ui/fragments/UserInfoFragment.java b/app/src/main/java/com/hapramp/ui/fragments/UserInfoFragment.java index 6b2f8a4f..48e8fa80 100644 --- a/app/src/main/java/com/hapramp/ui/fragments/UserInfoFragment.java +++ b/app/src/main/java/com/hapramp/ui/fragments/UserInfoFragment.java @@ -1,7 +1,6 @@ package com.hapramp.ui.fragments; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; @@ -9,6 +8,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.app.AlertDialog; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -30,7 +30,6 @@ import com.hapramp.datastore.callbacks.UserProfileCallback; import com.hapramp.models.AppServerUserModel; import com.hapramp.models.CommunityModel; -import com.hapramp.models.MicroCommunity; import com.hapramp.preferences.HaprampPreferenceManager; import com.hapramp.steem.CommunityListWrapper; import com.hapramp.steem.models.User; @@ -66,7 +65,8 @@ import static com.hapramp.ui.activity.FollowListActivity.EXTRA_KEY_TAB_INDEX; import static com.hapramp.ui.activity.FollowListActivity.EXTRA_KEY_USERNAME; -public class UserInfoFragment extends Fragment implements FollowInfoCallback, UserProfileCallback, CompleteFollowingHelper.FollowingsSyncCompleteListener { +public class UserInfoFragment extends Fragment implements FollowInfoCallback, UserProfileCallback, + CompleteFollowingHelper.FollowingsSyncCompleteListener { Unbinder unbinder; @BindView(R.id.profile_wall_pic) ImageView profileWallPic; @@ -147,7 +147,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.user_info_fragment, null); unbinder = ButterKnife.bind(this, view); init(mContext); @@ -172,32 +173,18 @@ private void init(Context context) { } } - private void attachListeners() { - followBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (isFollowed) { - confirmUnfollowAction(); - } else { - requestFollowOnSteem(); - } + followBtn.setOnClickListener(v -> { + if (isFollowed) { + confirmUnfollowAction(); + } else { + requestFollowOnSteem(); } }); - followersCountTv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - navigateToFollowersListPage(); - } - }); + followersCountTv.setOnClickListener(view -> navigateToFollowersListPage()); - followingsCountTv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - navigateToFollowingListPage(); - } - }); + followingsCountTv.setOnClickListener(view -> navigateToFollowingListPage()); } private void fetchUserInfo() { @@ -209,12 +196,7 @@ private void confirmUnfollowAction() { AlertDialog.Builder builder = new AlertDialog.Builder(mContext) .setTitle("Unfollow") .setMessage("Do you want to Unfollow " + mUsername + " ?") - .setPositiveButton("UnFollow", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - requestUnFollowOnSteem(); - } - }) + .setPositiveButton("UnFollow", (dialog, which) -> requestUnFollowOnSteem()) .setNegativeButton("No", null); builder.show(); } @@ -230,23 +212,17 @@ public void run() { new SteemConnectCallback() { @Override public void onResponse(String s) { - mHandler.post(new Runnable() { - @Override - public void run() { - showFollowProgress(false); - userFollowedOnSteem(); - } + mHandler.post(() -> { + showFollowProgress(false); + userFollowedOnSteem(); }); } @Override public void onError(SteemConnectException e) { - mHandler.post(new Runnable() { - @Override - public void run() { - showFollowProgress(false); - userFollowFailed(); - } + mHandler.post(() -> { + showFollowProgress(false); + userFollowFailed(); }); } } @@ -292,23 +268,17 @@ public void run() { new SteemConnectCallback() { @Override public void onResponse(String s) { - mHandler.post(new Runnable() { - @Override - public void run() { - showFollowProgress(false); - userUnFollowedOnSteem(); - } + mHandler.post(() -> { + showFollowProgress(false); + userUnFollowedOnSteem(); }); } @Override public void onError(SteemConnectException e) { - mHandler.post(new Runnable() { - @Override - public void run() { - showFollowProgress(false); - userUnfollowFailed(); - } + mHandler.post(() -> { + showFollowProgress(false); + userUnfollowFailed(); }); } } @@ -371,6 +341,7 @@ private void userUnfollowFailed() { } private void setFollowState(boolean state) { + Log.d("UserInfo", "setting follow " + state); try { // to avoid dead view access if (state) { followBtn.setText(TICK_TEXT + " Following"); @@ -386,7 +357,10 @@ private void setFollowState(boolean state) { } private void syncFollowings() { - FollowingsSyncUtils.syncFollowings(mContext, this); + new Handler().postDelayed(() -> { + Log.d("UserInfo","firing fetch..."); + FollowingsSyncUtils.syncFollowings(mContext, this); + }, 10000); } private void t(String s) { @@ -438,12 +412,7 @@ private void bind(User data) { followBtn.setVisibility(GONE); editBtn.setVisibility(VISIBLE); editBtn.setEnabled(true); - editBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - navigateToProfileEditActivity(); - } - }); + editBtn.setOnClickListener(view -> navigateToProfileEditActivity()); CommunityListWrapper listWrapper = new Gson().fromJson(HaprampPreferenceManager .getInstance().getUserSelectedCommunityAsJson(), CommunityListWrapper.class); if (interestsView != null) { @@ -495,6 +464,8 @@ private void invalidateFollowButton() { if (followBtn != null) { followBtn.setVisibility(VISIBLE); } + Log.d("UserInfo", "New Following set " + followings.toString()); + Log.d("UserInfo", "invalidating follow=" + followings.contains(mUsername)); setFollowState(followings.contains(mUsername)); } else { if (followBtn != null) { @@ -554,7 +525,7 @@ private void setMCData(AppServerUserModel userModel) { if (userModel != null) { mcView.setMicroCommunityList(userModel.getMicroCommunities()); } else { - mcView.setMicroCommunityList(new ArrayList()); + mcView.setMicroCommunityList(new ArrayList<>()); } } } @@ -578,12 +549,9 @@ public void onFollowInfoAvailable(final int followers, final int followings) { this.followersCount = followers; this.followingCount = followings; followInfoAvailable = true; - mHandler.post(new Runnable() { - @Override - public void run() { - setFollowerCount(followers); - setFollowingCount(followings); - } + mHandler.post(() -> { + setFollowerCount(followers); + setFollowingCount(followings); }); } diff --git a/app/src/main/java/com/hapramp/utils/CompleteFollowingHelper.java b/app/src/main/java/com/hapramp/utils/CompleteFollowingHelper.java index d00b36f3..35826d68 100644 --- a/app/src/main/java/com/hapramp/utils/CompleteFollowingHelper.java +++ b/app/src/main/java/com/hapramp/utils/CompleteFollowingHelper.java @@ -1,6 +1,7 @@ package com.hapramp.utils; import android.content.Context; +import android.util.Log; import com.hapramp.datastore.DataStore; import com.hapramp.datastore.callbacks.FollowingsCallback; @@ -51,6 +52,7 @@ public void onFollowingsAvailable(ArrayList followings) { if (followings.size() >= 19) { fetchFollowingsFrom(lastUserInResult); } else { + Log.d("UserInfo","fetched followings "+followings.toString()); HaprampPreferenceManager.getInstance().saveCurrentUserFollowings(followingList); if (followingsSyncCompleteListener != null) { followingsSyncCompleteListener.onSyncCompleted(); diff --git a/app/src/main/res/layout/activity_participate_in_competition_acitivity.xml b/app/src/main/res/layout/activity_participate_in_competition_acitivity.xml index 2b14a553..b5969f49 100644 --- a/app/src/main/res/layout/activity_participate_in_competition_acitivity.xml +++ b/app/src/main/res/layout/activity_participate_in_competition_acitivity.xml @@ -142,7 +142,7 @@ diff --git a/app/src/main/res/layout/contest_participate_meta_view.xml b/app/src/main/res/layout/contest_participate_meta_view.xml new file mode 100644 index 00000000..a17aec6e --- /dev/null +++ b/app/src/main/res/layout/contest_participate_meta_view.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f80b8c9..25e032d1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -32,4 +32,5 @@ Leaving less than 5 STEEM POWER in your account is not recommended and can leave your account in an unusable state. To cancel (take back) delegation: Delegate 0 STEEM to the account you delegated to. Hello blank fragment + My entry for the [%s](https://alpha.1ramp.io/competitions/%s) - 1Ramp Contests]]>