Search in sources :

Example 1 with ScriptOperations

use of com.stardust.scriptdroid.ui.common.ScriptOperations in project Auto.js by hyb1996.

the class ImportIntentActivity method handleIntent.

private void handleIntent(Intent intent) throws FileNotFoundException {
    Uri uri = intent.getData();
    if (uri != null && "content".equals(uri.getScheme())) {
        String ext = PFiles.getExtension(uri.getScheme());
        if (TextUtils.isEmpty(ext)) {
            ext = "js";
        }
        InputStream stream = getContentResolver().openInputStream(uri);
        new ScriptOperations(this, null).importFile("", stream, ext).subscribe(s -> finish());
    } else {
        final String path = intent.getData().getPath();
        if (!TextUtils.isEmpty(path)) {
            new ScriptOperations(this, null).importFile(path).subscribe(s -> finish());
        }
    }
}
Also used : InputStream(java.io.InputStream) ScriptOperations(com.stardust.scriptdroid.ui.common.ScriptOperations) Uri(android.net.Uri)

Example 2 with ScriptOperations

use of com.stardust.scriptdroid.ui.common.ScriptOperations in project Auto.js by hyb1996.

the class ScriptListView method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.rename:
            new ScriptOperations(getContext(), this).rename(mSelectedScriptFile).subscribe();
            break;
        case R.id.delete:
            new ScriptOperations(getContext(), this).delete(mSelectedScriptFile);
            break;
        case R.id.run_repeatedly:
            new ScriptLoopDialog(getContext(), mSelectedScriptFile).show();
            notifyOperated();
            break;
        case R.id.create_shortcut:
            new ScriptOperations(getContext(), this).createShortcut(mSelectedScriptFile);
            break;
        case R.id.open_by_other_apps:
            Scripts.openByOtherApps(mSelectedScriptFile);
            notifyOperated();
            break;
        case R.id.send:
            Scripts.send(mSelectedScriptFile);
            notifyOperated();
            break;
        case R.id.timed_task:
            new ScriptOperations(getContext(), this).timedTask(mSelectedScriptFile);
            notifyOperated();
            break;
        case R.id.action_build_apk:
            BuildActivity_.intent(getContext()).extra(BuildActivity.EXTRA_SOURCE_FILE, mSelectedScriptFile.getPath()).start();
            notifyOperated();
            break;
        case R.id.action_sort_by_date:
            sort(ScriptList.SORT_TYPE_DATE, mDirSortMenuShowing);
            break;
        case R.id.action_sort_by_type:
            sort(ScriptList.SORT_TYPE_TYPE, mDirSortMenuShowing);
            break;
        case R.id.action_sort_by_name:
            sort(ScriptList.SORT_TYPE_NAME, mDirSortMenuShowing);
            break;
        case R.id.action_sort_by_size:
            sort(ScriptList.SORT_TYPE_SIZE, mDirSortMenuShowing);
            break;
        default:
            return false;
    }
    return true;
}
Also used : ScriptLoopDialog(com.stardust.scriptdroid.ui.common.ScriptLoopDialog) ScriptOperations(com.stardust.scriptdroid.ui.common.ScriptOperations)

Aggregations

ScriptOperations (com.stardust.scriptdroid.ui.common.ScriptOperations)2 Uri (android.net.Uri)1 ScriptLoopDialog (com.stardust.scriptdroid.ui.common.ScriptLoopDialog)1 InputStream (java.io.InputStream)1