Skip to content

Commit

Permalink
Update v2.2-stable
Browse files Browse the repository at this point in the history
Added
  - Touch to pause splash screen for view inspection, lift to resume running next screen
  - Touch indicator in splash screen

Changes
  - Major UI changes
    - App text logo's position changed, now it is on top
    - Splash screen landscape layout
    - New splash screen colors added

Announcement
  - App is now in stable stage, only UI improvements and bug fixes will be done unless a new feature is highly necessary
  • Loading branch information
Hamza417 committed Nov 4, 2020
1 parent 4dfce33 commit a8baf94
Show file tree
Hide file tree
Showing 16 changed files with 576 additions and 88 deletions.
Binary file not shown.

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.

5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "app.simple.positional"
minSdkVersion 23
targetSdkVersion 29
versionCode 10
versionName "v2.1-beta"
versionCode 11
versionName "v2.2-stable"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -24,7 +24,6 @@ android {
}
full {
dimension "version"
versionNameSuffix "-full"
}
}

Expand Down
116 changes: 83 additions & 33 deletions app/src/main/java/app/simple/positional/activities/LauncherActivity.kt
Original file line number Diff line number Diff line change
@@ -1,64 +1,114 @@
package app.simple.positional.activities

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.*
import android.content.res.Configuration
import android.os.Bundle
import android.os.Handler
import android.view.MotionEvent
import android.view.View
import android.view.animation.AnimationUtils
import android.view.animation.DecelerateInterpolator
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import app.simple.positional.BuildConfig
import app.simple.positional.R
import app.simple.positional.constants.vectorBackground
import app.simple.positional.constants.vectorColors
import kotlinx.android.synthetic.main.launcher_activity.*
import app.simple.positional.util.addLinearGradient
import app.simple.positional.util.addRadialGradient
import app.simple.positional.util.getBitmapFromVectorDrawable
import kotlinx.android.synthetic.main.activity_launcher.*


class LauncherActivity : AppCompatActivity() {

private var randomValue: Int = 0
private val handler = Handler()
private var x = 20f
private var y = 20f
private var width: Int = 0
private var height: Int = 0

@SuppressLint("ClickableViewAccessibility")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.launcher_activity)
setContentView(R.layout.activity_launcher)

randomValue = (vectorBackground.indices).random()
if (BuildConfig.FLAVOR == "full") {
randomValue = (vectorBackground.indices).random()
} else {
randomValue = 5
}

launcher_background.setImageResource(vectorBackground[randomValue])
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
launcher_background.setImageResource(vectorBackground[randomValue])
}

launcher_icon.setImageBitmap(R.drawable.ic_place.getBitmapFromVectorDrawable()?.let { addGradient(it) })
touch_indicator.setImageBitmap(R.drawable.ic_touch_indicator.getBitmapFromVectorDrawable(context = baseContext)?.let { addRadialGradient(it, vectorColors[randomValue][1]) })

launcher_icon.setImageBitmap(R.drawable.ic_place.getBitmapFromVectorDrawable(context = baseContext)?.let { addLinearGradient(it, intArrayOf(vectorColors[randomValue][0], vectorColors[randomValue][1])) })

launcher_icon.startAnimation(AnimationUtils.loadAnimation(this, R.anim.launcher_icon))
launcher_text.startAnimation(AnimationUtils.loadAnimation(this, R.anim.image_in))

Handler().postDelayed({
val intent = Intent(this@LauncherActivity, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(intent)
this.finish()
}, 1500)
runPostDelayed(2000)

launcher_act.setOnTouchListener { _, event ->

when (event.action) {
MotionEvent.ACTION_DOWN -> {
touch_indicator.x = event.x - (touch_indicator.width / 2)
touch_indicator.y = event.y - (touch_indicator.height / 2)

touch_indicator.visibility = View.VISIBLE

touch_indicator.animate().scaleX(1.2f).scaleY(1.2f).alpha(1.0f).setInterpolator(DecelerateInterpolator()).start()

handler.removeCallbacksAndMessages(null)
}
MotionEvent.ACTION_MOVE -> {

println("${touch_indicator.x} : ${event.x}")

touch_indicator.x = event.x - (touch_indicator.width / 2f)
touch_indicator.y = event.y - (touch_indicator.height / 2f)
}
MotionEvent.ACTION_UP -> {
touch_indicator.animate().scaleX(0.5f).scaleY(0.5f).alpha(0f).start()
runPostDelayed(1000)
}
}

true
}
}

