Assorted crash fixes
This commit is contained in:
parent
f1b30f251c
commit
14209dc785
@ -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.3'
|
||||
implementation 'me.grishka.appkit:appkit:1.4.4'
|
||||
implementation 'com.google.code.gson:gson:2.8.9'
|
||||
implementation 'org.jsoup:jsoup:1.14.3'
|
||||
implementation 'com.squareup:otto:1.3.8'
|
||||
|
@ -124,6 +124,7 @@ public class AccountSessionManager{
|
||||
|
||||
public void addAccount(Instance instance, Token token, Account self, Application app, AccountActivationInfo activationInfo){
|
||||
instances.put(instance.getDomain(), instance);
|
||||
runOnDbThread(db->insertInstanceIntoDatabase(db, instance.getDomain(), instance, List.of(), 0));
|
||||
AccountSession session=new AccountSession(token, self, app, instance.getDomain(), activationInfo==null, activationInfo);
|
||||
sessions.put(session.getID(), session);
|
||||
lastActiveAccountID=session.getID();
|
||||
@ -349,6 +350,7 @@ public class AccountSessionManager{
|
||||
@Override
|
||||
public void onSuccess(Instance instance){
|
||||
instances.put(domain, instance);
|
||||
runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, List.of(), 0));
|
||||
updateInstanceEmojis(instance, domain);
|
||||
}
|
||||
|
||||
@ -581,6 +583,12 @@ public class AccountSessionManager{
|
||||
runOnDbThread(db->db.delete("dismissed_donation_campaigns", null, null));
|
||||
}
|
||||
|
||||
public void clearInstanceInfo(){
|
||||
SQLiteDatabase db=getOrOpenDatabase();
|
||||
db.delete("instances", null, null);
|
||||
db.close();
|
||||
}
|
||||
|
||||
private static void insertInstanceIntoDatabase(SQLiteDatabase db, String domain, Instance instance, List<Emoji> emojis, long lastUpdated){
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("domain", domain);
|
||||
|
@ -37,7 +37,8 @@ public class SettingsDebugFragment extends BaseSettingsFragment<Void>{
|
||||
new ListItem<>("Reset search info banners", null, this::onResetDiscoverBannersClick),
|
||||
new ListItem<>("Reset pre-reply sheets", null, this::onResetPreReplySheetsClick),
|
||||
new ListItem<>("Clear dismissed donation campaigns", null, this::onClearDismissedCampaignsClick),
|
||||
donationsStagingItem=new CheckableListItem<>("Use staging environment for donations", "Restart app to apply", CheckableListItem.Style.SWITCH, getPrefs().getBoolean("donationsStaging", false), this::toggleCheckableItem)
|
||||
donationsStagingItem=new CheckableListItem<>("Use staging environment for donations", "Restart app to apply", CheckableListItem.Style.SWITCH, getPrefs().getBoolean("donationsStaging", false), this::toggleCheckableItem),
|
||||
new ListItem<>("Delete cached instance info", null, this::onDeleteInstanceInfoClick)
|
||||
));
|
||||
if(!GithubSelfUpdater.needSelfUpdating()){
|
||||
resetUpdateItem.isEnabled=selfUpdateItem.isEnabled=false;
|
||||
@ -95,6 +96,11 @@ public class SettingsDebugFragment extends BaseSettingsFragment<Void>{
|
||||
Toast.makeText(getActivity(), "Dismissed campaigns cleared. Restart app to see your current campaign, if any", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onDeleteInstanceInfoClick(ListItem<?> item){
|
||||
AccountSessionManager.getInstance().clearInstanceInfo();
|
||||
Toast.makeText(getActivity(), "Instances removed from database", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void restartUI(){
|
||||
Bundle args=new Bundle();
|
||||
args.putString("account", accountID);
|
||||
|
@ -93,10 +93,12 @@ public class LinkCardHolder<T extends LinkCardHolder.LinkCardProvider> extends S
|
||||
authorChip.setVisibility(View.VISIBLE);
|
||||
authorBefore.setVisibility(View.VISIBLE);
|
||||
String[] authorParts=itemView.getContext().getString(R.string.article_by_author, "{author}").split("\\{author\\}");
|
||||
String before=authorParts[0].trim();
|
||||
String before=authorParts.length>0 ? authorParts[0].trim() : "";
|
||||
String after=authorParts.length>1 ? authorParts[1].trim() : "";
|
||||
if(!TextUtils.isEmpty(before)){
|
||||
authorBefore.setText(before);
|
||||
}else{
|
||||
authorBefore.setText("");
|
||||
}
|
||||
if(TextUtils.isEmpty(after)){
|
||||
authorAfter.setVisibility(View.GONE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user