Move the twitter special-case URL handling to java
This commit is contained in:
parent
5a55fd5fd3
commit
2c9787643d
2 changed files with 25 additions and 25 deletions
|
@ -846,11 +846,7 @@ UI::EventReturn CreditsScreen::OnSupport(UI::EventParams &e) {
|
|||
}
|
||||
|
||||
UI::EventReturn CreditsScreen::OnTwitter(UI::EventParams &e) {
|
||||
#ifdef __ANDROID__
|
||||
System_SendMessage("showTwitter", "PPSSPP_emu");
|
||||
#else
|
||||
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://twitter.com/#!/PPSSPP_emu");
|
||||
#endif
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1319,14 +1319,31 @@ public abstract class NativeActivity extends Activity {
|
|||
public boolean processCommand(String command, String params) {
|
||||
SurfaceView surfView = javaGL ? mGLSurfaceView : mSurfaceView;
|
||||
if (command.equals("launchBrowser")) {
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params));
|
||||
startActivity(i);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// No browser?
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
// Special case for twitter
|
||||
if (params.startsWith("https://twitter.com/#!/")) {
|
||||
try {
|
||||
String twitter_user_name = params.replaceFirst("https://twitter.com/#!/", "");
|
||||
try {
|
||||
Log.i(TAG, "Launching twitter directly: " + twitter_user_name);
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + twitter_user_name)));
|
||||
} catch (Exception e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params));
|
||||
startActivity(i);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// No browser?
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (command.equals("launchEmail")) {
|
||||
try {
|
||||
|
@ -1410,19 +1427,6 @@ public abstract class NativeActivity extends Activity {
|
|||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
} else if (command.equals("showTwitter")) {
|
||||
try {
|
||||
String twitter_user_name = params;
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + twitter_user_name)));
|
||||
} catch (Exception e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
} else if (command.equals("launchMarket")) {
|
||||
// Don't need this, can just use launchBrowser with a market:
|
||||
// http://stackoverflow.com/questions/3442366/android-link-to-market-from-inside-another-app
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue