Assorted crash fixes
This commit is contained in:
@@ -90,7 +90,7 @@ dependencies {
|
|||||||
implementation 'me.grishka.litex:viewpager:1.0.0'
|
implementation 'me.grishka.litex:viewpager:1.0.0'
|
||||||
implementation 'me.grishka.litex:viewpager2:1.0.0'
|
implementation 'me.grishka.litex:viewpager2:1.0.0'
|
||||||
implementation 'me.grishka.litex:palette: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 'com.google.code.gson:gson:2.8.9'
|
||||||
implementation 'org.jsoup:jsoup:1.14.3'
|
implementation 'org.jsoup:jsoup:1.14.3'
|
||||||
implementation 'com.squareup:otto:1.3.8'
|
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){
|
public void addAccount(Instance instance, Token token, Account self, Application app, AccountActivationInfo activationInfo){
|
||||||
instances.put(instance.getDomain(), instance);
|
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);
|
AccountSession session=new AccountSession(token, self, app, instance.getDomain(), activationInfo==null, activationInfo);
|
||||||
sessions.put(session.getID(), session);
|
sessions.put(session.getID(), session);
|
||||||
lastActiveAccountID=session.getID();
|
lastActiveAccountID=session.getID();
|
||||||
@@ -349,6 +350,7 @@ public class AccountSessionManager{
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Instance instance){
|
public void onSuccess(Instance instance){
|
||||||
instances.put(domain, instance);
|
instances.put(domain, instance);
|
||||||
|
runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, List.of(), 0));
|
||||||
updateInstanceEmojis(instance, domain);
|
updateInstanceEmojis(instance, domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,6 +583,12 @@ public class AccountSessionManager{
|
|||||||
runOnDbThread(db->db.delete("dismissed_donation_campaigns", null, null));
|
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){
|
private static void insertInstanceIntoDatabase(SQLiteDatabase db, String domain, Instance instance, List<Emoji> emojis, long lastUpdated){
|
||||||
ContentValues values=new ContentValues();
|
ContentValues values=new ContentValues();
|
||||||
values.put("domain", domain);
|
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 search info banners", null, this::onResetDiscoverBannersClick),
|
||||||
new ListItem<>("Reset pre-reply sheets", null, this::onResetPreReplySheetsClick),
|
new ListItem<>("Reset pre-reply sheets", null, this::onResetPreReplySheetsClick),
|
||||||
new ListItem<>("Clear dismissed donation campaigns", null, this::onClearDismissedCampaignsClick),
|
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()){
|
if(!GithubSelfUpdater.needSelfUpdating()){
|
||||||
resetUpdateItem.isEnabled=selfUpdateItem.isEnabled=false;
|
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();
|
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(){
|
private void restartUI(){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
|
|||||||
@@ -93,10 +93,12 @@ public class LinkCardHolder<T extends LinkCardHolder.LinkCardProvider> extends S
|
|||||||
authorChip.setVisibility(View.VISIBLE);
|
authorChip.setVisibility(View.VISIBLE);
|
||||||
authorBefore.setVisibility(View.VISIBLE);
|
authorBefore.setVisibility(View.VISIBLE);
|
||||||
String[] authorParts=itemView.getContext().getString(R.string.article_by_author, "{author}").split("\\{author\\}");
|
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() : "";
|
String after=authorParts.length>1 ? authorParts[1].trim() : "";
|
||||||
if(!TextUtils.isEmpty(before)){
|
if(!TextUtils.isEmpty(before)){
|
||||||
authorBefore.setText(before);
|
authorBefore.setText(before);
|
||||||
|
}else{
|
||||||
|
authorBefore.setText("");
|
||||||
}
|
}
|
||||||
if(TextUtils.isEmpty(after)){
|
if(TextUtils.isEmpty(after)){
|
||||||
authorAfter.setVisibility(View.GONE);
|
authorAfter.setVisibility(View.GONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user