mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 19:34:55 +01:00
added option to use nitter.net domain, added comments
This commit is contained in:
parent
adfb988766
commit
7c309a2ea2
@ -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 + "\"";
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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, "");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
@ -410,6 +410,30 @@
|
||||
app:layout_constraintBottom_toBottomOf="@id/settings_enable_prev"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/settings_enable_twitter_alt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/settings_column_margin"
|
||||
android:layout_marginRight="@dimen/settings_switch_margin"
|
||||
android:layout_marginEnd="@dimen/settings_switch_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/settings_enable_prev"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_list_seek"
|
||||
app:layout_constraintEnd_toStartOf="@id/settings_enable_twitter_alt_descr" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_enable_twitter_alt_descr"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/settings_description_enable_twitter_alt"
|
||||
android:textSize="@dimen/settings_textsize_small"
|
||||
app:layout_constraintStart_toEndOf="@id/settings_enable_twitter_alt"
|
||||
app:layout_constraintTop_toTopOf="@id/settings_enable_twitter_alt"
|
||||
app:layout_constraintBottom_toBottomOf="@id/settings_enable_twitter_alt"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_list_seek_descr"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -234,4 +234,5 @@
|
||||
<string name="menu_tweet_unhide">Antwort einblenden</string>
|
||||
<string name="info_reply_hidden">Antwort wurde ausgeblendet</string>
|
||||
<string name="info_reply_unhidden">Antwort wurde eingeblendet</string>
|
||||
<string name="settings_description_enable_twitter_alt">nitter.net für Links benutzen</string>
|
||||
</resources>
|
@ -224,6 +224,7 @@
|
||||
<string name="settings_enable_toolbar_overlap">Collapsed profile layout</string>
|
||||
<string name="settings_look">Look</string>
|
||||
<string name="settings_toggle_link_preview">enable link preview</string>
|
||||
<string name="settings_description_enable_twitter_alt">use nitter.net for links</string>
|
||||
<string name="item_load_more">load more</string>
|
||||
<string name="item_image_save">save image</string>
|
||||
<string name="settings_enable_proxy">enable proxy</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user