Skip to content

Commit

Permalink
Removed Nitter integration
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHalvdansson committed Jan 30, 2024
1 parent f600fd4 commit e2ac8c9
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 370 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -64,7 +63,6 @@
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -87,7 +85,6 @@
import com.simon.harmonichackernews.data.ArxivInfo;
import com.simon.harmonichackernews.data.Comment;
import com.simon.harmonichackernews.data.CommentsScrollProgress;
import com.simon.harmonichackernews.data.NitterInfo;
import com.simon.harmonichackernews.data.PollOption;
import com.simon.harmonichackernews.data.RepoInfo;
import com.simon.harmonichackernews.data.Story;
Expand All @@ -96,7 +93,6 @@
import com.simon.harmonichackernews.linkpreview.GitHubInfoGetter;
import com.simon.harmonichackernews.network.JSONParser;
import com.simon.harmonichackernews.network.NetworkComponent;
import com.simon.harmonichackernews.linkpreview.NitterGetter;
import com.simon.harmonichackernews.network.UserActions;
import com.simon.harmonichackernews.linkpreview.WikipediaGetter;
import com.simon.harmonichackernews.utils.AccountUtils;
Expand Down Expand Up @@ -749,7 +745,7 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}

webView.setWebViewClient(new MyWebViewClient());
if (preloadWebview.equals("always") || (preloadWebview.equals("onlywifi") && Utils.isOnWiFi(requireContext())) || showWebsite || (NitterGetter.isConvertibleToNitter(story.url) && SettingsUtils.shouldUseLinkPreviewX(getContext()))) {
if (preloadWebview.equals("always") || (preloadWebview.equals("onlywifi") && Utils.isOnWiFi(requireContext())) || showWebsite) {
loadUrl(story.url);
startedLoading = true;
}
Expand Down Expand Up @@ -841,10 +837,6 @@ public void onLoad() {
webView.getSettings().setUseWideViewPort(true);
}

if (NitterGetter.isConvertibleToNitter(url) && SettingsUtils.shouldRedirectNitter(getContext())) {
url = NitterGetter.convertToNitterUrl(url);
}

webView.loadUrl(url);
}

Expand Down Expand Up @@ -1659,24 +1651,6 @@ public void onPageFinished(WebView view, String url) {
//if we are at the webview and we just loaded, recheck the canGoBack status
toggleBackPressedCallback(webView != null && webView.canGoBack());
}


if (NitterGetter.isValidNitterUrl(url) && SettingsUtils.shouldUseLinkPreviewX(getContext())) {
NitterGetter.getInfo(view, getContext(), new NitterGetter.GetterCallback() {
@Override
public void onSuccess(NitterInfo nitterInfo) {
story.nitterInfo = nitterInfo;
if (adapter != null) {
adapter.notifyItemChanged(0);
}
}

@Override
public void onFailure(String reason) {

}
});
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,35 +269,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
headerViewHolder.wikiSummary.setHtml(story.wikiInfo.summary);
}

if (story.nitterInfo != null) {
headerViewHolder.nitterContainer.setVisibility(View.VISIBLE);
headerViewHolder.infoHeader.setText(story.nitterInfo.userName + " " + story.nitterInfo.userTag);

headerViewHolder.nitterText.setHtml(story.nitterInfo.text);
headerViewHolder.nitterDate.setText(story.nitterInfo.date);
headerViewHolder.nitterReplyCount.setText(String.valueOf(story.nitterInfo.replyCount));
headerViewHolder.nitterReposts.setText(String.valueOf(story.nitterInfo.reposts));
headerViewHolder.nitterQuotes.setText(String.valueOf(story.nitterInfo.quotes));
headerViewHolder.nitterLikes.setText(String.valueOf(story.nitterInfo.likes));

if (story.nitterInfo.quotes.equals("")) {
headerViewHolder.nitterQuotes.setVisibility(GONE);
headerViewHolder.nitterQuotesImageView.setVisibility(GONE);
}

if (story.nitterInfo.imgSrc != null) {
headerViewHolder.nitterImage.setVisibility(VISIBLE);
try {
Picasso.get()
.load(story.nitterInfo.imgSrc)
.into(headerViewHolder.nitterImage);
} catch (Exception e){
e.printStackTrace();
};
}

}

