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) {
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);
} else if (position == 2) {
showExtendedFilter = false;
} else if (position == BottomMenu.getPosition(bottomMenu, 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);
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 itemShowReplies = menu.findItem(R.id.action_show_replies);
final MenuItem itemFilter = menu.findItem(R.id.action_filter);
if (position > 0) {
if (!showExtendedFilter) {
itemShowBoosts.setVisible(false);
itemShowReplies.setVisible(false);
} else {
@ -751,13 +754,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this);
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);
} 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);
} 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);
}
itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies);
if (show_filtered != null && show_filtered.length() > 0) {

View File

@ -118,7 +118,7 @@ public class Account implements Serializable {
public List<Account> getPushNotificationAccounts() {
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);
} catch (Exception e) {
return null;

View File

@ -202,30 +202,32 @@ public class MastodonHelper {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
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;
if (account == null) {
Glide.with(view.getContext())
.asDrawable()
.load(placeholder)
.thumbnail(0.1f)
.placeholder(placeholder)
.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"))) {
Glide.with(view.getContext())
.asDrawable()
.load(targetedUrl)
.thumbnail(0.1f)
.placeholder(placeholder)
.into(view);
} else {
Glide.with(view.getContext())
.asGif()
.load(targetedUrl)
.thumbnail(0.1f)
.placeholder(placeholder)
.into(view);
if (Helper.isValidContextForGlide(view.getContext())) {
if (account == null) {
Glide.with(view.getContext())
.asDrawable()
.load(placeholder)
.thumbnail(0.1f)
.placeholder(placeholder)
.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"))) {
Glide.with(view.getContext())
.asDrawable()
.load(targetedUrl)
.thumbnail(0.1f)
.placeholder(placeholder)
.into(view);
} else {
Glide.with(view.getContext())
.asGif()
.load(targetedUrl)
.thumbnail(0.1f)
.placeholder(placeholder)
.into(view);
}
}
}

View File

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

View File

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

View File

@ -199,12 +199,14 @@ public class PostMessageService extends IntentService {
poll_hide_totals = false;
}
Call<Status> statusCall;
if (error) {
return;
}
if (dataPost.scheduledDate == null) {
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);
try {
Response<Status> statusResponse = statusCall.execute();
if (statusResponse.isSuccessful()) {
Status statusReply = statusResponse.body();
if (statusReply != null) {

View File

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