Some cleaning

This commit is contained in:
Thomas 2023-01-01 11:55:32 +01:00
parent 8fb7e4dc71
commit c590ab48f5
30 changed files with 320 additions and 341 deletions

View File

@ -165,6 +165,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public abstract class BaseMainActivity extends BaseActivity implements NetworkStateReceiver.NetworkStateReceiverListener, FragmentMastodonTimeline.UpdateCounters, FragmentNotificationContainer.UpdateCounters, FragmentMastodonConversation.UpdateCounters {
private static final int REQUEST_CODE = 5415;
public static String currentInstance, currentToken, currentUserID, client_id, client_secret, software;
public static HashMap<String, List<Emoji>> emojis = new HashMap<>();
public static Account.API api;
@ -297,7 +298,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
};
private NetworkStateReceiver networkStateReceiver;
private boolean headerMenuOpen;
private static final int REQUEST_CODE = 5415;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -786,7 +786,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
});
binding.toolbarSearch.setOnSearchClickListener(v -> binding.tabLayout.setVisibility(View.VISIBLE));
//For receiving data from other activities
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(broadcast_data, new IntentFilter(Helper.BROADCAST_DATA));
@ -1042,7 +1041,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
String title = "";
String description = "";
if(titleEl != null) {
if (titleEl != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
title = Html.fromHtml(titleEl.attr("content"), Html.FROM_HTML_MODE_LEGACY).toString();
} else {
@ -1050,7 +1049,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
}
if(descriptionEl != null) {
if (descriptionEl != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
description = Html.fromHtml(descriptionEl.attr("content"), Html.FROM_HTML_MODE_LEGACY).toString();
} else {
@ -1059,13 +1058,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
String imageUrl = "";
if(imageUrlEl != null) {
if (imageUrlEl != null) {
imageUrl = imageUrlEl.attr("content");
}
StringBuilder titleBuilder = new StringBuilder();
if(!originalUrl.trim().equalsIgnoreCase(sharedText.trim())) {
if (!originalUrl.trim().equalsIgnoreCase(sharedText.trim())) {
// If the shared text is not just the URL, add it to the top
String toAppend = sharedText.replaceAll("\\s*" + Pattern.quote(originalUrl) + "\\s*", "");
titleBuilder.append(toAppend);
@ -1073,7 +1072,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (title.length() > 0) {
// OG title fetched from source
if(titleBuilder.length() > 0) titleBuilder.append("\n\n");
if (titleBuilder.length() > 0)
titleBuilder.append("\n\n");
titleBuilder.append(title);
}

View File

@ -320,6 +320,7 @@ public class AccountReportActivity extends BaseBarActivity {
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {

View File

@ -107,11 +107,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
private Status statusReply, statusMention, statusQuoted;
private StatusDraft statusDraft;
private ComposeAdapter composeAdapter;
private boolean promptSaveDraft;
private boolean restoredDraft;
private List<Attachment> sharedAttachments;
private final BroadcastReceiver imageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context context, Intent intent) {
@ -138,7 +133,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
}
}
};
private boolean promptSaveDraft;
private boolean restoredDraft;
private List<Attachment> sharedAttachments;
private ActivityPaginationBinding binding;
private BaseAccount account;
private String instance, token;

View File

@ -117,8 +117,6 @@ public class ProfileActivity extends BaseActivity {
private String mention_str;
private WellKnownNodeinfo.NodeInfo nodeInfo;
private boolean checkRemotely;
private boolean homeMuted;
private final BroadcastReceiver broadcast_data = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@ -133,6 +131,7 @@ public class ProfileActivity extends BaseActivity {
}
}
};
private boolean homeMuted;
@Override
protected void onCreate(Bundle savedInstanceState) {

View File

@ -87,28 +87,6 @@ public class Account implements Serializable {
public Account moved;
@SerializedName("role")
public Role role;
public static class Role implements Serializable {
@SerializedName("id")
public String id;
@SerializedName("name")
public String name;
@SerializedName("color")
public String color;
@SerializedName("position")
public int position;
@SerializedName("permissions")
public int permissions;
@SerializedName("highlighted")
public boolean highlighted;
@SerializedName("created_at")
public Date created_at;
@SerializedName("updated_at")
public Date updated_at;
}
public transient RelationShip relationShip;
public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) {
@ -133,6 +111,34 @@ public class Account implements Serializable {
return SpannableHelper.convert(context, note, null, this, null, viewWeakReference);
}
@Override
public boolean equals(@Nullable Object obj) {
boolean same = false;
if (obj instanceof Account) {
same = this.id.equals(((Account) obj).id);
}
return same;
}
public static class Role implements Serializable {
@SerializedName("id")
public String id;
@SerializedName("name")
public String name;
@SerializedName("color")
public String color;
@SerializedName("position")
public int position;
@SerializedName("permissions")
public int permissions;
@SerializedName("highlighted")
public boolean highlighted;
@SerializedName("created_at")
public Date created_at;
@SerializedName("updated_at")
public Date updated_at;
}
public static class AccountParams implements Serializable {
@SerializedName("discoverable")
public boolean discoverable;
@ -150,14 +156,4 @@ public class Account implements Serializable {
public LinkedHashMap<Integer, Field.FieldParams> fields;
}
@Override
public boolean equals(@Nullable Object obj) {
boolean same = false;
if (obj instanceof Account) {
same = this.id.equals(((Account) obj).id);
}
return same;
}
}

View File

@ -153,10 +153,6 @@ public class Status implements Serializable, Cloneable {
return contentTranslateSpan;
}
public interface Callback {
void emojiFetched();
}
@NonNull
public Object clone() throws CloneNotSupportedException {
return super.clone();
@ -167,4 +163,8 @@ public class Status implements Serializable, Cloneable {
BOTTOM
}
public interface Callback {
void emojiFetched();
}
}

View File

@ -25,16 +25,6 @@ import app.fedilab.android.client.entities.api.Account;
public class AdminAccount implements Serializable {
@SerializedName("id")
public String id;
@SerializedName("username")
public String username;
@SerializedName("domain")
public String domain;
@SerializedName("created_at")
public Date created_at;
@SerializedName("email")
public String email;
public static LinkedHashMap<Integer, String> permissions;
static {
@ -61,6 +51,16 @@ public class AdminAccount implements Serializable {
permissions.put(80000, "Delete User Data");
}
@SerializedName("id")
public String id;
@SerializedName("username")
public String username;
@SerializedName("domain")
public String domain;
@SerializedName("created_at")
public Date created_at;
@SerializedName("email")
public String email;
@SerializedName("ip")
public String ip;
@SerializedName("role")

View File

@ -509,7 +509,7 @@ public class StatusCache {
try {
db.delete(Sqlite.TABLE_STATUS_CACHE,
Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_STATUS + " LIKE ?",
new String[]{userid, instance, "%\"id\":\"" + targetedUser + "\"%" });
new String[]{userid, instance, "%\"id\":\"" + targetedUser + "\"%"});
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -1965,6 +1965,20 @@ public class Helper {
return R.style.AppTheme;
}
public static void addMutedAccount(app.fedilab.android.client.entities.api.Account target) {
if (MainActivity.filteredAccounts == null) {
MainActivity.filteredAccounts = new ArrayList<>();
}
if (!MainActivity.filteredAccounts.contains(target)) {
MainActivity.filteredAccounts.add(target);
}
}
public static void removeMutedAccount(app.fedilab.android.client.entities.api.Account target) {
if (MainActivity.filteredAccounts != null) {
MainActivity.filteredAccounts.remove(target);
}
}
//Enum that described actions to replace inside a toot content
public enum PatternType {
@ -1996,19 +2010,4 @@ public class Helper {
public interface OnFileCopied {
void onFileCopied(File file);
}
public static void addMutedAccount(app.fedilab.android.client.entities.api.Account target) {
if (MainActivity.filteredAccounts == null) {
MainActivity.filteredAccounts = new ArrayList<>();
}
if (!MainActivity.filteredAccounts.contains(target)) {
MainActivity.filteredAccounts.add(target);
}
}
public static void removeMutedAccount(app.fedilab.android.client.entities.api.Account target) {
if (MainActivity.filteredAccounts != null) {
MainActivity.filteredAccounts.remove(target);
}
}
}

View File

@ -409,15 +409,6 @@ public class MediaHelper {
return maxHeight;
}
//Listener for recording media
public interface ActionRecord {
void onRecorded(String file);
}
public interface OnSchedule {
void scheduledAt(String scheduledDate);
}
public static void ResizedImageRequestBody(Context context, Uri uri, File targetedFile) {
InputStream decodeBitmapInputStream = null;
try {
@ -529,7 +520,6 @@ public class MediaHelper {
}
}
private static long getMaxSize(long maxSize) {
if (MainActivity.instanceInfo != null && MainActivity.instanceInfo.configuration != null && MainActivity.instanceInfo.configuration.media_attachments != null) {
maxSize = MainActivity.instanceInfo.configuration.media_attachments.image_size_limit;
@ -584,4 +574,14 @@ public class MediaHelper {
return null;
}
//Listener for recording media
public interface ActionRecord {
void onRecorded(String file);
}
public interface OnSchedule {
void scheduledAt(String scheduledDate);
}
}

View File

@ -98,7 +98,6 @@ public class PinnedTimelineHelper {
}
public synchronized static void redrawTopBarPinned(BaseMainActivity activity, ActivityMainBinding activityMainBinding, Pinned pinned, BottomMenu bottomMenu, List<MastodonList> mastodonLists) {
//Values must be initialized if there is no records in db
if (pinned == null) {

View File

@ -88,16 +88,13 @@ import es.dmoral.toasty.Toasty;
public class SpannableHelper {
public static final String CLICKABLE_SPAN = "CLICKABLE_SPAN";
private static int linkColor;
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, WeakReference<View> viewWeakReference) {
return convert(context, text, status, account, announcement, viewWeakReference, null);
}
private static int linkColor;
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, Status.Callback callback) {
@ -613,7 +610,6 @@ public class SpannableHelper {
}
/**
* Remove extra carriage returns at the bottom due to <p> tags in toots
*

View File

@ -70,7 +70,6 @@ public class ThemeHelper {
}
/**
* Animate two views, the current view will be hidden to left
*
@ -230,7 +229,6 @@ public class ThemeHelper {
}
/**
* Allow to set colors for having description on media
*

View File

@ -71,6 +71,8 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
private final ConstraintSet mConstraintSet = new ConstraintSet();
PhotoEditor mPhotoEditor;
String path;
CropImageContractOptions cropImageContractOptions;
ActivityResultLauncher<CropImageContractOptions> cropImageContractOptionsActivityResultLauncher;
private PropertiesBSFragment mPropertiesBSFragment;
private ShapeBSFragment mShapeBSFragment;
private ShapeBuilder mShapeBuilder;
@ -79,8 +81,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
private Uri uri;
private boolean exit;
private ActivityEditImageBinding binding;
CropImageContractOptions cropImageContractOptions;
ActivityResultLauncher<CropImageContractOptions> cropImageContractOptionsActivityResultLauncher;
private static int exifToDegrees(int exifOrientation) {
if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {

View File

@ -56,8 +56,8 @@ import es.dmoral.toasty.Toasty;
public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<Account> accountList;
private Context context;
private final boolean home_mute;
private Context context;
public AccountAdapter(List<Account> accountList, boolean home_mute) {
this.accountList = accountList;

View File

@ -150,6 +150,30 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
"..--..", ".-.-.-", ".----.", "-.-.--", "-..-.", "-.--.", "-.--.-", ".-...", "---...", "-.-.-.", "-...-", ".-.-.", "-....-", "..--.-",
".-..-.", "...-..-", ".--.-.", "..-.-", "--...-"
};
public static int currentCursorPosition;
private final List<Status> statusList;
private final int TYPE_NORMAL = 0;
private final BaseAccount account;
private final String visibility;
private final app.fedilab.android.client.entities.api.Account mentionedAccount;
private final String editMessageId;
public ManageDrafts manageDrafts;
public promptDraftListener promptDraftListener;
private int statusCount;
private Context context;
private AlertDialog alertDialogEmoji;
private List<Emoji> emojisList = new ArrayList<>();
private boolean unlisted_changed = false;
public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, app.fedilab.android.client.entities.api.Account mentionedAccount, String visibility, String editMessageId) {
this.statusList = statusList;
this.statusCount = statusCount;
this.account = account;
this.mentionedAccount = mentionedAccount;
this.visibility = visibility;
this.editMessageId = editMessageId;
}
public static int countMorseChar(String content) {
int count_char = 0;
@ -180,81 +204,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
return morseContent;
}
private final List<Status> statusList;
private final int TYPE_NORMAL = 0;
private final BaseAccount account;
private final String visibility;
private final app.fedilab.android.client.entities.api.Account mentionedAccount;
private final String editMessageId;
public ManageDrafts manageDrafts;
private int statusCount;
private Context context;
private AlertDialog alertDialogEmoji;
private List<Emoji> emojisList = new ArrayList<>();
public promptDraftListener promptDraftListener;
private boolean unlisted_changed = false;
public static int currentCursorPosition;
public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, app.fedilab.android.client.entities.api.Account mentionedAccount, String visibility, String editMessageId) {
this.statusList = statusList;
this.statusCount = statusCount;
this.account = account;
this.mentionedAccount = mentionedAccount;
this.visibility = visibility;
this.editMessageId = editMessageId;
}
/**
* Add an attachment from ComposeActivity
*
* @param position int - position of the drawer that added a media
* @param uris List<Uri> - uris of the media
*/
public void addAttachment(int position, List<Uri> uris) {
if (position == -1) {
position = statusList.size() - 1;
}
// position = statusCount-1+position;
if (statusList.get(position).media_attachments == null) {
statusList.get(position).media_attachments = new ArrayList<>();
}
if (promptDraftListener != null) {
promptDraftListener.promptDraft();
}
int finalPosition = position;
Helper.createAttachmentFromUri(context, uris, attachments -> {
for (Attachment attachment : attachments) {
statusList.get(finalPosition).media_attachments.add(attachment);
}
notifyItemChanged(finalPosition);
});
}
/**
* Add an attachment from ComposeActivity
*
* @param position int - position of the drawer that added a media
* @param attachment Attachment - media attachment
*/
public void addAttachment(int position, Attachment attachment) {
if (position == -1) {
position = statusList.size() - 1;
}
// position = statusCount-1+position;
if (statusList.get(position).media_attachments == null) {
statusList.get(position).media_attachments = new ArrayList<>();
}
if (promptDraftListener != null) {
promptDraftListener.promptDraft();
}
int finalPosition = position;
statusList.get(finalPosition).media_attachments.add(attachment);
notifyItemChanged(finalPosition);
}
private static void updateCharacterCount(ComposeViewHolder composeViewHolder) {
int charCount = MastodonHelper.countLength(composeViewHolder);
composeViewHolder.binding.characterCount.setText(String.valueOf(charCount));
@ -285,6 +234,55 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
return statusDraftDB;
}
/**
* Add an attachment from ComposeActivity
*
* @param position int - position of the drawer that added a media
* @param uris List<Uri> - uris of the media
*/
public void addAttachment(int position, List<Uri> uris) {
if (position == -1) {
position = statusList.size() - 1;
}
// position = statusCount-1+position;
if (statusList.get(position).media_attachments == null) {
statusList.get(position).media_attachments = new ArrayList<>();
}
if (promptDraftListener != null) {
promptDraftListener.promptDraft();
}
int finalPosition = position;
Helper.createAttachmentFromUri(context, uris, attachments -> {
for (Attachment attachment : attachments) {
statusList.get(finalPosition).media_attachments.add(attachment);
}
notifyItemChanged(finalPosition);
});
}
/**
* Add an attachment from ComposeActivity
*
* @param position int - position of the drawer that added a media
* @param attachment Attachment - media attachment
*/
public void addAttachment(int position, Attachment attachment) {
if (position == -1) {
position = statusList.size() - 1;
}
// position = statusCount-1+position;
if (statusList.get(position).media_attachments == null) {
statusList.get(position).media_attachments = new ArrayList<>();
}
if (promptDraftListener != null) {
promptDraftListener.promptDraft();
}
int finalPosition = position;
statusList.get(finalPosition).media_attachments.add(attachment);
notifyItemChanged(finalPosition);
}
//Create text when mentioning a toot
public void loadMentions(Status status) {
//Get the first draft

View File

@ -69,22 +69,6 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.conversationList = conversations;
}
public int getCount() {
return conversationList.size();
}
public Conversation getItem(int position) {
return conversationList.get(position);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
DrawerConversationBinding itemBinding = DrawerConversationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ConversationHolder(itemBinding);
}
public static void applyColorConversation(Context context, ConversationHolder holder) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
@ -123,6 +107,22 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
}
public int getCount() {
return conversationList.size();
}
public Conversation getItem(int position) {
return conversationList.get(position);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
DrawerConversationBinding itemBinding = DrawerConversationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ConversationHolder(itemBinding);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {

View File

@ -37,8 +37,8 @@ import app.fedilab.android.databinding.DrawerFieldBinding;
public class FieldAdapter extends RecyclerView.Adapter<FieldAdapter.FieldViewHolder> {
private final List<Field> fields;
private Context context;
private final Account account;
private Context context;
public FieldAdapter(List<Field> fields, Account account) {
this.fields = fields;

View File

@ -40,8 +40,12 @@ import app.fedilab.android.helper.Helper;
public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<JoinMastodonInstance> joinMastodonInstanceList;
private Context context;
public ActionClick actionClick;
private Context context;
public InstanceRegAdapter(List<JoinMastodonInstance> joinMastodonInstanceList) {
this.joinMastodonInstanceList = joinMastodonInstanceList;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
@ -67,11 +71,6 @@ public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
holder.binding.watchTrendig.setOnClickListener(v -> actionClick.trends(position));
}
public InstanceRegAdapter(List<JoinMastodonInstance> joinMastodonInstanceList) {
this.joinMastodonInstanceList = joinMastodonInstanceList;
}
public int getCount() {
return joinMastodonInstanceList.size();
}
@ -88,12 +87,6 @@ public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return new ViewHolder(itemBinding);
}
public interface ActionClick {
void instance(int position);
void trends(int position);
}
public long getItemId(int position) {
return position;
}
@ -103,6 +96,12 @@ public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return joinMastodonInstanceList.size();
}
public interface ActionClick {
void instance(int position);
void trends(int position);
}
public interface RecyclerViewClickListener {
void recyclerViewListClicked(View v, int position);
}

View File

@ -78,6 +78,50 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.notificationList = notificationList;
}
public static void applyColorAccount(Context context, ViewHolderFollow holder) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
boolean customLight = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS), false);
boolean customDark = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_DARK_COLORS), false);
int theme_icons_color = -1;
int theme_statuses_color = -1;
int theme_text_color = -1;
int theme_text_header_1_line = -1;
int theme_text_header_2_line = -1;
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) { //LIGHT THEME
if (customLight) {
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_ICON), -1);
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_BACKGROUND), -1);
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_TEXT), -1);
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_DISPLAY_NAME), -1);
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_USERNAME), -1);
}
} else {
if (customDark) {
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_ICON), -1);
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_BACKGROUND), -1);
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_TEXT), -1);
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_DISPLAY_NAME), -1);
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_USERNAME), -1);
}
}
if (theme_text_color != -1) {
holder.binding.title.setTextColor(theme_text_color);
}
if (theme_icons_color != -1) {
Helper.changeDrawableColor(context, holder.binding.icon, theme_icons_color);
}
if (theme_statuses_color != -1) {
holder.binding.cardviewContainer.setBackgroundColor(theme_statuses_color);
}
if (theme_text_header_1_line != -1) {
holder.binding.displayName.setTextColor(theme_text_header_1_line);
}
if (theme_text_header_2_line != -1) {
holder.binding.username.setTextColor(theme_text_header_2_line);
}
}
public int getCount() {
return notificationList.size();
}
@ -145,50 +189,6 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
}
public static void applyColorAccount(Context context, ViewHolderFollow holder) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
boolean customLight = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS), false);
boolean customDark = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_DARK_COLORS), false);
int theme_icons_color = -1;
int theme_statuses_color = -1;
int theme_text_color = -1;
int theme_text_header_1_line = -1;
int theme_text_header_2_line = -1;
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) { //LIGHT THEME
if (customLight) {
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_ICON), -1);
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_BACKGROUND), -1);
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_TEXT), -1);
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_DISPLAY_NAME), -1);
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_USERNAME), -1);
}
} else {
if (customDark) {
theme_icons_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_ICON), -1);
theme_statuses_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_BACKGROUND), -1);
theme_text_color = sharedpreferences.getInt(context.getString(R.string.SET_DARK_TEXT), -1);
theme_text_header_1_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_DISPLAY_NAME), -1);
theme_text_header_2_line = sharedpreferences.getInt(context.getString(R.string.SET_DARK_USERNAME), -1);
}
}
if (theme_text_color != -1) {
holder.binding.title.setTextColor(theme_text_color);
}
if (theme_icons_color != -1) {
Helper.changeDrawableColor(context, holder.binding.icon, theme_icons_color);
}
if (theme_statuses_color != -1) {
holder.binding.cardviewContainer.setBackgroundColor(theme_statuses_color);
}
if (theme_text_header_1_line != -1) {
holder.binding.displayName.setTextColor(theme_text_header_1_line);
}
if (theme_text_header_2_line != -1) {
holder.binding.username.setTextColor(theme_text_header_2_line);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
Notification notification = notificationList.get(position);

View File

@ -2215,28 +2215,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
mRecyclerView = recyclerView;
}
/* private static boolean mediaObfuscated(Status status) {
//Media is not sensitive and doesn't have a spoiler text
if (!status.isMediaObfuscated) {
return false;
}
if (!status.sensitive && (status.spoiler_text == null || status.spoiler_text.trim().isEmpty())) {
return false;
}
if (status.isMediaObfuscated && status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {
return true;
} else {
return status.sensitive;
}
}*/
/**
* Send a broadcast to other open fragments that content a timeline
*
@ -2261,68 +2239,20 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
}
@Override
public int getItemViewType(int position) {
if (timelineType == Timeline.TimeLineEnum.ART) {
return STATUS_ART;
/* private static boolean mediaObfuscated(Status status) {
//Media is not sensitive and doesn't have a spoiler text
if (!status.isMediaObfuscated) {
return false;
}
if (!status.sensitive && (status.spoiler_text == null || status.spoiler_text.trim().isEmpty())) {
return false;
}
if (status.isMediaObfuscated && status.spoiler_text != null && !status.spoiler_text.trim().isEmpty()) {
return true;
} else {
if (statusList.get(position).filteredByApp != null) {
if (statusList.get(position).filteredByApp.filter_action.equals("warn")) {
return STATUS_FILTERED;
} else { //These messages should not be displayed unless they contain a fetch more button
if (!statusList.get(position).isFetchMore) {
return STATUS_HIDDEN;
} else {
return STATUS_FILTERED_HIDE;
}
}
} else {
return isVisible(timelineType, statusList.get(position)) ? STATUS_VISIBLE : STATUS_HIDDEN;
}
return status.sensitive;
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
if (viewType == STATUS_HIDDEN) { //Hidden statuses - ie: filtered
DrawerStatusHiddenBinding itemBinding = DrawerStatusHiddenBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_ART) { //Art statuses
DrawerStatusArtBinding itemBinding = DrawerStatusArtBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_FILTERED) { //Filtered warn
DrawerStatusFilteredBinding itemBinding = DrawerStatusFilteredBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_FILTERED_HIDE) { //Filtered hide
DrawerStatusFilteredHideBinding itemBinding = DrawerStatusFilteredHideBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else { //Classic statuses
if (!minified) {
DrawerStatusBinding itemBinding = DrawerStatusBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else {
DrawerStatusReportBinding itemBinding = DrawerStatusReportBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
}
}
}
public int getCount() {
return statusList.size();
}
public Status getItem(int position) {
return statusList.get(position);
}
public long getItemId(int position) {
return position;
}
}*/
public static void applyColor(Context context, StatusViewHolder holder) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
@ -2410,6 +2340,74 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
mRecyclerView = recyclerView;
}
@Override
public int getItemViewType(int position) {
if (timelineType == Timeline.TimeLineEnum.ART) {
return STATUS_ART;
} else {
if (statusList.get(position).filteredByApp != null) {
if (statusList.get(position).filteredByApp.filter_action.equals("warn")) {
return STATUS_FILTERED;
} else { //These messages should not be displayed unless they contain a fetch more button
if (!statusList.get(position).isFetchMore) {
return STATUS_HIDDEN;
} else {
return STATUS_FILTERED_HIDE;
}
}
} else {
return isVisible(timelineType, statusList.get(position)) ? STATUS_VISIBLE : STATUS_HIDDEN;
}
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
if (viewType == STATUS_HIDDEN) { //Hidden statuses - ie: filtered
DrawerStatusHiddenBinding itemBinding = DrawerStatusHiddenBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_ART) { //Art statuses
DrawerStatusArtBinding itemBinding = DrawerStatusArtBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_FILTERED) { //Filtered warn
DrawerStatusFilteredBinding itemBinding = DrawerStatusFilteredBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else if (viewType == STATUS_FILTERED_HIDE) { //Filtered hide
DrawerStatusFilteredHideBinding itemBinding = DrawerStatusFilteredHideBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else { //Classic statuses
if (!minified) {
DrawerStatusBinding itemBinding = DrawerStatusBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
} else {
DrawerStatusReportBinding itemBinding = DrawerStatusReportBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusViewHolder(itemBinding);
}
}
}
public int getCount() {
return statusList.size();
}
public Status getItem(int position) {
return statusList.get(position);
}
public long getItemId(int position) {
return position;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
//Nothing to do with hidden statuses
@ -2604,6 +2602,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
DrawerStatusArtBinding bindingArt;
DrawerStatusFilteredBinding bindingFiltered;
DrawerStatusFilteredHideBinding bindingFilteredHide;
StatusViewHolder(DrawerStatusBinding itemView) {
super(itemView.getRoot());
binding = itemView;

View File

@ -200,5 +200,4 @@ public class FragmentAdminReport extends Fragment {
}
}

View File

@ -68,11 +68,11 @@ import es.dmoral.toasty.Toasty;
public class FragmentLoginMain extends Fragment {
private static final int REQUEST_CODE = 5412;
private final int PICK_IMPORT = 5557;
private FragmentLoginMainBinding binding;
private boolean searchInstanceRunning = false;
private String oldSearch;
private static final int REQUEST_CODE = 5412;
private final int PICK_IMPORT = 5557;
private ActivityResultLauncher<String> permissionLauncher;
public View onCreateView(@NonNull LayoutInflater inflater,

View File

@ -46,6 +46,8 @@ import es.dmoral.toasty.Toasty;
public class FragmentMediaProfile extends Fragment {
String tempToken;
String tempInstance;
private FragmentPaginationBinding binding;
private AccountsVM accountsVM;
private Account accountTimeline;
@ -53,8 +55,6 @@ public class FragmentMediaProfile extends Fragment {
private List<Status> mediaStatuses;
private String max_id;
private ImageAdapter imageAdapter;
String tempToken;
String tempInstance;
private boolean checkRemotely;
private String accountId;

View File

@ -32,7 +32,6 @@ import es.dmoral.toasty.Toasty;
public class FragmentThemingSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreatePreferences(Bundle bundle, String s) {
createPref();

View File

@ -50,12 +50,11 @@ import app.fedilab.android.viewmodel.mastodon.StatusesVM;
public class FragmentMastodonContext extends Fragment {
public FirstMessage firstMessage;
private FragmentPaginationBinding binding;
private StatusesVM statusesVM;
private List<Status> statuses;
private StatusAdapter statusAdapter;
public FirstMessage firstMessage;
//Handle actions that can be done in other fragments
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override

View File

@ -84,9 +84,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
private StatusAdapter statusAdapter;
private Timeline.TimeLineEnum timelineType;
private List<Status> timelineStatuses;
private boolean checkRemotely;
private String accountIDInRemoteInstance;
//Handle actions that can be done in other fragments
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
@ -162,6 +159,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}
}
};
private boolean checkRemotely;
private String accountIDInRemoteInstance;
private boolean isViewInitialized;
private Statuses initialStatuses;
private String list_id;
@ -180,6 +179,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
private int lockForResumeCall;
private boolean isNotPinnedTimeline;
private int extraCalls;
//Allow to recreate data when detaching/attaching fragment
public void recreate() {
initialStatuses = null;

View File

@ -36,6 +36,7 @@ public class FragmentProfileTimeline extends Fragment {
private Account account;
private FragmentProfileTimelinesBinding binding;
private boolean checkRemotely;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {

View File

@ -30,8 +30,8 @@ import app.fedilab.android.ui.fragment.timeline.FragmentMastodonTimeline;
public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
private final Account account;
private Fragment mCurrentFragment;
private final boolean checkRemotely;
private Fragment mCurrentFragment;
public FedilabProfilePageAdapter(FragmentManager fm, Account account, boolean remotely) {
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);

View File

@ -30,8 +30,8 @@ import app.fedilab.android.ui.fragment.timeline.FragmentProfileTimeline;
public class FedilabProfileTLPageAdapter extends FragmentStatePagerAdapter {
private final Account account;
private Fragment mCurrentFragment;
private final boolean checkRemotely;
private Fragment mCurrentFragment;
public FedilabProfileTLPageAdapter(FragmentManager fm, Account account, boolean remotely) {
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);