Compare commits

...

14 Commits

Author SHA1 Message Date
LucasGGamerM
26297fbb5b Lastcomm 2022-12-28 18:02:38 -03:00
LucasGGamerM
cd342d1034 I am trying my best 2022-12-28 14:56:49 -03:00
LucasGGamerM
029650ef2d Its almost working, the UI side is done. But the request is being canceled when the back button is pressed. 2022-12-28 12:34:00 -03:00
LucasGGamerM
ac24f636df Its a little less broken 2022-12-28 11:15:12 -03:00
LucasGGamerM
1688168bc1 The ui is less broken 2022-12-28 11:05:33 -03:00
LucasGGamerM
46b842afc4 It still does not work, but its one step closer to working 2022-12-28 10:45:15 -03:00
LucasGGamerM
3f773a52cc Created the class. Lets leave this for tomorrow 2022-12-27 21:43:42 -03:00
LucasGGamerM
48664bb580 Idk what to call this commit, so Note Improver it is 2022-12-27 21:42:21 -03:00
LucasGGamerM
094cd67728 Now adding a confirm button 2022-12-27 21:19:54 -03:00
LucasGGamerM
9d800106cc Added a framelayout just for adding the confirm button 2022-12-27 20:20:44 -03:00
LucasGGamerM
68bb23e3b4 It actually loads something. Perfect 2022-12-27 18:48:08 -03:00
LucasGGamerM
68397bd487 How did I add some many lines? Removing them 2022-12-27 18:27:57 -03:00
LucasGGamerM
3104ddb4b6 More polishes the UI side a little more, now also hides the private note on the personal profile 2022-12-27 18:26:35 -03:00
LucasGGamerM
9bddd6b274 The ui side is ready somehow. Still need to handle it all 2022-12-27 16:53:21 -03:00
5 changed files with 118 additions and 14 deletions

View File

@@ -0,0 +1,19 @@
package org.joinmastodon.android.api.requests.accounts;
import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.model.Relationship;
public class SetPrivateNote extends MastodonAPIRequest<Relationship>{
public SetPrivateNote(String id, String comment){
super(MastodonAPIRequest.HttpMethod.POST, "/accounts/"+id+"/note", Relationship.class);
Request req = new Request(comment);
setRequestBody(req);
}
private static class Request{
public String comment;
public Request(String comment){
this.comment=comment;
}
}
}

View File

@@ -1,16 +1,11 @@
package org.joinmastodon.android.fragments;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Outline;
@@ -19,8 +14,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ImageSpan;
@@ -37,8 +30,8 @@ import android.view.WindowInsets;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -52,6 +45,7 @@ import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
import org.joinmastodon.android.api.requests.accounts.GetAccountStatuses;
import org.joinmastodon.android.api.requests.accounts.GetOwnAccount;
import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed;
import org.joinmastodon.android.api.requests.accounts.SetPrivateNote;
import org.joinmastodon.android.api.requests.accounts.UpdateAccountCredentials;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.account_list.FollowerListFragment;
@@ -116,8 +110,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private SwipeRefreshLayout refreshLayout;
private CoverOverlayGradientDrawable coverGradient=new CoverOverlayGradientDrawable();
private float titleTransY;
private View postsBtn, followersBtn, followingBtn;
private EditText nameEdit, bioEdit;
private View postsBtn, followersBtn, followingBtn, noteEditWrapper;
private EditText nameEdit, bioEdit, noteEdit;
private ImageButton noteEditConfirm;
private ProgressBar actionProgress, notifyProgress;
private FrameLayout[] tabViews;
private TabLayoutMediator tabLayoutMediator;
@@ -180,6 +175,10 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
name=content.findViewById(R.id.name);
username=content.findViewById(R.id.username);
bio=content.findViewById(R.id.bio);
noteEdit=content.findViewById(R.id.note_edit);
// noteEditConfirm=content.findViewById(R.id.note_edit_confirm);
// noteEditConfirm.setOnClickListener(v->onClickNoteSave());
noteEditWrapper=content.findViewById(R.id.note_edit_wrap);
followersCount=content.findViewById(R.id.followers_count);
followersLabel=content.findViewById(R.id.followers_label);
followersBtn=content.findViewById(R.id.followers_btn);
@@ -446,6 +445,15 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account);
// noteEdit.setOnFocusChangeListener((v, hasFocus) -> {
// if(!hasFocus){
//// Toast.makeText(getActivity(), "Its going here", Toast.LENGTH_LONG).show();
// savePrivateNote();
//// noteEdit.setOnFocusChangeListener(savePrivateNote());
// }
// });
noteEdit.setOnClickListener(v->savePrivateNote());
if(account.locked){
ssb=new SpannableStringBuilder("@");
ssb.append(account.acct);
@@ -464,12 +472,28 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
username.setText('@'+account.acct+(isSelf ? ('@'+AccountSessionManager.getInstance().getAccount(accountID).domain) : ""));
}
CharSequence parsedBio=HtmlParser.parse(account.note, account.emojis, Collections.emptyList(), Collections.emptyList(), accountID);
bio.setOnClickListener(v->savePrivateNote());
if(TextUtils.isEmpty(parsedBio)){
bio.setVisibility(View.GONE);
}else{
bio.setVisibility(View.VISIBLE);
bio.setText(parsedBio);
}
if(isOwnProfile){
noteEditWrapper.setVisibility(View.GONE);
}
// if(noteEdit.getText().toString() == null){
// noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_regular);
// noteEditConfirm.setClickable(false);
// noteEditConfirm.setAlpha(.50f);
// }else{
// noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_filled);
// noteEditConfirm.setClickable(true);
// noteEditConfirm.setAlpha(1.0f);
// }
followersCount.setText(UiUtils.abbreviateNumber(account.followersCount));
followingCount.setText(UiUtils.abbreviateNumber(account.followingCount));
postsCount.setText(UiUtils.abbreviateNumber(account.statusesCount));
@@ -666,6 +690,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
notifyProgress.setIndeterminateTintList(notifyButton.getTextColors());
followsYouView.setVisibility(relationship.followedBy ? View.VISIBLE : View.GONE);
notifyButton.setSelected(relationship.notifying);
noteEdit.setText(relationship.note);
if (getActivity() != null) notifyButton.setContentDescription(getString(relationship.notifying ? R.string.sk_user_post_notifications_on : R.string.sk_user_post_notifications_off, '@'+account.username));
}
@@ -971,6 +996,17 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
scrollView.smoothScrollTo(0, 0);
}
private void savePrivateNote(){
currentRequest = new SetPrivateNote(profileAccountID, noteEdit.getText().toString()).setCallback(new SimpleCallback<>(this) {
@Override
public void onSuccess(Relationship result) {
relationship=result;
updateRelationship();
Toast.makeText(getActivity(), "Success", Toast.LENGTH_LONG).show();
}
});
}
private void onFollowersOrFollowingClick(View v){
Bundle args=new Bundle();
args.putString("account", accountID);

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M7.5,7C7.224,7 7,7.224 7,7.5C7,7.776 7.224,8 7.5,8H12.5C12.776,8 13,7.776 13,7.5C13,7.224 12.776,7 12.5,7H7.5ZM7,10.5C7,10.224 7.224,10 7.5,10H12.5C12.776,10 13,10.224 13,10.5C13,10.776 12.776,11 12.5,11H7.5C7.224,11 7,10.776 7,10.5ZM7.5,13C7.224,13 7,13.224 7,13.5C7,13.776 7.224,14 7.5,14H9.5C9.776,14 10,13.776 10,13.5C10,13.224 9.776,13 9.5,13H7.5ZM6.5,2C6.224,2 6,2.224 6,2.5V3H5.5C4.672,3 4,3.672 4,4.5V16.5C4,17.328 4.672,18 5.5,18H11.5C11.633,18 11.76,17.947 11.854,17.854L15.854,13.854C15.947,13.76 16,13.633 16,13.5V4.5C16,3.672 15.328,3 14.5,3H14V2.5C14,2.224 13.776,2 13.5,2C13.224,2 13,2.224 13,2.5V3H10.5V2.5C10.5,2.224 10.276,2 10,2C9.724,2 9.5,2.224 9.5,2.5V3H7V2.5C7,2.224 6.776,2 6.5,2ZM14.5,4C14.776,4 15,4.224 15,4.5V13H12.5C11.672,13 11,13.672 11,14.5V17H5.5C5.224,17 5,16.776 5,16.5V4.5C5,4.224 5.224,4 5.5,4H14.5ZM14.293,14L12,16.293V14.5C12,14.224 12.224,14 12.5,14H14.293Z"
android:fillColor="#212121"/>
</vector>

View File

@@ -256,11 +256,49 @@
android:textColor="?android:textColorSecondary"
tools:text="\@Gargron" />
<org.joinmastodon.android.ui.views.LinkedTextView
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/note_edit_wrap"
android:layout_below="@id/username"
android:layout_marginTop="0dp"
android:padding="2dp">
<EditText
android:id="@+id/note_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:layout_marginHorizontal="16dp"
android:inputType="textMultiLine|textCapSentences"
android:singleLine="false"
android:drawableStart="@drawable/ic_fluent_notepad_20_regular"
android:drawablePadding="12dp"
android:drawableTint="?android:textColorSecondary"
android:background="@drawable/bg_search_field"
android:paddingHorizontal="16dp"
android:elevation="0dp"
android:hint="@string/sk_personal_note"/>
<!-- <ImageButton-->
<!-- android:id="@+id/note_edit_confirm"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/ic_fluent_checkmark_24_regular"-->
<!-- android:backgroundTint="#00000000"-->
<!-- android:layout_marginTop="2dp"-->
<!-- android:layout_marginEnd="10dp"-->
<!-- android:layout_gravity="right|center_vertical" />-->
</FrameLayout>
<org.joinmastodon.android.ui.views.LinkedTextView
android:id="@+id/bio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username"
android:layout_below="@id/note_edit_wrap"
android:layout_marginLeft="16dp"
android:layout_marginTop="4dp"
android:layout_marginRight="16dp"
@@ -331,10 +369,11 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"
android:background="@drawable/bg_fab"
android:tint="@color/fab_icon"
android:scaleType="center"
android:src="@drawable/ic_edit_34"
android:stateListAnimator="@animator/fab_shadow"
android:src="@drawable/ic_edit_34"/>
android:tint="@color/fab_icon"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck" />
</FrameLayout>

View File

@@ -67,6 +67,7 @@
<string name="sk_app_username" translatable="false">\@megalodon</string>
<string name="sk_tabs_disable_swipe">Disable swiping between tabs</string>
<string name="sk_settings_profile">Set up profile</string>
<string name="sk_personal_note">Personal note for this profile:</string>
<string name="sk_settings_posting">Posting preferences</string>
<string name="sk_settings_filters">Configure filters</string>
<string name="sk_settings_auth">Security settings</string>