if (story.pollOptionArrayList != null) {
headerViewHolder.pollLayout.setVisibility(View.VISIBLE);
headerViewHolder.pollLayout.removeAllViews();
Expand Down Expand Up @@ -605,7 +576,6 @@ public class HeaderViewHolder extends RecyclerView.ViewHolder {
public final LinearLayout githubContainer;
public final LinearLayout arxivContainer;
public final LinearLayout wikiContainer;
public final LinearLayout nitterContainer;
public final TextView infoHeader;
public final LinearLayout emptyView;
public final TextView emptyViewText;
Expand Down Expand Up @@ -644,15 +614,6 @@ public class HeaderViewHolder extends RecyclerView.ViewHolder {

public final HtmlTextView wikiSummary;

public final HtmlTextView nitterText;
public final TextView nitterDate;
public final TextView nitterReplyCount;
public final TextView nitterReposts;
public final TextView nitterQuotes;
public final TextView nitterLikes;
public final ImageView nitterQuotesImageView;
public final ImageView nitterImage;

public final ImageView favicon;
public final RelativeLayout sheetRefreshButton;
public final RelativeLayout sheetExpandButton;
Expand Down Expand Up @@ -727,15 +688,6 @@ public HeaderViewHolder(View view) {
arxivSubjects = view.findViewById(R.id.comments_header_arxiv_subjects);
arxivByIcon = view.findViewById(R.id.comments_header_arxiv_by_icon);
arxivDownloadButton = view.findViewById(R.id.comments_header_arxiv_download);
nitterContainer = view.findViewById(R.id.comments_header_nitter_container);
nitterText = view.findViewById(R.id.comments_header_nitter_text);
nitterDate = view.findViewById(R.id.comments_header_nitter_date);
nitterReplyCount = view.findViewById(R.id.comments_header_nitter_reply_count);
nitterReposts = view.findViewById(R.id.comments_header_nitter_reposts);
nitterQuotes = view.findViewById(R.id.comments_header_nitter_quotes);
nitterLikes = view.findViewById(R.id.comments_header_nitter_likes);
nitterQuotesImageView = view.findViewById(R.id.comments_header_nitter_quotes_image);
nitterImage = view.findViewById(R.id.comments_header_nitter_image);

final int SHEET_ITEM_HEIGHT = Utils.pxFromDpInt(view.getResources(), 56);

Expand Down Expand Up @@ -805,23 +757,6 @@ public boolean onClick(View widget, String spannedText, @Nullable String href) {
}
});

nitterText.setOnClickATagListener(new OnClickATagListener() {
@Override
public boolean onClick(View widget, String spannedText, @Nullable String href) {
if (TextUtils.isEmpty(href)) {
return false;
}
if (spannedText.startsWith("#") && href.startsWith("/search?q=")) {
Utils.launchCustomTab(widget.getContext(), "https://www.x.com/" + href);
} else if (spannedText.startsWith("@") && href.startsWith("/")) {
Utils.launchCustomTab(widget.getContext(), "https://www.x.com/" + href);
} else {
Utils.launchCustomTab(widget.getContext(), href);
}
return false;
}
});

LinearLayout sheetButtonsContainer = view.findViewById(R.id.comment_sheet_buttons_container);
BottomSheetBehavior.from(bottomSheet).addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class Story {
public RepoInfo repoInfo;
public ArxivInfo arxivInfo;
public WikipediaInfo wikiInfo;
public NitterInfo nitterInfo;
public boolean isLink;
public boolean isJob = false;
public boolean loadingFailed = false;
Expand Down Expand Up @@ -81,7 +80,7 @@ public Bundle toBundle() {
}

public boolean hasExtraInfo() {
return arxivInfo != null || repoInfo != null || wikiInfo != null || nitterInfo != null;
return arxivInfo != null || repoInfo != null || wikiInfo != null;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ public static boolean shouldHideClicked(Context ctx) {
return getBooleanPref("pref_hide_clicked", false, ctx);
}

public static boolean shouldRedirectNitter(Context ctx) {
return getBooleanPref("pref_redirect_nitter", false, ctx);
}

public static boolean shouldUseLinkPreviewArxiv(Context ctx) {
return getBooleanPref("pref_link_preview_arxiv", false, ctx);
}
Expand All @@ -195,10 +191,6 @@ public static boolean shouldUseLinkPreviewGithub(Context ctx) {
return getBooleanPref("pref_link_preview_github", false, ctx);
}

public static boolean shouldUseLinkPreviewX(Context ctx) {
return getBooleanPref("pref_link_preview_x", false, ctx);
}

public static boolean shouldUseLinkPreviewWikipedia(Context ctx) {
return getBooleanPref("pref_link_preview_wikipedia", false, ctx);
}
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/layout/comments_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@

<include layout="@layout/link_preview_github" />

<include layout="@layout/link_preview_nitter" />


</LinearLayout>

<LinearLayout
Expand Down
Loading

0 comments on commit e2ac8c9

Please sign in to comment.