From 01798ad5c5f088e49484f6bf321655ef349d1461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 2 Oct 2019 20:05:18 +0200 Subject: [PATCH] Some Android Styling --- android/app/build.gradle | 3 +- android/app/src/main/AndroidManifest.xml | 5 +- .../{MainActivity.kt => TestStartActivity.kt} | 48 +++++++++++++++- .../com/metallic/chiaki/main/MainActivity.kt | 43 ++++++++++++++ .../com/metallic/chiaki/main/MainViewModel.kt | 25 +++++++++ android/app/src/main/res/drawable/ic_add.xml | 9 +++ .../app/src/main/res/layout/activity_main.xml | 53 ++++-------------- .../main/res/layout/activity_test_start.xml | 56 +++++++++++++++++++ android/app/src/main/res/values/styles.xml | 7 +++ 9 files changed, 202 insertions(+), 47 deletions(-) rename android/app/src/main/java/com/metallic/chiaki/{MainActivity.kt => TestStartActivity.kt} (61%) create mode 100644 android/app/src/main/java/com/metallic/chiaki/main/MainActivity.kt create mode 100644 android/app/src/main/java/com/metallic/chiaki/main/MainViewModel.kt create mode 100644 android/app/src/main/res/drawable/ic_add.xml create mode 100644 android/app/src/main/res/layout/activity_test_start.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index 4a3dc4f..5936c21 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -49,7 +49,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0" } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 660cb2d..bca0080 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - + @@ -25,6 +25,9 @@ android:theme="@style/StreamTheme" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="userLandscape"/> + + \ No newline at end of file diff --git a/android/app/src/main/java/com/metallic/chiaki/MainActivity.kt b/android/app/src/main/java/com/metallic/chiaki/TestStartActivity.kt similarity index 61% rename from android/app/src/main/java/com/metallic/chiaki/MainActivity.kt rename to android/app/src/main/java/com/metallic/chiaki/TestStartActivity.kt index e1913b3..5bb3849 100644 --- a/android/app/src/main/java/com/metallic/chiaki/MainActivity.kt +++ b/android/app/src/main/java/com/metallic/chiaki/TestStartActivity.kt @@ -22,18 +22,60 @@ import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Base64 +import android.view.View +import android.view.ViewAnimationUtils +import android.view.ViewTreeObserver +import android.view.animation.AccelerateInterpolator import androidx.core.content.edit import androidx.core.widget.addTextChangedListener import com.metallic.chiaki.lib.* import com.metallic.chiaki.stream.StreamActivity -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.activity_test_start.* +import kotlin.math.max -class MainActivity : AppCompatActivity() +class TestStartActivity : AppCompatActivity() { + companion object + { + const val EXTRA_REVEAL_X = "reveal_x" + const val EXTRA_REVEAL_Y = "reveal_y" + } + + private fun revealActivity(x: Float, y: Float) + { + val finalRadius = max(rootLayout.width, rootLayout.height).toFloat() + val reveal = ViewAnimationUtils.createCircularReveal(rootLayout, x.toInt(), y.toInt(), 0f, finalRadius) + reveal.interpolator = AccelerateInterpolator() + rootLayout.visibility = View.VISIBLE + reveal.start() + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + setContentView(R.layout.activity_test_start) + + window.setBackgroundDrawableResource(android.R.color.transparent) + + if(intent.hasExtra(EXTRA_REVEAL_X) && intent.hasExtra(EXTRA_REVEAL_Y)) + { + val revealX = intent.getFloatExtra(EXTRA_REVEAL_X, 0.0f) + val revealY = intent.getFloatExtra(EXTRA_REVEAL_Y, 0.0f) + rootLayout.visibility = View.INVISIBLE + + rootLayout.viewTreeObserver.also { + if(it.isAlive) + { + it.addOnGlobalLayoutListener(object: ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() + { + revealActivity(revealX, revealY) + rootLayout.viewTreeObserver.removeOnGlobalLayoutListener(this) + } + }) + } + } + } val prefs = getPreferences(Context.MODE_PRIVATE) diff --git a/android/app/src/main/java/com/metallic/chiaki/main/MainActivity.kt b/android/app/src/main/java/com/metallic/chiaki/main/MainActivity.kt new file mode 100644 index 0000000..4311b3c --- /dev/null +++ b/android/app/src/main/java/com/metallic/chiaki/main/MainActivity.kt @@ -0,0 +1,43 @@ +/* + * This file is part of Chiaki. + * + * Chiaki is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Chiaki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chiaki. If not, see . + */ + +package com.metallic.chiaki.main + +import android.app.ActivityOptions +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import com.metallic.chiaki.R +import com.metallic.chiaki.TestStartActivity +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : AppCompatActivity() +{ + override fun onCreate(savedInstanceState: Bundle?) + { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + addButton.setOnClickListener { + Intent(this, TestStartActivity::class.java).also { + it.putExtra(TestStartActivity.EXTRA_REVEAL_X, addButton.x + addButton.width * 0.5f) + it.putExtra(TestStartActivity.EXTRA_REVEAL_Y, addButton.y + addButton.height * 0.5f) + startActivity(it, ActivityOptions.makeSceneTransitionAnimation(this).toBundle()) + } + } + } +} diff --git a/android/app/src/main/java/com/metallic/chiaki/main/MainViewModel.kt b/android/app/src/main/java/com/metallic/chiaki/main/MainViewModel.kt new file mode 100644 index 0000000..cd9ee39 --- /dev/null +++ b/android/app/src/main/java/com/metallic/chiaki/main/MainViewModel.kt @@ -0,0 +1,25 @@ +/* + * This file is part of Chiaki. + * + * Chiaki is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Chiaki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chiaki. If not, see . + */ + +package com.metallic.chiaki.main + +import androidx.lifecycle.ViewModel + +class MainViewModel: ViewModel() +{ + +} \ No newline at end of file diff --git a/android/app/src/main/res/drawable/ic_add.xml b/android/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 0000000..0258249 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,9 @@ + + + diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index 7e350d7..a6810b2 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -1,54 +1,23 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + tools:context=".main.MainActivity"> - + - - - - - -