Fix Nitter issues + invalid ssl certificate for onion (no longer supported for Google)
This commit is contained in:
parent
1e65074a4b
commit
97ebb9c36e
|
@ -589,8 +589,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
if (binding == null || getActivity() == null || !isAdded()) {
|
||||
return;
|
||||
}
|
||||
boolean nitterInstance = timelineType == Timeline.TimeLineEnum.REMOTE && pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER;
|
||||
QuickLoad quickLoad = new QuickLoad(requireActivity()).getSavedValue(BaseMainActivity.currentUserID, BaseMainActivity.currentInstance, timelineType, ident);
|
||||
if (!fetchingMissing && !binding.swipeContainer.isRefreshing() && direction == null && quickLoad != null && quickLoad.statuses != null && quickLoad.statuses.size() > 0) {
|
||||
if (!nitterInstance && !fetchingMissing && !binding.swipeContainer.isRefreshing() && direction == null && quickLoad != null && quickLoad.statuses != null && quickLoad.statuses.size() > 0) {
|
||||
Statuses statuses = new Statuses();
|
||||
statuses.statuses = quickLoad.statuses;
|
||||
statuses.pagination = new Pagination();
|
||||
|
@ -655,15 +656,15 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
//NITTER TIMELINES
|
||||
if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) {
|
||||
if (direction == null) {
|
||||
timelinesVM.getNitter(remoteInstance, pinnedTimeline.remoteInstance.host, null)
|
||||
timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, null)
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
} else if (direction == DIRECTION.BOTTOM) {
|
||||
timelinesVM.getNitter(remoteInstance, pinnedTimeline.remoteInstance.host, max_id)
|
||||
timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, max_id)
|
||||
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
|
||||
} else if (direction == DIRECTION.TOP) {
|
||||
flagLoading = false;
|
||||
} else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) {
|
||||
timelinesVM.getNitter(remoteInstance, pinnedTimeline.remoteInstance.host, null)
|
||||
timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, null)
|
||||
.observe(getViewLifecycleOwner(), statusesRefresh -> {
|
||||
if (statusAdapter != null) {
|
||||
dealWithPagination(statusesRefresh, direction, true);
|
||||
|
|
|
@ -16,6 +16,8 @@ package app.fedilab.android.viewmodel.mastodon;
|
|||
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
|
@ -23,12 +25,14 @@ import androidx.annotation.NonNull;
|
|||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.endpoints.MastodonTimelinesService;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
import app.fedilab.android.client.entities.api.Conversation;
|
||||
|
@ -210,9 +214,13 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
* @param max_position Return results older than this id
|
||||
* @return {@link LiveData} containing a {@link Statuses}
|
||||
*/
|
||||
public LiveData<Statuses> getNitter(@NonNull String instance,
|
||||
String accountsStr,
|
||||
String max_position) {
|
||||
public LiveData<Statuses> getNitter(
|
||||
String accountsStr,
|
||||
String max_position) {
|
||||
Context context = getApplication().getApplicationContext();
|
||||
SharedPreferences sharedpreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
String instance = sharedpreferences.getString(context.getString(R.string.SET_NITTER_HOST), context.getString(R.string.DEFAULT_NITTER_HOST)).toLowerCase();
|
||||
MastodonTimelinesService mastodonTimelinesService = initInstanceXMLOnly(instance);
|
||||
accountsStr = accountsStr.replaceAll("\\s", ",");
|
||||
statusesMutableLiveData = new MutableLiveData<>();
|
||||
|
@ -229,7 +237,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
List<Status> statusList = new ArrayList<>();
|
||||
if (rssResponse != null && rssResponse.mFeedItems != null) {
|
||||
for (Nitter.FeedItem feedItem : rssResponse.mFeedItems) {
|
||||
if (feedItem.title.startsWith("RT by")) {
|
||||
if (!feedItem.title.startsWith("RT by")) {
|
||||
Status status = Nitter.convert(getApplication(), instance, feedItem);
|
||||
statusList.add(status);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.net.URISyntaxException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.BuildConfig;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.WebviewActivity;
|
||||
|
||||
|
@ -111,8 +112,12 @@ public class FedilabWebViewClient extends WebViewClient {
|
|||
|
||||
@Override
|
||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||
if (view.getUrl() != null && view.getUrl().endsWith(".onion")) {
|
||||
handler.proceed();
|
||||
if (BuildConfig.DONATIONS) {
|
||||
if (view.getUrl() != null && view.getUrl().endsWith(".onion")) {
|
||||
handler.proceed();
|
||||
} else {
|
||||
super.onReceivedSslError(view, handler, error);
|
||||
}
|
||||
} else {
|
||||
super.onReceivedSslError(view, handler, error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue