Skip to content

Commit

Permalink
Update: Added animation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
soheilkd committed Oct 7, 2019
1 parent 2404a8f commit cf62cc3
Show file tree
Hide file tree
Showing 46 changed files with 438 additions and 266 deletions.
1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ android {
}
}
compileSdkVersion 29
buildToolsVersion "29.0.0"
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "soheilkd.BurninWiper"
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 29
versionCode 18
versionName "1.07.1"
versionCode 24
versionName "1.1"
}
buildTypes {
release {
Expand All @@ -35,11 +35,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'com.android.billingclient:billing:2.0.1'
implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.preference:preference:1.1.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
implementation 'com.google.android.material:material:1.1.0-alpha10'
}
30 changes: 19 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="soheilkd.BurninWiper">
xmlns:tools="http://schemas.android.com/tools"
package="soheilkd.BurninWiper">

<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -12,28 +14,34 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".AnimActivity"
android:label="@string/title_activity_anim"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".DonationActivity"
android:label="@string/title_activity_donation"
android:theme="@style/Theme.AppCompat"
android:label="@string/title_activity_donation">
</activity>
android:screenOrientation="portrait" />
<activity
android:name=".ColorActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_color"
android:theme="@style/FullscreenTheme">
</activity>
android:screenOrientation="portrait"
android:theme="@style/FullscreenTheme" />
</application>

</manifest>
68 changes: 68 additions & 0 deletions app/src/main/java/soheilkd/burninwiper/AnimActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package soheilkd.BurninWiper

import android.os.Bundle
import android.os.SystemClock
import android.util.DisplayMetrics
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

import kotlinx.android.synthetic.main.activity_anim.*
import pl.droidsonroids.gif.GifImageView
import kotlin.math.roundToInt

class AnimActivity : AppCompatActivity() {
private val gifViews = arrayListOf<GifImageView>()
private val gifs = arrayOf(
R.drawable.gif_0,
R.drawable.gif_1,
R.drawable.gif_2,
R.drawable.gif_3,
R.drawable.gif_4,
R.drawable.gif_5,
R.drawable.gif_6,
R.drawable.gif_7
)
private var animThread = Thread(Runnable {
while (true) {
for (gif in gifs) {
for (view in gifViews) {
runOnUiThread { view.setImageResource(gif) }
}
SystemClock.sleep(20000)
}
}
})

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_anim)
anim_grid.setOnClickListener { finish() }

Helper.makeImmersive(window, anim_grid)
if (intent.getBooleanExtra("IsChecking", false))
return
loadViews()
animThread.start()
Helper.setTimer(intent.getIntExtra("TimerIndex", 0)) { finish() }
Toast.makeText(this, "Cautious: Device may heat up after a while", Toast.LENGTH_LONG).show()
}

private fun loadViews() {
val metrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(metrics)

anim_grid.columnCount = (metrics.widthPixels / metrics.density / 75).roundToInt() + 1
anim_grid.rowCount = (metrics.heightPixels / metrics.density / 75).roundToInt() + 1
val dps = (75 * metrics.scaledDensity + 0.5f).toInt()
for (i in 0..anim_grid.columnCount * anim_grid.rowCount) {
val view = GifImageView(this)
view.layoutParams = ViewGroup.LayoutParams(dps, dps)
view.setOnClickListener { finish() }
gifViews.add(view)
}
for (view in gifViews) {
anim_grid.addView(view)
}
}
}
100 changes: 26 additions & 74 deletions app/src/main/java/soheilkd/burninwiper/ColorActivity.kt
Original file line number Diff line number Diff line change
@@ -1,109 +1,61 @@
package soheilkd.BurninWiper

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.AsyncTask
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.SystemClock
import android.util.Log
import androidx.preference.PreferenceManager
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_color.*
import java.util.*
import kotlin.concurrent.timerTask

class ColorActivity : AppCompatActivity() {
private var currentColors: Array<ColorDrawable> = arrayOf()
private var shutdownTimer = Timer()
private var colorThread = Thread(Runnable {
while(true){
for(color in currentColors){
runOnUiThread { ColorFrameLayout.background = color }
runOnUiThread { color_layout.background = color }
SystemClock.sleep(1250)
}
}
})

private fun getColorArrayById(id: Int): Array<ColorDrawable>{
return when (id){
R.id.modeRadioButton1 -> getColorArray(0)
R.id.modeRadioButton2 -> getColorArray(1)
R.id.modeRadioButton3 -> getColorArray(2)
else -> getColorArray(-1)
}
}
private fun getColorArray(index: Int): Array<ColorDrawable>{
val white by lazy { ColorDrawable(Color.WHITE) }
val red by lazy { ColorDrawable(Color.RED) }
val green by lazy { ColorDrawable(Color.GREEN) }
val blue by lazy { ColorDrawable(Color.BLUE) }
val black by lazy { ColorDrawable(Color.BLACK) }
val gray by lazy { ColorDrawable(Color.DKGRAY) }

return when (index){
0 -> arrayOf(white, red, green, blue, black)
1 -> arrayOf(white, black)
2 -> arrayOf(white)
else -> arrayOf(gray)
}
}

private fun start(){
makeAppImmersive()
Helper.makeImmersive(window, color_layout)
applyPreferences()
colorThread.start()
}
private fun makeAppImmersive(){
window.setFlags(128, 128)
ColorFrameLayout.systemUiVisibility =
View.SYSTEM_UI_FLAG_LOW_PROFILE or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

//Check if application is launched by app shortcuts
private fun checkFromShortcut(): Boolean {
if (intent.action?.startsWith("soheilkd.BurninWiper.") == true) {
currentColors = Helper.getColorArray(
when (intent.action?.takeLast(4)) {
"run1" -> 0
"run2" -> 1
"run3" -> 2
else -> -1
}
)
return true
}
return false
}

private fun applyPreferences(){
if (intent.getBooleanExtra("burninwiper.ischecking", false)){
currentColors = getColorArray(-1)
if (intent.getBooleanExtra("IsChecking", false)) {
currentColors = Helper.getColorArray(-1)
return
}
//The comparisions to true are for casting the Boolean? expressions to Boolean
if (intent.action?.startsWith("soheilkd.BurninWiper.") == true){
if (intent.action?.endsWith("runfirstmode") == true)
currentColors = getColorArray(0)
else if (intent.action?.endsWith("runsecondmode") == true)
currentColors = getColorArray(1)
else
currentColors = getColorArray(2)
}
if (currentColors.count() == 0)
currentColors = getColorArrayById(intent.getIntExtra("burninwiper.colormode", 0))
setShutdownTimer(intent.getIntExtra("burninwiper.timerindex", 0))
}
private fun setShutdownTimer(index: Int){
val timerTask = timerTask {
finish()
}
fun minToMs(m: Int): Long {return m*60L*1000}
when(index) {
1 -> shutdownTimer.schedule(timerTask, minToMs(5))
2 -> shutdownTimer.schedule(timerTask, minToMs(10))
3 -> shutdownTimer.schedule(timerTask, minToMs(20))
4 -> shutdownTimer.schedule(timerTask, minToMs(30))
5 -> shutdownTimer.schedule(timerTask, minToMs(60))
6 -> shutdownTimer.schedule(timerTask, minToMs(120))
7 -> shutdownTimer.schedule(timerTask, minToMs(180))
}
if (!checkFromShortcut())
currentColors = Helper.getColorArrayById(intent.getIntExtra("ColorMode", 0))

Helper.setTimer(intent.getIntExtra("TimerIndex", 0)) { finish() }
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_color)

ColorFrameLayout.setOnTouchListener{ _, _ ->
color_layout.setOnTouchListener { _, _ ->
finish()
true
}
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/java/soheilkd/burninwiper/DonationActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package soheilkd.BurninWiper

import android.annotation.SuppressLint
import android.os.Bundle
import android.util.TypedValue
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.android.billingclient.api.*

import kotlinx.android.synthetic.main.activity_donation.*
import kotlin.collections.ArrayList
import android.util.TypedValue


class DonationActivity : AppCompatActivity(), PurchasesUpdatedListener {
Expand Down Expand Up @@ -63,7 +61,6 @@ class DonationActivity : AppCompatActivity(), PurchasesUpdatedListener {
skuList.add("soheilkd.burninwiper.donation3")
skuList.add("soheilkd.burninwiper.donation4")
skuList.add("soheilkd.burninwiper.donation5")
skuList.add("soheilkd.burninwiper.donation6")
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP)
var i = 0
Expand All @@ -77,7 +74,7 @@ class DonationActivity : AppCompatActivity(), PurchasesUpdatedListener {
listOfSkuDetails = skuDetailsList
for (sku in skuDetailsList) {
val index = i++
MainLinearLayout.addView(
donation_layout.addView(
Button(this@DonationActivity).also { button ->
run {
val r = resources
Expand All @@ -89,10 +86,11 @@ class DonationActivity : AppCompatActivity(), PurchasesUpdatedListener {

button.layoutParams =
LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, px.toInt())
button.text = "${sku.priceCurrencyCode}${sku.price}"

button.text = "${sku.description} for ${sku.price}"
px = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
8f,
5f,
r.displayMetrics
)
button.textSize = px
Expand All @@ -110,13 +108,21 @@ class DonationActivity : AppCompatActivity(), PurchasesUpdatedListener {
}

override fun onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
Toast.makeText(
this@DonationActivity,
"Billing Service Disconnected",
Toast.LENGTH_LONG
).show()
finish()
}
})
}
catch (e: Exception) {
Toast.makeText(this@DonationActivity, "Connection To Playstore Billing Failed", Toast.LENGTH_LONG).show()
Toast.makeText(
this@DonationActivity,
"Connection To Play Store Billing Failed",
Toast.LENGTH_LONG
).show()
finish()
}
}
Expand Down
Loading

0 comments on commit cf62cc3

Please sign in to comment.