-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
|
||
android { | ||
namespace 'com.pdb82.flashlighttiramisu' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.pdb82.flashlighttiramisu" | ||
minSdk 33 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'com.google.android.material:material:1.7.0-alpha03' | ||
|
||
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.2' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "com.pdb82.flashlighttiramisu", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.pdb82.flashlighttiramisu | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.pdb82.flashlighttiramisu", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-feature android:name="android.hardware.camera.flash" /> | ||
|
||
<application android:name=".DynamicColor" | ||
android:enableOnBackInvokedCallback="true" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:targetApi="33"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<service | ||
android:name=".MyTileService" | ||
android:enabled="true" | ||
android:label="Brightness control" | ||
android:icon="@drawable/baseline_highlight_24" | ||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.service.quicksettings.action.QS_TILE" /> | ||
</intent-filter> | ||
</service> | ||
|
||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.pdb82.flashlighttiramisu | ||
|
||
import android.app.Application | ||
import com.google.android.material.color.DynamicColors | ||
|
||
class DynamicColor : Application() { | ||
override fun onCreate() { | ||
DynamicColors.applyToActivitiesIfAvailable(this) | ||
super.onCreate() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.pdb82.flashlighttiramisu | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.graphics.Color | ||
import android.hardware.camera2.CameraAccessException | ||
import android.hardware.camera2.CameraCharacteristics | ||
import android.hardware.camera2.CameraManager | ||
import android.hardware.camera2.CameraMetadata | ||
import android.net.Uri | ||
import android.os.Build | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.View | ||
import android.widget.Button | ||
import android.widget.SeekBar | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import androidx.cardview.widget.CardView | ||
import androidx.core.view.WindowCompat | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private val cameraManager by lazy { getSystemService(Context.CAMERA_SERVICE) as CameraManager } | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
window.statusBarColor = Color.TRANSPARENT | ||
|
||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val seekBar = findViewById<SeekBar>(R.id.seekBar) | ||
val errorText = findViewById<TextView>(R.id.textView) | ||
val card = findViewById<CardView>(R.id.card) | ||
|
||
val list = cameraManager.cameraIdList | ||
val outCameraId = list[0] | ||
val cameraCharacteristics = cameraManager.getCameraCharacteristics(outCameraId) | ||
|
||
val torchMaxLevel = | ||
cameraCharacteristics[CameraCharacteristics.FLASH_INFO_STRENGTH_MAXIMUM_LEVEL] ?: -1 | ||
|
||
if (torchMaxLevel > 1) { | ||
seekBar.max = torchMaxLevel | ||
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { | ||
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) { | ||
if (p1 == 0) { | ||
cameraManager.setTorchMode(outCameraId, false) | ||
} else { | ||
cameraManager.turnOnTorchWithStrengthLevel(outCameraId, p1) | ||
} | ||
} | ||
|
||
override fun onStartTrackingTouch(p0: SeekBar?) { | ||
} | ||
|
||
override fun onStopTrackingTouch(p0: SeekBar?) { | ||
} | ||
}) | ||
} else { | ||
errorText.visibility = View.VISIBLE | ||
card.visibility = View.VISIBLE | ||
errorText.text = "Device not supported" | ||
seekBar.isEnabled = false | ||
} | ||
|
||
|
||
val button_en = findViewById<Button>(R.id.button) | ||
val button_ru = findViewById<Button>(R.id.button2) | ||
|
||
val url_en = "https://t.me/google_nws" | ||
val url_ru = "https://t.me/googlenws_ru" | ||
|
||
val link_en = Intent(Intent.ACTION_VIEW, Uri.parse(url_en)) | ||
val link_ru = Intent(Intent.ACTION_VIEW, Uri.parse(url_ru)) | ||
|
||
button_en.setOnClickListener { | ||
startActivity(link_en) | ||
} | ||
|
||
button_ru.setOnClickListener { | ||
startActivity(link_ru) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.pdb82.flashlighttiramisu | ||
|
||
import android.content.Intent | ||
import android.service.quicksettings.TileService | ||
|
||
class MyTileService : TileService() { | ||
override fun onClick() { | ||
super.onClick() | ||
val launchIntent = packageManager.getLaunchIntentForPackage(packageName) | ||
startActivityAndCollapse(launchIntent) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M6,14l3,3v5h6v-5l3,-3V9H6V14zM11,2h2v3h-2V2zM3.5,5.88l1.41,-1.41l2.12,2.12L5.62,8L3.5,5.88zM16.96,6.59l2.12,-2.12l1.41,1.41L18.38,8L16.96,6.59z"/> | ||
</vector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#000000"> | ||
<group android:scaleX="0.551" | ||
android:scaleY="0.551" | ||
android:translateX="5.388" | ||
android:translateY="5.388"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M6,14l3,3v5h6v-5l3,-3V9H6V14zM11,2h2v3h-2V2zM3.5,5.88l1.41,-1.41l2.12,2.12L5.62,8L3.5,5.88zM16.96,6.59l2.12,-2.12l1.41,1.41L18.38,8L16.96,6.59z"/> | ||
</group> | ||
</vector> |