Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit cfc218c

Browse files
authored
Merge pull request #133 from crimera/dev
chore: Merge branch `dev` to `main`
2 parents efd30b3 + 960e326 commit cfc218c

8 files changed

Lines changed: 142 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## [1.40.0-dev.2](https://github.com/crimera/revanced-integrations/compare/v1.40.0-dev.1...v1.40.0-dev.2) (2025-07-22)
2+
3+
4+
### Updates
5+
6+
* **Twitter - Show post source label:** Change default settings value ([4458b37](https://github.com/crimera/revanced-integrations/commit/4458b370659a62707c4b61e73b355cc376e1c4f7))
7+
8+
## [1.40.0-dev.1](https://github.com/crimera/revanced-integrations/compare/v1.39.0...v1.40.0-dev.1) (2025-07-13)
9+
10+
11+
### Features
12+
13+
* **Twitter:** Added `Show post source label` patch ([f1c01a8](https://github.com/crimera/revanced-integrations/commit/f1c01a8fb33a086b36d6f9448c499888bd8e2c18))
14+
115
## [1.39.0](https://github.com/crimera/revanced-integrations/compare/v1.38.3...v1.39.0) (2025-07-05)
216

317

app/src/main/java/app/revanced/integrations/twitter/Pref.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
@SuppressWarnings("unused")
99
public class Pref {
10-
public static boolean ROUND_OFF_NUMBERS,ENABLE_FORCE_HD, HIDE_COMM_BADGE;
10+
public static boolean ROUND_OFF_NUMBERS,ENABLE_FORCE_HD, HIDE_COMM_BADGE,SHOW_SRC_LBL;
1111
public static float POST_FONT_SIZE;
1212
static{
1313
ROUND_OFF_NUMBERS = isRoundOffNumbersEnabled();
1414
ENABLE_FORCE_HD = enableForceHD();
1515
POST_FONT_SIZE = setPostFontSize();
1616
HIDE_COMM_BADGE = hideCommBadge();
17+
SHOW_SRC_LBL = showSourceLabel();
1718
}
1819
public static float setPostFontSize() {
1920
Float fontSize = 0.0f;
@@ -30,6 +31,10 @@ public static boolean serverResponseLogging() {
3031
public static boolean serverResponseLoggingOverwriteFile() {
3132
return Utils.getBooleanPerf(Settings.LOG_RES_OVRD);
3233
}
34+
35+
public static boolean showSourceLabel() {
36+
return Utils.getBooleanPerf(Settings.TIMELINE_SHOW_SOURCE_LABEL);
37+
}
3338
public static boolean hideCommBadge() {
3439
return Utils.getBooleanPerf(Settings.TIMELINE_HIDE_COMM_BADGE);
3540
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package app.revanced.integrations.twitter.patches.tweet;
2+
3+
import org.json.JSONObject;
4+
5+
import java.io.BufferedReader;
6+
import java.io.InputStreamReader;
7+
import java.net.HttpURLConnection;
8+
import java.net.URL;
9+
import app.revanced.integrations.twitter.Utils;
10+
11+
public class TweetInfoAPI {
12+
private static JSONObject responseObj = null;
13+
private static JSONObject cache = new JSONObject();
14+
// Lock is used so that getTweetSource waits till request is fetched.
15+
private static final Object lock = new Object();
16+
17+
private static JSONObject fetchStatusById(String id) {
18+
HttpURLConnection connection = null;
19+
BufferedReader reader = null;
20+
if(!app.revanced.integrations.shared.Utils.isNetworkConnected()){
21+
return null;
22+
}
23+
try {
24+
String apiUrl = "https://api.fxtwitter.com/x/status/" + id;
25+
URL url = new URL(apiUrl);
26+
connection = (HttpURLConnection) url.openConnection();
27+
28+
connection.setRequestMethod("GET");
29+
connection.setConnectTimeout(5000); // 5 seconds
30+
connection.setReadTimeout(5000); // 5 seconds
31+
32+
int responseCode = connection.getResponseCode();
33+
if (responseCode != HttpURLConnection.HTTP_OK) {
34+
throw new Exception("HTTP error code: " + responseCode);
35+
}
36+
37+
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
38+
StringBuilder responseBuilder = new StringBuilder();
39+
String line;
40+
41+
while ((line = reader.readLine()) != null) {
42+
responseBuilder.append(line);
43+
}
44+
return new JSONObject(responseBuilder.toString());
45+
46+
} catch (Exception e) {
47+
Utils.logger(e);
48+
return null;
49+
50+
} finally {
51+
try {
52+
if (reader != null) reader.close();
53+
if (connection != null) connection.disconnect();
54+
} catch (Exception ignored) {
55+
}
56+
}
57+
}
58+
59+
public static void sendRequest(long id) {
60+
String tweetId = String.valueOf(id);
61+
62+
synchronized (lock) {
63+
if (!cache.has(tweetId)) {
64+
new Thread(() -> {
65+
synchronized (lock) {
66+
responseObj = fetchStatusById(tweetId);
67+
lock.notifyAll();
68+
}
69+
}).start();
70+
}
71+
}
72+
}
73+
74+
public static String getTweetSource(long id) {
75+
String src = null;
76+
String tweetId = String.valueOf(id);
77+
try {
78+
if(app.revanced.integrations.shared.Utils.isNetworkConnected()){
79+
synchronized (lock) {
80+
if (cache.has(tweetId)) {
81+
src = cache.optString(tweetId);
82+
} else {
83+
while (responseObj == null) {
84+
try {
85+
lock.wait();
86+
}catch (InterruptedException e){
87+
Thread.currentThread().interrupt();
88+
Utils.logger("Interrupted while waiting: " + e.getMessage());
89+
}
90+
}
91+
92+
if (responseObj != null && responseObj.has("tweet")) {
93+
src = responseObj.optJSONObject("tweet").optString("source");
94+
if(src!=null) cache.put(tweetId, src);
95+
}
96+
}
97+
}
98+
}
99+
}catch(Exception e){
100+
Utils.logger(e);
101+
}
102+
return src;
103+
}
104+
}

app/src/main/java/app/revanced/integrations/twitter/settings/ScreenBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,15 @@ public void buildTimelineSection(boolean buildCategory){
658658
)
659659
);
660660
}
661+
if (SettingsStatus.showSourceLabel) {
662+
addPreference(category,
663+
helper.switchPreference(
664+
strRes("piko_pref_show_post_source"),
665+
strRes("piko_pref_show_post_source_desc"),
666+
Settings.TIMELINE_SHOW_SOURCE_LABEL
667+
)
668+
);
669+
}
661670
if (SettingsStatus.hideLiveThreads) {
662671
addPreference(category,
663672
helper.switchPreference(

app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class Settings extends BaseSettings {
5151
public static final StringSetting NATIVE_TRANSLATOR_LANG = new StringSetting("native_translator_language", "en");
5252

5353
public static final BooleanSetting TIMELINE_DISABLE_AUTO_SCROLL = new BooleanSetting("timeline_disable_auto_scroll", true);
54+
public static final BooleanSetting TIMELINE_SHOW_SOURCE_LABEL = new BooleanSetting("timeline_show_source_label", false);
5455
public static final BooleanSetting TIMELINE_HIDE_LIVETHREADS = new BooleanSetting("timeline_hide_livethreads", false);
5556
public static final BooleanSetting TIMELINE_HIDE_BANNER = new BooleanSetting("timeline_hide_banner", true);
5657
public static final BooleanSetting TIMELINE_HIDE_BMK_ICON = new BooleanSetting("timeline_hide_bookmark_icon", false);

app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class SettingsStatus {
4545
public static boolean enableUndoPosts = false;
4646
public static boolean customAppIcon = false;
4747
public static boolean enableForcePip = false;
48-
48+
public static boolean showSourceLabel = false;
4949
public static boolean hideImmersivePlayer = false;
5050
public static boolean enableVidAutoAdvance = false;
5151

@@ -294,6 +294,10 @@ public static void enableForcePip() {
294294
enableForcePip = true;
295295
}
296296

297+
public static void showSourceLabel() {
298+
showSourceLabel = true;
299+
}
300+
297301
public static void hideImmersivePlayer() {
298302
hideImmersivePlayer = true;
299303
}
@@ -334,7 +338,7 @@ public static void typeaheadCustomisation() {
334338
}
335339

336340
public static boolean enableTimelineSection() {
337-
return ( hideCommBadge || showSensitiveMedia || hideNudgeButton || disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote || hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer || enableVidAutoAdvance || enableForceHD);
341+
return ( showSourceLabel || hideCommBadge || showSensitiveMedia || hideNudgeButton || disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote || hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer || enableVidAutoAdvance || enableForceHD);
338342
}
339343

340344
public static boolean enableMiscSection() {

app/src/main/java/app/revanced/integrations/twitter/settings/fragments/SettingsAboutFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta
124124
flags.put(strRes("piko_pref_customisation_searchtabs"),SettingsStatus.searchTabCustomisation);
125125
flags.put(strRemoveRes("piko_pref_hide_todays_news"),SettingsStatus.hideTodaysNews);
126126
flags.put(strRemoveRes("piko_pref_server_response_logging"),SettingsStatus.serverResponseLogging);
127+
flags.put(strRes("piko_pref_show_post_source"),SettingsStatus.showSourceLabel);
127128

128129
LegacyTwitterPreferenceCategory patPref = preferenceCategory(strRes("piko_pref_patches"), screen);
129130

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.gradle.parallel = true
22
org.gradle.caching = true
33
android.useAndroidX = true
4-
version = 1.39.0
4+
version = 1.40.0-dev.2

0 commit comments

Comments
 (0)