Merge branch 'mastodon:master' into master
This commit is contained in:
commit
62cd754f3a
|
@ -13,8 +13,8 @@ android {
|
||||||
applicationId "org.joinmastodon.android"
|
applicationId "org.joinmastodon.android"
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 126
|
versionCode 128
|
||||||
versionName "2.8.0"
|
versionName "2.9.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.joinmastodon.android.api.requests.accounts;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
|
|
||||||
|
public class GetDomainBlockPreview extends MastodonAPIRequest<GetDomainBlockPreview.Response>{
|
||||||
|
public GetDomainBlockPreview(String domain){
|
||||||
|
super(HttpMethod.GET, "/domain_blocks/preview", Response.class);
|
||||||
|
addQueryParameter("domain", domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Response{
|
||||||
|
public int followingCount;
|
||||||
|
public int followersCount;
|
||||||
|
}
|
||||||
|
}
|
|
@ -308,8 +308,9 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD
|
||||||
if(!gap.visible){
|
if(!gap.visible){
|
||||||
gap.visible=true;
|
gap.visible=true;
|
||||||
gap.enteredFromTop=child.getTop()<list.getHeight()/2;
|
gap.enteredFromTop=child.getTop()<list.getHeight()/2;
|
||||||
gaps.remove(gap);
|
holder.text.setText(gap.enteredFromTop ? R.string.load_missing_posts_above : R.string.load_missing_posts_below);
|
||||||
}
|
}
|
||||||
|
gaps.remove(gap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(GapStatusDisplayItem gap:gaps){
|
for(GapStatusDisplayItem gap:gaps){
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class GapStatusDisplayItem extends StatusDisplayItem{
|
||||||
public void onBind(GapStatusDisplayItem item){
|
public void onBind(GapStatusDisplayItem item){
|
||||||
text.setVisibility(item.loading ? View.GONE : View.VISIBLE);
|
text.setVisibility(item.loading ? View.GONE : View.VISIBLE);
|
||||||
progress.setVisibility(item.loading ? View.VISIBLE : View.GONE);
|
progress.setVisibility(item.loading ? View.VISIBLE : View.GONE);
|
||||||
|
text.setText(item.enteredFromTop ? R.string.load_missing_posts_above : R.string.load_missing_posts_below);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,10 +66,10 @@ public abstract class AccountRestrictionConfirmationSheet extends BottomSheet{
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addRow(@DrawableRes int icon, CharSequence text){
|
protected TextView addRow(@DrawableRes int icon, CharSequence text){
|
||||||
TextView tv=new TextView(getContext());
|
TextView tv=new TextView(getContext());
|
||||||
tv.setTextAppearance(R.style.m3_body_large);
|
tv.setTextAppearance(R.style.m3_body_large);
|
||||||
tv.setTextColor(UiUtils.getThemeColor(getContext(), R.attr.colorM3OnSurfaceVariant));
|
tv.setTextColor(UiUtils.getThemeColor(getContext(), R.attr.colorM3OnSurface));
|
||||||
tv.setCompoundDrawableTintList(ColorStateList.valueOf(UiUtils.getThemeColor(getContext(), R.attr.colorM3Primary)));
|
tv.setCompoundDrawableTintList(ColorStateList.valueOf(UiUtils.getThemeColor(getContext(), R.attr.colorM3Primary)));
|
||||||
tv.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
tv.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||||
tv.setText(text);
|
tv.setText(text);
|
||||||
|
@ -78,6 +78,7 @@ public abstract class AccountRestrictionConfirmationSheet extends BottomSheet{
|
||||||
tv.setCompoundDrawablesRelative(drawable, null, null, null);
|
tv.setCompoundDrawablesRelative(drawable, null, null, null);
|
||||||
tv.setCompoundDrawablePadding(V.dp(16));
|
tv.setCompoundDrawablePadding(V.dp(16));
|
||||||
contentWrap.addView(tv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
contentWrap.addView(tv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
return tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addRow(@DrawableRes int icon, @StringRes int text){
|
protected void addRow(@DrawableRes int icon, @StringRes int text){
|
||||||
|
|
|
@ -1,24 +1,33 @@
|
||||||
package org.joinmastodon.android.ui.sheets;
|
package org.joinmastodon.android.ui.sheets;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
|
import org.joinmastodon.android.api.requests.accounts.GetDomainBlockPreview;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import me.grishka.appkit.api.APIRequest;
|
||||||
|
import me.grishka.appkit.api.Callback;
|
||||||
|
import me.grishka.appkit.api.ErrorResponse;
|
||||||
|
|
||||||
public class BlockDomainConfirmationSheet extends AccountRestrictionConfirmationSheet{
|
public class BlockDomainConfirmationSheet extends AccountRestrictionConfirmationSheet{
|
||||||
public BlockDomainConfirmationSheet(@NonNull Context context, Account user, ConfirmCallback confirmCallback, ConfirmCallback blockUserConfirmCallback){
|
private APIRequest<?> currentRequest;
|
||||||
|
|
||||||
|
public BlockDomainConfirmationSheet(@NonNull Context context, Account user, ConfirmCallback confirmCallback, ConfirmCallback blockUserConfirmCallback, String accountID){
|
||||||
super(context, user, confirmCallback);
|
super(context, user, confirmCallback);
|
||||||
titleView.setText(R.string.block_domain_confirm_title);
|
titleView.setText(R.string.block_domain_confirm_title);
|
||||||
confirmBtn.setText(R.string.do_block_server);
|
confirmBtn.setText(R.string.do_block_server);
|
||||||
secondaryBtn.setText(context.getString(R.string.block_user_x_instead, user.getDisplayUsername()));
|
secondaryBtn.setText(context.getString(R.string.block_user_x_instead, user.getDisplayUsername()));
|
||||||
icon.setImageResource(R.drawable.ic_domain_disabled_24px);
|
icon.setImageResource(R.drawable.ic_domain_disabled_24px);
|
||||||
subtitleView.setText(user.getDomain());
|
subtitleView.setText(user.getDomain());
|
||||||
|
TextView relationsRow=addRow(R.drawable.ic_person_remove_24px, "");
|
||||||
addRow(R.drawable.ic_campaign_24px, R.string.users_cant_see_blocked);
|
addRow(R.drawable.ic_campaign_24px, R.string.users_cant_see_blocked);
|
||||||
addRow(R.drawable.ic_visibility_off_24px, R.string.you_wont_see_server_posts);
|
addRow(R.drawable.ic_visibility_off_24px, R.string.you_wont_see_server_posts);
|
||||||
addRow(R.drawable.ic_person_remove_24px, R.string.server_followers_will_be_removed);
|
|
||||||
addRow(R.drawable.ic_reply_24px, R.string.server_cant_mention_or_follow_you);
|
addRow(R.drawable.ic_reply_24px, R.string.server_cant_mention_or_follow_you);
|
||||||
addRow(R.drawable.ic_history_24px, R.string.server_can_interact_with_older);
|
addRow(R.drawable.ic_history_24px, R.string.server_can_interact_with_older);
|
||||||
|
|
||||||
|
@ -32,5 +41,44 @@ public class BlockDomainConfirmationSheet extends AccountRestrictionConfirmation
|
||||||
loading=false;
|
loading=false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
relationsRow.setVisibility(View.GONE);
|
||||||
|
relationsRow.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
|
currentRequest=new GetDomainBlockPreview(user.getDomain())
|
||||||
|
.setCallback(new Callback<>(){
|
||||||
|
@Override
|
||||||
|
public void onSuccess(GetDomainBlockPreview.Response result){
|
||||||
|
currentRequest=null;
|
||||||
|
if(result.followersCount>0 || result.followingCount>0){
|
||||||
|
UiUtils.beginLayoutTransition(container);
|
||||||
|
relationsRow.setVisibility(View.VISIBLE);
|
||||||
|
if(result.followersCount>0 && result.followingCount>0){
|
||||||
|
relationsRow.setText(context.getString(R.string.server_x_followers_and_following_will_be_removed,
|
||||||
|
context.getResources().getQuantityString(R.plurals.will_lose_x_followers, result.followersCount, result.followersCount),
|
||||||
|
context.getResources().getQuantityString(R.plurals.will_lose_x_following, result.followingCount, result.followingCount)));
|
||||||
|
}else if(result.followersCount>0){
|
||||||
|
relationsRow.setText(context.getResources().getQuantityString(R.plurals.server_x_followers_will_be_removed, result.followersCount, result.followersCount));
|
||||||
|
}else{
|
||||||
|
relationsRow.setText(context.getString(R.string.server_x_following_will_be_removed,
|
||||||
|
context.getResources().getQuantityString(R.plurals.will_lose_x_following, result.followingCount, result.followingCount)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error){
|
||||||
|
currentRequest=null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec(accountID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dismiss(){
|
||||||
|
if(currentRequest!=null){
|
||||||
|
currentRequest.cancel();
|
||||||
|
currentRequest=null;
|
||||||
|
}
|
||||||
|
super.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,7 +501,7 @@ public class UiUtils{
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
}).show();
|
}, accountID).show();
|
||||||
}else{
|
}else{
|
||||||
new SetDomainBlocked(account.getDomain(), false)
|
new SetDomainBlocked(account.getDomain(), false)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
|
@ -651,6 +651,9 @@ public class UiUtils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void updateList(List<T> oldList, List<T> newList, RecyclerView list, RecyclerView.Adapter<?> adapter, BiPredicate<T, T> areItemsSame){
|
public static <T> void updateList(List<T> oldList, List<T> newList, RecyclerView list, RecyclerView.Adapter<?> adapter, BiPredicate<T, T> areItemsSame){
|
||||||
|
RecyclerView.ItemAnimator animator=list.getItemAnimator();
|
||||||
|
if(animator!=null)
|
||||||
|
animator.endAnimations();
|
||||||
// Save topmost item position and offset because for some reason RecyclerView would scroll the list to weird places when you insert items at the top
|
// Save topmost item position and offset because for some reason RecyclerView would scroll the list to weird places when you insert items at the top
|
||||||
int topItem, topItemOffset;
|
int topItem, topItemOffset;
|
||||||
if(list.getChildCount()==0){
|
if(list.getChildCount()==0){
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="75dp"
|
android:layout_height="75dp"
|
||||||
android:background="@drawable/bg_timeline_gap">
|
android:background="@drawable/bg_timeline_gap">
|
||||||
|
@ -9,10 +10,13 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textAppearance="@style/m3_body_large"
|
android:textAppearance="@style/m3_body_large"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:text="@string/load_missing_posts"/>
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
tools:text="@string/load_missing_posts_above"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress"
|
android:id="@+id/progress"
|
||||||
|
|
|
@ -240,7 +240,6 @@
|
||||||
<string name="local_timeline_info_banner">These are all the posts from all users in your server (%s).</string>
|
<string name="local_timeline_info_banner">These are all the posts from all users in your server (%s).</string>
|
||||||
<string name="recommended_accounts_info_banner">You might like these accounts based on others you follow.</string>
|
<string name="recommended_accounts_info_banner">You might like these accounts based on others you follow.</string>
|
||||||
<string name="see_new_posts">New posts</string>
|
<string name="see_new_posts">New posts</string>
|
||||||
<string name="load_missing_posts">Load missing posts</string>
|
|
||||||
<string name="follow_back">Follow back</string>
|
<string name="follow_back">Follow back</string>
|
||||||
<string name="button_follow_pending">Pending</string>
|
<string name="button_follow_pending">Pending</string>
|
||||||
<string name="follows_you">Follows you</string>
|
<string name="follows_you">Follows you</string>
|
||||||
|
@ -675,7 +674,6 @@
|
||||||
<string name="block_user_x_instead">Block %s instead</string>
|
<string name="block_user_x_instead">Block %s instead</string>
|
||||||
<string name="users_cant_see_blocked">You won’t see posts or notifications from users on this server.</string>
|
<string name="users_cant_see_blocked">You won’t see posts or notifications from users on this server.</string>
|
||||||
<string name="you_wont_see_server_posts">You won’t see any posts from users on this server.</string>
|
<string name="you_wont_see_server_posts">You won’t see any posts from users on this server.</string>
|
||||||
<string name="server_followers_will_be_removed">Your followers from this server will be removed.</string>
|
|
||||||
<string name="server_cant_mention_or_follow_you">Nobody from this server can follow you.</string>
|
<string name="server_cant_mention_or_follow_you">Nobody from this server can follow you.</string>
|
||||||
<string name="server_can_interact_with_older">People from this server can interact with your old posts.</string>
|
<string name="server_can_interact_with_older">People from this server can interact with your old posts.</string>
|
||||||
<string name="unblocked_domain_x">Unblocked domain %s</string>
|
<string name="unblocked_domain_x">Unblocked domain %s</string>
|
||||||
|
@ -840,4 +838,23 @@
|
||||||
<item quantity="one">%,d follower you know</item>
|
<item quantity="one">%,d follower you know</item>
|
||||||
<item quantity="other">%,d followers you know</item>
|
<item quantity="other">%,d followers you know</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
<!-- appears when you're about to block a server -->
|
||||||
|
<plurals name="server_x_followers_will_be_removed">
|
||||||
|
<item quantity="one">%,d follower from this server will be removed.</item>
|
||||||
|
<item quantity="other">%,d followers from this server will be removed.</item>
|
||||||
|
</plurals>
|
||||||
|
<!-- The complete string will look like "You will lose X followers and Y people you follow". See will_lose_x_followers and will_lose_x_following -->
|
||||||
|
<string name="server_x_followers_and_following_will_be_removed">You will lose %1$s and %2$s.</string>
|
||||||
|
<plurals name="will_lose_x_followers">
|
||||||
|
<item quantity="one">%,d follower</item>
|
||||||
|
<item quantity="other">%,d followers</item>
|
||||||
|
</plurals>
|
||||||
|
<plurals name="will_lose_x_following">
|
||||||
|
<item quantity="one">%,d person you follow</item>
|
||||||
|
<item quantity="other">%,d people you follow</item>
|
||||||
|
</plurals>
|
||||||
|
<!-- The complete string will look like "You will lose X people you follow". See will_lose_x_following -->
|
||||||
|
<string name="server_x_following_will_be_removed">You will lose %s.</string>
|
||||||
|
<string name="load_missing_posts_above">Load missing posts above</string>
|
||||||
|
<string name="load_missing_posts_below">Load missing posts below</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue