use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class I2PHelpers method installI2PHelper.
public static boolean installI2PHelper(String extra_text, String remember_id, final boolean[] install_outcome, final Runnable callback) {
String decline_key = remember_id;
if (decline_key == null) {
decline_key = extra_text;
}
if (decline_key == null) {
decline_key = "generic";
}
synchronized (i2p_install_lock) {
Long decline = declines.get(decline_key);
if (decline != null && SystemTime.getMonotonousTime() - decline < 60 * 1000) {
return (false);
}
if (i2p_installing) {
Debug.out("I2P Helper already installing");
return (false);
}
i2p_installing = true;
}
boolean installing = false;
boolean declined = false;
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
Debug.out("UIFunctions unavailable - can't install plugin");
return (false);
}
String title = MessageText.getString("azneti2phelper.install");
String text = "";
if (extra_text != null) {
text = extra_text + "\n\n";
}
text += MessageText.getString("azneti2phelper.install.text");
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
if (remember_id != null) {
prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
}
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean install = prompter.waitUntilClosed() == 0;
if (install) {
installing = true;
uif.installPlugin("azneti2phelper", "azneti2phelper.install", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
try {
if (callback != null) {
if (result instanceof Boolean) {
install_outcome[0] = (Boolean) result;
}
callback.run();
}
} finally {
synchronized (i2p_install_lock) {
i2p_installing = false;
}
}
}
});
} else {
declined = true;
Debug.out("I2P Helper install declined (either user reply or auto-remembered)");
}
return (install);
} finally {
synchronized (i2p_install_lock) {
if (!installing) {
i2p_installing = false;
}
if (declined) {
declines.put(decline_key, SystemTime.getMonotonousTime());
}
}
}
}
Aggregations