Bot accounts detection
This commit is contained in:
parent
593fc547ee
commit
3ef5473c2c
|
@ -125,10 +125,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
private ViewPager mPager;
|
||||
private String accountId;
|
||||
private TabLayout tabLayout;
|
||||
private TextView account_note, account_follow_request, account_type;
|
||||
private TextView account_note, account_follow_request, account_type, account_bot;
|
||||
private String userId;
|
||||
private Relationship relationship;
|
||||
private ImageView pp_actionBar;
|
||||
private FloatingActionButton header_edit_profile;
|
||||
private List<Status> pins;
|
||||
private String accountUrl;
|
||||
|
@ -183,6 +182,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
account_dn = findViewById(R.id.account_dn);
|
||||
account_un = findViewById(R.id.account_un);
|
||||
account_type = findViewById(R.id.account_type);
|
||||
account_bot = findViewById(R.id.account_bot);
|
||||
if(b != null){
|
||||
accountId = b.getString("accountId");
|
||||
peertubeAccount = b.getBoolean("peertubeAccount", false);
|
||||
|
@ -525,10 +525,15 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
if( peertubeAccount) {
|
||||
account_type.setVisibility(View.VISIBLE);
|
||||
}
|
||||
//Bot account
|
||||
if( account.isBot()){
|
||||
account_bot.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
TextView actionbar_title = findViewById(R.id.show_account_title);
|
||||
if( account.getAcct() != null)
|
||||
actionbar_title.setText(account.getAcct());
|
||||
pp_actionBar = findViewById(R.id.pp_actionBar);
|
||||
ImageView pp_actionBar = findViewById(R.id.pp_actionBar);
|
||||
if( account.getAvatar() != null){
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
|
|
|
@ -3316,6 +3316,11 @@ public class API {
|
|||
account.setFollowing_count(Integer.valueOf(resobj.get("following_count").toString()));
|
||||
account.setStatuses_count(Integer.valueOf(resobj.get("statuses_count").toString()));
|
||||
account.setNote(resobj.get("note").toString());
|
||||
try {
|
||||
account.setBot(Boolean.parseBoolean(resobj.get("bot").toString()));
|
||||
}catch (Exception e){
|
||||
account.setBot(false);
|
||||
}
|
||||
try{
|
||||
account.setMoved_to_account(parseAccountResponse(context, resobj.getJSONObject("moved")));
|
||||
}catch (Exception ignored){account.setMoved_to_account(null);}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class Account implements Parcelable {
|
|||
private List<Emojis> emojis;
|
||||
private Account account;
|
||||
private String host;
|
||||
|
||||
private boolean isBot;
|
||||
|
||||
protected Account(Parcel in) {
|
||||
id = in.readString();
|
||||
|
@ -105,6 +105,7 @@ public class Account implements Parcelable {
|
|||
displayNameSpan = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
noteSpan = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
locked = in.readByte() != 0;
|
||||
isBot = in.readByte() != 0;
|
||||
followers_count = in.readInt();
|
||||
following_count = in.readInt();
|
||||
statuses_count = in.readInt();
|
||||
|
@ -146,6 +147,7 @@ public class Account implements Parcelable {
|
|||
TextUtils.writeToParcel(displayNameSpan, dest, flags);
|
||||
TextUtils.writeToParcel(noteSpan, dest, flags);
|
||||
dest.writeByte((byte) (locked ? 1 : 0));
|
||||
dest.writeByte((byte) (isBot ? 1 : 0));
|
||||
dest.writeInt(followers_count);
|
||||
dest.writeInt(following_count);
|
||||
dest.writeInt(statuses_count);
|
||||
|
@ -240,6 +242,14 @@ public class Account implements Parcelable {
|
|||
this.host = host;
|
||||
}
|
||||
|
||||
public boolean isBot() {
|
||||
return isBot;
|
||||
}
|
||||
|
||||
public void setBot(boolean bot) {
|
||||
isBot = bot;
|
||||
}
|
||||
|
||||
|
||||
public enum followAction{
|
||||
FOLLOW,
|
||||
|
|
|
@ -778,13 +778,21 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
for (int i = statuses.size() - 1; i >= 0; i--) {
|
||||
if( this.statuses != null) {
|
||||
if (this.statuses.size() == 0 ||
|
||||
Long.parseLong(statuses.get(i).getId()) > Long.parseLong(this.statuses.get(0).getId())) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
statuses.get(i).setNew(true);
|
||||
MainActivity.countNewStatus++;
|
||||
inserted++;
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
if (this.statuses.size() == 0){
|
||||
if( type != RetrieveFeedsAsyncTask.Type.HOME){
|
||||
if( Long.parseLong(statuses.get(i).getId()) > Long.parseLong(this.statuses.get(0).getId())) {
|
||||
inserted++;
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
}
|
||||
}else {
|
||||
if( Long.parseLong(statuses.get(i).getId()) > Long.parseLong(lastReadToot)) {
|
||||
statuses.get(i).setNew(true);
|
||||
MainActivity.countNewStatus++;
|
||||
inserted++;
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -829,7 +837,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
//Put the toot at its place in the list (id desc)
|
||||
if( !this.statuses.contains(tmpStatus) ) { //Element not already added
|
||||
//Mark status at new ones when their id is greater than the last read toot id
|
||||
if (lastReadToot != null && Long.parseLong(tmpStatus.getId()) > Long.parseLong(lastReadToot)) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME && lastReadToot != null && Long.parseLong(tmpStatus.getId()) > Long.parseLong(lastReadToot)) {
|
||||
tmpStatus.setNew(true);
|
||||
MainActivity.countNewStatus++;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:width="1dip" android:color="@color/mastodonC4"/>
|
||||
<corners
|
||||
android:radius="2dp">
|
||||
</corners>
|
||||
<padding android:bottom="1dip"
|
||||
android:left="4dip"
|
||||
android:right="4dip"
|
||||
android:top="1dip"/>
|
||||
</shape>
|
|
@ -154,6 +154,15 @@
|
|||
android:id="@+id/account_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_marginTop="5dp"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/mastodonC4"
|
||||
android:background="@drawable/blue_border"
|
||||
android:text="@string/bot"
|
||||
android:id="@+id/account_bot"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/temp_mute"
|
||||
android:visibility="gone"
|
||||
|
|
|
@ -773,6 +773,7 @@
|
|||
<string name="crowdin_manager">Crowdin manager</string>
|
||||
<string name="translation_app">Translation of the application</string>
|
||||
<string name="about_crowdin">About Crowdin</string>
|
||||
<string name="bot">Bot</string>
|
||||
<!-- end languages -->
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue