Its almost working, the UI side is done. But the request is being canceled when the back button is pressed.
This commit is contained in:
parent
ac24f636df
commit
029650ef2d
|
@ -4,17 +4,17 @@ import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.model.PrivateNote;
|
import org.joinmastodon.android.model.PrivateNote;
|
||||||
|
|
||||||
public class SetPrivateNote extends MastodonAPIRequest<PrivateNote>{
|
public class SetPrivateNote extends MastodonAPIRequest<PrivateNote>{
|
||||||
public SetPrivateNote(String id, String note){
|
public SetPrivateNote(String id, String comment){
|
||||||
super(MastodonAPIRequest.HttpMethod.POST, "/accounts/"+id+"/note", PrivateNote.class);
|
super(MastodonAPIRequest.HttpMethod.POST, "/accounts/"+id+"/note", PrivateNote.class);
|
||||||
Request req = new Request(note);
|
Request req = new Request(comment);
|
||||||
setRequestBody(req);
|
setRequestBody(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request{
|
private static class Request{
|
||||||
public String comment;
|
public String comment;
|
||||||
|
|
||||||
public Request(String note){
|
public Request(String comment){
|
||||||
this.comment = note;
|
this.comment=comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Outline;
|
import android.graphics.Outline;
|
||||||
|
@ -19,8 +14,6 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
|
@ -39,7 +32,6 @@ import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -185,9 +177,28 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
username=content.findViewById(R.id.username);
|
username=content.findViewById(R.id.username);
|
||||||
bio=content.findViewById(R.id.bio);
|
bio=content.findViewById(R.id.bio);
|
||||||
noteEdit=content.findViewById(R.id.note_edit);
|
noteEdit=content.findViewById(R.id.note_edit);
|
||||||
noteEditConfirm=content.findViewById(R.id.note_edit_confirm);
|
noteEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
noteEditConfirm.setOnClickListener(v->onClickNoteSave());
|
@Override
|
||||||
noteEditWrapper=content.findViewById(R.id.note_edit_wrapper);
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
if(!hasFocus){
|
||||||
|
Toast.makeText(getActivity(), "Its going here", Toast.LENGTH_LONG).show();
|
||||||
|
currentRequest = new SetPrivateNote(account.id, noteEdit.getText().toString()).setCallback(new Callback<>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(PrivateNote result) {
|
||||||
|
Toast.makeText(getActivity(), "Success", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error) {
|
||||||
|
Toast.makeText(getActivity(), "Error, not success", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 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);
|
followersCount=content.findViewById(R.id.followers_count);
|
||||||
followersLabel=content.findViewById(R.id.followers_label);
|
followersLabel=content.findViewById(R.id.followers_label);
|
||||||
followersBtn=content.findViewById(R.id.followers_btn);
|
followersBtn=content.findViewById(R.id.followers_btn);
|
||||||
|
@ -307,16 +318,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
return sizeWrapper;
|
return sizeWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickNoteSave() {
|
|
||||||
Toast.makeText(getActivity(), "Its going here", Toast.LENGTH_LONG).show();
|
|
||||||
currentRequest = new SetPrivateNote(account.id, noteEdit.getText().toString()).setCallback(new SimpleCallback<PrivateNote>(this) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(PrivateNote result) {
|
|
||||||
Toast.makeText(getActivity(), "Success", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(){
|
protected void doLoadData(){
|
||||||
currentRequest=new GetAccountByID(profileAccountID)
|
currentRequest=new GetAccountByID(profileAccountID)
|
||||||
|
@ -493,15 +494,15 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
noteEditWrapper.setVisibility(View.GONE);
|
noteEditWrapper.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(noteEdit.getText().toString() == null){
|
// if(noteEdit.getText().toString() == null){
|
||||||
noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_regular);
|
// noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_regular);
|
||||||
noteEditConfirm.setClickable(false);
|
// noteEditConfirm.setClickable(false);
|
||||||
noteEditConfirm.setAlpha(.50f);
|
// noteEditConfirm.setAlpha(.50f);
|
||||||
}else{
|
// }else{
|
||||||
noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_filled);
|
// noteEditConfirm.setImageResource(R.drawable.ic_fluent_checkmark_24_filled);
|
||||||
noteEditConfirm.setClickable(true);
|
// noteEditConfirm.setClickable(true);
|
||||||
noteEditConfirm.setAlpha(1.0f);
|
// noteEditConfirm.setAlpha(1.0f);
|
||||||
}
|
// }
|
||||||
|
|
||||||
followersCount.setText(UiUtils.abbreviateNumber(account.followersCount));
|
followersCount.setText(UiUtils.abbreviateNumber(account.followersCount));
|
||||||
followingCount.setText(UiUtils.abbreviateNumber(account.followingCount));
|
followingCount.setText(UiUtils.abbreviateNumber(account.followingCount));
|
||||||
|
|
|
@ -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>
|
|
@ -259,7 +259,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/note_edit_wrapper"
|
android:id="@+id/note_edit_wrap"
|
||||||
android:layout_below="@id/username"
|
android:layout_below="@id/username"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
android:padding="2dp">
|
android:padding="2dp">
|
||||||
|
@ -274,39 +274,23 @@
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:inputType="textMultiLine|textCapSentences"
|
android:inputType="textMultiLine|textCapSentences"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:drawableStart="@drawable/ic_fluent_globe_20_regular"
|
android:drawableStart="@drawable/ic_fluent_notepad_20_regular"
|
||||||
android:drawablePadding="12dp"
|
android:drawablePadding="12dp"
|
||||||
android:drawableTint="?android:textColorSecondary"
|
android:drawableTint="?android:textColorSecondary"
|
||||||
android:background="@drawable/bg_search_field"
|
android:background="@drawable/bg_search_field"
|
||||||
android:paddingHorizontal="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:hint="@string/sk_example_domain"/>
|
android:hint="@string/sk_personal_note"/>
|
||||||
|
|
||||||
<!-- <EditText-->
|
<!-- <ImageButton-->
|
||||||
<!-- android:id="@+id/note_edit"-->
|
<!-- android:id="@+id/note_edit_confirm"-->
|
||||||
<!-- android:layout_width="match_parent"-->
|
<!-- android:layout_width="wrap_content"-->
|
||||||
<!-- android:layout_height="wrap_content"-->
|
<!-- android:layout_height="wrap_content"-->
|
||||||
<!-- android:layout_marginLeft="16dp"-->
|
<!-- android:src="@drawable/ic_fluent_checkmark_24_regular"-->
|
||||||
<!-- android:layout_marginTop="8dp"-->
|
<!-- android:backgroundTint="#00000000"-->
|
||||||
<!-- android:layout_marginRight="16dp"-->
|
<!-- android:layout_marginTop="2dp"-->
|
||||||
<!-- android:layout_marginBottom="4dp"-->
|
<!-- android:layout_marginEnd="10dp"-->
|
||||||
<!-- android:textAppearance="@style/m3_body_large"-->
|
<!-- android:layout_gravity="right|center_vertical" />-->
|
||||||
<!-- android:textSize="16sp"-->
|
|
||||||
<!-- android:background="@drawable/bg_search_field"-->
|
|
||||||
<!-- android:inputType="textMultiLine|textCapSentences"-->
|
|
||||||
<!-- android:elevation="0dp"-->
|
|
||||||
<!-- android:hint="@string/sk_personal_note"-->
|
|
||||||
<!-- android:textColorHint="?android:textColorSecondaryInverseNoDisable" />-->
|
|
||||||
|
|
||||||
<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>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -314,7 +298,7 @@
|
||||||
android:id="@+id/bio"
|
android:id="@+id/bio"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/note_edit_wrapper"
|
android:layout_below="@id/note_edit_wrap"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
|
|
Loading…
Reference in New Issue