This commit is contained in:
Thomas 2022-04-29 17:51:52 +02:00
parent 713b5307e2
commit d7acab0a8c
5 changed files with 25 additions and 19 deletions

View file

@ -176,7 +176,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
@Override @Override
public void onResponse(@NonNull Call call, @NonNull final Response response) { public void onResponse(@NonNull Call call, @NonNull final Response response) {
if (!response.isSuccessful()) { if (response.isSuccessful()) {
runOnUiThread(() -> { runOnUiThread(() -> {
dialog.dismiss(); dialog.dismiss();
RemoteInstance.InstanceType instanceType = null; RemoteInstance.InstanceType instanceType = null;

View file

@ -51,7 +51,6 @@ import android.provider.MediaStore;
import android.provider.OpenableColumns; import android.provider.OpenableColumns;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -177,6 +176,7 @@ public class Helper {
public static final String ARG_TYPE_OF_INFO = "ARG_TYPE_OF_INFO"; public static final String ARG_TYPE_OF_INFO = "ARG_TYPE_OF_INFO";
public static final String ARG_TOKEN = "ARG_TOKEN"; public static final String ARG_TOKEN = "ARG_TOKEN";
public static final String ARG_INSTANCE = "ARG_INSTANCE"; public static final String ARG_INSTANCE = "ARG_INSTANCE";
public static final String ARG_REMOTE_INSTANCE = "ARG_REMOTE_INSTANCE";
public static final String ARG_STATUS_ID = "ARG_STATUS_ID"; public static final String ARG_STATUS_ID = "ARG_STATUS_ID";
public static final String ARG_WORK_ID = "ARG_WORK_ID"; public static final String ARG_WORK_ID = "ARG_WORK_ID";
public static final String ARG_LIST_ID = "ARG_LIST_ID"; public static final String ARG_LIST_ID = "ARG_LIST_ID";
@ -1189,14 +1189,9 @@ public class Helper {
attachment.size = Helper.getRealSizeFromUri(context, uri); attachment.size = Helper.getRealSizeFromUri(context, uri);
ContentResolver cR = context.getApplicationContext().getContentResolver(); ContentResolver cR = context.getApplicationContext().getContentResolver();
attachment.mimeType = cR.getType(uri); attachment.mimeType = cR.getType(uri);
Log.v(Helper.TAG, "uri: " + uri);
Log.v(Helper.TAG, "attachment.mimeType: " + attachment.mimeType);
MimeTypeMap mime = MimeTypeMap.getSingleton(); MimeTypeMap mime = MimeTypeMap.getSingleton();
String extension = mime.getExtensionFromMimeType(cR.getType(uri)); String extension = mime.getExtensionFromMimeType(cR.getType(uri));
Log.v(Helper.TAG, "mime: " + attachment.mimeType);
Log.v(Helper.TAG, "extension: " + attachment.mimeType);
if (uri.toString().endsWith("fedilab_recorded_audio.wav")) { if (uri.toString().endsWith("fedilab_recorded_audio.wav")) {
extension = "wav"; extension = "wav";
attachment.mimeType = "audio/x-wav"; attachment.mimeType = "audio/x-wav";

View file

@ -305,7 +305,7 @@ public class PinnedTimelineHelper {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("tag", tagTimeline.name); bundle.putString("tag", tagTimeline.name);
bundle.putInt("timelineId", tagTimeline.id); bundle.putInt("timelineId", tagTimeline.id);
bundle.putSerializable("type", Timeline.TimeLineEnum.TAG); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG);
if (mediaOnly[0]) if (mediaOnly[0])
bundle.putString("instanceType", "ART"); bundle.putString("instanceType", "ART");
else else
@ -529,10 +529,10 @@ public class PinnedTimelineHelper {
} }
fragTransaction.detach(fragmentMastodonTimeline); fragTransaction.detach(fragmentMastodonTimeline);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("remote_instance", remoteInstance.host != null ? remoteInstance.host : ""); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remoteInstance.host != null ? remoteInstance.host : "");
bundle.putString("instanceType", remoteInstance.type.getValue()); bundle.putString("instanceType", remoteInstance.type.getValue());
bundle.putString("timelineId", remoteInstance.id); bundle.putString("timelineId", remoteInstance.id);
bundle.putSerializable("type", Timeline.TimeLineEnum.REMOTE); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
fragmentMastodonTimeline.setArguments(bundle); fragmentMastodonTimeline.setArguments(bundle);
fragTransaction.attach(fragmentMastodonTimeline); fragTransaction.attach(fragmentMastodonTimeline);
fragTransaction.commit(); fragTransaction.commit();
@ -569,11 +569,11 @@ public class PinnedTimelineHelper {
currentFilter[0] = remoteInstance.filteredWith; currentFilter[0] = remoteInstance.filteredWith;
fragTransaction.detach(fragmentMastodonTimeline); fragTransaction.detach(fragmentMastodonTimeline);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("remote_instance", remoteInstance.host != null ? remoteInstance.host : ""); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remoteInstance.host != null ? remoteInstance.host : "");
bundle.putString("instanceType", remoteInstance.type.getValue()); bundle.putString("instanceType", remoteInstance.type.getValue());
bundle.putString("timelineId", remoteInstance.id); bundle.putString("timelineId", remoteInstance.id);
bundle.putString("currentfilter", remoteInstance.filteredWith); bundle.putString("currentfilter", remoteInstance.filteredWith);
bundle.putSerializable("type", Timeline.TimeLineEnum.REMOTE); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
fragmentMastodonTimeline.setArguments(bundle); fragmentMastodonTimeline.setArguments(bundle);
fragTransaction.attach(fragmentMastodonTimeline); fragTransaction.attach(fragmentMastodonTimeline);
fragTransaction.commit(); fragTransaction.commit();
@ -621,7 +621,7 @@ public class PinnedTimelineHelper {
} }
popup.getMenu().clear(); popup.getMenu().clear();
popup.getMenu().close(); popup.getMenu().close();
instanceClick(context, pinned, view, offSetPosition); instanceClick(context, pinned, view, position);
}); });
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show(); alertDialog.show();
@ -638,13 +638,13 @@ public class PinnedTimelineHelper {
return; return;
fragTransaction.detach(fragmentMastodonTimeline); fragTransaction.detach(fragmentMastodonTimeline);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("remote_instance", remoteInstance.host != null ? remoteInstance.host : ""); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remoteInstance.host != null ? remoteInstance.host : "");
bundle.putString("instanceType", remoteInstance.type.getValue()); bundle.putString("instanceType", remoteInstance.type.getValue());
bundle.putString("timelineId", remoteInstance.id); bundle.putString("timelineId", remoteInstance.id);
if (currentFilter[0] != null) { if (currentFilter[0] != null) {
bundle.putString("currentfilter", remoteInstance.filteredWith); bundle.putString("currentfilter", remoteInstance.filteredWith);
} }
bundle.putSerializable("type", Timeline.TimeLineEnum.REMOTE); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
fragmentMastodonTimeline.setArguments(bundle); fragmentMastodonTimeline.setArguments(bundle);
fragTransaction.attach(fragmentMastodonTimeline); fragTransaction.attach(fragmentMastodonTimeline);
fragTransaction.commit(); fragTransaction.commit();

View file

@ -71,7 +71,7 @@ public class FragmentMastodonTimeline extends Fragment {
private LinearLayoutManager mLayoutManager; private LinearLayoutManager mLayoutManager;
private Account accountTimeline; private Account accountTimeline;
private boolean exclude_replies, exclude_reblogs, show_pinned, media_only, minified; private boolean exclude_replies, exclude_reblogs, show_pinned, media_only, minified;
private String viewModelKey; private String viewModelKey, remoteInstance;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
@ -83,6 +83,7 @@ public class FragmentMastodonTimeline extends Fragment {
list_id = getArguments().getString(Helper.ARG_LIST_ID, null); list_id = getArguments().getString(Helper.ARG_LIST_ID, null);
search = getArguments().getString(Helper.ARG_SEARCH_KEYWORD, null); search = getArguments().getString(Helper.ARG_SEARCH_KEYWORD, null);
searchCache = getArguments().getString(Helper.ARG_SEARCH_KEYWORD_CACHE, null); searchCache = getArguments().getString(Helper.ARG_SEARCH_KEYWORD_CACHE, null);
remoteInstance = getArguments().getString(Helper.ARG_REMOTE_INSTANCE, null);
tagTimeline = (TagTimeline) getArguments().getSerializable(Helper.ARG_TAG_TIMELINE); tagTimeline = (TagTimeline) getArguments().getSerializable(Helper.ARG_TAG_TIMELINE);
accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT); accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
exclude_replies = !getArguments().getBoolean(Helper.ARG_SHOW_REPLIES, true); exclude_replies = !getArguments().getBoolean(Helper.ARG_SHOW_REPLIES, true);
@ -93,7 +94,6 @@ public class FragmentMastodonTimeline extends Fragment {
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false); minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT); statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
} }
binding = FragmentPaginationBinding.inflate(inflater, container, false); binding = FragmentPaginationBinding.inflate(inflater, container, false);
return binding.getRoot(); return binding.getRoot();
} }
@ -337,6 +337,17 @@ public class FragmentMastodonTimeline extends Fragment {
timelinesVM.getPublic(BaseMainActivity.currentToken, BaseMainActivity.currentInstance, false, true, false, null, null, min_id, MastodonHelper.statusesPerCall(requireActivity())) timelinesVM.getPublic(BaseMainActivity.currentToken, BaseMainActivity.currentInstance, false, true, false, null, null, min_id, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.TOP)); .observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.TOP));
} }
} else if (timelineType == Timeline.TimeLineEnum.REMOTE) { //REMOTE TIMELINE
if (direction == null) {
timelinesVM.getPublic(null, remoteInstance, false, true, false, null, null, null, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
} else if (direction == DIRECTION.BOTTOM) {
timelinesVM.getPublic(null, remoteInstance, false, true, false, max_id, null, null, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM));
} else if (direction == DIRECTION.TOP) {
timelinesVM.getPublic(null, remoteInstance, false, true, false, null, null, min_id, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.TOP));
}
} else if (timelineType == Timeline.TimeLineEnum.LIST) { //LIST TIMELINE } else if (timelineType == Timeline.TimeLineEnum.LIST) { //LIST TIMELINE
if (direction == null) { if (direction == null) {
timelinesVM.getList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, list_id, null, null, null, MastodonHelper.statusesPerCall(requireActivity())) timelinesVM.getList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, list_id, null, null, null, MastodonHelper.statusesPerCall(requireActivity()))

View file

@ -88,9 +88,9 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
String tag = pinnedTimeline.tagTimeline.name.replaceAll("#", ""); String tag = pinnedTimeline.tagTimeline.name.replaceAll("#", "");
bundle.putString(Helper.ARG_SEARCH_KEYWORD, tag); bundle.putString(Helper.ARG_SEARCH_KEYWORD, tag);
} else if (pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) { } else if (pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) {
String instance = pinnedTimeline.remoteInstance.host;
bundle.putString(Helper.ARG_REMOTE_INSTANCE, instance);
} }
} }
bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + position); bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + position);
fragment.setArguments(bundle); fragment.setArguments(bundle);