private fun runPostDelayed(delay: Long) {
handler.postDelayed({
/**
* [isDestroyed] and [isFinishing] will check if the activity is alive or not
* It is possible that the app could have been launched by accident and user might want
* to close it immediately, in such cases leaving the [Handler.postDelayed] in queue will
* explicitly execute the action in the background even if the activity is closed
* and this will run the [MainActivity] and we don't want that
*/
if (this.isDestroyed || this.isFinishing) return@postDelayed
runIntent()
}, delay)
}

private fun addGradient(originalBitmap: Bitmap): Bitmap? {
val width = originalBitmap.width
val height = originalBitmap.height
val updatedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(updatedBitmap)
canvas.drawBitmap(originalBitmap, 0f, 0f, null)
val paint = Paint()
val shader = LinearGradient(0f, 0f, 0f, height.toFloat(), vectorColors[randomValue][0], vectorColors[randomValue][1], Shader.TileMode.CLAMP)
paint.shader = shader
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
return updatedBitmap
private fun runIntent() {
val intent = Intent(this@LauncherActivity, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(intent)
this@LauncherActivity.finish()
}

private fun Int.getBitmapFromVectorDrawable(): Bitmap? {
val drawable = ContextCompat.getDrawable(this@LauncherActivity, this)
val bitmap = Bitmap.createBitmap(400,
400, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
drawable?.setBounds(0, 0, canvas.width, canvas.height)
drawable?.draw(canvas)
return bitmap
override fun onDestroy() {
super.onDestroy()
// Preventing memory leaks although insignificant but important for precaution
launcher_icon.clearAnimation()
launcher_text.clearAnimation()
handler.removeCallbacksAndMessages(null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ val vectorBackground = arrayOf(
R.drawable.launcher_background_four,
R.drawable.launcher_background_five,
R.drawable.launcher_background_six,
R.drawable.launcher_background_seven
R.drawable.launcher_background_seven,
R.drawable.launcher_background_eight
)

val vectorColors: Array<Array<Int>> = arrayOf(
arrayOf(parseColor("#F6E58D"), parseColor("#E056FD")),
arrayOf(parseColor("#FFD71D"), parseColor("#804700")),
arrayOf(parseColor("#aa8659"), parseColor("#aa8659")),
arrayOf(parseColor("#9d56a0"), parseColor("#246887")),
arrayOf(parseColor("#DE542A"), parseColor("#BA2D0A")),
arrayOf(parseColor("#52618c"), parseColor("#6b8ea9")),
arrayOf(parseColor("#434E94"), parseColor("#081146"))
arrayOf(parseColor("#FFF6E58D"), parseColor("#FFE056FD")),
arrayOf(parseColor("#FFFFD71D"), parseColor("#FF804700")),
arrayOf(parseColor("#FFaa8659"), parseColor("#FFaa8659")),
arrayOf(parseColor("#FF9d56a0"), parseColor("#FF246887")),
arrayOf(parseColor("#FFDE542A"), parseColor("#FFBA2D0A")),
arrayOf(parseColor("#FF52618c"), parseColor("#FF6b8ea9")),
arrayOf(parseColor("#FF434E94"), parseColor("#FF081146")),
arrayOf(parseColor("#FFDE7E42"), parseColor("#FFBF5047"))
)

fun parseColor(value: String): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class ClockPreferences {
}

fun getClockFaceTheme(context: Context): Int {
return context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getInt(clockFace, 1)
return context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getInt(clockFace, 12)
}

fun setClockNeedleTheme(value: Int, context: Context) {
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).edit().putInt(clockNeedle, value).apply()
}

fun getClockNeedleTheme(context: Context): Int {
return context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getInt(clockNeedle, 0)
return context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getInt(clockNeedle, 1)
}

fun getSkins(context: Context): IntArray {
Expand Down
24 changes: 21 additions & 3 deletions app/src/main/java/app/simple/positional/ui/AppSettings.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.simple.positional.ui

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand All @@ -16,6 +17,7 @@ import app.simple.positional.preference.MainPreferences
import app.simple.positional.theme.setTheme
import com.github.zawadz88.materialpopupmenu.popupMenu
import kotlinx.android.synthetic.main.frag_settings.*
import kotlinx.android.synthetic.main.frag_settings.view.*


class AppSettings : Fragment() {
Expand All @@ -37,7 +39,7 @@ class AppSettings : Fragment() {
fullVersion = view.findViewById(R.id.buy_full)

if (BuildConfig.FLAVOR == "lite") {
buy_full.visibility = View.VISIBLE
view.buy_full.visibility = View.VISIBLE
}

setCurrentThemeValue(MainPreferences().getCurrentTheme(requireContext()))
Expand Down Expand Up @@ -111,16 +113,32 @@ class AppSettings : Fragment() {
}

github.setOnClickListener {
val uri: Uri = Uri.parse("https://github.com/Hamza417/Positional") // missing 'https://' will cause crash
val uri: Uri = Uri.parse("https://github.com/Hamza417/Positional")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}

found_issues.setOnClickListener {
val uri: Uri = Uri.parse("https://github.com/Hamza417/Positional/issues/new") // missing 'https://' will cause crash
val uri: Uri = Uri.parse("https://github.com/Hamza417/Positional/issues/new")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}

buy_full.setOnClickListener {
val uri: Uri = Uri.parse("market://details?id=app.simple.positional")
val goToMarket = Intent(Intent.ACTION_VIEW, uri)
// To count with Play market back stack, After pressing back button,
// to taken back to our application, we need to add following flags to intent.
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or
Intent.FLAG_ACTIVITY_NEW_DOCUMENT or
Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
try {
startActivity(goToMarket)
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=app.simple.positional")))
}
}
}

private fun setCurrentThemeValue(themeValue: Int) {
Expand Down
33 changes: 18 additions & 15 deletions app/src/main/java/app/simple/positional/ui/Clock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import app.simple.positional.BuildConfig
import app.simple.positional.R
import app.simple.positional.callbacks.BottomSheetSlide
import app.simple.positional.constants.faces
Expand Down Expand Up @@ -215,22 +216,24 @@ class Clock : Fragment() {
val popupMenu = popupMenu {
style = R.style.popupMenu
dropdownGravity = Gravity.END
section {
title = "Appearances"
item {
label = "Face"
hasNestedItems = true
icon = R.drawable.ic_minimal
callback = {
Face().faceSkinsOptions(context = requireContext(), clock = this@Clock)
if (BuildConfig.FLAVOR == "full") {
section {
title = "Appearances"
item {
label = "Face"
hasNestedItems = true
icon = R.drawable.ic_minimal
callback = {
Face().faceSkinsOptions(context = requireContext(), clock = this@Clock)
}
}
}
item {
label = "Needle"
hasNestedItems = true
icon = R.drawable.ic_clock_needle
callback = {
Needle().openNeedleMenu(context = requireContext(), clock = this@Clock)
item {
label = "Needle"
hasNestedItems = true
icon = R.drawable.ic_clock_needle
callback = {
Needle().openNeedleMenu(context = requireContext(), clock = this@Clock)
}
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/app/simple/positional/util/BitmapGradient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package app.simple.positional.util

import android.graphics.*

fun addLinearGradient(originalBitmap: Bitmap, array: IntArray): Bitmap? {
val width = originalBitmap.width
val height = originalBitmap.height
val updatedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(updatedBitmap)
canvas.drawBitmap(originalBitmap, 0f, 0f, null)
val paint = Paint()
val shader = LinearGradient(0f, 0f, 0f, height.toFloat(), array[0], array[1], Shader.TileMode.CLAMP)
paint.shader = shader
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
return updatedBitmap
}

fun addRadialGradient(originalBitmap: Bitmap, int: Int): Bitmap? {
val width = originalBitmap.width
val height = originalBitmap.height
val updatedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(updatedBitmap)
canvas.drawBitmap(originalBitmap, 0f, 0f, null)
val paint = Paint()
val shader = RadialGradient(200f, 200f, 200f, 0x000000, int, Shader.TileMode.CLAMP)
paint.shader = shader
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
return updatedBitmap
}
Loading

0 comments on commit a8baf94

Please sign in to comment.