Skip to content

AndroidCalculator/ThemeEngine

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThemeEngine

A library for grabbing images, fonts, and colors from another apk.

Where to Download

dependencies {
  implementation 'com.xlythe:theme-engine:1.0.7'
}

How to Use

The main app must make the following call before setContentView. This is only needed in the very first Activity.

Theme.setPackageName(MY_THEME_PACKAGE_NAME);

Then you can either automatically grab the images and colors via ThemedView in xml or programmaically set them in java.

<com.xlythe.engine.theme.ThemedTextView xmlns:theme="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    theme:textColor="@color/text_color" />

or

TextView tv = new TextView(this);
tv.setTextColor(Theme.getColor(this, R.color.text_color));

The library also includes a ThemePreference. This preference will query for all installed themes and let the user select one. You can then set Theme.setPackageName via the PreferenceManager. A good default is your own package name.

As for the theme apk, it's job is simple. It requires no java code. For starters, add the following intent filter to any activity in the Activity Manifest.

<intent-filter>
    <action android:name="com.example.myapp.THEME" /> <!-- Change com.example.myapp to your main app's package name -->
</intent-filter>

Then add in any drawables and colors you want to replace. Just name them the same as they are in the main app. For custom fonts, add a font file called "font" to /assets.

About

ThemeEngine rollback to support legacy mobile calculator by Xlythe

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%