├── settings.gradle ├── app ├── .gitignore ├── version.properties ├── src │ └── main │ │ ├── ic_launcher-web.png │ │ ├── assets │ │ ├── binary │ │ │ └── busybox │ │ └── fonts │ │ │ ├── blowbrush.ttf │ │ │ ├── sans_bold.ttf │ │ │ └── sans_regular.ttf │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ └── ic_launcher_foreground.png │ │ ├── values │ │ │ ├── ic_launcher_background.xml │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ ├── arrays.xml │ │ │ └── strings.xml │ │ ├── anim │ │ │ ├── fade_in.xml │ │ │ └── fade_out.xml │ │ ├── drawable │ │ │ ├── information.xml │ │ │ ├── mail.xml │ │ │ ├── button_bg.xml │ │ │ ├── settings.xml │ │ │ ├── tile_master.xml │ │ │ ├── telegram.xml │ │ │ ├── ic_td.xml │ │ │ ├── ic_tile_yellow.xml │ │ │ ├── ic_tile_white.xml │ │ │ ├── torch_big.xml │ │ │ └── ic_launcher_background.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── activity_settings.xml │ │ │ ├── activity_main.xml │ │ │ ├── select_device_layout.xml │ │ │ ├── fragment_single_knob.xml │ │ │ ├── fragment_launch.xml │ │ │ ├── fragment_three_knob.xml │ │ │ └── fragment_incompatible.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── xml │ │ │ └── preferences_main.xml │ │ ├── java │ │ └── com │ │ │ └── teamdarkness │ │ │ └── godlytorch │ │ │ ├── Utils │ │ │ ├── OnFragmentBackPressListener.kt │ │ │ ├── Constrains.kt │ │ │ ├── Device.kt │ │ │ ├── Utils.kt │ │ │ └── DeviceList.kt │ │ │ ├── MainApplication.kt │ │ │ ├── Dialog │ │ │ └── TileDialog.kt │ │ │ ├── Settings │ │ │ ├── SelectDevicePreference.kt │ │ │ ├── SettingsActivity.kt │ │ │ ├── DeviceListAdapter.kt │ │ │ └── PreferenceFragment.kt │ │ │ ├── Fragment │ │ │ ├── LaunchFragment.kt │ │ │ ├── SingleKnobFragment.kt │ │ │ ├── IncompatibleFragment.kt │ │ │ └── ThreeKnobFragment.kt │ │ │ ├── Activity │ │ │ └── MainActivity.kt │ │ │ └── Service │ │ │ └── WhiteTileService.kt │ │ └── AndroidManifest.xml ├── google-services.json └── build.gradle ├── debug-key ├── sans_bold.ttf ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── Android.mk ├── README.md ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | androidTest 3 | test -------------------------------------------------------------------------------- /debug-key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/debug-key -------------------------------------------------------------------------------- /app/version.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 10 18:21:49 IST 2018 2 | VERSION_CODE=755 3 | -------------------------------------------------------------------------------- /sans_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/sans_bold.ttf -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/assets/binary/busybox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/assets/binary/busybox -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/assets/fonts/blowbrush.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/assets/fonts/blowbrush.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/sans_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/assets/fonts/sans_bold.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/sans_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/assets/fonts/sans_regular.ttf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BRoy98/GodlyTorch/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #D4371F 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea/* 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | proguard-rules.pro 10 | /app/build/* 11 | release.keystore 12 | app/release/ 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e2381e 4 | #d4371f 5 | #ffe240 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | <<<<<<< Updated upstream 2 | #Mon Jun 04 14:32:43 IST 2018 3 | ======= 4 | #Sun Sep 09 22:08:00 IST 2018 5 | >>>>>>> Stashed changes 6 | distributionBase=GRADLE_USER_HOME 7 | distributionPath=wrapper/dists 8 | zipStoreBase=GRADLE_USER_HOME 9 | zipStorePath=wrapper/dists 10 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/information.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Utils/OnFragmentBackPressListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Utils 19 | 20 | interface OnFragmentBackPressListener { 21 | 22 | fun onBackPressed() 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mail.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 14 | 18 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | android.useAndroidX=true 11 | android.enableJetifier=true 12 | RELEASE_STORE_FILE=release_keystore.jks 13 | RELEASE_STORE_PASSWORD=$BITRISEIO_ANDROID_KEYSTORE_PASSWORD 14 | RELEASE_KEY_ALIAS=$BITRISEIO_ANDROID_KEYSTORE_ALIAS 15 | RELEASE_KEY_PASSWORD=$BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | LOCAL_MODULE_TAGS := optional 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_PACKAGE_NAME := Godly Torch 8 | LOCAL_CERTIFICATE := platform 9 | LOCAL_PROGUARD_ENABLED := disabled 10 | LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml 11 | 12 | LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-appcompat 13 | LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-cardview 14 | LOCAL_STATIC_JAVA_LIBRARIES += android-support-design 15 | LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4 16 | 17 | LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java faboptions/src/main/java ) 18 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res \ 19 | $(LOCAL_PATH)/faboptions/src/main/res \ 20 | frameworks/support/v7/appcompat/res \ 21 | frameworks/support/v7/cardview/res \ 22 | frameworks/support/design/res 23 | 24 | LOCAL_AAPT_FLAGS := --auto-add-overlay 25 | LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.cardview:android.support.design 26 | 27 | include $(BUILD_PACKAGE) 28 | 29 | include $(CLEAR_VARS) 30 | 31 | include $(BUILD_MULTI_PREBUILT) -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/MainApplication.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch 19 | 20 | import android.app.Application 21 | 22 | import com.crashlytics.android.core.CrashlyticsCore 23 | import io.fabric.sdk.android.Fabric 24 | 25 | class MainApplication : Application() { 26 | 27 | override fun onCreate() { 28 | super.onCreate() 29 | val fabric = Fabric.Builder(this) 30 | .kits(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()) 31 | .build() 32 | Fabric.with(fabric) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tile_master.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Dialog/TileDialog.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Dialog 19 | 20 | import android.app.AlertDialog 21 | import android.content.Context 22 | import android.content.DialogInterface 23 | 24 | object TileDialog { 25 | fun getDialog(context: Context, title: String, message: String): AlertDialog { 26 | 27 | val builder = AlertDialog.Builder(context) 28 | builder.setTitle(title) 29 | builder.setMessage(message) 30 | builder.setPositiveButton("OK.") { dialogInterface, _ -> dialogInterface.dismiss() } 31 | 32 | return builder.create() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Godly Torch 2 | [![Telegram](https://img.shields.io/badge/Telegram-join%20chat-blue.svg)](https://telegram.me/dndofficial) 3 | [![Build Status](https://app.bitrise.io/app/763ee94ca31e7d95.svg?token=jBe0br2dBnJd6cJkNKJYqg)](https://github.com/BRoy98/GodlyTorch) 4 | [![GNU GPL License](https://img.shields.io/badge/License-GNU%20GPL%20v3-orange.svg)](https://github.com/BRoy98/GodlyTorch/blob/master/LICENSE) 5 | [![Platform](https://img.shields.io/badge/Platform-android-brightgreen.svg)]() 6 | 7 | A Torch app that can manage specific LEDs of flash and control intensity. 8 | 9 | **NEEDS ROOT !** 10 | 11 | Features 12 | ------------ 13 | 1. Control specific LED of flash as torch for dual tone LED devices. 14 | 2. Control intensity for LED through knobs. 15 | 3. Double tap knobs to toggle LED. 16 | 4. Quick settings tiles for android N and up devices. 17 | 3. More coming soon! 18 | 19 | Credits 20 | ---------- 21 | * [**Bishwajyoti Roy**](https://github.com/broy98/) 22 | * [**Rohan Khurana**](https://github.com/rk2810/) 23 | 24 | -------- 25 | Thanks to a [**Dušan Uverić**](https://github.com/uvera/) for a poorly written bash script as a motivation to make it into app. 26 | 27 | Contributions 28 | ------------ 29 | Feel free to fork this project, work on it and then make a pull request against **DEV** branch. Most of the times We will accept them if they add something valuable to the code. 30 | 31 | Donation 32 | ----------- 33 | Will have to think of that! :no_mouth: 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Toggle 6 | Intensity 7 | 8 | 9 | 10 | 11 | 1 12 | 2 13 | 14 | 15 | 16 | 17 | 2 steps 18 | 3 steps 19 | 4 steps 20 | 5 steps 21 | 6 steps 22 | 23 | 24 | 25 | 1 26 | 2 27 | 3 28 | 4 29 | 5 30 | 31 | 32 | 33 | 15% 34 | 35% 35 | 50% 36 | 65% 37 | 85% 38 | 100% 39 | 40 | 41 | 42 | 15 43 | 35 44 | 50 45 | 65 46 | 85 47 | 100 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 23 | 24 | 30 | 31 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 25 | 26 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "619050989138", 4 | "firebase_url": "https://goldytorch.firebaseio.com", 5 | "project_id": "goldytorch", 6 | "storage_bucket": "goldytorch.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:619050989138:android:bfeb5aef0b0cfaec", 12 | "android_client_info": { 13 | "package_name": "com.teamdarkness.godlytorch" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "619050989138-9rkm17omm0k8t4aqiguflh47togp7f5v.apps.googleusercontent.com", 19 | "client_type": 1, 20 | "android_info": { 21 | "package_name": "com.teamdarkness.godlytorch", 22 | "certificate_hash": "42749678b33d4446f1a9d0741686005fb16e91b9" 23 | } 24 | }, 25 | { 26 | "client_id": "619050989138-oket2k37hmqchh6kjrphe8ah8ca00nuv.apps.googleusercontent.com", 27 | "client_type": 3 28 | } 29 | ], 30 | "api_key": [ 31 | { 32 | "current_key": "AIzaSyCnZcei4C3xSbEx7kgRWym7ki2m3IL8j5g" 33 | } 34 | ], 35 | "services": { 36 | "analytics_service": { 37 | "status": 1 38 | }, 39 | "appinvite_service": { 40 | "status": 2, 41 | "other_platform_oauth_client": [ 42 | { 43 | "client_id": "619050989138-oket2k37hmqchh6kjrphe8ah8ca00nuv.apps.googleusercontent.com", 44 | "client_type": 3 45 | } 46 | ] 47 | }, 48 | "ads_service": { 49 | "status": 2 50 | } 51 | } 52 | } 53 | ], 54 | "configuration_version": "1" 55 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Utils/Constrains.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Utils 19 | 20 | object Constrains { 21 | 22 | val PREF_DEVICE_ID = "deviceId" 23 | val PREF_DEVICE = "device" 24 | val PREF_SELECTED_DEVICE = "selectedDevice" 25 | val PREF_DOUBLE_TONE_ENABLED = "doubleTapKnob" 26 | val PREF_IS_DUAL_TONE = "deviceDualTone" 27 | val PREF_SINGLE_FILE_LOCATION = "singleLedFileLocation" 28 | val PREF_WHITE_FILE_LOCATION = "whiteLedFileLocation" 29 | val PREF_YELLOW_FILE_LOCATION = "yellowLedFileLocation" 30 | val PREF_TOGGLE_FILE_LOCATION = "toggleFileLocation" 31 | val PREF_BRIGHTNESS_MAX = "brightnessMax" 32 | val PREF_TILE_WHITE_ON = "tileWhiteIsOn" 33 | val PREF_TILE_YELLOW_ON = "tileYellowIsOn" 34 | val PREF_TILE_MASTER_ON = "tileMasterIsOn" 35 | val PREF_TILE_WHITE_NAME = "tileWhiteName" 36 | val PREF_TILE_YELLOW_NAME = "tileYellowName" 37 | val PREF_TILE_MASTER_NAME = "tileMasterName" 38 | val PREF_TILE_MASTER_STATE = "tileMasterState" 39 | val PREF_TILE_WHITE_STATE = "tileWhiteState" 40 | val PREF_TILE_YELLOW_STATE = "tileYellowState" 41 | val PREF_USE_INTERNAL_BUSYBOX = "useInternalBusybox" 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/telegram.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 15 | 20 | 23 | 27 | 30 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Settings/SelectDevicePreference.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Settings 19 | 20 | import android.content.Context 21 | import android.preference.DialogPreference 22 | import android.support.v7.widget.LinearLayoutManager 23 | import android.support.v7.widget.RecyclerView 24 | import android.util.AttributeSet 25 | import android.view.View 26 | import com.teamdarkness.godlytorch.Utils.Device 27 | import com.teamdarkness.godlytorch.Utils.DeviceList 28 | import com.teamdarkness.godlytorch.Utils.Utils .getDevicePositionById 29 | 30 | class SelectDevicePreference(context: Context, attrs: AttributeSet?) : DialogPreference(context, attrs) { 31 | 32 | private var deviceList = emptyList() 33 | 34 | init { 35 | deviceList = DeviceList.getDevices() 36 | } 37 | 38 | override fun onCreateDialogView(): View { 39 | val deviceView = RecyclerView(context) 40 | deviceView.layoutManager = LinearLayoutManager(context) 41 | deviceView.adapter = DeviceListAdapter(context) 42 | 43 | //Scroll to the selected device 44 | getPersistedString(null)?.let { 45 | deviceView.smoothScrollToPosition(getDevicePositionById(getPersistedString(null))) 46 | } 47 | return deviceView 48 | } 49 | } -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | Godly Torch 20 | 21 | sleep 0.01; 22 | echo %1$s > /sys/class/leds/%2$s; 23 | 24 | Looking for root… 25 | I AM ROOT! 26 | I ain\'t root, gimme ROOT ! 27 | Root not found. 28 | Checking device compatibility… 29 | Device Incompatible 30 | %1$s is not officially supported yet.

