public class XWalkDialogManager
extends java.lang.Object
By XWalkDialogManager, you can customize what the dialog looks like when
initializing Crosswalk Project runtime. Please note that you can only specify how the dialog to
be displayed but cann't specify how it reacts.
Here is the sample code when using XWalkActivity:
import android.app.AlertDialog;
import android.os.Bundle;
import org.xwalk.core.XWalkActivity;
import org.xwalk.core.XWalkDialogManager;
import org.xwalk.core.XWalkView;
public class MainActivity extends XWalkActivity {
private XWalkView mXWalkView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mXWalkView = (XWalkView) findViewById(R.id.xwalkview);
// Get default dialog and modifiy it as needed, or set a completely customized dialog.
XWalkDialogManager dialogManager = getDialogManager();
AlertDialog dialog = dialogManager.getAlertDialog(XWalkDialogManager.DIALOG_NOT_FOUND);
dialog.setTitle("TestTitle");
dialog.setMessage("TestMessage");
}
@Override
public void onXWalkReady() {
mXWalkView.load("https://crosswalk-project.org/", null);
}
}
And when using XWalkUpdater:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import org.xwalk.core.XWalkDialogManager;
import org.xwalk.core.XWalkInitializer;
import org.xwalk.core.XWalkUpdater;
import org.xwalk.core.XWalkView;
public class MainActivity extends Activity implements
XWalkInitializer.XWalkInitListener,
XWalkUpdater.XWalkUpdateListener {
private XWalkInitializer mXWalkInitializer;
private XWalkUpdater mXWalkUpdater;
private XWalkView mXWalkView;
private XWalkDialogManager mDialogManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mXWalkInitializer = new XWalkInitializer(this, this);
mXWalkInitializer.initAsync();
setContentView(R.layout.activity_main);
mXWalkView = (XWalkView) findViewById(R.id.xwalkview);
}
@Override
protected void onResume() {
super.onResume();
mXWalkInitializer.initAsync();
}
@Override
public void onXWalkInitStarted() {
}
@Override
public void onXWalkInitCancelled() {
finish();
}
@Override
public void onXWalkInitFailed() {
if (mXWalkUpdater == null) {
// Get default dialog and modifiy it as needed, or set a completely customized dialog.
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setIcon(android.R.drawable.ic_dialog_alert);
dialog.setTitle("TextTitle");
dialog.setMessage("TextMessage");
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Download", (OnClickListener) null);
mDialogManager = new XWalkDialogManager(this);
mDialogManager.setAlertDialog(XWalkDialogManager.DIALOG_NOT_FOUND, dialog);
mXWalkUpdater = new XWalkUpdater(this, this, mDialogManager);
}
mXWalkUpdater.updateXWalkRuntime();
}
@Override
public void onXWalkInitCompleted() {
mXWalkView.load("https://crosswalk-project.org/", null);
}
@Override
public void onXWalkUpdateCancelled() {
finish();
}
}
| Modifier and Type | Field and Description |
|---|---|
static int |
DIALOG_ARCHITECTURE_MISMATCH
Dialog Type: AlertDialog
Dialog Information: Mismatch of CPU Architecture for Crosswalk Project Runtime. Positive Button(Mandatory): download Crosswalk Project runtime Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_DECOMPRESSING
Dialog Type: ProgressDialog
Dialog Information: Decompressing Crosswalk Project runtime. Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() |
static int |
DIALOG_DOWNLOAD_ERROR
Dialog Type: AlertDialog
Dialog Information: Failed to download Crosswalk Project runtime. Positive Button(Mandatory): re-download Crosswalk Project runtime Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_DOWNLOADING
Dialog Type: ProgressDialog
Dialog Information: Downloading Crosswalk Project runtime. Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_NEWER_VERSION
Dialog Type: AlertDialog
Dialog Information: The version of Crosswalk Project runtime is newer than the application. Negative Button(Mandatory): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_NOT_FOUND
Dialog Type: AlertDialog
Dialog Information: The Crosswalk Project runtime is not found. Positive Button(Mandatory): download Crosswalk Project runtime Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_OLDER_VERSION
Dialog Type: AlertDialog
Dialog Information: The version of Crosswalk Project runtime is older than the application. Positive Button(Mandatory): download Crosswalk Project runtime Negative Button(Optional): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_SELECT_STORE
Dialog Type: AlertDialog
Dialog Information: Select stores that support Crosswalk Project runtime. Positive Button(Mandatory): go to the store's page |
static int |
DIALOG_SIGNATURE_CHECK_ERROR
Dialog Type: AlertDialog
Dialog Information: The Crosswalk signature verification failed. Negative Button(Mandatory): invoke XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled() |
static int |
DIALOG_UNSUPPORTED_STORE
Dialog Type: AlertDialog
Dialog Information: The stores on the device don't support Crosswalk Project. |
| Constructor and Description |
|---|
XWalkDialogManager(android.content.Context context)
Create XWalkDialogManager for
XWalkUpdater or XWalkActivity. |
| Modifier and Type | Method and Description |
|---|---|
android.app.AlertDialog |
getAlertDialog(int id)
Get alert dialog for each situation.
|
android.app.ProgressDialog |
getProgressDialog(int id)
Get progress dialog for each situation.
|
void |
setAlertDialog(int id,
android.app.AlertDialog dialog)
Set up alert dialog for each situation.
|
void |
setProgressDialog(int id,
android.app.ProgressDialog dialog)
Set up progress dialog for each situation.
|
public static final int DIALOG_NOT_FOUND
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_OLDER_VERSION
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_NEWER_VERSION
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_ARCHITECTURE_MISMATCH
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_SIGNATURE_CHECK_ERROR
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_DOWNLOAD_ERROR
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_SELECT_STORE
public static final int DIALOG_UNSUPPORTED_STORE
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public static final int DIALOG_DECOMPRESSING
XWalkActivity.onXWalkFailed()public static final int DIALOG_DOWNLOADING
XWalkActivity.onXWalkFailed() /
XWalkUpdater.XWalkUpdateListener.onXWalkUpdateCancelled()public XWalkDialogManager(android.content.Context context)
XWalkUpdater or XWalkActivity.context - The context that is used by XWalkUpdater or XWalkActivity
itselfpublic void setAlertDialog(int id,
android.app.AlertDialog dialog)
id - the dialog IDdialog - the customized dialogpublic void setProgressDialog(int id,
android.app.ProgressDialog dialog)
id - the dialog IDdialog - the customized dialogpublic android.app.AlertDialog getAlertDialog(int id)
id - the dialog IDpublic android.app.ProgressDialog getProgressDialog(int id)
id - the dialog ID