version upgrade, login layout fix, bug fix
This commit is contained in:
parent
0bcf4c1494
commit
2eb99730dd
@ -12,8 +12,8 @@ android {
|
||||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 65
|
||||
versionName '2.2'
|
||||
versionCode 66
|
||||
versionName '3.0a'
|
||||
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ dependencies {
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation 'org.jsoup:jsoup:1.15.3'
|
||||
//noinspection GradleDependency
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
//noinspection GradleDependency
|
||||
|
@ -92,7 +92,7 @@ public class AccountAdapter extends Adapter<AccountHolder> {
|
||||
// set profile image
|
||||
if (settings.imagesEnabled() && !user.getProfileUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage()) {
|
||||
if (!user.hasDefaultProfileImage() && account.getApiType() == Account.API_TWITTER) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
|
@ -66,12 +66,14 @@ public class ConnectionManager {
|
||||
}
|
||||
// select automatically
|
||||
else {
|
||||
if (settings.getLogin().getApiType() == Account.API_TWITTER) {
|
||||
Account login = settings.getLogin();
|
||||
if (login.getApiType() == Account.API_TWITTER) {
|
||||
connection = new Twitter(context);
|
||||
} else if (settings.getLogin().getApiType() == Account.API_MASTODON) {
|
||||
} else if (login.getApiType() == Account.API_MASTODON) {
|
||||
connection = new Mastodon(context);
|
||||
} else {
|
||||
throw new RuntimeException("no connection selected!");
|
||||
connection = new Twitter(context);
|
||||
//throw new RuntimeException("no connection selected!");
|
||||
}
|
||||
}
|
||||
settings.addSettingsChangeListener(new OnSettingsChangeListener() {
|
||||
|
@ -2,6 +2,7 @@ package org.nuclearfog.twidda.backend.api.mastodon.impl;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.nuclearfog.twidda.model.Relation;
|
||||
|
||||
@ -22,12 +23,17 @@ public class MastodonRelation implements Relation {
|
||||
* @param json Relation json object
|
||||
* @param currentId ID of the current user
|
||||
*/
|
||||
public MastodonRelation(JSONObject json, long currentId) {
|
||||
currentUser = currentId == Long.parseLong(json.optString("id", "0"));
|
||||
public MastodonRelation(JSONObject json, long currentId) throws JSONException {
|
||||
String idStr = json.getString("id");
|
||||
following = json.optBoolean("following");
|
||||
follower = json.optBoolean("followed_by");
|
||||
blocked = json.optBoolean("blocking");
|
||||
muted = json.optBoolean("muting");
|
||||
try {
|
||||
currentUser = currentId == Long.parseLong(idStr);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JSONException("bad ID:" + idStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.model.Status;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
@ -51,7 +52,8 @@ public class MastodonStatus implements Status {
|
||||
favoriteCount = json.optInt("favourites_count");
|
||||
favorited = json.optBoolean("favourited");
|
||||
reblogged = json.optBoolean("reblogged");
|
||||
text = json.optString("text", "");
|
||||
text = json.optString("content", "");
|
||||
text = Jsoup.parse(text).text();
|
||||
sensitive = json.optBoolean("sensitive", false);
|
||||
if (mentionsJson != null) {
|
||||
StringBuilder mentionsBuilder = new StringBuilder();
|
||||
@ -60,7 +62,6 @@ public class MastodonStatus implements Status {
|
||||
mentionsBuilder.append('@').append(item).append(' ');
|
||||
}
|
||||
mentions = mentionsBuilder.toString();
|
||||
text = mentions + ' ' + text;
|
||||
} else {
|
||||
mentions = "";
|
||||
}
|
||||
@ -71,7 +72,9 @@ public class MastodonStatus implements Status {
|
||||
}
|
||||
try {
|
||||
id = Long.parseLong(idStr);
|
||||
if (!replyIdStr.equals("null"))
|
||||
replyId = Long.parseLong(replyIdStr);
|
||||
if (!replyUserIdStr.equals("null"))
|
||||
replyUserId = Long.parseLong(replyUserIdStr);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JSONException("bad ID:" + idStr + ' ' + replyIdStr + ' ' + replyUserIdStr);
|
||||
|
@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.model.Status;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
@ -81,10 +82,12 @@ public class TweetV1 implements Status {
|
||||
JSONObject locationJson = json.optJSONObject("place");
|
||||
JSONObject currentUserJson = json.optJSONObject("current_user_retweet");
|
||||
JSONObject embeddedTweetJson = json.optJSONObject("retweeted_status");
|
||||
String retweetIdStr = "0";
|
||||
String tweetIdStr = json.optString("id_str", "");
|
||||
String replyName = json.optString("in_reply_to_screen_name", "");
|
||||
String replyTweetIdStr = json.optString("in_reply_to_status_id_str", "0");
|
||||
String replyUsrIdStr = json.optString("in_reply_to_user_id_str", "0");
|
||||
String source = json.optString("source", "");
|
||||
String text = createText(json);
|
||||
|
||||
author = new UserV1(json.getJSONObject("user"), twitterId);
|
||||
@ -94,21 +97,22 @@ public class TweetV1 implements Status {
|
||||
isRetweeted = json.optBoolean("retweeted");
|
||||
isSensitive = json.optBoolean("possibly_sensitive");
|
||||
timestamp = StringTools.getTime1(json.optString("created_at", ""));
|
||||
source = StringTools.getSource(json.optString("source", ""));
|
||||
coordinates = getLocation(json);
|
||||
mediaLinks = addMedia(json);
|
||||
userMentions = StringTools.getUserMentions(text, author.getScreenname());
|
||||
|
||||
this.source = Jsoup.parse(source).text();
|
||||
try {
|
||||
id = Long.parseLong(tweetIdStr);
|
||||
if (currentUserJson != null)
|
||||
retweetIdStr = currentUserJson.optString("id_str", "0");
|
||||
if (!replyTweetIdStr.equals("null"))
|
||||
replyTweetId = Long.parseLong(replyTweetIdStr);
|
||||
if (!replyUsrIdStr.equals("null"))
|
||||
replyUserId = Long.parseLong(replyUsrIdStr);
|
||||
if (currentUserJson != null) {
|
||||
String retweetIdStr = currentUserJson.optString("id_str", "0");
|
||||
if (!retweetIdStr.equals("null"))
|
||||
retweetId = Long.parseLong(retweetIdStr);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JSONException("bad IDs: " + tweetIdStr + "," + replyUsrIdStr + " or retweet ID");
|
||||
throw new JSONException("bad IDs:" + tweetIdStr + "," + replyUsrIdStr + "," + retweetIdStr);
|
||||
}
|
||||
if (!replyName.isEmpty() && !replyName.equals("null")) {
|
||||
this.replyName = '@' + replyName;
|
||||
|
@ -32,8 +32,14 @@ public class LoginAction extends AsyncTask<String, Void, String> {
|
||||
*/
|
||||
public static final int MODE_LOGIN = 2;
|
||||
|
||||
/**
|
||||
* use Twitter account to login
|
||||
*/
|
||||
public static final int LOGIN_TWITTER = 10;
|
||||
|
||||
/**
|
||||
* use Mastodon account to login
|
||||
*/
|
||||
public static final int LOGIN_MASTODON = 11;
|
||||
|
||||
private WeakReference<LoginActivity> weakRef;
|
||||
@ -57,13 +63,15 @@ public class LoginAction extends AsyncTask<String, Void, String> {
|
||||
weakRef = new WeakReference<>(activity);
|
||||
accountDB = new AccountDatabase(activity);
|
||||
database = new AppDatabase(activity);
|
||||
this.mode = mode;
|
||||
|
||||
if (network == LOGIN_TWITTER) {
|
||||
connection = ConnectionManager.get(activity, ConnectionManager.SELECT_TWITTER);
|
||||
} else if (network == LOGIN_MASTODON) {
|
||||
connection = ConnectionManager.get(activity, ConnectionManager.SELECT_MASTODON);
|
||||
} else {
|
||||
throw new RuntimeException("no connection selected: " + mode);
|
||||
}
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,20 +217,6 @@ public final class StringTools {
|
||||
return DEFAULT_TIME;
|
||||
}
|
||||
|
||||
/**
|
||||
* extract API name from Twitter href string
|
||||
*
|
||||
* @param srcHref twitter API href
|
||||
* @return API name
|
||||
*/
|
||||
public static String getSource(String srcHref) {
|
||||
int start = srcHref.indexOf('>') + 1;
|
||||
int end = srcHref.lastIndexOf('<');
|
||||
if (start > 0 && end > start)
|
||||
return srcHref.substring(start, end);
|
||||
return srcHref;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate index offset caused by emojies
|
||||
*
|
||||
|
@ -26,6 +26,7 @@ public class AccountImpl implements Account {
|
||||
AccountTable.TOKEN_SECRET,
|
||||
AccountTable.CLIENT_ID,
|
||||
AccountTable.CLIENT_SECRET,
|
||||
AccountTable.BEARER,
|
||||
AccountTable.HOSTNAME,
|
||||
AccountTable.API
|
||||
};
|
||||
@ -64,8 +65,9 @@ public class AccountImpl implements Account {
|
||||
tokenSecret = cursor.getString(3);
|
||||
consumerToken = cursor.getString(4);
|
||||
consumerSecret = cursor.getString(5);
|
||||
host = cursor.getString(6);
|
||||
apiType = cursor.getInt(7);
|
||||
bearerToken = cursor.getString(6);
|
||||
host = cursor.getString(7);
|
||||
apiType = cursor.getInt(8);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@ import org.nuclearfog.twidda.backend.async.LoginAction;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.Account;
|
||||
|
||||
/**
|
||||
* Account Activity of the App
|
||||
@ -119,18 +120,22 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener,
|
||||
hostSelector.setSelection(0);
|
||||
|
||||
if (settings.isCustomApiSet() || !Tokens.USE_DEFAULT_KEYS) {
|
||||
apiSwitch.setCheckedImmediately(true);
|
||||
// force using custom API tokens
|
||||
if (!Tokens.USE_DEFAULT_KEYS) {
|
||||
apiSwitch.setVisibility(View.GONE);
|
||||
switchLabel.setVisibility(View.GONE);
|
||||
}
|
||||
apiSwitch.setCheckedImmediately(true);
|
||||
apiKey1.setText(settings.getLogin().getConsumerToken());
|
||||
apiKey2.setText(settings.getLogin().getConsumerSecret());
|
||||
// use custom API tokens if there were set in a previously login
|
||||
Account login = settings.getLogin();
|
||||
if (login.getApiType() == Account.API_TWITTER) {
|
||||
apiKey1.setText(login.getConsumerToken());
|
||||
apiKey2.setText(login.getConsumerSecret());
|
||||
}
|
||||
} else {
|
||||
apiKey1.setVisibility(View.INVISIBLE);
|
||||
apiKey2.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
AppStyles.setTheme(root, settings.getBackgroundColor());
|
||||
|
||||
linkButton.setOnClickListener(this);
|
||||
@ -351,6 +356,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener,
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.backend.utils.PicassoBuilder;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.Account;
|
||||
import org.nuclearfog.twidda.model.Relation;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||
@ -658,7 +659,7 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
}
|
||||
if (!user.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage()) {
|
||||
if (!user.hasDefaultProfileImage() && settings.getLogin().getApiType() == Account.API_TWITTER) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), PROFILE_IMG_HIGH_RES);
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
|
@ -87,6 +87,7 @@
|
||||
android:layout_marginStart="@dimen/loginpage_layout_margin"
|
||||
android:layout_marginTop="@dimen/loginpage_layout_margin"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintHorizontal_weight="2"
|
||||
app:layout_constraintStart_toEndOf="@id/login_enable_key_input_label"
|
||||
app:layout_constraintTop_toBottomOf="@id/login_network_selector"
|
||||
@ -105,6 +106,7 @@
|
||||
android:layout_marginTop="@dimen/loginpage_layout_margin"
|
||||
android:layout_marginEnd="@dimen/loginpage_layout_margin"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintHorizontal_weight="3"
|
||||
app:layout_constraintStart_toEndOf="@id/login_enter_key1"
|
||||
app:layout_constraintTop_toBottomOf="@id/login_network_selector"
|
||||
@ -174,7 +176,7 @@
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_enter_code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="pin"
|
||||
android:background="@android:color/transparent"
|
||||
@ -184,6 +186,8 @@
|
||||
android:textSize="@dimen/loginpage_textsize_login_key"
|
||||
android:maxLines="1"
|
||||
android:layout_marginEnd="@dimen/loginpage_layout_margin"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintWidth_percent="0.5"
|
||||
app:layout_constraintStart_toEndOf="@id/login_third_opt"
|
||||
app:layout_constraintTop_toBottomOf="@id/login_get_link"
|
||||
app:layout_constraintBottom_toTopOf="@id/login_verifier"
|
||||
|
Loading…
x
Reference in New Issue
Block a user