openUri: handle scheme-less urls
This commit is contained in:
parent
895e87c2a3
commit
48d2b51a1a
|
@ -319,10 +319,20 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
// uses chrome custom tabs when available
|
// uses chrome custom tabs when available
|
||||||
public void openUri(final Uri uri) {
|
public void openUri(Uri uri) {
|
||||||
boolean enableCustomTabs = m_prefs.getBoolean("enable_custom_tabs", true);
|
boolean enableCustomTabs = m_prefs.getBoolean("enable_custom_tabs", true);
|
||||||
final boolean askEveryTime = m_prefs.getBoolean("custom_tabs_ask_always", true);
|
final boolean askEveryTime = m_prefs.getBoolean("custom_tabs_ask_always", true);
|
||||||
|
|
||||||
|
if (uri.getScheme() == null) {
|
||||||
|
try {
|
||||||
|
uri = Uri.parse("https:" + uri.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Uri finalUri = uri;
|
||||||
|
|
||||||
if (enableCustomTabs && m_customTabClient != null) {
|
if (enableCustomTabs && m_customTabClient != null) {
|
||||||
|
|
||||||
if (askEveryTime) {
|
if (askEveryTime) {
|
||||||
|
@ -345,7 +355,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
openUriWithCustomTab(uri);
|
openUriWithCustomTab(finalUri);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -361,7 +371,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
Intent intent = new Intent(Intent.ACTION_VIEW, finalUri);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user