Feel free to contact us for your device support. We are more than happy to help you! You must provide us proper details about your device to get official support.

You can manually change the device below.

Note: Manual device changing may harm your device.]]>
31 | Contact Us 32 | {faw-code} with {faw-heart} by Team Darkness 33 | No device selected 34 | Select device 35 | Apply 36 |
37 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Settings/SettingsActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Settings 19 | 20 | import android.content.Context 21 | import android.support.v7.app.AppCompatActivity 22 | import android.os.Bundle 23 | import android.support.v7.widget.Toolbar 24 | import com.teamdarkness.godlytorch.R 25 | import uk.co.chrisjenx.calligraphy.CalligraphyConfig 26 | import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper 27 | 28 | class SettingsActivity : AppCompatActivity() { 29 | 30 | override fun onCreate(savedInstanceState: Bundle?) { 31 | super.onCreate(savedInstanceState) 32 | CalligraphyConfig.initDefault(CalligraphyConfig.Builder() 33 | .setDefaultFontPath("fonts/sans_regular.ttf") 34 | .setFontAttrId(R.attr.fontPath) 35 | .build()) 36 | setContentView(R.layout.activity_settings) 37 | val toolbar: Toolbar = findViewById(R.id.toolbar) 38 | 39 | setSupportActionBar(toolbar) 40 | supportActionBar?.title = "Settings" 41 | supportActionBar?.setDisplayHomeAsUpEnabled(true) 42 | toolbar.setNavigationOnClickListener { onBackPressed() } 43 | 44 | fragmentManager.beginTransaction().replace(R.id.fragment_container, 45 | PreferenceFragment()).commit() 46 | } 47 | 48 | override fun attachBaseContext(newBase: Context) { 49 | super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)) 50 | } 51 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_td.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Utils/Device.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Utils 19 | 20 | class Device { 21 | var deviceName: String = "" 22 | var deviceId: String = "" 23 | var isDualTone: Boolean = false 24 | 25 | var brightnessMax: Int = 0 26 | 27 | // Only for single tone led devices 28 | var singleLedFileLocation: String = "" 29 | 30 | // Only for dual tone led devices 31 | var whiteLedFileLocation: String = "" 32 | var yellowLedFileLocation: String = "" 33 | var toggleFileLocation: String = "" 34 | 35 | fun setName(deviceName: String = ""): Device { 36 | this.deviceName = deviceName 37 | return this 38 | } 39 | 40 | fun setDeviceId(deviceId: String = ""): Device { 41 | this.deviceId = deviceId 42 | return this 43 | } 44 | 45 | fun isDualTone(isDualTone: Boolean = false): Device { 46 | this.isDualTone = isDualTone 47 | return this 48 | } 49 | 50 | fun setBrightnessMax(brightnessMax: Int = 0): Device { 51 | this.brightnessMax = brightnessMax 52 | return this 53 | } 54 | 55 | fun setSingleLedFileLocation(singleLedFileLocation: String = ""): Device { 56 | this.singleLedFileLocation = singleLedFileLocation 57 | return this 58 | } 59 | 60 | fun setWhiteLedFileLocation(whiteLedFileLocation: String = ""): Device { 61 | this.whiteLedFileLocation = whiteLedFileLocation 62 | return this 63 | } 64 | 65 | fun setYellowLedFileLocation(yellowLedFileLocation: String = ""): Device { 66 | this.yellowLedFileLocation = yellowLedFileLocation 67 | return this 68 | } 69 | 70 | fun setToggleFileLocation(toggleFileLocation: String = ""): Device { 71 | this.toggleFileLocation = toggleFileLocation 72 | return this 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/select_device_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 28 | 29 | 39 | 40 | 52 | 53 | 54 | 55 | 61 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tile_yellow.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tile_white.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/xml/preferences_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 34 | 35 | 36 | 37 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 17 | 19 | 20 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | 60 | 65 | 66 | 67 | 68 | 69 | 70 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Settings/DeviceListAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Settings 19 | 20 | import android.content.Context 21 | import android.support.v7.widget.RecyclerView 22 | import android.util.Log 23 | import android.view.LayoutInflater 24 | import android.view.View 25 | import android.view.ViewGroup 26 | import android.widget.RadioButton 27 | import android.widget.TextView 28 | import com.teamdarkness.godlytorch.R 29 | import com.teamdarkness.godlytorch.Settings.DeviceListAdapter.DeviceHolder 30 | import com.teamdarkness.godlytorch.Utils.Constrains 31 | import com.teamdarkness.godlytorch.Utils.Device 32 | import com.teamdarkness.godlytorch.Utils.DeviceList 33 | import com.teamdarkness.godlytorch.Utils.Utils 34 | import com.teamdarkness.godlytorch.Utils.Utils.getDevicePositionById 35 | import org.jetbrains.anko.defaultSharedPreferences 36 | 37 | class DeviceListAdapter(val context: Context?) : RecyclerView.Adapter() { 38 | 39 | override fun getItemCount(): Int { 40 | return DeviceList.getDevices().size 41 | } 42 | 43 | override fun onBindViewHolder(holder: DeviceHolder, position: Int) { 44 | holder?.bind(DeviceList.getDevices()[position]) 45 | } 46 | 47 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeviceHolder { 48 | val view = LayoutInflater.from(parent?.context).inflate(R.layout.select_device_layout, parent, false) 49 | return DeviceHolder(view) 50 | } 51 | 52 | inner class DeviceHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 53 | 54 | private val radioButton: RadioButton = itemView.findViewById(R.id.radioButton) 55 | private val deviceName: TextView = itemView.findViewById(R.id.deviceName) 56 | private val deviceType: TextView = itemView.findViewById(R.id.deviceType) 57 | 58 | 59 | fun bind(device: Device) { 60 | 61 | val prefs = context?.defaultSharedPreferences 62 | 63 | // get torch file locations 64 | var selectedDevice = prefs?.getString(Constrains.PREF_SELECTED_DEVICE, "") 65 | 66 | deviceName.text = device.deviceName 67 | deviceType.text = device.deviceId 68 | selectedDevice?.let { 69 | radioButton.isChecked = device.deviceId == selectedDevice 70 | } 71 | 72 | itemView.setOnClickListener { 73 | radioButton.performClick() 74 | } 75 | 76 | radioButton.setOnClickListener { 77 | selectedDevice = prefs?.getString(Constrains.PREF_SELECTED_DEVICE, "") 78 | val lastSelectPosition = getDevicePositionById(selectedDevice) 79 | selectedDevice?.let { 80 | notifyItemChanged(lastSelectPosition) 81 | } 82 | Utils.selectDevice(context, device) 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'io.fabric' 4 | 5 | android { 6 | compileSdkVersion 28 7 | 8 | def versionProp = file('version.properties') 9 | if (versionProp.canRead()) { 10 | 11 | // Get properties from version.properties 12 | Properties versionProps = new Properties() 13 | versionProps.load(new FileInputStream(versionProp)) 14 | 15 | // Increase versionCode 16 | def code = versionProps['VERSION_CODE'].toInteger() + 1 17 | 18 | // Write new versionCode to version.properties 19 | versionProps['VERSION_CODE'] = code.toString() 20 | versionProps.store(versionProp.newWriter(), null) 21 | 22 | defaultConfig { 23 | applicationId "com.teamdarkness.godlytorch" 24 | minSdkVersion 21 25 | targetSdkVersion 28 26 | versionCode code 27 | versionName "1.4.6" 28 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 29 | } 30 | } else { 31 | throw new GradleException("Could not read version.properties!") 32 | } 33 | 34 | configurations.all { 35 | resolutionStrategy.cacheChangingModulesFor 3600, 'seconds' 36 | } 37 | 38 | signingConfigs { 39 | debug { 40 | storeFile file("../debug-key") 41 | storePassword 'godlytorch' 42 | keyAlias 'godly' 43 | keyPassword 'godlytorch' 44 | } 45 | release { 46 | v1SigningEnabled true 47 | v2SigningEnabled true 48 | } 49 | } 50 | 51 | buildTypes { 52 | release { 53 | minifyEnabled false 54 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 55 | signingConfig signingConfigs.release 56 | } 57 | } 58 | 59 | } 60 | 61 | dependencies { 62 | implementation fileTree(dir: 'libs', include: ['*.jar']) 63 | implementation 'com.github.BRoy98:Croller:master-SNAPSHOT' 64 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02' 65 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 66 | implementation 'com.android.support:design:28.0.0-rc02' 67 | implementation 'com.android.support:support-v4:28.0.0-rc02' 68 | implementation 'com.android.support:cardview-v7:28.0.0-rc02' 69 | 70 | testImplementation 'junit:junit:4.12' 71 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 72 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 73 | 74 | implementation 'com.afollestad.material-dialogs:core:0.9.6.0' 75 | implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') { 76 | transitive = true 77 | } 78 | implementation "com.mikepenz:iconics-core:3.0.3@aar" 79 | implementation "com.mikepenz:iconics-views:3.0.0@aar" 80 | implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar' 81 | implementation 'com.mikepenz:fontawesome-typeface:4.7.0.2@aar' 82 | implementation 'com.github.nisrulz:easydeviceinfo-base:2.4.1' 83 | //implementation 'com.github.Stericson:RootTools:5.0' 84 | implementation 'com.google.firebase:firebase-core:16.0.3' 85 | implementation "org.jetbrains.anko:anko-commons:$anko_version" 86 | implementation 'eu.chainfire:libsuperuser:1.0.0.+' 87 | implementation 'uk.co.chrisjenx:calligraphy:2.3.0' 88 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 89 | } 90 | repositories { 91 | mavenCentral() 92 | } 93 | 94 | apply plugin: 'kotlin-android-extensions' 95 | apply plugin: 'com.google.gms.google-services' -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_single_knob.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 27 | 28 | 55 | 56 | 74 | 75 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/torch_big.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 14 | 20 | 23 | 33 | 36 | 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Fragment/LaunchFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Fragment 19 | 20 | 21 | import android.os.Bundle 22 | import android.os.Handler 23 | import android.support.v4.app.Fragment 24 | import android.view.LayoutInflater 25 | import android.view.View 26 | import android.view.ViewGroup 27 | import android.widget.ProgressBar 28 | import android.widget.TextView 29 | 30 | import com.teamdarkness.godlytorch.R 31 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_IS_DUAL_TONE 32 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_SELECTED_DEVICE 33 | import com.teamdarkness.godlytorch.Utils.Utils 34 | import com.teamdarkness.godlytorch.Utils.Utils.askRoot 35 | import org.jetbrains.anko.defaultSharedPreferences 36 | 37 | class LaunchFragment : Fragment() { 38 | 39 | private var selectedDevice = "" 40 | private var isDualTone = true 41 | 42 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, 43 | savedInstanceState: Bundle?): View? { 44 | // Inflate the layout for this fragment 45 | val view = inflater.inflate(R.layout.fragment_launch, container, false) 46 | 47 | val logText: TextView = view.findViewById(R.id.logText) 48 | val progressBar: ProgressBar = view.findViewById(R.id.progressBar) 49 | 50 | val prefs = context?.defaultSharedPreferences 51 | 52 | prefs?.let { 53 | // get torch file locations 54 | selectedDevice = prefs.getString(PREF_SELECTED_DEVICE, "") 55 | // check for dual tone device 56 | isDualTone = prefs.getBoolean(PREF_IS_DUAL_TONE, true) 57 | } 58 | 59 | logText.text = getString(R.string.root_check) 60 | progressBar.visibility = View.VISIBLE 61 | 62 | 63 | 64 | Handler().postDelayed({ 65 | if (askRoot()) { 66 | logText.text = getString(R.string.check_device) 67 | if (selectedDevice.isNotEmpty()) 68 | launchKnobs() 69 | else { 70 | if (Utils.checkSupport(context)) { 71 | launchKnobs() 72 | } else { 73 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 74 | fragTransaction?.let { 75 | fragTransaction.replace(R.id.mainFrame, IncompatibleFragment()) 76 | fragTransaction.commit() 77 | } 78 | } 79 | } 80 | } else { 81 | logText.text = getString(R.string.root_denied) 82 | progressBar.visibility = View.INVISIBLE 83 | } 84 | }, 1000) 85 | return view 86 | } 87 | 88 | private fun launchKnobs() { 89 | if (isDualTone) { 90 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 91 | fragTransaction?.let { 92 | fragTransaction.replace(R.id.mainFrame, ThreeKnobFragment()) 93 | fragTransaction.commit() 94 | } 95 | } else { 96 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 97 | fragTransaction?.let { 98 | fragTransaction.replace(R.id.mainFrame, SingleKnobFragment()) 99 | fragTransaction.commit() 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Settings/PreferenceFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Settings 19 | 20 | import android.content.SharedPreferences 21 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener 22 | import android.os.Bundle 23 | import android.preference.PreferenceFragment 24 | import com.teamdarkness.godlytorch.R 25 | import android.preference.PreferenceManager 26 | import com.teamdarkness.godlytorch.Utils.Utils.getDeviceNameById 27 | 28 | 29 | class PreferenceFragment : PreferenceFragment(), OnSharedPreferenceChangeListener { 30 | 31 | override fun onCreate(savedInstanceState: Bundle?) { 32 | super.onCreate(savedInstanceState) 33 | addPreferencesFromResource(R.xml.preferences_main) 34 | 35 | updatePrefs() 36 | } 37 | 38 | override fun onSharedPreferenceChanged(p0: SharedPreferences?, p1: String?) { 39 | updatePrefs() 40 | } 41 | 42 | override fun onResume() { 43 | super.onResume() 44 | 45 | // Register preference change listener 46 | preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this) 47 | } 48 | 49 | override fun onPause() { 50 | super.onPause() 51 | 52 | // Remove preference change listener 53 | preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this) 54 | } 55 | 56 | private fun updatePrefs() { 57 | val prefs = PreferenceManager.getDefaultSharedPreferences(activity) 58 | 59 | val selectedDevice = findPreference("selectedDevice") 60 | val tileBehaviour = findPreference("tileBehaviour") 61 | val toggleIntensity = findPreference("toggleIntensity") 62 | val intensitySteps = findPreference("intensitySteps") 63 | 64 | prefs.getString("selectedDevice", null)?.let { 65 | selectedDevice.summary = getDeviceNameById(prefs.getString("selectedDevice", null)) 66 | } 67 | 68 | // Set 'Tile Behaviour' summery and update 'Intensity Steps' state 69 | tileBehaviour.summary = when(prefs.getString("tileBehaviour", null)) { 70 | "1" -> { 71 | toggleIntensity.isEnabled = true 72 | intensitySteps.isEnabled = false 73 | "Toggle" 74 | } 75 | "2" -> { 76 | toggleIntensity.isEnabled = false 77 | intensitySteps.isEnabled = true 78 | "Intensity" 79 | } 80 | "3" -> { 81 | toggleIntensity.isEnabled = false 82 | intensitySteps.isEnabled = false 83 | "Popup Dialog" 84 | } 85 | else -> { 86 | toggleIntensity.isEnabled = true 87 | intensitySteps.isEnabled = false 88 | "Toggle" 89 | } 90 | } 91 | 92 | // Set 'Intensity Steps' summery 93 | intensitySteps.summary = when(prefs.getString("intensitySteps", null)) { 94 | "1" -> "2 steps" 95 | "2" -> "3 steps" 96 | "3" -> "4 steps" 97 | "4" -> "5 steps" 98 | "5" -> "6 steps" 99 | else -> "6 steps" 100 | } 101 | 102 | // Set 'Toggle intensity' summery 103 | toggleIntensity.summary = when(prefs.getString("toggleIntensity", null)) { 104 | "15" -> "15%%" 105 | "35" -> "35%%" 106 | "50" -> "50%%" 107 | "65" -> "65%%" 108 | "85" -> "85%%" 109 | "100" -> "100%%" 110 | else -> "100%%" 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_launch.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 24 | 25 | 35 | 36 | 39 | 40 | 53 | 54 | 55 | 56 | 57 | 58 | 65 | 66 | 73 | 74 | 75 | 76 | 82 | 83 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Activity/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Activity 19 | 20 | import android.content.Context 21 | import android.support.v7.app.AppCompatActivity 22 | import android.os.Bundle 23 | import android.util.Log 24 | import com.teamdarkness.godlytorch.Fragment.IncompatibleFragment 25 | import com.teamdarkness.godlytorch.Fragment.LaunchFragment 26 | import com.teamdarkness.godlytorch.Fragment.SingleKnobFragment 27 | import com.teamdarkness.godlytorch.Fragment.ThreeKnobFragment 28 | import com.teamdarkness.godlytorch.R 29 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_IS_DUAL_TONE 30 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_SELECTED_DEVICE 31 | import com.teamdarkness.godlytorch.Utils.OnFragmentBackPressListener 32 | import com.teamdarkness.godlytorch.Utils.Utils 33 | import org.jetbrains.anko.defaultSharedPreferences 34 | import uk.co.chrisjenx.calligraphy.CalligraphyConfig 35 | import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper 36 | 37 | 38 | 39 | class MainActivity : AppCompatActivity() { 40 | 41 | private var selectedDevice = "" 42 | private var isDualTone = true 43 | private var paused = false 44 | 45 | override fun onCreate(savedInstanceState: Bundle?) { 46 | super.onCreate(savedInstanceState) 47 | CalligraphyConfig.initDefault(CalligraphyConfig.Builder() 48 | .setDefaultFontPath("fonts/sans_regular.ttf") 49 | .setFontAttrId(R.attr.fontPath) 50 | .build()) 51 | setContentView(R.layout.activity_main) 52 | 53 | val fragTransaction = supportFragmentManager.beginTransaction() 54 | fragTransaction.replace(R.id.mainFrame, LaunchFragment()) 55 | fragTransaction.commit() 56 | } 57 | 58 | override fun attachBaseContext(newBase: Context) { 59 | super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)) 60 | } 61 | 62 | override fun onPause() { 63 | super.onPause() 64 | paused = true 65 | } 66 | 67 | override fun onResume() { 68 | super.onResume() 69 | if(paused) { 70 | paused = false 71 | 72 | val prefs = defaultSharedPreferences 73 | 74 | prefs.let { 75 | // get torch file locations 76 | selectedDevice = prefs.getString(PREF_SELECTED_DEVICE, "") 77 | // check for dual tone device 78 | isDualTone = prefs.getBoolean(PREF_IS_DUAL_TONE, true) 79 | } 80 | if (selectedDevice.isNotEmpty()) 81 | launchKnobs() 82 | else { 83 | if (Utils.checkSupport(this)) { 84 | launchKnobs() 85 | } else { 86 | val fragTransaction = supportFragmentManager?.beginTransaction() 87 | fragTransaction?.let { 88 | fragTransaction.replace(R.id.mainFrame, IncompatibleFragment()) 89 | fragTransaction.commit() 90 | } 91 | } 92 | } 93 | } 94 | } 95 | 96 | override fun onBackPressed() { 97 | val fragmentList = supportFragmentManager.fragments 98 | fragmentList?.filterIsInstance()?.forEach { 99 | it.onBackPressed() 100 | } 101 | } 102 | 103 | 104 | private fun launchKnobs() { 105 | if (isDualTone) { 106 | val fragTransaction = supportFragmentManager.beginTransaction() 107 | fragTransaction.replace(R.id.mainFrame, ThreeKnobFragment()) 108 | fragTransaction.commit() 109 | 110 | } else { 111 | val fragTransaction = supportFragmentManager.beginTransaction() 112 | fragTransaction.replace(R.id.mainFrame, SingleKnobFragment()) 113 | fragTransaction.commit() 114 | 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Fragment/SingleKnobFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Fragment 19 | 20 | import android.app.ProgressDialog 21 | import android.content.Intent 22 | import android.os.Bundle 23 | import android.os.Handler 24 | import android.support.v4.app.ActivityCompat.finishAffinity 25 | import android.support.v4.app.Fragment 26 | import android.util.Log 27 | import android.view.LayoutInflater 28 | import android.view.View 29 | import android.view.ViewGroup 30 | import android.widget.ImageButton 31 | import android.widget.Toast 32 | import com.sdsmdg.harjot.crollerTest.Croller 33 | import com.sdsmdg.harjot.crollerTest.OnCrollerChangeListener 34 | import com.teamdarkness.godlytorch.R 35 | import com.teamdarkness.godlytorch.R.layout 36 | import com.teamdarkness.godlytorch.Settings.SettingsActivity 37 | import com.teamdarkness.godlytorch.Utils.Constrains 38 | import com.teamdarkness.godlytorch.Utils.OnFragmentBackPressListener 39 | import com.teamdarkness.godlytorch.Utils.Utils 40 | import org.jetbrains.anko.defaultSharedPreferences 41 | 42 | class SingleKnobFragment : Fragment(), OnFragmentBackPressListener { 43 | 44 | private var doubleBackToExitPressedOnce = false 45 | private var masterSingleTap = false 46 | private var doubleTapEnabled = false 47 | 48 | private var masterValue = 0 49 | private var masterValueOld = 0 50 | 51 | private var singleLedFileLocation = "" 52 | private var brightnessMax: Int = 0 53 | 54 | private var masterProgress = 1 55 | 56 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, 57 | savedInstanceState: Bundle?): View? { 58 | // Inflate the layout for this fragment 59 | val view = inflater.inflate(layout.fragment_single_knob, container, false) 60 | 61 | val masterCroller: Croller = view.findViewById(R.id.masterCroller) 62 | val settingsButton: ImageButton = view.findViewById(R.id.settingsButton) 63 | 64 | // get default preference 65 | val prefs = context?.defaultSharedPreferences 66 | 67 | prefs?.let { 68 | // get torch file location 69 | singleLedFileLocation = prefs.getString(Constrains.PREF_SINGLE_FILE_LOCATION, null) 70 | 71 | doubleTapEnabled = prefs.getBoolean(Constrains.PREF_DOUBLE_TONE_ENABLED, true) 72 | 73 | // get max brightness 74 | brightnessMax = prefs.getInt("brightnessMax", 0) 75 | } 76 | 77 | settingsButton.setOnClickListener { 78 | val intent = Intent(context, SettingsActivity::class.java) 79 | startActivity(intent) 80 | } 81 | 82 | masterCroller.setOnCrollerChangeListener(object : OnCrollerChangeListener { 83 | 84 | override fun onProgressChanged(croller: Croller?, progress: Int) { 85 | 86 | if (progress != masterProgress) { 87 | if (progress == 1) { 88 | masterValue = 0 89 | } else { 90 | masterValue = (brightnessMax / 20) * (progress - 1) 91 | if (masterValue > brightnessMax) 92 | masterValue = brightnessMax 93 | } 94 | masterProgress = progress 95 | } 96 | } 97 | 98 | override fun onTap(croller: Croller?) { 99 | if (doubleTapEnabled) { 100 | if (masterSingleTap) { 101 | if (masterProgress > 1) 102 | masterCroller.progress = 1 103 | else 104 | masterCroller.progress = 20 105 | } 106 | masterSingleTap = true 107 | Handler().postDelayed({ masterSingleTap = false }, 300) 108 | } 109 | } 110 | 111 | override fun onStartTrackingTouch(croller: Croller?) { 112 | } 113 | 114 | override fun onStopTrackingTouch(croller: Croller?) { 115 | if (masterValue != masterValueOld) { 116 | controlLed(masterValue) 117 | masterValueOld = masterValue 118 | } 119 | } 120 | }) 121 | 122 | return view 123 | } 124 | 125 | private fun controlLed(singleLed: Int = 0) { 126 | 127 | if (singleLedFileLocation.isEmpty()) 128 | return 129 | val command: String = String.format(getString(R.string.cmd_echo), "0", singleLedFileLocation) + 130 | getString(R.string.cmd_sleep) + 131 | String.format(getString(R.string.cmd_echo), singleLed, singleLedFileLocation) 132 | return Utils.runCommand(command) 133 | } 134 | 135 | override fun onBackPressed() { 136 | if (doubleBackToExitPressedOnce) { 137 | 138 | val alertDialogBuilder = ProgressDialog.show(context, "Quit", "Please wait...") 139 | alertDialogBuilder.setCancelable(false) 140 | alertDialogBuilder.setProgressStyle(ProgressDialog.STYLE_SPINNER); 141 | alertDialogBuilder.show() 142 | 143 | controlLed(0) 144 | 145 | Handler().postDelayed({ 146 | alertDialogBuilder.dismiss() 147 | activity?.finishAffinity() 148 | }, 300) 149 | 150 | return 151 | } 152 | 153 | this.doubleBackToExitPressedOnce = true 154 | Toast.makeText(context, "Please click BACK again to exit", Toast.LENGTH_SHORT).show() 155 | 156 | Handler().postDelayed({ doubleBackToExitPressedOnce = false }, 2000) 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_three_knob.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 27 | 28 | 53 | 54 | 60 | 61 | 62 | 87 | 88 | 94 | 95 | 120 | 121 | 127 | 128 | 147 | 148 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /app/src/main/java/com/teamdarkness/godlytorch/Fragment/IncompatibleFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Godly Torch. 3 | * 4 | * Godly Torch is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Godly Torch is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Godly Torch. If not, see . 16 | */ 17 | 18 | package com.teamdarkness.godlytorch.Fragment 19 | 20 | 21 | import android.app.AlertDialog 22 | import android.content.ActivityNotFoundException 23 | import android.os.Bundle 24 | import android.os.Handler 25 | import android.support.v4.app.Fragment 26 | import android.view.LayoutInflater 27 | import android.view.View 28 | import android.view.ViewGroup 29 | import android.widget.Button 30 | import android.widget.TextView 31 | import android.widget.Toast 32 | 33 | import com.teamdarkness.godlytorch.R 34 | import com.teamdarkness.godlytorch.Utils.OnFragmentBackPressListener 35 | import com.teamdarkness.godlytorch.Utils.Utils.fromHtml 36 | import com.teamdarkness.godlytorch.Utils.Utils.getDeviceId 37 | import com.teamdarkness.godlytorch.Utils.Utils.getDeviceName 38 | import android.content.Intent 39 | import android.net.Uri 40 | import android.support.constraint.ConstraintLayout 41 | import android.support.design.widget.Snackbar 42 | import android.support.v7.widget.LinearLayoutManager 43 | import android.support.v7.widget.RecyclerView 44 | import com.teamdarkness.godlytorch.Settings.DeviceListAdapter 45 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_IS_DUAL_TONE 46 | import com.teamdarkness.godlytorch.Utils.Constrains.PREF_SELECTED_DEVICE 47 | import com.teamdarkness.godlytorch.Utils.Utils 48 | import com.teamdarkness.godlytorch.Utils.Utils.getDeviceNameById 49 | import com.teamdarkness.godlytorch.Utils.Utils.getSystemProp 50 | import org.jetbrains.anko.defaultSharedPreferences 51 | 52 | 53 | class IncompatibleFragment : Fragment(), OnFragmentBackPressListener { 54 | 55 | private var doubleBackToExitPressedOnce = false 56 | 57 | private lateinit var root: ConstraintLayout 58 | 59 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, 60 | savedInstanceState: Bundle?): View? { 61 | // Inflate the layout for this fragment 62 | val view = inflater.inflate(R.layout.fragment_incompatible, container, false) 63 | 64 | val incompatibleText: TextView = view.findViewById(R.id.incompatibleText) 65 | val contactButton: Button = view.findViewById(R.id.contactButton) 66 | val btnSelectDevice: Button = view.findViewById(R.id.btnSelectDevice) 67 | val btnApplyDevice: Button = view.findViewById(R.id.btnApplyDevice) 68 | val deviceName: TextView = view.findViewById(R.id.deviceName) 69 | root = view.findViewById(R.id.root) 70 | 71 | val prefs = context?.defaultSharedPreferences 72 | 73 | contactButton.setOnClickListener { 74 | val colors = arrayOf("Fill up Google form", "Join Telegram Community") 75 | 76 | val builder = AlertDialog.Builder(context) 77 | builder.setTitle(R.string.contact_us) 78 | builder.setItems(colors) { dialog, which -> 79 | when (which) { 80 | 0 -> { 81 | openLink("https://goo.gl/forms/JnbCfWDh6Q0Yrwy83") 82 | } 83 | 1 -> { 84 | openLink("https://t.me/DNDofficial") 85 | } 86 | } 87 | dialog.dismiss() 88 | } 89 | builder.show() 90 | } 91 | 92 | btnSelectDevice.setOnClickListener { 93 | val builder = AlertDialog.Builder(context) 94 | builder.setTitle("Choose device") 95 | val deviceView = RecyclerView(it.context) 96 | deviceView.layoutManager = LinearLayoutManager(context) 97 | deviceView.adapter = DeviceListAdapter(context) 98 | builder.setView(deviceView) 99 | builder.setNegativeButton("Cancel") { dialogInterface, _ -> 100 | dialogInterface.dismiss() 101 | } 102 | builder.setPositiveButton("Select") { dialogInterface, _ -> 103 | dialogInterface.dismiss() 104 | val selectedDevice = prefs?.getString(PREF_SELECTED_DEVICE, "") 105 | deviceName.text = getDeviceNameById(selectedDevice) 106 | } 107 | builder.show() 108 | } 109 | 110 | btnApplyDevice.setOnClickListener { 111 | val selectedDevice = prefs?.getString(PREF_SELECTED_DEVICE, "") 112 | 113 | selectedDevice?.let { 114 | if (selectedDevice.isNotEmpty()) 115 | launchKnobs() 116 | else { 117 | if (Utils.checkSupport(context)) { 118 | launchKnobs() 119 | } else { 120 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 121 | fragTransaction?.let { 122 | fragTransaction.replace(R.id.mainFrame, IncompatibleFragment()) 123 | fragTransaction.commit() 124 | } 125 | } 126 | } 127 | } 128 | } 129 | 130 | incompatibleText.text = fromHtml(String.format(getString(R.string.incompatible_message), "${getDeviceName()} (${getDeviceId()})")) 131 | 132 | return view 133 | } 134 | 135 | override fun onBackPressed() { 136 | if (doubleBackToExitPressedOnce) { 137 | activity?.finishAffinity() 138 | return 139 | } 140 | 141 | this.doubleBackToExitPressedOnce = true 142 | Toast.makeText(context, "Please click BACK again to exit", Toast.LENGTH_SHORT).show() 143 | 144 | Handler().postDelayed({ doubleBackToExitPressedOnce = false }, 2000) 145 | } 146 | 147 | private fun openLink(link: String) { 148 | val intent = Intent() 149 | intent.action = Intent.ACTION_VIEW 150 | intent.data = Uri.parse(link) 151 | try { 152 | startActivity(intent) 153 | } catch (e: ActivityNotFoundException) { 154 | Snackbar.make(root, "Please install a browser and try again", Snackbar.LENGTH_SHORT).show() 155 | } 156 | } 157 | 158 | private fun launchKnobs() { 159 | 160 | val prefs = context?.defaultSharedPreferences 161 | val isDualTone = prefs?.getBoolean(PREF_IS_DUAL_TONE, true) 162 | 163 | isDualTone?.let { 164 | if (isDualTone) { 165 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 166 | fragTransaction?.let { 167 | fragTransaction.replace(R.id.mainFrame, ThreeKnobFragment()) 168 | fragTransaction.commit() 169 | } 170 | } else { 171 | val fragTransaction = activity?.supportFragmentManager?.beginTransaction() 172 | fragTransaction?.let { 173 | fragTransaction.replace(R.id.mainFrame, SingleKnobFragment()) 174 | fragTransaction.commit() 175 | } 176 | } 177 | } 178 | } 179 | 180 | }// Required empty public constructor 181 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_incompatible.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 25 | 26 | 36 | 37 | 40 | 41 | 54 | 55 | 67 | 68 | 75 | 76 | 81 | 82 |