diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/TwitterException.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/TwitterException.java
index bc47e8f6..8f020e3b 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/api/TwitterException.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/TwitterException.java
@@ -24,14 +24,20 @@ public class TwitterException extends Exception implements TwitterError {
private int errorCode = -1;
private int retryAfter = -1;
-
+ /**
+ * create exception caused by another exception
+ */
TwitterException(Exception e) {
super(e);
httpCode = -1;
message = e.getMessage();
}
-
+ /**
+ * create exception caused by response error
+ *
+ * @param response response from API containing additional error information
+ */
TwitterException(Response response) {
// basic information
this.httpCode = response.code();
@@ -143,6 +149,6 @@ public class TwitterException extends Exception implements TwitterError {
@NonNull
@Override
public String toString() {
- return "http:" + httpCode + " errorcode:" + errorCode + " message:\"" + message + "\"";
+ return "http=" + httpCode + " errorcode=" + errorCode + " message=\"" + message + "\"";
}
}
\ No newline at end of file
diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV1.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV1.java
index 25758b6b..44e29a5b 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV1.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV1.java
@@ -30,7 +30,7 @@ public class UserV1 implements User {
private int following;
private int follower;
private int tweetCount;
- private int favorCount;
+ private int favoriteCount;
private boolean isVerified;
private boolean isLocked;
private boolean followReqSent;
@@ -57,7 +57,7 @@ public class UserV1 implements User {
following = json.optInt("friends_count");
follower = json.optInt("followers_count");
tweetCount = json.optInt("statuses_count");
- favorCount = json.optInt("favourites_count");
+ favoriteCount = json.optInt("favourites_count");
followReqSent = json.optBoolean("follow_request_sent");
defaultImage = json.optBoolean("default_profile_image");
created = StringTools.getTime1(json.optString("created_at"));
@@ -141,7 +141,7 @@ public class UserV1 implements User {
@Override
public int getFavoriteCount() {
- return favorCount;
+ return favoriteCount;
}
@Override
diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV2.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV2.java
index ab049d53..6bc5be3a 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV2.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/impl/UserV2.java
@@ -10,7 +10,7 @@ import org.nuclearfog.twidda.backend.utils.StringTools;
import org.nuclearfog.twidda.model.User;
/**
- * implementation of User accessed by API 2.0
+ * User implementation of API V2
*
* @author nuclearfog
*/
@@ -36,7 +36,7 @@ public class UserV2 implements User {
private int following;
private int follower;
private int tweetCount;
- private int favorCount;
+ private int likeCount;
private boolean isCurrentUser;
private boolean isVerified;
private boolean isProtected;
@@ -66,7 +66,7 @@ public class UserV2 implements User {
}
// not yet implemented in API 2.0
- favorCount = -1;
+ likeCount = -1;
followReqSent = false;
defaultImage = false;
}
@@ -148,7 +148,7 @@ public class UserV2 implements User {
@Override
public int getFavoriteCount() {
- return favorCount;
+ return likeCount;
}
@Override
diff --git a/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java b/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
index 578cefc1..42e8a139 100644
--- a/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
+++ b/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
@@ -48,6 +48,13 @@ public class GlobalSettings {
*/
public static final String BANNER_IMG_MID_RES = "/600x200";
+ /**
+ * alternative Twitter service
+ */
+ private static final String TWITTER_ALT_HOST = "https://nitter.net/";
+
+ private static final String TWITTER_HOST = "https://twitter.com/";
+
/**
* custom android font
*/
@@ -101,6 +108,7 @@ public class GlobalSettings {
private static final String TREND_ID = "world_id";
private static final String LINK_PREVIEW = "link_preview";
private static final String ENABLE_LIKE = "like_enable";
+ private static final String ENABLE_TWITTER_ALT = "twitter_alt_set";
private static final String FILTER_RESULTS = "filter_results";
private static final String CUSTOM_CONSUMER_KEY_SET = "custom_api_keys";
private static final String CUSTOM_CONSUMER_KEY_1 = "api_key1";
@@ -150,6 +158,7 @@ public class GlobalSettings {
private boolean linkPreview;
private boolean filterResults;
private boolean enableLike;
+ private boolean twitterAlt;
private int background_color;
private int font_color;
private int highlight_color;
@@ -702,6 +711,39 @@ public class GlobalSettings {
edit.apply();
}
+ /**
+ * check if Twitter link alternative is set (e.G. nitter.net)
+ *
+ * @return true if link alternative is set
+ */
+ public boolean twitterAltSet() {
+ return twitterAlt;
+ }
+
+ /**
+ * set Twitter alternative link
+ *
+ * @param enable true to enable alternative link
+ */
+ public void setTwitterAlt(boolean enable) {
+ twitterAlt = enable;
+
+ Editor edit = settings.edit();
+ edit.putBoolean(ENABLE_TWITTER_ALT, enable);
+ edit.apply();
+ }
+
+ /**
+ * get hostname of the Twitter service to use
+ *
+ * @return custom host domain name if alternative is set, otherwise default Twitter host
+ */
+ public String getTwitterHostname() {
+ if (twitterAlt)
+ return TWITTER_ALT_HOST;
+ return TWITTER_HOST;
+ }
+
/**
* set proxy address
*
@@ -1060,6 +1102,7 @@ public class GlobalSettings {
filterResults = settings.getBoolean(FILTER_RESULTS, true);
enableLike = settings.getBoolean(ENABLE_LIKE, false);
customAPIKey = settings.getBoolean(CUSTOM_CONSUMER_KEY_SET, false);
+ twitterAlt = settings.getBoolean(ENABLE_TWITTER_ALT, false);
proxyHost = settings.getString(PROXY_ADDR, "");
proxyPort = settings.getString(PROXY_PORT, "");
proxyUser = settings.getString(PROXY_USER, "");
diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/AppSettings.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/AppSettings.java
index be9f8de9..a32b1e1b 100644
--- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/AppSettings.java
+++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/AppSettings.java
@@ -138,6 +138,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
SwitchButton toolbarOverlap = findViewById(R.id.settings_toolbar_ov);
SwitchButton enablePreview = findViewById(R.id.settings_enable_prev);
SwitchButton enableLike = findViewById(R.id.enable_like);
+ SwitchButton enableTwitterAlt = findViewById(R.id.settings_enable_twitter_alt);
SeekBar listSizeSelector = findViewById(R.id.settings_list_seek);
Spinner fontSelector = findViewById(R.id.spinner_font);
Spinner scaleSelector = findViewById(R.id.spinner_scale);
@@ -230,6 +231,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
enablePreview.setCheckedImmediately(settings.linkPreviewEnabled());
toolbarOverlap.setCheckedImmediately(settings.toolbarOverlapEnabled());
enableLike.setCheckedImmediately(settings.likeEnabled());
+ enableTwitterAlt.setCheckedImmediately(settings.twitterAltSet());
enableAPI.setCheckedImmediately(settings.isCustomApiSet());
enableProxy.setCheckedImmediately(settings.isProxyEnabled());
enableAuth.setCheckedImmediately(settings.isProxyAuthSet());
@@ -253,6 +255,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
toggleAns.setOnCheckedChangeListener(this);
enableAPI.setOnCheckedChangeListener(this);
enableLike.setOnCheckedChangeListener(this);
+ enableTwitterAlt.setOnCheckedChangeListener(this);
enablePreview.setOnCheckedChangeListener(this);
enableProxy.setOnCheckedChangeListener(this);
enableAuth.setOnCheckedChangeListener(this);
@@ -521,6 +524,10 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
colorButtons[COLOR_FAVORITE].setText(R.string.settings_color_fav);
}
}
+ // enable alternative Twitter service
+ else if (c.getId() == R.id.settings_enable_twitter_alt) {
+ settings.setTwitterAlt(checked);
+ }
// enable link preview
else if (c.getId() == R.id.settings_enable_prev) {
settings.setLinkPreview(checked);
diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/TweetActivity.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/TweetActivity.java
index 2f8bfb22..706d7cb1 100644
--- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/TweetActivity.java
+++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/TweetActivity.java
@@ -341,7 +341,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
// get tweet link
else if (item.getItemId() == R.id.menu_tweet_browser) {
String username = author.getScreenname().substring(1);
- String tweetLink = "https://twitter.com/" + username + "/status/" + clickedTweet.getId();
+ String tweetLink = settings.getTwitterHostname() + username + "/status/" + clickedTweet.getId();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tweetLink));
try {
startActivity(intent);
@@ -361,7 +361,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
// copy tweet link to clipboard
else if (item.getItemId() == R.id.menu_tweet_copy_tweetlink) {
String username = author.getScreenname().substring(1);
- String tweetLink = "https://twitter.com/" + username + "/status/" + clickedTweet.getId();
+ String tweetLink = settings.getTwitterHostname() + username + "/status/" + clickedTweet.getId();
ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clip != null) {
ClipData linkClip = ClipData.newPlainText("tweet link", tweetLink);
diff --git a/app/src/main/res/layout/page_settings.xml b/app/src/main/res/layout/page_settings.xml
index bb319928..8265dd14 100644
--- a/app/src/main/res/layout/page_settings.xml
+++ b/app/src/main/res/layout/page_settings.xml
@@ -395,7 +395,7 @@
android:layout_marginEnd="@dimen/settings_switch_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toggleAns"
- app:layout_constraintBottom_toTopOf="@id/settings_list_seek"
+ app:layout_constraintBottom_toTopOf="@id/settings_enable_twitter_alt"
app:layout_constraintEnd_toStartOf="@id/settings_enable_prev_descr" />
+
+
+
+
Antwort einblenden
Antwort wurde ausgeblendet
Antwort wurde eingeblendet
+ nitter.net für Links benutzen
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 36c07bd3..ceb7dae1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -224,6 +224,7 @@
Collapsed profile layout
Look
enable link preview
+ use nitter.net for links
load more
save image
enable proxy