Skip to content

Commit

Permalink
Assorted crash fixes
Browse files Browse the repository at this point in the history
fixes #896
  • Loading branch information
grishka committed Oct 3, 2024
1 parent 74986a1 commit 853f9dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mastodon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 34
versionCode 119
versionName "2.7.0"
versionCode 120
versionName "2.7.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -90,7 +90,7 @@ dependencies {
implementation 'me.grishka.litex:viewpager:1.0.0'
implementation 'me.grishka.litex:viewpager2:1.0.0'
implementation 'me.grishka.litex:palette:1.0.0'
implementation 'me.grishka.appkit:appkit:1.4.0'
implementation 'me.grishka.appkit:appkit:1.4.1'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'com.squareup:otto:1.3.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ public class AccountSession{
activated=(flags & FLAG_ACTIVATED)==FLAG_ACTIVATED;
needUpdatePushSettings=(flags & FLAG_NEED_UPDATE_PUSH_SETTINGS)==FLAG_NEED_UPDATE_PUSH_SETTINGS;
JsonObject pushKeys=JsonParser.parseString(values.getAsString("push_keys")).getAsJsonObject();
pushAuthKey=pushKeys.get("auth").getAsString();
pushPrivateKey=pushKeys.get("private").getAsString();
pushPublicKey=pushKeys.get("public").getAsString();
if(!pushKeys.get("auth").isJsonNull() && !pushKeys.get("private").isJsonNull() && !pushKeys.get("public").isJsonNull()){
pushAuthKey=pushKeys.get("auth").getAsString();
pushPrivateKey=pushKeys.get("private").getAsString();
pushPublicKey=pushKeys.get("public").getAsString();
}
pushSubscription=MastodonAPIController.gson.fromJson(values.getAsString("push_subscription"), PushSubscription.class);
JsonObject legacyFilters=JsonParser.parseString(values.getAsString("legacy_filters")).getAsJsonObject();
wordFilters=MastodonAPIController.gson.fromJson(legacyFilters.getAsJsonArray("filters"), new TypeToken<List<LegacyFilter>>(){}.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ private void maybeMigrateAccounts(SQLiteDatabase db){
File file=new File(MastodonApp.context.getFilesDir(), "instance_"+domain.replace('.', '_')+".json");
try(FileInputStream in=new FileInputStream(file)){
JsonObject jobj=JsonParser.parseReader(new InputStreamReader(in, StandardCharsets.UTF_8)).getAsJsonObject();

insertInstanceIntoDatabase(db, domain, MastodonAPIController.gson.fromJson(jobj.get("instance"), Instance.class),
insertInstanceIntoDatabase(db, domain, MastodonAPIController.gson.fromJson(jobj.get(jobj.has("instance") ? "instance" : "a"), Instance.class),
MastodonAPIController.gson.fromJson(jobj.get("emojis"), new TypeToken<>(){}.getType()), jobj.get("last_updated").getAsLong());
}catch(Exception x){
Log.w(TAG, "Error reading instance info file for "+domain, x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.jsoup.select.NodeVisitor;
import org.parceler.Parcels;

import java.time.Instant;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -237,6 +238,11 @@ public void onSuccess(Token result){
fakeAccount.acct=fakeAccount.username=username;
fakeAccount.id="tmp"+System.currentTimeMillis();
fakeAccount.displayName=displayName.getText().toString();
fakeAccount.createdAt=Instant.now();
fakeAccount.username=username;
fakeAccount.acct=username;
fakeAccount.url="https://"+instance.getDomain()+"/@"+username;
fakeAccount.avatar=fakeAccount.avatarStatic=fakeAccount.headerStatic=fakeAccount.header=fakeAccount.note="";
AccountSessionManager.getInstance().addAccount(instance, result, fakeAccount, apiApplication, new AccountActivationInfo(email, System.currentTimeMillis()));
Bundle args=new Bundle();
args.putString("account", AccountSessionManager.getInstance().getLastActiveAccountID());
Expand Down

0 comments on commit 853f9dc

Please sign in to comment.