Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

Latest commit

 

History

History
87 lines (57 loc) · 3.41 KB

README.md

File metadata and controls

87 lines (57 loc) · 3.41 KB

os-thm Logo

os-thm-sketchware

os-thm implementation for sketchware.

What is os-thm?

os-thm is a simple library used to manage themes that can be applied globaly.

Original GitHub Repository

NOTE: THIS REPOSITORY IS DEPRECATED, USE OS-THM-SKETCHWARE SKETCHUB PROJECT INSTEAD.

Implementing os-thm

There are 2 ways of implementing os-thm to your sketchware app:

  1. Injecting the osthm library
  2. Using ASD

Injecting the osthm library

To implement os-thm to your sketchware app,

  • Add your package in the first line of osthm.java

    Example:

    package my.newproject23.yay;
    
    // osthm.java contents //
  • Grant READ and WRITE External storage permission.

  • Inject the osthm.java file, and ignore the os-thm-sketchware-asd.java

And you're all set!

Using ASD

  • Create a new activity named osthm
  • Grant READ and WRITE External storage permission.
  • Add an ASD block in onCreate ontop of the File block you placed
  • Copy and paste the os-thm-sketchware-asd.java file into the ASD, and ignore the osthm.java

To grant storage permission, you can use external tools, or write something in a random temporal file and then delete that file.

Note: We suggest you to check if the user denied the dialog because if the permission is denied, os-thm will not work.

And you're all set!

Using os-thm

Here is an example code to apply theme to your sketchware app:

Note: For the people using ASD to implement os-thm, replace the osthm word into OsthmActivity, Because sketchware is concating the word Activity after the given text, and uppercasing the first letter.

// Put this in onStart

// Getting current applied theme
osthm.Theme currentTheme = osthm.getCurrentTheme();

// Applying color to the ActionBar
getSupportActionBar().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(currentTheme.colorPrimary));

// Applying color to the StatusBar
// Check if the android version is 5+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
    android.view.Window window = getWindow();
    window.addFlags(android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(currentTheme.colorPrimaryDark);
}

// Applying color to the FAB
_fab.setBackgroundTintList(android.graphics.drawable.ColorDrawable.valueOf(currentTheme.colorAccent));

// Applying ripple color to the FAB
_fab.setRippleColor(currentTheme.colorControlHighlight);

// etc.

Don't understand what are the colors means? Click Here

Still don't understand? Download the os-thm Theme Manager, and try playing around with the Theme Editor to determine which colors point to which.

Have questions? Join our discord server.

Documentation written by Iyxan23.

(c) Copyright 2020 ThatCakeID