{"id":19224063,"url":"https://github.com/simbiose/sau","last_synced_at":"2025-04-20T23:31:59.728Z","repository":{"id":11376909,"uuid":"13815579","full_name":"simbiose/SAU","owner":"simbiose","description":"Simbio.se Android Utils","archived":false,"fork":false,"pushed_at":"2014-09-13T17:39:39.000Z","size":3710,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T06:51:20.191Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simbiose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-23T21:37:27.000Z","updated_at":"2019-08-13T15:28:47.000Z","dependencies_parsed_at":"2022-08-29T20:21:21.032Z","dependency_job_id":null,"html_url":"https://github.com/simbiose/SAU","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbiose%2FSAU","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbiose%2FSAU/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbiose%2FSAU/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbiose%2FSAU/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simbiose","download_url":"https://codeload.github.com/simbiose/SAU/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249977433,"owners_count":21354859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T15:10:27.447Z","updated_at":"2025-04-20T23:31:59.343Z","avatar_url":"https://github.com/simbiose.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Simbiose Android Utils (SAU)\n----------------------------\n\nThis a collection of utilities for android development, like Log Manager, Shared Preferences Management, SQLite management, Easy share, Key Key Map, Copy Assests easy, open documents with correct intent, decrypt \u0026 encrypt strings, Remote Image View and a lot of others littles things.\n\n##License\nGNU Lesser General Public License at version 3\n\n##Developer\n\n- Ademar Alves de Oliveira \u003cademar111190@gmail.com\u003e\n\n##About Simbiose\n\n- \u003chttp://simbio.se\u003e\n\n##Contribute\n\nFell free to fork, modify and send a pull request.\n\n##How to\n\nClone with recursive tag the sau repository and import the /android project named SAU to eclipse and add it a android library on your android application and now you're ready to use it.\nYou also can see the documentation on /doc/index.html\n\n##Get It\n- BitBucket \u003chttps://bitbucket.org/simbiose/sau/overview\u003e\n- GitHub \u003chttps://github.com/simbiose/SAU\u003e\n\n##Examples\n\n###Log\n\n    SimbiLog.print(\"Hello World\"); //Print a normal String\n    SimbiLog.print(param1, foo1, foo2); //You can print a lot of objects\n    SimbiLog.printException(new Exception(\"A mock exception\")); //Print Exceptions\n    SimbiLog.log(this, param1, foo1, null, foo2); //You can log your methods\n    SimbiLog.here(); //Easy \"here\" print\n\n###Json\n\n    Foo foo = (Foo) JsonUtils.fromJsonOrNull(\"{}\", Foo.class); //You can load objects from json strings powered by GSON core\n    JsonUtils.toJson(foo); //You can make json Strings from objects easily\n\n###Shared Preferences\n\n    PreferencesHelper myPrefs = new PreferencesHelper(getContext());\n    myPrefs.put(\"Any Key\", \"Any Value\"); //You can easily save data on shared preferences\n    myPrefs.put(\"Any Key\", new Foo()); //You can storage objects too\n    myPrefs.getString(\"Any Key\", \"Default\"); //Read is easy too\n    myPrefs.getStringOrEmpty(keyString); //if you do not want a default values\n    myPrefs.getObjectOrNull(keyObject, Foo.class); //Read objects\n\n###Key Key Map\n\n    KeyKeyMap keyKeyMap = new KeyKeyMap(); //Know the KeyKey Map\n    \n    String key1 = \"Key 1\"; //You can use any key, a String\n\tint key2 = 2; //any number\n\tFoo key3 = new Foo(); //or Objects too\n\t\n\tkeyKeyMap.put(key1, key2); //Now you mapped key1 \u003c-\u003e key2\n\tkeyKeyMap.get(key1); //returns the key2\n\tkeyKeyMap.get(key2); //returns the key1\n\tkeyKeyMap.get(key3); //returns null because you not mapped the key3\n\t\n\tkeyKeyMap.put(key1, key3); //Now you mapped key1 \u003c-\u003e key3 and key1 \u003c- key2\n\tkeyKeyMap.get(key1); //returns the key3\n\tkeyKeyMap.get(key3); //returns the key1\n\tkeyKeyMap.get(key2); //returns the key1 too\n\tkeyKeyMap.get(null); //returns null\n\t\n\tkeyKeyMap.put(null, key3); //Now you mapped null \u003c-\u003e key3, key1 -\u003e key3 and key1 \u003c- key2\n\tkeyKeyMap.get(null); //returns key3\n\tkeyKeyMap.get(key3); //returns null\n    \n###Simple Encryption and Decryption of Strings\n\n    Encryption encryption = new Encryption(); //The encryptor\n    String key = \"Some Key\"; //The secret key to encrypt\n\tString data = \"top secret string\"; //The text to be encrypted\n\tString encrypted = encryption.encrypt(key, data); //Create the encrypted String\n\tSimbiLog.print(encrypted); //Just to you see\n\tString decrypted = encryption.decrypt(key, encrypted); //Back to original String\n\tSimbiLog.print(decrypted); //Just to you see again\n\n###Range\n\n    import static simbio.se.sau.iterable.Range.range; //It is like the range of python\n    for (int i : range(3)) //passes through the numbers 0, 1 and 2\n\t\tSimbiLog.print(\"range example a\", i);\n\tfor (int i : range(-4)) //passes through the numbers 0, -1, -2 and -3\n\t\tSimbiLog.print(\"range example b\", i);\n\tfor (int i : range(4, 7)) //passes through the numbers 4, 5 and 6\n\t\tSimbiLog.print(\"range example c\", i);\n\tfor (int i : range(-5, -30, 10)) //passes through the numbers -5, -15 and -25\n\t\tSimbiLog.print(\"range example d\", i);\n\n###Range Seek Bar\n####See the sample running to a better understanding of what the Range Seek Bar is\n\n    //put on xml file\n    \u003csimbio.se.sau.view.RangeSeekBar\n        android:id=\"@+id/range_seek_bar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentLeft=\"true\"\n        android:layout_below=\"@+id/button_resize_my_width\"\n        android:layout_marginTop=\"@dimen/activity_vertical_margin\"/\u003e\n    \n    RangeSeekBar\u003cInteger\u003e rangeSeekBar = (RangeSeekBar\u003cInteger\u003e) findViewById(R.id.range_seek_bar); //load from xml\n\trangeSeekBar.init( //init the params\n\t    0, //min value\n\t    100, //max value\n\t    BitmapFactory.decodeResource(getResources(), R.drawable.scrubber_control_normal_holo), //image to be the control BitmapFactory.decodeResource(getResources(), R.drawable.scrubber_control_pressed_holo), //image to be the controll pressed\n\t    this); //set listener and ends\n\trangeSeekBar.setNormalizedMinValue(0.3f); //default min value\n\trangeSeekBar.setNormalizedMaxValue(0.7f); //default max value\n\trangeSeekBar.setNotifyWhileDragging(true); //call listener when drawing\n\trangeSeekBar.setLineColor(Color.rgb(0, 153, 0)); //line color\n\n####it will show something like that:\n![Range Seek Bar][1]\n\n###Clipboard Text View\n####A TextView that when is clicked copy your text to clipboard\n\n    //put on xml file\n    \u003csimbio.se.sau.view.ClipboardTextView\n        android:id=\"@+id/clipboard_text_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentLeft=\"true\"\n        android:layout_below=\"@+id/button_open_sql_example_activity\"\n        android:layout_marginTop=\"@dimen/activity_vertical_margin\"\n        android:text=\"@string/copy_me\"\n        android:textAppearance=\"?android:attr/textAppearanceLarge\" /\u003e\n    \n    ClipboardTextView myCTV = (ClipboardTextView) findViewById(R.id.clipboard_text_view); //load from xml\n    myCTV.setCopyListener(new CopiedInterface(){ //set interface\n        @Override\n\t    public void textHasCopied(ClipboardTextView clipboardTextView, String stringCopied, boolean hasSucces) {\n\t\t    SimbiLog.print(stringCopied, hasSucces); //show the value\n\t    }\n    });\n\n###Remote Image View\n####A remote image view tha make cache of downloaded image\n\n    //Do not need java code\n    \u003csimbio.se.sau.view.RemoteImageView\n        xmlns:sau=\"http://schemas.android.com/apk/res-auto\"\n        android:id=\"@+id/remote_imageview_working\"\n        android:layout_width=\"@dimen/zero\"\n        android:layout_height=\"match_parent\"\n        android:layout_weight=\"1\"\n        sau:defaultImage=\"@drawable/remote_image_default\"\n        sau:errorImage=\"@drawable/remote_image_fail\"\n        sau:imageUrl=\"https://any.png\" /\u003e\n    \n    //But you can use java code too\n    RemoteImageView remoteImageView = new RemoteImageView(context); //create a view or load from xml if prefers\n    remoteImageView.setImageUrl(\"https://any.png\"); //any image url\n    remoteImageView.setErrorImage(R.drawable.remote_image_fail); //a local image resource to be used when download fails\n\tremoteImageView.setDefaultImage(R.drawable.remote_image_default); //a local image resource to be used when download is not ended\n\tremoteImageView.deleteCachedImage(); //Maybe you wants delete the cached image\n\tremoteImageView.start(); //Starts download proccess\n\n###Share\n\n    SimbiShare.shareWithChooser(this, R.string.hello_world, R.string.app_name, R.string.action_share); //an easy way to share with android native choose method\n    SimbiShare.shareWithChooser(this, \"content\", \"subject\", \"title\"); //you can use Strings too\n\n###Toast maker\n\n    ToastMaker.toast(getApplicationContext(), \"Some Text\"); //show toasts easily\n    ToastMaker.toast(getApplicationContext(), R.string.hello_world); //use strings xml resources too\n    ToastMaker.toast(getApplicationContext()); // Toast just a \"here\"\n\n###Resize Animation\n\n    ResizeAnimation resizeAnimation = new ResizeAnimation(view, toHeight, toWidth); //Resive the view to new height and width\n    resizeAnimation.setDuration(resizeDuration); //set the duration of animation\n\tresizeAnimation.setAnimationListener(this); //set the listener if you want\n\tview.startAnimation(resizeAnimation); //start it\n\n###SQLite\n####powered by [Shiva][2]\n\n    //To use SQLite easily extends our class DatabaseHelper like bellow\n    public class SqlManager extends DatabaseHelper {\n\t    public SqlManager(Context context, DatabaseDelegate delegate) {\n\t\t    super(context, delegate, \"yourDatabase.sqlite\", 1);\n\t    }\n\t    @Override\n\t    protected List\u003cClass\u003c?\u003e\u003e getModelsToBeCreatedOnDatabase() {\n\t        //create this list to add the classes that you want save on database\n\t\t    List\u003cClass\u003c?\u003e\u003e clazzez = new ArrayList\u003cClass\u003c?\u003e\u003e();\n\t\t    //add any classes that you want\n\t\t    clazzez.add(SqlFooModel.class);\n\t\t    return clazzez;\n\t    }\n\t    @Override\n\t    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n\t        //normal onUpgrade of android sqlite\n\t    }\n    }\n    \n    //before we use, we need create a delegate. You can implements DatabaseDelegate interface on your own class too\n    DatabaseDelegate delegate = new DatabaseDelegate() {\n\t\t@Override\n\t\tpublic void onRequestSuccess(DatabaseHelper databaseHelper, int requestId, Object object) {\n\t\t    //do anything that you want, the object is the return os a select for example\n\t\t}\n\t\t@Override\n\t\tpublic void onRequestFail(DatabaseHelper databaseHelper, int requestId, Exception exception) {\n\t\t    //if fails\n\t\t}\n\t};\n\t\n\t//now we can use our sqlite easily\n\tnew SqlManager(getApplicationContext(), this).insert(new SqlFooModel(), REQUEST_ADD); //insert\n\tnew SqlManager(getApplicationContext(), delegate).select(SqlFooModel.class, REQUEST_LOAD); //select\n    new SqlManager(getApplicationContext(), this).delete(object, REQUEST_DELETE); //delete\n    new SqlManager(getApplicationContext(), this).clearTable(REQUEST_DELETE_ALL, SqlFooModel.class); //clear table\n\n###Open Documents\n\n    new ActivityUtils(this).openDocumentWithCorrectActivity(\"/path/to/text.txt\"); //open the txt file with correct intent\n    new ActivityUtils(this).openDocumentWithCorrectActivity(\"/path/to/doc.ods\"); //works to any file format since the android device has the correctly app to open this file format\n    new ActivityUtils(this).openDocumentWithCorrectActivity(\"/path/to/music.ogg\"); //just more one example\n\n###Array Adapter\n####to be used on list views or fragments adapters\n\n    //first extends the class AbstractAdapter and send the type of object used by your adapter\n    public class MyAdapter extends AbstractAdapter\u003cFooModel\u003e {\n        public interface MyAdapterDelegate extends IAbstractAdapter\u003cFooModel\u003e {\n\t    }\n        public SqlListViewAdapter(Context context, MyAdapterDelegate delegate) {\n\t\t    super(context, delegate, R.layout.your_xml_layout);\n\t    }\n    }\n    \n    //it's all but probably you want edit your views so you can override getView method like:\n    @Override\n\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\tView rootView = super.getView(position, convertView, parent);\n\t\t// do anything with your rootView, to get views inside use rootView.findViewById(id);\n    \treturn rootView;\n\t}\n\n###Copy files from assest to an usable folder\n\n    ActivityUtils activityUtils = new ActivityUtils(this);\n    // we need files on sdcard, so we go copy from assests to a folder called sauSample on sdcard\n    path = Environment.getExternalStorageDirectory().getAbsolutePath() + \"/sauSample/\";\n    try {\n        activityUtils.copyAssetsFilesToFolder(path);\n    } catch (Exception e) {\n        ToastMaker.toast(getApplicationContext(), e);\n    }\n\n###Get primary user email\n\n    //you need the follow permission:\n    \u003cuses-permission android:name=\"android.permission.GET_ACCOUNTS\" /\u003e\n    \n    //and you need the follow code\n    DeviceInformationsManager dim = new DeviceInformationsManager(context)\n    String email = dim.getPrimaryUserEmailOrNull()\n\n###Null or Empty validation\n\n    NullOrEmpty.verify(\"\"); //returns true\n    NullOrEmpty.verify(\"not empty\"); //returns false\n    NullOrEmpty.verify(null); //returns true\n    ArrayList\u003cObject\u003e list = null;\n    NullOrEmpty.verify(list); //returns true\n    list = new ArrayList\u003cObject\u003e();\n    NullOrEmpty.verify(list); //returns true\n    list.add(new Foo());\n    NullOrEmpty.verify(list); //returns false\n\n####SAU have a lot of more things, see the examples :D\n\n\n  [1]: https://raw2.github.com/simbiose/SAU/master/images/rangeSeekBar.png\n  [2]: https://github.com/simbiose/Shiva\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimbiose%2Fsau","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimbiose%2Fsau","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimbiose%2Fsau/lists"}