generalize notification handling, open reports in browser
This commit is contained in:
parent
7a6af89375
commit
37622ba9ce
|
@ -117,25 +117,13 @@ public class MainActivity extends FragmentStackActivity implements ProvidesAssis
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFragmentForNotification(Notification notification, String accountID){
|
private void showFragmentForNotification(Notification notification, String accountID){
|
||||||
Fragment fragment;
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putBoolean("_can_go_back", true);
|
|
||||||
try{
|
try{
|
||||||
notification.postprocess();
|
notification.postprocess();
|
||||||
}catch(ObjectValidationException x){
|
}catch(ObjectValidationException x){
|
||||||
Log.w("MainActivity", x);
|
Log.w("MainActivity", x);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(notification.status!=null){
|
UiUtils.showFragmentForNotification(this, notification, accountID, null);
|
||||||
fragment=new ThreadFragment();
|
|
||||||
args.putParcelable("status", Parcels.wrap(notification.status));
|
|
||||||
}else{
|
|
||||||
fragment=new ProfileFragment();
|
|
||||||
args.putParcelable("profileAccount", Parcels.wrap(notification.account));
|
|
||||||
}
|
|
||||||
fragment.setArguments(args);
|
|
||||||
showFragment(fragment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFragmentForExternalShare(Bundle args) {
|
private void showFragmentForExternalShare(Bundle args) {
|
||||||
|
|
|
@ -192,23 +192,10 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(String id){
|
public void onItemClick(String id){
|
||||||
Notification n=getNotificationByID(id);
|
Notification n=getNotificationByID(id);
|
||||||
if(n.status!=null){
|
Bundle args = new Bundle();
|
||||||
Status status=n.status;
|
if(n.status != null && n.status.inReplyToAccountId != null && knownAccounts.containsKey(n.status.inReplyToAccountId))
|
||||||
Bundle args=new Bundle();
|
args.putParcelable("inReplyToAccount", Parcels.wrap(knownAccounts.get(n.status.inReplyToAccountId)));
|
||||||
args.putString("account", accountID);
|
UiUtils.showFragmentForNotification(getContext(), n, accountID, args);
|
||||||
args.putParcelable("status", Parcels.wrap(status));
|
|
||||||
if(status.inReplyToAccountId!=null && knownAccounts.containsKey(status.inReplyToAccountId))
|
|
||||||
args.putParcelable("inReplyToAccount", Parcels.wrap(knownAccounts.get(status.inReplyToAccountId)));
|
|
||||||
Nav.go(getActivity(), ThreadFragment.class, args);
|
|
||||||
}else if(n.report != null){
|
|
||||||
String domain = AccountSessionManager.getInstance().getAccount(accountID).domain;
|
|
||||||
UiUtils.launchWebBrowser(getActivity(), "https://"+domain+"/admin/reports/"+n.report.id);
|
|
||||||
}else{
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putParcelable("profileAccount", Parcels.wrap(n.account));
|
|
||||||
Nav.go(getActivity(), ProfileFragment.class, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1387,6 +1387,23 @@ public class UiUtils {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showFragmentForNotification(Context context, Notification n, String accountID, Bundle extras) {
|
||||||
|
if (extras == null) extras = new Bundle();
|
||||||
|
extras.putString("account", accountID);
|
||||||
|
if (n.status!=null) {
|
||||||
|
Status status=n.status;
|
||||||
|
extras.putParcelable("status", Parcels.wrap(status));
|
||||||
|
Nav.go((Activity) context, ThreadFragment.class, extras);
|
||||||
|
} else if (n.report != null) {
|
||||||
|
String domain = AccountSessionManager.getInstance().getAccount(accountID).domain;
|
||||||
|
UiUtils.launchWebBrowser(context, "https://"+domain+"/admin/reports/"+n.report.id);
|
||||||
|
} else if (n.account != null) {
|
||||||
|
extras.putString("account", accountID);
|
||||||
|
extras.putParcelable("profileAccount", Parcels.wrap(n.account));
|
||||||
|
Nav.go((Activity) context, ProfileFragment.class, extras);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a View.OnClickListener to filter multiple clicks in succession.
|
* Wraps a View.OnClickListener to filter multiple clicks in succession.
|
||||||
* Useful for buttons that perform some action that changes their state asynchronously.
|
* Useful for buttons that perform some action that changes their state asynchronously.
|
||||||
|
|
Loading…
Reference in New Issue