mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Add hidden option to execute commands (type .<command> into the name field).
This commit is contained in:
@@ -196,6 +196,17 @@ JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrMailboxGetInfo(JNIEnv
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrMailboxExecute(JNIEnv *env, jclass c, jlong hMailbox, jstring cmd)
|
||||
{
|
||||
CHAR_REF(cmd);
|
||||
char* temp = mrmailbox_execute((mrmailbox_t*)hMailbox, cmdPtr);
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
free(temp);
|
||||
CHAR_UNREF(cmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* MrChatlist
|
||||
******************************************************************************/
|
||||
|
||||
@@ -101,6 +101,7 @@ public class MrMailbox {
|
||||
public native static String MrMailboxGetConfig (long hMailbox, String key, String def); // def may be NULL, returns empty string as NULL
|
||||
|
||||
public native static String MrMailboxGetInfo (long hMailbox);
|
||||
public native static String MrMailboxExecute (long hMailbox, String cmd);
|
||||
|
||||
// MrChatlist objects
|
||||
public native static void MrChatlistUnref (long hChatlist);
|
||||
|
||||
@@ -118,7 +118,6 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
}
|
||||
} else if (id == done_button) {
|
||||
saveData();
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -153,10 +152,30 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
private void saveData() {
|
||||
if( displaynameCell != null ) {
|
||||
String v = displaynameCell.getValue().trim();
|
||||
|
||||
if( v.charAt(0)=='.') {
|
||||
String cmd = v.substring(1);
|
||||
String execute_result = MrMailbox.MrMailboxExecute(MrMailbox.hMailbox, cmd);
|
||||
if( execute_result!=null && !execute_result.isEmpty()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(execute_result);
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
;
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MrMailbox.MrMailboxSetConfig(MrMailbox.hMailbox, "displayname", v.isEmpty() ? null : v);
|
||||
}
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
|
||||
finishFragment();
|
||||
}
|
||||
|
||||
private boolean isModified()
|
||||
|
||||
Reference in New Issue
Block a user