My 1st Ever Script :) I feel like a Genius Lol

My 1st Ever Script 🙂 I feel like a Genius Lol

How it works: run it from a shortcut,

What it does: You type something in the box tap save and its gets written to a text file on your Internal Storage and any other notes you write will then get appended to that file.

To Do

# Add Text Color Options Somehow.

# Check If Text Is Longer than a certain number of characters before allowing the save button to work, to avoid blank notes being made.

#Make The View Note button open The Note File directly, or make A custom view to display them or whatevers easier for me to do.

Thanks to Lutz Linke​ For recommending a kick ass Code Editor

Lukas Morawietz​ For His Animations Script and Multi Tool Script which I referred to a lot while writing this.

TrianguloY​ For His Case Change Script which inspired me to try writing my own script.

Pierre Hébert​ For Lightning Launcher, Scripting and His Sample Code Showing how to use the Android Framework through Script.

And anybody who trys running this. If you want to improve it / finish it off feel free but it would be great if you could add some noob proof comments in your code so I can learn from it cheers.

WARNING! Don’t save sensitive info (Phone #s, Passwords etc I have no idea how secure this is but I’m guessing not very);

]]>

9 Commentsto My 1st Ever Script :) I feel like a Genius Lol

  1. Anonymous says:

    < ![CDATA[

    /*


    * Quick Note – My 1st Script 🙂


    * Jay M


    * Wednesday 29th October 2014


    * 8:12


    */



    LL.bindClass(“android.content.Context”);


    LL.bindClass(“java.lang.Object”);


    LL.bindClass(“android.app.AlertDialog”);


    LL.bindClass(“android.content.DialogInterface”);


    LL.bindClass(“android.view.View”);


    LL.bindClass(“android.widget.EditText”);


    LL.bindClass(“java.io.File”);


    LL.bindClass(“java.io.FileWriter”);


    LL.bindClass(“android.os.Environment”);



    // Create A Dialog With 3 Buttons, Cancel, Save And View Notes.



    var adb = new AlertDialog.Builder(LL.getContext());


    adb.setCancelable(false);


    adb.setTitle(“Make A Note”);


    var input = EditText(LL.getContext());


    input.setHint(“Start Typing..”);


    input.setLines(4);


    input.setTextColor(Color.WHITE);


    input.setGravity(0);


    adb.setView(input);



    // Cancel Button



    adb.setNegativeButton(“Close”,new DialogInterface.OnClickListener(){


    onClick:function(dialog,id){


    dialog.cancel();


    }


    });



    // View Notes Button



    adb.setNeutralButton(“View Notes”,new DialogInterface.OnClickListener(){


    onClick:function(dialog, id){


    dialog.cancel();


    Android.makeNewToast(“Here You Can View Your Notes (Coming Soon – Hopefully)”, false).show();


    }


    });



    // Save Button



    adb.setPositiveButton(“Save”,new DialogInterface.OnClickListener(){


    onClick:function(dialog, id){


    var note;


    note = input.getText().toString().trim();



    // Create a new directory



    var createDirectory = new File(Environment.getExternalStorageDirectory()


    +File.separator+


    “QuickNote”);


    createDirectory.mkdirs();



    // create a new file



    var createFile = new File(Environment.getExternalStorageDirectory()


    +File.separator+


    “QuickNote”


    +File.separator+


    “MyNotes.txt”);


    createFile.createNewFile();



    // write to the file



    var createFileWriter = new FileWriter(createFile, true);


    createFileWriter.write(note+”\n”+”#”+”\n”); // # Is To Be Used As A Splitter In Tasker


    createFileWriter.flush();


    createFileWriter.close();


    Android.makeNewToast(“Saved”, true).show();


    }


    });



    // Show Dialog



    var alert = adb.create();


    alert.show();

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Its probably a mess but theres my code. enjoy.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Not a mess. I would structure it a bit different, but thats dev’s choice. I also wouldn’t call something adb, because adb is the android debug bridge to me.



    Anyway, what you need is a input-/outputstream to a file (i have used both in my multitool script. however it’s maybe a bit long to search trough. Tip: its used for import/export scripts).

    ]]>

  4. Anonymous says:

    < ![CDATA[

    How would you structure it? Any tips to help me learns much appreciated. If you mean with spacing between blocks of code it did have loads but i removed them all before i pasted it here. Yeah I no adb is a bad word choice but it was just easier for me to remember and I don’t have the skills to write anything that uses ADB anyway 🙂



    I’ll have a look at that script later cheers.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Spacing is one part. I consider it to be useful for structuring. But my structure is something I wouldn’t teach anyone, because I think it’s your personal style. It doesn’t give any performance improvements, it’s just your footprint, and it’s good if it’s different to mine or anyone else’s.


    It’s always better to tell someone what to use but not how. Otherwise he’ll have the same footprint as me.


    Getting philosophical now, I better stop here 😄.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    I have the multi tool script up and I’m making progress, but very slowly, I have a directory created and a text file written to it so I’m getting somewhere 🙂 im glad you put loads of comments in your code makes it easier for me to read even though I don’t understand a lot of it. Lol

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Updated its now possible to write to a text file and any new notes get added to the bottom of the last note and are split with a # character. So its easier to Use The Information in the file in Tasker.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I did about 2 month ago some kind of APIs to be able to use basic things (like writing to a file, showing an alertdialog (and a pregress dialog, infodialog, etc)) in a few lines, with default (and customizable) behavior for everything… Maybe if you’re interested I can work again on it!

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Sounds cool.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *