Fixes
This commit is contained in:
parent
9a0c383da8
commit
e8eb12532a
@ -141,7 +141,9 @@ public class PushSubscriptionManager{
|
||||
encodedPublicKey=Base64.encodeToString(serializeRawPublicKey(publicKey), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
|
||||
authKey=new byte[16];
|
||||
new SecureRandom().nextBytes(authKey);
|
||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
||||
if(session==null)
|
||||
return;
|
||||
session.pushPrivateKey=Base64.encodeToString(privateKey.getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
|
||||
session.pushPublicKey=Base64.encodeToString(publicKey.getEncoded(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
|
||||
session.pushAuthKey=encodedAuthKey=Base64.encodeToString(authKey, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
|
||||
@ -162,7 +164,9 @@ public class PushSubscriptionManager{
|
||||
MastodonAPIController.runInBackground(()->{
|
||||
serverKey=deserializeRawPublicKey(Base64.decode(result.serverKey, Base64.URL_SAFE));
|
||||
|
||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
||||
if(session==null)
|
||||
return;
|
||||
session.pushSubscription=result;
|
||||
AccountSessionManager.getInstance().writeAccountsFile();
|
||||
Log.d(TAG, "Successfully registered "+accountID+" for push notifications");
|
||||
@ -183,7 +187,9 @@ public class PushSubscriptionManager{
|
||||
.setCallback(new Callback<>(){
|
||||
@Override
|
||||
public void onSuccess(PushSubscription result){
|
||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
||||
if(session==null)
|
||||
return;
|
||||
if(result.policy!=subscription.policy)
|
||||
result.policy=subscription.policy;
|
||||
session.pushSubscription=result;
|
||||
@ -196,7 +202,9 @@ public class PushSubscriptionManager{
|
||||
if(((MastodonErrorResponse)error).httpStatus==404){ // Not registered for push, register now
|
||||
registerAccountForPush(subscription);
|
||||
}else{
|
||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
||||
if(session==null)
|
||||
return;
|
||||
session.needUpdatePushSettings=true;
|
||||
session.pushSubscription=subscription;
|
||||
AccountSessionManager.getInstance().writeAccountsFile();
|
||||
|
@ -133,10 +133,20 @@ public class AccountSessionManager{
|
||||
return session;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AccountSession tryGetAccount(String id){
|
||||
return sessions.get(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AccountSession getLastActiveAccount(){
|
||||
if(sessions.isEmpty() || lastActiveAccountID==null)
|
||||
return null;
|
||||
if(!sessions.containsKey(lastActiveAccountID)){
|
||||
// TODO figure out why this happens. It should not be possible.
|
||||
lastActiveAccountID=getLoggedInAccounts().get(0).getID();
|
||||
writeAccountsFile();
|
||||
}
|
||||
return getAccount(lastActiveAccountID);
|
||||
}
|
||||
|
||||
@ -197,6 +207,7 @@ public class AccountSessionManager{
|
||||
|
||||
new CustomTabsIntent.Builder()
|
||||
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
|
||||
.setShowTitle(true)
|
||||
.build()
|
||||
.launchUrl(activity, uri);
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public class AccountTimelineFragment extends StatusListFragment{
|
||||
|
||||
@Override
|
||||
protected void doLoadData(int offset, int count){
|
||||
if(user==null) // TODO figure out why this happens
|
||||
return;
|
||||
currentRequest=new GetAccountStatuses(user.id, offset>0 ? getMaxID() : null, null, count, filter)
|
||||
.setCallback(new SimpleCallback<>(this){
|
||||
@Override
|
||||
|
@ -1049,6 +1049,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
||||
}
|
||||
|
||||
private void updateVisibilityIcon(){
|
||||
if(statusVisibility==null){ // TODO find out why this happens
|
||||
statusVisibility=StatusPrivacy.PUBLIC;
|
||||
}
|
||||
visibilityBtn.setImageResource(switch(statusVisibility){
|
||||
case PUBLIC -> R.drawable.ic_fluent_earth_24_filled;
|
||||
case UNLISTED -> R.drawable.ic_fluent_people_community_24_regular;
|
||||
|
@ -56,6 +56,8 @@ public class ThreadFragment extends StatusListFragment{
|
||||
.setCallback(new SimpleCallback<>(this){
|
||||
@Override
|
||||
public void onSuccess(StatusContext result){
|
||||
if(getActivity()==null)
|
||||
return;
|
||||
if(refreshing){
|
||||
data.clear();
|
||||
displayItems.clear();
|
||||
|
@ -250,6 +250,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||
Menu menu=optionsMenu.getMenu();
|
||||
boolean isOwnPost=AccountSessionManager.getInstance().isSelf(item.parentFragment.getAccountID(), account);
|
||||
menu.findItem(R.id.delete).setVisible(item.status!=null && isOwnPost);
|
||||
menu.findItem(R.id.open_in_browser).setVisible(item.status!=null);
|
||||
MenuItem blockDomain=menu.findItem(R.id.block_domain);
|
||||
MenuItem mute=menu.findItem(R.id.mute);
|
||||
MenuItem block=menu.findItem(R.id.block);
|
||||
|
Loading…
Reference in New Issue
Block a user