Some fixes

This commit is contained in:
Thomas 2022-06-13 18:34:31 +02:00
parent 3b1b46cbd4
commit 113db92ce7
7 changed files with 48 additions and 42 deletions

View file

@ -729,10 +729,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
private void manageFilters(int position) { private void manageFilters(int position) {
View view = binding.bottomNavView.findViewById(R.id.nav_home); View view = binding.bottomNavView.findViewById(R.id.nav_home);
if (position == 1) { boolean showExtendedFilter = true;
if (position == BottomMenu.getPosition(bottomMenu, R.id.nav_local)) {
view = binding.bottomNavView.findViewById(R.id.nav_local); view = binding.bottomNavView.findViewById(R.id.nav_local);
} else if (position == 2) { showExtendedFilter = false;
} else if (position == BottomMenu.getPosition(bottomMenu, R.id.nav_public)) {
view = binding.bottomNavView.findViewById(R.id.nav_public); view = binding.bottomNavView.findViewById(R.id.nav_public);
showExtendedFilter = false;
} }
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(BaseMainActivity.this, Helper.popupStyle()), view, Gravity.TOP); PopupMenu popup = new PopupMenu(new ContextThemeWrapper(BaseMainActivity.this, Helper.popupStyle()), view, Gravity.TOP);
popup.getMenuInflater() popup.getMenuInflater()
@ -741,7 +744,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts); final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies); final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
final MenuItem itemFilter = menu.findItem(R.id.action_filter); final MenuItem itemFilter = menu.findItem(R.id.action_filter);
if (position > 0) { if (!showExtendedFilter) {
itemShowBoosts.setVisible(false); itemShowBoosts.setVisible(false);
itemShowReplies.setVisible(false); itemShowReplies.setVisible(false);
} else { } else {
@ -751,13 +754,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this);
String show_filtered = null; String show_filtered = null;
if (position == 0) { if (position == BottomMenu.getPosition(bottomMenu, R.id.nav_home)) {
show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_HOME) + currentUserID + currentInstance, null); show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_HOME) + currentUserID + currentInstance, null);
} else if (position == 1) { } else if (position == BottomMenu.getPosition(bottomMenu, R.id.nav_local)) {
show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_LOCAL) + currentUserID + currentInstance, null); show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_LOCAL) + currentUserID + currentInstance, null);
} else if (position == 2) { } else if (position == BottomMenu.getPosition(bottomMenu, R.id.nav_public)) {
show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_PUBLIC) + currentUserID + currentInstance, null); show_filtered = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_PUBLIC) + currentUserID + currentInstance, null);
} }
itemShowBoosts.setChecked(show_boosts); itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies); itemShowReplies.setChecked(show_replies);
if (show_filtered != null && show_filtered.length() > 0) { if (show_filtered != null && show_filtered.length() > 0) {

View file

@ -118,7 +118,7 @@ public class Account implements Serializable {
public List<Account> getPushNotificationAccounts() { public List<Account> getPushNotificationAccounts() {
try { try {
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, "(" + Sqlite.COL_API + " = 'MASTODON' OR " + Sqlite.COL_API + " = 'PLEROMA') AND " + Sqlite.COL_TOKEN + " IS NOT NULL", null, null, null, Sqlite.COL_INSTANCE + " ASC", null); Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, "(" + Sqlite.COL_API + " = 'MASTODON' OR " + Sqlite.COL_API + " = 'PLEROMA' OR " + Sqlite.COL_API + " = 'FRIENDICA') AND " + Sqlite.COL_TOKEN + " IS NOT NULL", null, null, null, Sqlite.COL_INSTANCE + " ASC", null);
return cursorToListUserWithOwner(c); return cursorToListUserWithOwner(c);
} catch (Exception e) { } catch (Exception e) {
return null; return null;

View file

@ -202,30 +202,32 @@ public class MastodonHelper {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false); boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false);
@DrawableRes int placeholder = type == MediaAccountType.AVATAR ? R.drawable.ic_person : R.drawable.default_banner; @DrawableRes int placeholder = type == MediaAccountType.AVATAR ? R.drawable.ic_person : R.drawable.default_banner;
if (account == null) { if (Helper.isValidContextForGlide(view.getContext())) {
Glide.with(view.getContext()) if (account == null) {
.asDrawable() Glide.with(view.getContext())
.load(placeholder) .asDrawable()
.thumbnail(0.1f) .load(placeholder)
.placeholder(placeholder) .thumbnail(0.1f)
.into(view); .placeholder(placeholder)
return; .into(view);
} return;
String targetedUrl = disableGif ? (type == MediaAccountType.AVATAR ? account.avatar_static : account.header_static) : (type == MediaAccountType.AVATAR ? account.avatar : account.header); }
if (disableGif || (!targetedUrl.endsWith(".gif"))) { String targetedUrl = disableGif ? (type == MediaAccountType.AVATAR ? account.avatar_static : account.header_static) : (type == MediaAccountType.AVATAR ? account.avatar : account.header);
Glide.with(view.getContext()) if (disableGif || (!targetedUrl.endsWith(".gif"))) {
.asDrawable() Glide.with(view.getContext())
.load(targetedUrl) .asDrawable()
.thumbnail(0.1f) .load(targetedUrl)
.placeholder(placeholder) .thumbnail(0.1f)
.into(view); .placeholder(placeholder)
} else { .into(view);
Glide.with(view.getContext()) } else {
.asGif() Glide.with(view.getContext())
.load(targetedUrl) .asGif()
.thumbnail(0.1f) .load(targetedUrl)
.placeholder(placeholder) .thumbnail(0.1f)
.into(view); .placeholder(placeholder)
.into(view);
}
} }
} }

View file

@ -187,7 +187,7 @@ public class PinnedTimelineHelper {
int finalI = i; int finalI = i;
Pinned finalPinned = pinned; Pinned finalPinned = pinned;
tabStrip.getChildAt(i).setOnLongClickListener(v -> { tabStrip.getChildAt(i).setOnLongClickListener(v -> {
switch (pinnedTimelineVisibleList.get(finalI - BOTTOM_TIMELINE_COUNT).type) { switch (pinnedTimelineVisibleList.get(finalI - (BOTTOM_TIMELINE_COUNT - toRemove)).type) {
case LIST: case LIST:
break; break;
@ -288,9 +288,9 @@ public class PinnedTimelineHelper {
* @param position - int position of the tab * @param position - int position of the tab
*/ */
public static void tagClick(Context context, Pinned pinned, View view, ActivityMainBinding activityMainBinding, int position) { public static void tagClick(Context context, Pinned pinned, View view, ActivityMainBinding activityMainBinding, int position) {
int toRemove = itemToRemoveInBottomMenu(context);
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(context, Helper.popupStyle()), view); PopupMenu popup = new PopupMenu(new ContextThemeWrapper(context, Helper.popupStyle()), view);
int offSetPosition = position - BOTTOM_TIMELINE_COUNT; int offSetPosition = position - (BOTTOM_TIMELINE_COUNT - toRemove);
String tag; String tag;
TagTimeline tagTimeline = pinned.pinnedTimelines.get(offSetPosition).tagTimeline; TagTimeline tagTimeline = pinned.pinnedTimelines.get(offSetPosition).tagTimeline;
if (tagTimeline == null) if (tagTimeline == null)
@ -503,7 +503,8 @@ public class PinnedTimelineHelper {
public static void instanceClick(Context context, Pinned pinned, View view, ActivityMainBinding activityMainBinding, int position) { public static void instanceClick(Context context, Pinned pinned, View view, ActivityMainBinding activityMainBinding, int position) {
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(context, Helper.popupStyle()), view); PopupMenu popup = new PopupMenu(new ContextThemeWrapper(context, Helper.popupStyle()), view);
int offSetPosition = position - BOTTOM_TIMELINE_COUNT; int toRemove = itemToRemoveInBottomMenu(context);
int offSetPosition = position - (BOTTOM_TIMELINE_COUNT - toRemove);
RemoteInstance remoteInstance = pinned.pinnedTimelines.get(offSetPosition).remoteInstance; RemoteInstance remoteInstance = pinned.pinnedTimelines.get(offSetPosition).remoteInstance;
if (remoteInstance == null) if (remoteInstance == null)
return; return;

View file

@ -111,7 +111,9 @@ public class PushHelper {
private static void registerAppWithDialog(Context context, List<Account> accounts) { private static void registerAppWithDialog(Context context, List<Account> accounts) {
if (accounts == null) {
return;
}
List<String> distributors = UnifiedPush.getDistributors(context, new ArrayList<>()); List<String> distributors = UnifiedPush.getDistributors(context, new ArrayList<>());
if (distributors.size() == 1 || !UnifiedPush.getDistributor(context).isEmpty()) { if (distributors.size() == 1 || !UnifiedPush.getDistributor(context).isEmpty()) {
if (distributors.size() == 1) { if (distributors.size() == 1) {

View file

@ -199,12 +199,14 @@ public class PostMessageService extends IntentService {
poll_hide_totals = false; poll_hide_totals = false;
} }
Call<Status> statusCall; Call<Status> statusCall;
if (error) {
return;
}
if (dataPost.scheduledDate == null) { if (dataPost.scheduledDate == null) {
statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in, statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
poll_multiple, poll_hide_totals, in_reply_to_status, statuses.get(i).sensitive, statuses.get(i).spoiler_text, statuses.get(i).visibility.toLowerCase(), statuses.get(i).language); poll_multiple, poll_hide_totals, in_reply_to_status, statuses.get(i).sensitive, statuses.get(i).spoiler_text, statuses.get(i).visibility.toLowerCase(), statuses.get(i).language);
try { try {
Response<Status> statusResponse = statusCall.execute(); Response<Status> statusResponse = statusCall.execute();
if (statusResponse.isSuccessful()) { if (statusResponse.isSuccessful()) {
Status statusReply = statusResponse.body(); Status statusReply = statusResponse.body();
if (statusReply != null) { if (statusReply != null) {

View file

@ -16,7 +16,6 @@ package app.fedilab.android.ui.pageadapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -75,11 +74,9 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
FragmentMastodonTimeline fragment = new FragmentMastodonTimeline(); FragmentMastodonTimeline fragment = new FragmentMastodonTimeline();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
//Position 3 is for notifications //Position 3 is for notifications
Log.v(Helper.TAG, "position: " + position + " -> " + (BOTTOM_TIMELINE_COUNT - toRemove));
if (position < (BOTTOM_TIMELINE_COUNT - toRemove)) { if (position < (BOTTOM_TIMELINE_COUNT - toRemove)) {
if (bottomMenu != null) { if (bottomMenu != null) {
BottomMenu.ItemMenuType type = BottomMenu.getType(bottomMenu, position); BottomMenu.ItemMenuType type = BottomMenu.getType(bottomMenu, position);
Log.v(Helper.TAG, "type: " + type);
if (type == null) { if (type == null) {
return fragment; return fragment;
} }
@ -101,10 +98,8 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
} else { } else {
int pinnedPosition = position - (BOTTOM_TIMELINE_COUNT - toRemove); //Real position has an offset. int pinnedPosition = position - (BOTTOM_TIMELINE_COUNT - toRemove); //Real position has an offset.
Log.v(Helper.TAG, "pinnedPosition: " + pinnedPosition);
PinnedTimeline pinnedTimeline = pinned.pinnedTimelines.get(pinnedPosition); PinnedTimeline pinnedTimeline = pinned.pinnedTimelines.get(pinnedPosition);
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, pinnedTimeline.type); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, pinnedTimeline.type);
Log.v(Helper.TAG, " pinnedTimeline.type: " + pinnedTimeline.type);
if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST) { if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST) {
bundle.putString(Helper.ARG_LIST_ID, pinnedTimeline.mastodonList.id); bundle.putString(Helper.ARG_LIST_ID, pinnedTimeline.mastodonList.id);
} else if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) { } else if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) {