Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open in browser with current session instance #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public boolean onOptionsItemSelected(MenuItem item){
args.putParcelable("reportAccount", Parcels.wrap(account));
Nav.go(getActivity(), ReportReasonChoiceFragment.class, args);
}else if(id==R.id.open_in_browser){
UiUtils.launchWebBrowser(getActivity(), account.url);
UiUtils.launchWebBrowser(getActivity(), UiUtils.getSessionAccountURL(accountID, account));
}else if(id==R.id.block_domain){
UiUtils.confirmToggleBlockDomain(getActivity(), accountID, account.getDomain(), relationship.domainBlocking, ()->{
relationship.domainBlocking=!relationship.domainBlocking;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private boolean onContextMenuItemSelected(MenuItem item){
args.putParcelable("reportAccount", Parcels.wrap(account));
Nav.go(getActivity(), ReportReasonChoiceFragment.class, args);
}else if(id==R.id.open_in_browser){
UiUtils.launchWebBrowser(getActivity(), account.url);
UiUtils.launchWebBrowser(getActivity(), UiUtils.getSessionAccountURL(accountID, account));
}else if(id==R.id.block_domain){
UiUtils.confirmToggleBlockDomain(getActivity(), accountID, account.getDomain(), relationship.domainBlocking, ()->{
relationship.domainBlocking=!relationship.domainBlocking;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void onError(ErrorResponse error){
args.putParcelable("reportAccount", Parcels.wrap(item.status.account));
Nav.go(item.parentFragment.getActivity(), ReportReasonChoiceFragment.class, args);
}else if(id==R.id.open_in_browser){
UiUtils.launchWebBrowser(activity, item.status.url);
UiUtils.launchWebBrowser(activity, UiUtils.getSessionStatusURL(item.parentFragment.getAccountID(), item.status));
}else if(id==R.id.follow){
if(relationship==null)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ public static boolean isDarkTheme(){
return GlobalUserPreferences.theme==GlobalUserPreferences.ThemePreference.DARK;
}

public static String getSessionAccountURL(String accountID, Account account){
if(accountID==null)
return account.url;
return "https://"+AccountSessionManager.getInstance().getAccount(accountID).domain+"/@"+account.acct;
}

public static String getSessionStatusURL(String accountID, Status status){
if(accountID==null)
return status.url;
return "https://"+AccountSessionManager.getInstance().getAccount(accountID).domain+"/@"+status.account.acct+"/"+status.id;
}

public static void openURL(Context context, String accountID, String url){
Uri uri=Uri.parse(url);
if(accountID!=null && "https".equals(uri.getScheme()) && AccountSessionManager.getInstance().getAccount(accountID).domain.equalsIgnoreCase(uri.getAuthority())){
Expand Down