feat(profile): add private notes textfield
This commit is contained in:
parent
26297fbb5b
commit
2c1b8da475
|
@ -4,8 +4,10 @@ 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.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
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;
|
||||||
|
@ -14,19 +16,24 @@ 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.text.Editable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewOutlineProvider;
|
import android.view.ViewOutlineProvider;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
@ -176,8 +183,7 @@ 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);
|
noteEditConfirm=content.findViewById(R.id.note_edit_confirm);
|
||||||
// noteEditConfirm.setOnClickListener(v->onClickNoteSave());
|
|
||||||
noteEditWrapper=content.findViewById(R.id.note_edit_wrap);
|
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);
|
||||||
|
@ -445,14 +451,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
|
|
||||||
boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account);
|
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){
|
if(account.locked){
|
||||||
ssb=new SpannableStringBuilder("@");
|
ssb=new SpannableStringBuilder("@");
|
||||||
|
@ -472,7 +470,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
username.setText('@'+account.acct+(isSelf ? ('@'+AccountSessionManager.getInstance().getAccount(accountID).domain) : ""));
|
username.setText('@'+account.acct+(isSelf ? ('@'+AccountSessionManager.getInstance().getAccount(accountID).domain) : ""));
|
||||||
}
|
}
|
||||||
CharSequence parsedBio=HtmlParser.parse(account.note, account.emojis, Collections.emptyList(), Collections.emptyList(), accountID);
|
CharSequence parsedBio=HtmlParser.parse(account.note, account.emojis, Collections.emptyList(), Collections.emptyList(), accountID);
|
||||||
bio.setOnClickListener(v->savePrivateNote());
|
// bio.setOnClickListener(v->savePrivateNote());
|
||||||
if(TextUtils.isEmpty(parsedBio)){
|
if(TextUtils.isEmpty(parsedBio)){
|
||||||
bio.setVisibility(View.GONE);
|
bio.setVisibility(View.GONE);
|
||||||
}else{
|
}else{
|
||||||
|
@ -484,6 +482,19 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
noteEditWrapper.setVisibility(View.GONE);
|
noteEditWrapper.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noteEdit.setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
|
noteEditConfirm.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
});
|
||||||
|
|
||||||
|
noteEditConfirm.setOnClickListener((v -> {
|
||||||
|
if (!noteEdit.getText().toString().trim().equals(account.note)) {
|
||||||
|
savePrivateNote();
|
||||||
|
}
|
||||||
|
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(this.getView().getRootView().getWindowToken(), 0);
|
||||||
|
noteEdit.clearFocus();
|
||||||
|
}));
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -1000,11 +1011,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
currentRequest = new SetPrivateNote(profileAccountID, noteEdit.getText().toString()).setCallback(new SimpleCallback<>(this) {
|
currentRequest = new SetPrivateNote(profileAccountID, noteEdit.getText().toString()).setCallback(new SimpleCallback<>(this) {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Relationship result) {
|
public void onSuccess(Relationship result) {
|
||||||
relationship=result;
|
Toast.makeText(getActivity(), "Successfully updated note", Toast.LENGTH_LONG).show();
|
||||||
updateRelationship();
|
|
||||||
Toast.makeText(getActivity(), "Success", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
});
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFollowersOrFollowingClick(View v){
|
private void onFollowersOrFollowingClick(View v){
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/refresh_layout"
|
android:id="@+id/refresh_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -282,15 +284,19 @@
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:hint="@string/sk_personal_note"/>
|
android:hint="@string/sk_personal_note"/>
|
||||||
|
|
||||||
<!-- <ImageButton-->
|
<ImageButton
|
||||||
<!-- android:id="@+id/note_edit_confirm"-->
|
android:id="@+id/note_edit_confirm"
|
||||||
<!-- android:layout_width="wrap_content"-->
|
android:layout_width="wrap_content"
|
||||||
<!-- android:layout_height="wrap_content"-->
|
android:layout_height="wrap_content"
|
||||||
<!-- android:src="@drawable/ic_fluent_checkmark_24_regular"-->
|
android:src="@drawable/ic_fluent_checkmark_24_filled"
|
||||||
<!-- android:backgroundTint="#00000000"-->
|
android:backgroundTint="#00000000"
|
||||||
<!-- android:layout_marginTop="2dp"-->
|
android:layout_marginTop="2dp"
|
||||||
<!-- android:layout_marginEnd="10dp"-->
|
android:visibility="invisible"
|
||||||
<!-- android:layout_gravity="right|center_vertical" />-->
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_gravity="right|center_vertical"
|
||||||
|
android:tooltipText="@string/sk_personal_note_confirm"
|
||||||
|
android:contentDescription="@string/sk_personal_note_confirm" />
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@
|
||||||
<string name="sk_app_username" translatable="false">\@megalodon</string>
|
<string name="sk_app_username" translatable="false">\@megalodon</string>
|
||||||
<string name="sk_tabs_disable_swipe">Disable swiping between tabs</string>
|
<string name="sk_tabs_disable_swipe">Disable swiping between tabs</string>
|
||||||
<string name="sk_settings_profile">Set up profile</string>
|
<string name="sk_settings_profile">Set up profile</string>
|
||||||
<string name="sk_personal_note">Personal note for this profile:</string>
|
<string name="sk_personal_note">Add a note for this profile</string>
|
||||||
|
<string name="sk_personal_note_confirm">Confirm edited note</string>
|
||||||
<string name="sk_settings_posting">Posting preferences</string>
|
<string name="sk_settings_posting">Posting preferences</string>
|
||||||
<string name="sk_settings_filters">Configure filters</string>
|
<string name="sk_settings_filters">Configure filters</string>
|
||||||
<string name="sk_settings_auth">Security settings</string>
|
<string name="sk_settings_auth">Security settings</string>
|
||||||
|
|
Loading…
Reference in New Issue