Themers: Add OTGSubs Support to your Theme - PDDStudio/OTGSubs GitHub Wiki
To add support for OTGSubs to your either new or existing Theme is pretty simple and straight forward.
Add the following snippet to your AndroidManifest.xml
<meta-data
android:name="OTGSubs_Supported"
android:value="true" />
Example:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="substratum.theme.template"
android:installLocation="internalOnly">
<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature
android:name="projekt.substratum.theme"
android:required="false" /> <!-- Set to true for block to be enabled -->
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/ThemeName"
android:supportsRtl="true"
android:theme="@style/DialogStyle"
tools:node="replace">
<activity android:name=".SubstratumLauncher">
<intent-filter>
<action android:name="projekt.substratum.THEME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<meta-data
android:name="Substratum_Legacy"
android:value="true"/>
<meta-data
android:name="Substratum_Name"
android:value="@string/ThemeName"/>
<meta-data
android:name="Substratum_Author"
android:value="@string/ThemeAuthor"/>
<meta-data
android:name="Substratum_Email"
android:value=""/> <!-- Insert your email for bug reports -->
<!-- Do you support Stock and Theme Ready Gapps? -> all -->
<!-- Do you support Theme Ready but not Stock Gapps? -> ready -->
<!-- Do you support Stock but not Theme Ready Gapps? -> stock -->
<meta-data
android:name="Substratum_ThemeReady"
android:value="all|ready|stock"/> <!-- Only pick one! -->
<meta-data
android:name="Substratum_Wallpapers"
android:value="http://pastebin.com/raw/TG4mFdXz"/>
<!-- SUBSTRATUM INTERNAL USE: DO NOT TOUCH -->
<meta-data
android:name="Substratum_Plugin"
android:value="7.0.5"/>
<meta-data
android:name="OTGSubs_Supported"
android:value="true" />
</application>
</manifest>
Create a file called theme_config.json
in your assets/overlays/android/
folder.
Add the following content into this json file:
{
"themeName" : "xyz",
"themeAuthor" : "xyz",
"themeTemplates" : [
{
"id" : "accentColorTemplate",
"title" : "Accent Colors",
"description" : "Choose your favorite Accent Colors",
"templateFile" : "template_type1a.xml",
"templateType" : "type1a",
"themes" : {
"primaryColor" : "#ff2196f3",
"primaryColorDark" : "#ff1976d2"
}
},
{
"id" : "backgroundColorTemplate",
"title" : "Background Colors",
"description" : "Choose your favorite Background Colors",
"templateFile" : "template_type1b.xml",
"templateType" : "type1b",
"themes" : {
"backgroundColor" : "#ff2196f3",
"backgroundColorDark" : "#ff1976d2",
"buttonColor" : "#ff219601"
}
}
]
}
Field Explanations:
-
themeName
: The Theme Name -
themeAuthor
: The Theme Author -
templateFile
: The Name of your XML Template file (see instructions below) -
themeTemplates
: Collection of differentTemplates
for each type of substratum resource
Template
Field Explanations:
-
id
: A unique identifier for this template -
title
: Title for this set of colors which is shown inside OTGSubs -
description
: Description for this set of colors which is shown inside OTGSubs -
templateFile
: The file which will be used for template patching -
templateType
: The type of resources (Same as in the official substratum app) -
themes
: XML Template Keys to default Value Mappings (Color values are used as fallback in case the user doesn't override them)
Create a new XML file with the same name as declared in the configuration's templateFile
.
Place all color resources that can be overridden by the user into this XML file, and replace the actual color value with one of the Keys you defined in the configuration's themes
field.
Example:
Example for a type1a
XML File:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="material_deep_teal_200">{primaryColor}</color>
<color name="material_deep_teal_500">{primaryColorDark}</color>
<color name="accent_material_dark">{primaryColorDark}</color>
<color name="accent_material_light">{primaryColorDark}</color>
</resources>
Example for a type1b
XML File:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_dark">{backgroundColorDark}</color>
<color name="background_material_dark">{backgroundColorDark}</color>
<color name="background_floating_material_dark">{backgroundColor}</color>
<color name="primary_material_dark">{backgroundColor}</color>
<color name="primary_dark_material_dark">{backgroundColorDark}</color>
<color name="button_material_dark">{buttonColor}</color>
</resources>
You're all set. Once you're done with the steps 1-3 above you can package, test and publish your Theme with support for OTGSubs!