work around black screen opening notifs
closes sk22#342
This commit is contained in:
parent
fe519f10a1
commit
4ab1c61262
1 changed files with 34 additions and 7 deletions
|
@ -40,12 +40,13 @@ public class MainActivity extends FragmentStackActivity{
|
||||||
AccountSession session;
|
AccountSession session;
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
Intent intent=getIntent();
|
Intent intent=getIntent();
|
||||||
if(intent.getBooleanExtra("fromNotification", false)){
|
boolean fromNotification = intent.getBooleanExtra("fromNotification", false);
|
||||||
|
boolean hasNotification = intent.hasExtra("notification");
|
||||||
|
if(fromNotification){
|
||||||
String accountID=intent.getStringExtra("accountID");
|
String accountID=intent.getStringExtra("accountID");
|
||||||
try{
|
try{
|
||||||
session=AccountSessionManager.getInstance().getAccount(accountID);
|
session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||||
if(!intent.hasExtra("notification"))
|
if(!hasNotification) args.putString("tab", "notifications");
|
||||||
args.putString("tab", "notifications");
|
|
||||||
}catch(IllegalStateException x){
|
}catch(IllegalStateException x){
|
||||||
session=AccountSessionManager.getInstance().getLastActiveAccount();
|
session=AccountSessionManager.getInstance().getLastActiveAccount();
|
||||||
}
|
}
|
||||||
|
@ -55,13 +56,13 @@ public class MainActivity extends FragmentStackActivity{
|
||||||
args.putString("account", session.getID());
|
args.putString("account", session.getID());
|
||||||
Fragment fragment=session.activated ? new HomeFragment() : new AccountActivationFragment();
|
Fragment fragment=session.activated ? new HomeFragment() : new AccountActivationFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
showFragmentClearingBackStack(fragment);
|
if(fromNotification && hasNotification){
|
||||||
if(intent.getBooleanExtra("fromNotification", false) && intent.hasExtra("notification")){
|
|
||||||
Notification notification=Parcels.unwrap(intent.getParcelableExtra("notification"));
|
Notification notification=Parcels.unwrap(intent.getParcelableExtra("notification"));
|
||||||
showFragmentForNotification(notification, session.getID());
|
showFragmentForNotification(notification, session.getID());
|
||||||
}else if(intent.getBooleanExtra("compose", false)){
|
} else if (intent.getBooleanExtra("compose", false)){
|
||||||
showCompose();
|
showCompose();
|
||||||
}else{
|
} else {
|
||||||
|
showFragmentClearingBackStack(fragment);
|
||||||
maybeRequestNotificationsPermission();
|
maybeRequestNotificationsPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,4 +141,30 @@ public class MainActivity extends FragmentStackActivity{
|
||||||
requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 100);
|
requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* when opening app through a notification: if (thread) fragment "can go back", clear back stack
|
||||||
|
* and show home fragment. upstream's implementation doesn't require this as it opens home first
|
||||||
|
* and then immediately switches to the notification's ThreadFragment. this causes a black
|
||||||
|
* screen in megalodon, for some reason, so i'm working around this that way.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Fragment currentFragment = getFragmentManager().findFragmentById(
|
||||||
|
(fragmentContainers.get(fragmentContainers.size() - 1)).getId()
|
||||||
|
);
|
||||||
|
Bundle currentArgs = currentFragment.getArguments();
|
||||||
|
if (this.fragmentContainers.size() == 1
|
||||||
|
&& currentArgs.getBoolean("_can_go_back", false)
|
||||||
|
&& currentArgs.containsKey("account")) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("account", currentArgs.getString("account"));
|
||||||
|
args.putString("tab", "notifications");
|
||||||
|
Fragment fragment=new HomeFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
showFragmentClearingBackStack(fragment);
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue