diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..098cc86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,102 @@ +############################################################################# +# +# .gitignore declares what files should be ignored by git +# +# This particular file is a composite of github's Android and Eclipse +# files, along with some custom additions. +# +############################################################################# + +############################################################################# +# Eclipse related files +############################################################################# + +*.pydevproject +.metadata +.gradle +bin/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +# sbteclipse plugin +.target + +# TeXlipse plugin +.texlipse + +############################################################################# +# Android related files +############################################################################# + +# Built application files +*.apk +#*.ap_ + +# Generated files +gen/ + +# Gradle files +build/ + +# Proguard folder generated by Eclipse +proguard/ + +#Log Files +*.log + +############################################################################# +# Other Misc. files +############################################################################# + +# Temp files for KDE and other Editor's +*~ + +############################################################################# +# Android Studio related files +############################################################################# + +.idea/ +#gradle.properties +*.iml + +############################################################################# +# Encrypted Assets +############################################################################# +app/src/main/assets-temp + +############################################################################# +# Build Bots +############################################################################# +app/release/output\.json + +############################################################################# +# C++ +############################################################################# +app/.externalNativeBuild + +############################################################################# +# Windows thumbnail cache +############################################################################# +Thumbs.db + +############################################################################# +# Mac thumbnail cache +############################################################################# +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3224528 --- /dev/null +++ b/README.md @@ -0,0 +1,174 @@ +# Substratum Theme Template + +The official theme template from the team, for every prospective/current themer who wishes to join the Substratum game! + +There are seven types of Substratum as of this date (06/05/18) + - Substratum OMS (3/7) (Marshmallow) [Marshmallow has been deprecated since 510, but it is still available] + - Substratum OMS (7) (Nougat) + - Substratum Dynamic Overlays (Stock Oreo) [Will require a rooted device, or Andromeda installed] + - Substratum Dynamic Overlays (Oreo) + - Substratum Samsung (RRO-OMS fusion) [Will require a device with the samsung plugin] + - Substratum Samsung Oreo (OMS-RRO fusion) [Will require a device with the andromeda plugin] + - Substratum Legacy (RRO) [Rooted] + +To get started, first of all, FORK and CLONE this project on GitHub and open it up with Android Studio (We recommend to keep yourself up to date with the latest Google has to offer) + +## Step 0: PRECONFIGURATIONS! +Install the latest Android Studio Preview: https://developer.android.com/studio/preview/index.html + +Disable Instant Run: http://stackoverflow.com/a/35169716 + +Disable activity launch on theme: + - Click on the above dropdown menu in Android Studio that says `app` (by default there should be an icon of andy with an x on it) + - Click on `Edit configurations...` + - Locate "Launch Options" and instead of Default Activity, select Nothing + - This will now push your theme APK to your device without having to worry about build errors + +## Step 1: Package Naming +The FIRST thing you need to change is the package identifier (the name the app identifies as) to something more meaningful to you. Open up [build.gradle](app/build.gradle) and look for this line +``` +applicationId "substratum.theme.template" +``` +Change this to anything you want, for instance: +``` +applicationId "com.yourname.themename" +``` + +Change Package Name in the project structure (optional): + - Just follow the instructions listed brilliantly [here](http://stackoverflow.com/a/29092698) + +NOTE: If you change your project structure name, the AndroidManifest AND the build.gradle package names must match, or else encrypted assets will break. + +## Step 2: Theme Properties +You can control your theme properties such as whether your theme supports OMS, RRO or both inside +the theme configuration file: [theme_configurations.xml](app/src/main/res/values/theme_configurations.xml) + +For wallpapers, make sure you use DIRECT LINKS for everything you see in the pastebin template. We recommend using pastebin, +but you could use Google Drive (for the XML file). Pictures must be located in a public area so that people can download them freely. + +## Step 3: Start theming! +### Audio +To install system sound effects, you will need to have an audio folder, just like it's listed [here](app/src/main/assets/audio). + +You are allowed to add multiple audio files and name them differently so they show up indivually on the spinner dropdown in the app. + +Example: +``` +assets/audio/StarWarsLockUnlock.zip +``` +Audio ZIP root structure: +``` +StarWarsLockUnlock.zip/ui/Lock.ogg(or mp3) +StarWarsLockUnlock.zip/ui/Unlock.ogg(or mp3) +StarWarsLockUnlock.zip/ui/effect_tick.ogg(or mp3) +StarWarsLockUnlock.zip/alarms/alarm.ogg(or mp3) +StarWarsLockUnlock.zip/ringtones/ringtone.ogg(or mp3) +StarWarsLockUnlock.zip/notifications/notification.ogg(or mp3) +``` + +### Boot Animations +To install boot animations, you will need to have a bootanimations folder, just like it's listed [here](app/src/main/assets/bootanimation). + +You are allowed to add multiple bootanimations and name them differently so they show up individually on the spinner dropdown in the app. + +Example: +``` +assets/bootanimation/Sakura.zip +``` + +### Shutdown Animations +To install shutdown animations, you will need to have a shutdownanimation folder, just like it's listed [here](app/src/main/assets/shutdownanimation). + +Just like bootanimations, but only enabled on Oreo based devices and above! + +Example: +``` +assets/shutdownanimation/Sakura.zip +``` + +### Fonts +To install fonts, you will need to have a fonts folder, just like it's listed [here](app/src/main/assets/fonts). + +You are allowed to add multiple fonts and name them differently so they show up individually on the spinner dropdown in the app. + +If you are looking to load up DOWNLOADED fonts from the internet, then download the ZIP from your source, extract it and navigate INTO the folder, until you find the folder "fonts" in "/system/fonts", and ZIP the whole contents of the folder up to form your new fonts pack. + +This also supports fonts.xml within the font's ZIP file, so if you have any knowledge of this, you can add it in. + +Example: +``` +assets/fonts/Ubuntu.zip +``` +Font ZIP root structure: +``` +Ubuntu.zip/font1.ttf +Ubuntu.zip/font2.ttf +Ubuntu.zip/font3.ttf +``` + +### Overlays +If you had any experience with overlays on CMTE, it is rather the same format, except we added our own twists for enhanced theming capabilities for Substratum users. + +If you would like to theme an application, first you need their package identifier. Let's say you wanted to theme Substratum (projekt.substratum), you will create a folder within "assets/overlays" and name it the package name and start following the app's resource structure, e.g. +``` +assets/overlays/projekt.substratum/res/values/colors.xml +``` + +### Overlay Type Options Guide + +https://docs.google.com/document/d/1H8tC1hjhADPOZdjebJEeC3FYZid9gZ7F56OA-27PxfU/edit?usp=sharing + +## Step 4: Finalize your theme! +To get your theme to show up on Substratum, all you need to ensure that your hero image relates to your theme. The hero image DETERMINES the color of the automatic actionbar and nav bar colors based on the (0,0)'th pixel on your image. Your theme hero image is located [here](app/src/main/res/drawable-xxhdpi/heroimage.png). + +If you have a completely white image, your actionbar and nav bar will change to that color, and the text colors will determine whether the black text is more visible on that color, or a white color. + +## Step 5: Include a built in changelog for your users! + +If you take a look at the aforementioned theme_configurations.xml, you will see a with name "ThemeChangelog" where you can add your own changelog line by line. Please do not include line breaks unless you really have to. Substratum does this automagically! You can have as many lines as you want, so don't worry about the default 5 lines in the template! + +## Step 6: Safeguard your theme! Don't let the pirates win! + +### If you want to enable the Substratum theme for other Theme Managers (e.g. Slim) +In ThemerConstants.gradle, change the [SUPPORTS_THIRD_PARTY_SYSTEMS](app/ThemerConstants.gradle#L9) on line 9. + +### If you don't want to activate AntiPiracy +Then you can stop reading and get your theme published! Good luck! + +### Getting started with AntiPiracy + +If you are ready to get AntiPiracy set up, all you need to look at is [ThemerConstants.gradle](app/ThemerConstants.gradle)! + +Compile your theme as a SIGNED release APK from Android Studio (Build -> Generate Signed APK). Then launch the signed apk on your device and your log will spit out an error log under the name "SubstratumThemeReport", and you want to copy and paste that into [APK_SIGNATURE_PRODUCTION](app/ThemerConstants.gradle#L13) on line 13. + +**NOTE**: If you are planning to make use of [Google Play App Signing](https://developer.android.com/studio/publish/app-signing.html#google-play-app-signing), **DO NOT** fill the `APK_SIGNATURE_PRODUCTION` field in [ThemerConstants.gradle](app/ThemerConstants.gradle). + +Then you would need to go to Play Developer Console. Then access to your app -> Services and APIs, generate a new API key for your app and then paste it into [BASE_64_LICENSE_KEY](app/ThemerConstants.gradle#L12) on line 12. + +Third, if you would like to change where it checks for various things such as Amazon App Store Enforcement or Play Store Enforcement, you have options listed on line 16 and lines below it, simply change from `true` to `false` and vice versa to make your desired configuration. + +Finally, if you would like to enable intensive mode anti-piracy (App package blacklist), add as many package names as you want under [BLACKLISTED_APPLICATIONS](app/src/main/kotlin/substratum/theme/template/AdvancedConstants.kt#L12) on line 12. Then make sure to enable [ENABLE_APP_BLACKLIST_CHECK](app/ThemerConstants.gradle#L16) on line 16. + +**Under no circumstances should you share your ThemerConstants.gradle file, unless specifically asked by an [official substratum developer](https://github.com/substratum/documentation#team-info-and-responsibilities)**! + +### Encrypted Assets +As of template version 11.0.0, all theme assets are duplicated are encrypted within the APK by default, not your original assets! + +Always use a version control tool listed below to host your private themes! + +BitBucket: https://bitbucket.org/ +GitLab: https://about.gitlab.com/ + +If you want to keep your theme assets unencrypted, just change the value [here](app/ThemerConstants.gradle#L4) to false. + +### Enforcing security +As of template version 11.0.0, themes have an additional check on the build of substratum your users should be running. + +What this means is that themes can ensure their themes ONLY function with our full release cycle with debug and Play Store releases. + +If you would like to enable this feature (only allow your theme to be used with official substratum builds), all you have to do is to flip `true` to `false` [here](app/ThemerConstants.gradle#L20)! + +### Now what? +Nothing. Now you're set to publish your theme! + +## Written with ❤ from themers and developers alike! \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..e55afb0 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,3 @@ +/build +/src/main/assets-temp +/src/main/jni/LoadingProcess.h \ No newline at end of file diff --git a/app/ThemerConstants.gradle b/app/ThemerConstants.gradle new file mode 100644 index 0000000..be5379a --- /dev/null +++ b/app/ThemerConstants.gradle @@ -0,0 +1,21 @@ +ext { + // Whether the theme assets should be encrypted or not, + // this makes it harder for pirates and kangers! (DEFAULT: true) + SHOULD_ENCRYPT_ASSETS = true + + // Whether this theme supports third party theme systems, we will not be able to help you debug + // your themes on external theming systems, so the team will NOT respond to external systems if + // there are issues with your theme (DEFAULT: false) + SUPPORTS_THIRD_PARTY_SYSTEMS = false + + // Play Store AntiPiracy LVL configurations + BASE_64_LICENSE_KEY = "" + APK_SIGNATURE_PRODUCTION = "" + + // Piracy library configurations + ENABLE_APP_BLACKLIST_CHECK = false + ENFORCE_GOOGLE_PLAY_INSTALL = false + + // Allow third party substratum builds + ALLOW_THIRD_PARTY_SUBSTRATUM_BUILDS = true +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..23e4c58 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,172 @@ +import groovy.io.FileType + +import javax.crypto.Cipher +import javax.crypto.SecretKey +import javax.crypto.spec.IvParameterSpec +import javax.crypto.spec.SecretKeySpec + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: 'ThemerConstants.gradle' + +ext { + // Themers: DO NOT MODIFY + byte[] key = new byte[16] + new Random().nextBytes(key) + KEY = key + byte[] iv = new byte[16] + new Random().nextBytes(iv) + IV_KEY = iv +} + +android { + compileSdkVersion 28 + + + defaultConfig { + // If you're planning to change up the package name, ensure you have read the readme + // thoroughly! + applicationId "com.alienator88.lockr" + // We are only supporting Nougat and above, all new changes will incorporate Nougat changes + // to the substratum repo rather than anything lower. Keep targetSdkVersion the same. + minSdkVersion 24 + // Both versions must be changed to increment on Play Store/user's devices + versionCode 2 + versionName "2.0" + + // Themers: DO NOT MODIFY + buildConfigField "boolean", "SUPPORTS_THIRD_PARTY_SYSTEMS", "" + SUPPORTS_THIRD_PARTY_SYSTEMS + buildConfigField "boolean", "ENABLE_APP_BLACKLIST_CHECK", "" + ENABLE_APP_BLACKLIST_CHECK + buildConfigField "boolean", "ALLOW_THIRD_PARTY_SUBSTRATUM_BUILDS", "" + ALLOW_THIRD_PARTY_SUBSTRATUM_BUILDS + buildConfigField "String", "IV_KEY", "\"" + IV_KEY + "\"" + buildConfigField "byte[]", "DECRYPTION_KEY", String.valueOf("\"" + KEY + "\"").replace("\"", "").replace("[", "{").replace("]", "}") + buildConfigField "byte[]", "IV_KEY", String.valueOf("\"" + IV_KEY + "\"").replace("\"", "").replace("[", "{").replace("]", "}") + resValue "string", "encryption_status", (shouldEncrypt() ? "onCompileVerify" : "false") + } + buildTypes { + debug { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + + // Themers: DO NOT MODIFY + buildConfigField "boolean", "ENFORCE_GOOGLE_PLAY_INSTALL", "false" + buildConfigField "String", "BASE_64_LICENSE_KEY", "\"\"" + buildConfigField "String", "APK_SIGNATURE_PRODUCTION", "\"\"" + } + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + + // Themers: DO NOT MODIFY + buildConfigField "boolean", "ENFORCE_GOOGLE_PLAY_INSTALL", "" + ENFORCE_GOOGLE_PLAY_INSTALL + buildConfigField "String", "BASE_64_LICENSE_KEY", "\"" + BASE_64_LICENSE_KEY + "\"" + buildConfigField "String", "APK_SIGNATURE_PRODUCTION", "\"" + APK_SIGNATURE_PRODUCTION + "\"" + } + } + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.github.javiersantos:PiracyChecker:1.2.5' + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") + implementation("androidx.appcompat:appcompat:1.0.2") + implementation 'com.anjlab.android.iab.v3:library:1.1.0' +} + +// Themers: DO NOT MODIFY ANYTHING BELOW +task encryptAssets { + if (!shouldEncrypt()) { + println("Skipping assets encryption...") + return + } + + def tempAssets = new File(getProjectDir(), "/src/main/assets-temp") + if (!tempAssets.exists()) { + println("Encrypting duplicated assets, don't worry, your original assets are safe...") + def list = [] + def dir = new File(getProjectDir(), "/src/main/assets") + dir.eachFileRecurse(FileType.FILES) { file -> + list << file + + FileInputStream fis = new FileInputStream(file) + File fo = new File(file.getAbsolutePath().replace("assets", "assets-temp")) + fo.getParentFile().mkdirs() + FileOutputStream fos = new FileOutputStream(fo) + byte[] buffer = new byte[4096] + int n + while ((n = fis.read(buffer)) != -1) { + fos.write(buffer, 0, n) + } + fis.close() + fos.close() + } + + list.each { + if (it.getAbsolutePath().contains("overlays")) { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding") + SecretKey secret = new SecretKeySpec(KEY, "AES") + IvParameterSpec iv = new IvParameterSpec(IV_KEY) + + cipher.init(Cipher.ENCRYPT_MODE, secret, iv) + FileInputStream fis = new FileInputStream(it) + FileOutputStream fos = new FileOutputStream(it.getAbsolutePath() + ".enc") + + byte[] input = new byte[64] + int bytesRead + while ((bytesRead = fis.read(input)) != -1) { + byte[] output = cipher.update(input, 0, bytesRead) + if (output != null) { + fos.write(output) + } + } + byte[] output = cipher.doFinal() + if (output != null) { + fos.write(output) + } + fis.close() + fos.flush() + fos.close() + + it.delete() + } + } + } else { + throw new RuntimeException("Old temporary assets found! Try and do a clean project.") + } +} + +project.afterEvaluate { + preBuild.dependsOn encryptAssets +} + +gradle.buildFinished { + def tempAssets = new File(getProjectDir(), "/src/main/assets-temp") + if (tempAssets.exists()) { + println("Cleaning duplicated encrypted assets, not your decrypted assets...") + def encryptedAssets = new File(getProjectDir(), "src/main/assets") + encryptedAssets.deleteDir() + + tempAssets.eachFileRecurse(FileType.FILES) { file -> + FileInputStream fis = new FileInputStream(file) + File fo = new File(file.getAbsolutePath().replace("assets-temp", "assets")) + fo.getParentFile().mkdirs() + FileOutputStream fos = new FileOutputStream(fo) + byte[] buffer = new byte[4096] + int n + while ((n = fis.read(buffer)) != -1) { + fos.write(buffer, 0, n) + } + fis.close() + fos.close() + } + tempAssets.deleteDir() + } +} + +boolean shouldEncrypt() { + ArrayList tasks = project.gradle.startParameter.taskNames + return SHOULD_ENCRYPT_ASSETS && Arrays.toString(tasks).toLowerCase().contains("release") +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..4b8f4fe --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,22 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/Nicholas/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +-dontwarn org.apache.** +-keep class com.google.** +-dontwarn com.google.** +-keep public class com.android.vending.licensing.ILicensingService \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0771d63 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/colors.xml b/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/colors.xml new file mode 100644 index 0000000..8f23c24 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #00ffffff + diff --git a/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/dimens.xml b/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/dimens.xml new file mode 100644 index 0000000..6999c36 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui.statusbars/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + 900000.0dip + 90000.0dip + 90000.0dip + 0.0dip + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_camera_alt_24dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_camera_alt_24dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_camera_alt_24dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_mic_26dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_mic_26dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_mic_26dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_phone_24dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_phone_24dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable-anydpi/ic_phone_24dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable-xxhdpi/fod_icon_default.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable-xxhdpi/fod_icon_default.png new file mode 100644 index 0000000..c2d3605 Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable-xxhdpi/fod_icon_default.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_alt_24dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_alt_24dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_alt_24dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_fod.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_fod.xml new file mode 100644 index 0000000..209a21d --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_camera_fod.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_fingerprint_error.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_fingerprint_error.xml new file mode 100644 index 0000000..50d1ca1 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_fingerprint_error.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_24dp.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_24dp.xml new file mode 100644 index 0000000..73b1cab --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_24dp.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_24dp.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_24dp.xml new file mode 100644 index 0000000..f1916ff --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_24dp.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_fod.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_fod.xml new file mode 100644 index 0000000..891c786 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_lock_open_fod.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_26dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_26dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_26dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_fod.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_fod.xml new file mode 100644 index 0000000..96cedb0 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_mic_fod.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_24dp.png b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_24dp.png new file mode 100644 index 0000000..65b25ad Binary files /dev/null and b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_24dp.png differ diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_fod.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_fod.xml new file mode 100644 index 0000000..ec46df7 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/ic_phone_fod.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_off.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_off.xml new file mode 100644 index 0000000..b0b6713 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_off.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_on.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_on.xml new file mode 100644 index 0000000..d4a2f2c --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_draw_on.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_error_state_to_fp.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_error_state_to_fp.xml new file mode 100644 index 0000000..a8d31ae --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_error_state_to_fp.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_fp_to_error_state.xml b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_fp_to_error_state.xml new file mode 100644 index 0000000..835ac6a --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/drawable/lockscreen_fingerprint_fp_to_error_state.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/values/colors.xml b/app/src/main/assets/overlays/com.android.systemui/res/values/colors.xml new file mode 100644 index 0000000..b648e4b --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #00ffffff + diff --git a/app/src/main/assets/overlays/com.android.systemui/res/values/dimens.xml b/app/src/main/assets/overlays/com.android.systemui/res/values/dimens.xml new file mode 100644 index 0000000..cefa602 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/values/dimens.xml @@ -0,0 +1,8 @@ + + + 0.0dip + 0.0dip + 0.0dip + 0.0dip + 0.0dip + \ No newline at end of file diff --git a/app/src/main/assets/overlays/com.android.systemui/res/values/strings.xml b/app/src/main/assets/overlays/com.android.systemui/res/values/strings.xml new file mode 100644 index 0000000..2ce1d17 --- /dev/null +++ b/app/src/main/assets/overlays/com.android.systemui/res/values/strings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/kotlin/com/alienator88/lockr/AdvancedConstants.kt b/app/src/main/kotlin/com/alienator88/lockr/AdvancedConstants.kt new file mode 100644 index 0000000..bd6dd8b --- /dev/null +++ b/app/src/main/kotlin/com/alienator88/lockr/AdvancedConstants.kt @@ -0,0 +1,55 @@ +package com.alienator88.lockr + +object AdvancedConstants { + + // Custom message on theme launch, see theme_strings.xml for changing the dialog content + // Set SHOW_DIALOG_REPEATEDLY to true if you want the dialog to be showed on every theme launch + const val SHOW_LAUNCH_DIALOG = true + const val SHOW_DIALOG_REPEATEDLY = true + + // Blacklisted APKs to prevent theme launching, these include simple regex formatting, without + // full regex formatting (e.g. com.android. will block everything that starts with com.android.) + val BLACKLISTED_APPLICATIONS = arrayOf( + "cc.madkite.freedom", + "zone.jasi2169.uretpatcher", + "uret.jasi2169.patcher", + "p.jasi2169.al3", + "com.dimonvideo.luckypatcher", + "com.chelpus.lackypatch", + "com.forpda.lp", + "com.android.vending.billing.InAppBillingService", + "com.android.vending.billing.InAppBillingSorvice", + "com.android.vendinc", + "com.appcake", + "ac.market.store", + "org.sbtools.gamehack", + "com.zune.gamekiller", + "com.aag.killer", + "com.killerapp.gamekiller", + "cn.lm.sq", + "net.schwarzis.game_cih", + "org.creeplays.hack", + "com.baseappfull.fwd", + "com.zmapp", + "com.dv.marketmod.installer", + "org.mobilism.android", + "com.blackmartalpha", + "org.blackmart.market", + "com.happymod.apk" + ) + + // List of all organization theming systems officially supported by the team + val ORGANIZATION_THEME_SYSTEMS = arrayOf( + "projekt.substratum", + "projekt.substratum.debug", + "projekt.substratum.lite", + "projekt.themer" + ) + + // List of other theme systems that are officially unsupported by the team, but fully supported + // by their corresponding organizations + val OTHER_THEME_SYSTEMS = arrayOf( + "com.slimroms.thememanager", + "com.slimroms.omsbackend" + ) +} diff --git a/app/src/main/kotlin/com/alienator88/lockr/SubstratumLauncher.kt b/app/src/main/kotlin/com/alienator88/lockr/SubstratumLauncher.kt new file mode 100644 index 0000000..8302c55 --- /dev/null +++ b/app/src/main/kotlin/com/alienator88/lockr/SubstratumLauncher.kt @@ -0,0 +1,272 @@ +@file:Suppress("ConstantConditionIf") + +package com.alienator88.lockr + +import android.annotation.SuppressLint +import android.app.Activity +import android.app.AlertDialog +import android.content.Context +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.widget.* +import com.anjlab.android.iab.v3.BillingProcessor +import com.anjlab.android.iab.v3.TransactionDetails +import com.github.javiersantos.piracychecker.* +import com.github.javiersantos.piracychecker.enums.InstallerID +import com.github.javiersantos.piracychecker.utils.apkSignature +import com.alienator88.lockr.AdvancedConstants.ORGANIZATION_THEME_SYSTEMS +import com.alienator88.lockr.AdvancedConstants.OTHER_THEME_SYSTEMS +import com.alienator88.lockr.ThemeFunctions.checkApprovedSignature +import com.alienator88.lockr.ThemeFunctions.getSelfSignature +import com.alienator88.lockr.ThemeFunctions.getSelfVerifiedPirateTools +import com.alienator88.lockr.ThemeFunctions.isCallingPackageAllowed + +/** + * NOTE TO THEMERS + * + * This class is a TEMPLATE of how you should be launching themes. As long as you keep the structure + * of launching themes the same, you can avoid easy script crackers by changing how + * functions/methods are coded, as well as boolean variable placement. + * + * The more you play with this the harder it would be to decompile and crack! + */ + +class SubstratumLauncher : Activity(), BillingProcessor.IBillingHandler { + private var bp: BillingProcessor? = null + + private val debug = false + private val tag = "SubstratumThemeReport" + private val substratumIntentData = "projekt.substratum.THEME" + private val getKeysIntent = "projekt.substratum.GET_KEYS" + private val receiveKeysIntent = "projekt.substratum.RECEIVE_KEYS" + + private val themePiracyCheck by lazy { + if (BuildConfig.ENABLE_APP_BLACKLIST_CHECK) { + getSelfVerifiedPirateTools(applicationContext) + } else { + false + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + /*TODO replace the null with license key from play console (developement tools > service & APIs)*/ + bp = BillingProcessor(this, "ffffffffffffff", this) + + /* STEP 1: Block hijackers */ + val caller = callingActivity!!.packageName + val organizationsSystem = ORGANIZATION_THEME_SYSTEMS.contains(caller) + val supportedSystem = organizationsSystem || OTHER_THEME_SYSTEMS.contains(caller) + if (!BuildConfig.SUPPORTS_THIRD_PARTY_SYSTEMS && !supportedSystem) { + Log.e(tag, "This theme does not support the launching theme system. [HIJACK] ($caller)") + Toast.makeText(this, + String.format(getString(R.string.unauthorized_theme_client_hijack), caller), + Toast.LENGTH_LONG).show() + finish() + } + if (debug) { + Log.d(tag, "'$caller' has been authorized to launch this theme. (Phase 1)") + } + + /* STEP 2: Ensure that our support is added where it belongs */ + val action = intent.action +// val sharedPref = getPreferences(Context.MODE_PRIVATE) + var verified = false + if ((action == substratumIntentData) or (action == getKeysIntent)) { + // Assume this called from organization's app + if (organizationsSystem) { + verified = when { + BuildConfig.ALLOW_THIRD_PARTY_SUBSTRATUM_BUILDS -> true + else -> checkApprovedSignature(this, caller) + } + } + } else { + OTHER_THEME_SYSTEMS + .filter { action?.startsWith(prefix = it, ignoreCase = true) ?: false } + .forEach { _ -> verified = true } + } + if (!verified) { + Log.e(tag, "This theme does not support the launching theme system. ($action)") + Toast.makeText(this, R.string.unauthorized_theme_client, Toast.LENGTH_LONG).show() + finish() + return + } + if (debug) { + Log.d(tag, "'$action' has been authorized to launch this theme. (Phase 2)") + } + + showDialog() + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (!bp!!.handleActivityResult(requestCode, resultCode, data)) { + super.onActivityResult(requestCode, resultCode, data) + } + } + + override fun onProductPurchased(productId: String, details: TransactionDetails?) { + + } + + override fun onPurchaseHistoryRestored() { + + } + + override fun onBillingError(errorCode: Int, error: Throwable?) { + + } + + override fun onBillingInitialized() { + + } + + public override fun onDestroy() { + if (bp != null) { + bp!!.release() + } + super.onDestroy() + } + + private fun startAntiPiracyCheck() { + if (BuildConfig.BASE_64_LICENSE_KEY.isEmpty() && debug && !BuildConfig.DEBUG) { + Log.e(tag, apkSignature) + } + + if (!themePiracyCheck) { + piracyChecker { + if (BuildConfig.ENFORCE_GOOGLE_PLAY_INSTALL) { + enableInstallerId(InstallerID.GOOGLE_PLAY) + } + if (BuildConfig.BASE_64_LICENSE_KEY.isNotEmpty()) { + enableGooglePlayLicensing(BuildConfig.BASE_64_LICENSE_KEY) + } + if (BuildConfig.APK_SIGNATURE_PRODUCTION.isNotEmpty()) { + enableSigningCertificate(BuildConfig.APK_SIGNATURE_PRODUCTION) + } + callback { + allow { + val returnIntent = if (intent.action == getKeysIntent) { + Intent(receiveKeysIntent) + } else { + Intent() + } + + val themeName = getString(R.string.ThemeName) + val themeAuthor = getString(R.string.ThemeAuthor) + val themePid = packageName + returnIntent.putExtra("theme_name", themeName) + returnIntent.putExtra("theme_author", themeAuthor) + returnIntent.putExtra("theme_pid", themePid) + returnIntent.putExtra("theme_debug", BuildConfig.DEBUG) + returnIntent.putExtra("theme_piracy_check", themePiracyCheck) + returnIntent.putExtra("encryption_key", BuildConfig.DECRYPTION_KEY) + returnIntent.putExtra("iv_encrypt_key", BuildConfig.IV_KEY) + + val callingPackage = intent.getStringExtra("calling_package_name") + if (!isCallingPackageAllowed(callingPackage)) { + finish() + } else { + returnIntent.`package` = callingPackage + } + + if (intent.action == substratumIntentData) { + setResult(getSelfSignature(applicationContext), returnIntent) + } else if (intent.action == getKeysIntent) { + returnIntent.action = receiveKeysIntent + sendBroadcast(returnIntent) + } + destroy() + finish() + } + doNotAllow { _, _ -> + val parse = String.format( + getString(R.string.toast_unlicensed), + getString(R.string.ThemeName)) + Toast.makeText(this@SubstratumLauncher, parse, Toast.LENGTH_SHORT).show() + destroy() + finish() + } + onError { error -> + Toast.makeText(this@SubstratumLauncher, error.toString(), Toast.LENGTH_LONG) + .show() + destroy() + finish() + } + } + }.start() + } else { + Toast.makeText(this, R.string.unauthorized, Toast.LENGTH_LONG).show() + finish() + } + } + + @SuppressLint("InflateParams") + private fun showDialog() { + + val alertDialog = AlertDialog.Builder(this, R.style.DialogStyle) + .setCancelable(false) + val view = LayoutInflater.from(this).inflate(R.layout.custom_dialog, null) + val title = view.findViewById(R.id.title) as TextView + title.text = getString(R.string.launch_dialog_title) + + /*Buttons*/ + val changelog = view.findViewById(R.id.changelog) as ImageButton + changelog.setImageResource(R.drawable.ic_changelog) + changelog.setOnClickListener { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.link_changelog)))) + } + val review = view.findViewById(R.id.playstore) as ImageButton + review.setImageResource(R.drawable.ic_playstore) + review.setOnClickListener { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.link_playstore)))) + } + val support = view.findViewById(R.id.ic_support) as ImageButton + support.setImageResource(R.drawable.ic_telegram) + support.setOnClickListener { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.link_support)))) + } + val cont = view.findViewById(R.id.button_continue) as Button + cont.setOnClickListener { + startAntiPiracyCheck() + } + val donation = view.findViewById(R.id.donate) as ImageButton + donation.setImageResource(R.drawable.ic_paypal) + donation.setOnClickListener { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.link_paypal)))) + } + /*Checkbox*/ + val myCheckBox = view.findViewById(R.id.myCheckBox) as CheckBox + myCheckBox.setOnCheckedChangeListener { _, isChecked -> + if (isChecked) { + storeDialogStatus(true) + } else { + storeDialogStatus(false) + } + } + + alertDialog.setView(view) + + if (getDialogStatus()) { + startAntiPiracyCheck() + } else { + alertDialog.show() + } + + } + + private fun storeDialogStatus(isChecked: Boolean) { + val mSharedPreferences = getSharedPreferences("dialog", Context.MODE_PRIVATE) + val mEditor = mSharedPreferences.edit() + mEditor.putBoolean("show_dialog_" + BuildConfig.VERSION_CODE, isChecked) + mEditor.apply() + } + + private fun getDialogStatus(): Boolean { + val mSharedPreferences = getSharedPreferences("dialog", Context.MODE_PRIVATE) + return mSharedPreferences.getBoolean("show_dialog_" + BuildConfig.VERSION_CODE, false) + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/com/alienator88/lockr/ThemeFunctions.kt b/app/src/main/kotlin/com/alienator88/lockr/ThemeFunctions.kt new file mode 100644 index 0000000..8ec82bc --- /dev/null +++ b/app/src/main/kotlin/com/alienator88/lockr/ThemeFunctions.kt @@ -0,0 +1,108 @@ +package com.alienator88.lockr + + +import android.annotation.SuppressLint +import android.content.Context +import android.content.pm.PackageManager +import android.content.pm.Signature +import android.os.RemoteException +import com.alienator88.lockr.AdvancedConstants.BLACKLISTED_APPLICATIONS +import com.alienator88.lockr.AdvancedConstants.ORGANIZATION_THEME_SYSTEMS +import com.alienator88.lockr.AdvancedConstants.OTHER_THEME_SYSTEMS +@Suppress("ConstantConditionIf") +object ThemeFunctions { + + fun isCallingPackageAllowed(packageId: String): Boolean { + if (BuildConfig.SUPPORTS_THIRD_PARTY_SYSTEMS) { + OTHER_THEME_SYSTEMS.contains(packageId) + } + return ORGANIZATION_THEME_SYSTEMS.contains(packageId) + } + + fun getSelfVerifiedPirateTools(context: Context): Boolean { + val pm = context.packageManager + val packages = pm.getInstalledApplications(PackageManager.GET_META_DATA) + val listOfInstalled = arrayListOf() + packages.mapTo(listOfInstalled) { it.packageName } + return BLACKLISTED_APPLICATIONS.any { listOfInstalled.contains(it) } + } + + @Suppress("DEPRECATION") + @SuppressLint("PackageManagerGetSignatures") + fun checkApprovedSignature(context: Context, packageName: String): Boolean { + SIGNATURES.filter { + try { + val pm = context.packageManager + val pi = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES) + if (pi.signatures != null && pi.signatures.size == 1 + && ((SIGNATURES[0] == pi.signatures[0]) || + (SIGNATURES[1] == pi.signatures[0]))) { + return true + } + return false + } catch (e: RemoteException) { + return false + } + }.forEach { return true } + return false + } + + @Suppress("DEPRECATION") + @SuppressLint("PackageManagerGetSignatures") + fun getSelfSignature(context: Context): Int { + try { + val sigs = context.packageManager.getPackageInfo( + context.packageName, + PackageManager.GET_SIGNATURES + ).signatures + return sigs[0].hashCode() + } catch (e: PackageManager.NameNotFoundException) { + e.printStackTrace() + } + + return 0 + } + + // Enforce a way to get official support from the team, by ensuring that only + private val SUBSTRATUM_SIGNATURE = Signature("" + + "308202eb308201d3a003020102020411c02f2f300d06092a864886f70d01010b050030263124302206" + + "03550403131b5375627374726174756d20446576656c6f706d656e74205465616d301e170d31363037" + + "30333032333335385a170d3431303632373032333335385a3026312430220603550403131b53756273" + + "74726174756d20446576656c6f706d656e74205465616d30820122300d06092a864886f70d01010105" + + "000382010f003082010a02820101008855626336f645a335aa5d40938f15db911556385f72f72b5f8b" + + "ad01339aaf82ae2d30302d3f2bba26126e8da8e76a834e9da200cdf66d1d5977c90a4e4172ce455704" + + "a22bbe4a01b08478673b37d23c34c8ade3ec040a704da8570d0a17fce3c7397ea63ebcde3a2a3c7c5f" + + "983a163e4cd5a1fc80c735808d014df54120e2e5708874739e22e5a22d50e1c454b2ae310b480825ab" + + "3d877f675d6ac1293222602a53080f94e4a7f0692b627905f69d4f0bb1dfd647e281cc0695e0733fa3" + + "efc57d88706d4426c4969aff7a177ac2d9634401913bb20a93b6efe60e790e06dad3493776c2c0878c" + + "e82caababa183b494120edde3d823333efd464c8aea1f51f330203010001a321301f301d0603551d0e" + + "04160414203ec8b075d1c9eb9d600100281c3924a831a46c300d06092a864886f70d01010b05000382" + + "01010042d4bd26d535ce2bf0375446615ef5bf25973f61ecf955bdb543e4b6e6b5d026fdcab09fec09" + + "c747fb26633c221df8e3d3d0fe39ce30ca0a31547e9ec693a0f2d83e26d231386ff45f8e4fd5c06095" + + "8681f9d3bd6db5e940b1e4a0b424f5c463c79c5748a14a3a38da4dd7a5499dcc14a70ba82a50be5fe0" + + "82890c89a27e56067d2eae952e0bcba4d6beb5359520845f1fdb7df99868786055555187ba46c69ee6" + + "7fa2d2c79e74a364a8b3544997dc29cc625395e2f45bf8bdb2c9d8df0d5af1a59a58ad08b32cdbec38" + + "19fa49201bb5b5aadeee8f2f096ac029055713b77054e8af07cd61fe97f7365d0aa92d570be98acb89" + + "41b8a2b0053b54f18bfde092eb") + + // Also allow our CI builds + private val SUBSTRATUM_CI_SIGNATURE = Signature("" + + "308201dd30820146020101300d06092a864886f70d010105050030373116301406035504030c0d416e" + + "64726f69642044656275673110300e060355040a0c07416e64726f6964310b30090603550406130255" + + "53301e170d3137303232333036303730325a170d3437303231363036303730325a3037311630140603" + + "5504030c0d416e64726f69642044656275673110300e060355040a0c07416e64726f6964310b300906" + + "035504061302555330819f300d06092a864886f70d010101050003818d00308189028181008aa6cf56" + + "e3ba4d0921da3baf527529205efbe440e1f351c40603afa5e6966e6a6ef2def780c8be80d189dc6101" + + "935e6f8340e61dc699cfd34d50e37d69bf66fbb58619d0ebf66f22db5dbe240b6087719aa3ceb1c68f" + + "3fa277b8846f1326763634687cc286b0760e51d1b791689fa2d948ae5f31cb8e807e00bd1eb72788b2" + + "330203010001300d06092a864886f70d0101050500038181007b2b7e432bff612367fbb6fdf8ed0ad1" + + "a19b969e4c4ddd8837d71ae2ec0c35f52fe7c8129ccdcdc41325f0bcbc90c38a0ad6fc0c604a737209" + + "17d37421955c47f9104ea56ad05031b90c748b94831969a266fa7c55bc083e20899a13089402be49a5" + + "edc769811adc2b0496a8a066924af9eeb33f8d57d625a5fa150f7bc18e55") + + // Whitelisted signatures + private val SIGNATURES = arrayOf( + SUBSTRATUM_SIGNATURE, + SUBSTRATUM_CI_SIGNATURE + ) +} \ No newline at end of file diff --git a/app/src/main/res/drawable-xxhdpi/heroimage.png b/app/src/main/res/drawable-xxhdpi/heroimage.png new file mode 100644 index 0000000..c7cbeed Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/heroimage.png differ diff --git a/app/src/main/res/drawable/btn_continue.xml b/app/src/main/res/drawable/btn_continue.xml new file mode 100644 index 0000000..595cbba --- /dev/null +++ b/app/src/main/res/drawable/btn_continue.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_donate.xml b/app/src/main/res/drawable/btn_donate.xml new file mode 100644 index 0000000..b937375 --- /dev/null +++ b/app/src/main/res/drawable/btn_donate.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dialog_bg.xml b/app/src/main/res/drawable/dialog_bg.xml new file mode 100644 index 0000000..be79995 --- /dev/null +++ b/app/src/main/res/drawable/dialog_bg.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_changelog.xml b/app/src/main/res/drawable/ic_changelog.xml new file mode 100644 index 0000000..3042ec5 --- /dev/null +++ b/app/src/main/res/drawable/ic_changelog.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable/ic_paypal.xml b/app/src/main/res/drawable/ic_paypal.xml new file mode 100644 index 0000000..31a9373 --- /dev/null +++ b/app/src/main/res/drawable/ic_paypal.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/drawable/ic_playstore.xml b/app/src/main/res/drawable/ic_playstore.xml new file mode 100644 index 0000000..5e2620f --- /dev/null +++ b/app/src/main/res/drawable/ic_playstore.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_telegram.xml b/app/src/main/res/drawable/ic_telegram.xml new file mode 100644 index 0000000..bf1ac6a --- /dev/null +++ b/app/src/main/res/drawable/ic_telegram.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/font/exo_2_light.ttf b/app/src/main/res/font/exo_2_light.ttf new file mode 100644 index 0000000..252b905 Binary files /dev/null and b/app/src/main/res/font/exo_2_light.ttf differ diff --git a/app/src/main/res/font/jolly_lodger.ttf b/app/src/main/res/font/jolly_lodger.ttf new file mode 100644 index 0000000..cfb3b8c Binary files /dev/null and b/app/src/main/res/font/jolly_lodger.ttf differ diff --git a/app/src/main/res/layout/custom_dialog.xml b/app/src/main/res/layout/custom_dialog.xml new file mode 100644 index 0000000..eb997d0 --- /dev/null +++ b/app/src/main/res/layout/custom_dialog.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + +