mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Stub RegistActivity to Android
This commit is contained in:
parent
5fab5b9f05
commit
b11bc55d9f
8 changed files with 166 additions and 53 deletions
|
@ -30,8 +30,15 @@
|
|||
<activity
|
||||
android:name=".settings.SettingsActivity" />
|
||||
|
||||
<activity android:name=".TestStartActivity"
|
||||
android:theme="@style/MageTheme"/>
|
||||
<activity
|
||||
android:name=".TestStartActivity"
|
||||
android:theme="@style/MageTheme"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
<activity
|
||||
android:name=".regist.RegistActivity"
|
||||
android:theme="@style/MageTheme"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -19,63 +19,30 @@ package com.metallic.chiaki
|
|||
|
||||
import android.content.Context
|
||||
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 android.view.Window
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import com.metallic.chiaki.lib.*
|
||||
import com.metallic.chiaki.common.ext.RevealActivity
|
||||
import com.metallic.chiaki.lib.ConnectInfo
|
||||
import com.metallic.chiaki.lib.ConnectVideoProfile
|
||||
import com.metallic.chiaki.stream.StreamActivity
|
||||
import kotlinx.android.synthetic.main.activity_test_start.*
|
||||
import kotlin.math.max
|
||||
|
||||
class TestStartActivity : AppCompatActivity()
|
||||
class TestStartActivity : AppCompatActivity(), RevealActivity
|
||||
{
|
||||
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 val revealIntent: Intent get() = intent
|
||||
override val revealRootLayout: View get() = rootLayout
|
||||
override val revealWindow: Window get() = window
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?)
|
||||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
handleReveal()
|
||||
|
||||
val prefs = getPreferences(Context.MODE_PRIVATE)
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.metallic.chiaki.common.ext
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.view.*
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import kotlin.math.max
|
||||
|
||||
interface RevealActivity
|
||||
{
|
||||
companion object
|
||||
{
|
||||
const val EXTRA_REVEAL_X = "reveal_x"
|
||||
const val EXTRA_REVEAL_Y = "reveal_y"
|
||||
}
|
||||
|
||||
val revealRootLayout: View
|
||||
val revealIntent: Intent
|
||||
val revealWindow: Window
|
||||
|
||||
private fun revealActivity(x: Int, y: Int)
|
||||
{
|
||||
val finalRadius = max(revealRootLayout.width, revealRootLayout.height).toFloat()
|
||||
val reveal = ViewAnimationUtils.createCircularReveal(revealRootLayout, x, y, 0f, finalRadius)
|
||||
reveal.interpolator = AccelerateInterpolator()
|
||||
revealRootLayout.visibility = View.VISIBLE
|
||||
reveal.start()
|
||||
}
|
||||
|
||||
fun handleReveal()
|
||||
{
|
||||
if(!revealIntent.hasExtra(EXTRA_REVEAL_X) || !revealIntent.hasExtra(EXTRA_REVEAL_Y))
|
||||
return
|
||||
revealWindow.setBackgroundDrawableResource(android.R.color.transparent)
|
||||
val revealX = revealIntent.getIntExtra(EXTRA_REVEAL_X, 0)
|
||||
val revealY = revealIntent.getIntExtra(EXTRA_REVEAL_Y, 0)
|
||||
revealRootLayout.visibility = View.INVISIBLE
|
||||
|
||||
revealRootLayout.viewTreeObserver.also {
|
||||
if(it.isAlive)
|
||||
{
|
||||
it.addOnGlobalLayoutListener(object: ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout()
|
||||
{
|
||||
revealActivity(revealX, revealY)
|
||||
revealRootLayout.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Intent.putRevealExtra(originView: View, rootLayout: ViewGroup)
|
||||
{
|
||||
val offsetRect = Rect()
|
||||
originView.getDrawingRect(offsetRect)
|
||||
rootLayout.offsetDescendantRectToMyCoords(originView, offsetRect)
|
||||
putExtra(RevealActivity.EXTRA_REVEAL_X, offsetRect.left)
|
||||
putExtra(RevealActivity.EXTRA_REVEAL_Y, offsetRect.top)
|
||||
}
|
|
@ -37,6 +37,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|||
import com.google.android.material.transformation.ExpandableTransformationBehavior
|
||||
import com.metallic.chiaki.R
|
||||
|
||||
// see https://github.com/lcdsmao/ExpandableFABExample
|
||||
|
||||
class FloatingActionButtonSpeedDialBehavior @JvmOverloads constructor(context: Context? = null, attrs: AttributeSet? = null) : ExpandableTransformationBehavior(context, attrs)
|
||||
{
|
||||
companion object
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.app.ActivityOptions
|
|||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
|
@ -30,12 +29,14 @@ import androidx.lifecycle.ViewModelProviders
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.metallic.chiaki.R
|
||||
import com.metallic.chiaki.TestStartActivity
|
||||
import com.metallic.chiaki.common.ext.RevealActivity
|
||||
import com.metallic.chiaki.common.ext.putRevealExtra
|
||||
import com.metallic.chiaki.common.getDatabase
|
||||
import com.metallic.chiaki.common.ext.viewModelFactory
|
||||
import com.metallic.chiaki.regist.RegistActivity
|
||||
import com.metallic.chiaki.settings.SettingsActivity
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_test_start.*
|
||||
|
||||
class MainActivity : AppCompatActivity()
|
||||
{
|
||||
|
@ -63,6 +64,9 @@ class MainActivity : AppCompatActivity()
|
|||
addManualButton.setOnClickListener { addManualConsole() }
|
||||
addManualLabelButton.setOnClickListener { addManualConsole() }
|
||||
|
||||
registerButton.setOnClickListener { showRegistration() }
|
||||
registerLabelButton.setOnClickListener { showRegistration() }
|
||||
|
||||
viewModel = ViewModelProviders
|
||||
.of(this, viewModelFactory { MainViewModel(getDatabase(this)) })
|
||||
.get(MainViewModel::class.java)
|
||||
|
@ -148,13 +152,16 @@ class MainActivity : AppCompatActivity()
|
|||
|
||||
private fun addManualConsole()
|
||||
{
|
||||
val parent = addManualButton.parent as View
|
||||
val parentParent = parent.parent as View
|
||||
val x = addManualButton.x + parent.x + parentParent.x + addManualButton.width * 0.5f
|
||||
val y = addManualButton.y + parent.y + parentParent.y + addManualButton.height * 0.5f
|
||||
Intent(this, TestStartActivity::class.java).also {
|
||||
it.putExtra(TestStartActivity.EXTRA_REVEAL_X, x)
|
||||
it.putExtra(TestStartActivity.EXTRA_REVEAL_Y, y)
|
||||
it.putRevealExtra(addManualButton, rootLayout)
|
||||
startActivity(it, ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showRegistration()
|
||||
{
|
||||
Intent(this, RegistActivity::class.java).also {
|
||||
it.putRevealExtra(registerButton, rootLayout)
|
||||
startActivity(it, ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.metallic.chiaki.regist
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.metallic.chiaki.R
|
||||
import com.metallic.chiaki.common.ext.RevealActivity
|
||||
import kotlinx.android.synthetic.main.activity_regist.*
|
||||
|
||||
class RegistActivity: AppCompatActivity(), RevealActivity
|
||||
{
|
||||
override val revealWindow: Window get() = window
|
||||
override val revealIntent: Intent get() = intent
|
||||
override val revealRootLayout: View get() = rootLayout
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?)
|
||||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_regist)
|
||||
handleReveal()
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/rootLayout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
|
|
10
android/app/src/main/res/layout/activity_regist.xml
Normal file
10
android/app/src/main/res/layout/activity_regist.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/rootLayout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/windowBackground">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Add a link
Reference in a new issue