mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add support for market:// urls
This commit is contained in:
parent
a2b195aff8
commit
027514c3e6
6 changed files with 60 additions and 2 deletions
|
@ -20,6 +20,7 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.servoview.ServoView;
|
||||
import org.mozilla.servoview.Servo;
|
||||
|
@ -162,6 +163,19 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
mCanGoBack = canGoBack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onAllowNavigation(String url) {
|
||||
if (url.startsWith("market://")) {
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
Log.e("onAllowNavigation", e.toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRedrawing(boolean redrawing) {
|
||||
if (redrawing) {
|
||||
mIdleText.setText("LOOP");
|
||||
|
|
|
@ -169,6 +169,8 @@ public class Servo {
|
|||
}
|
||||
|
||||
public interface Client {
|
||||
boolean onAllowNavigation(String url);
|
||||
|
||||
void onLoadStarted();
|
||||
|
||||
void onLoadEnded();
|
||||
|
@ -234,6 +236,10 @@ public class Servo {
|
|||
mRunCallback.inGLThread(() -> mGfxCb.animationStateChanged(animating));
|
||||
}
|
||||
|
||||
public boolean onAllowNavigation(String url) {
|
||||
return mClient.onAllowNavigation(url);
|
||||
}
|
||||
|
||||
public void onLoadStarted() {
|
||||
mRunCallback.inUIThread(() -> mClient.onLoadStarted());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue