Some Android Styling

This commit is contained in:
Florian Märkl 2019-10-02 20:05:18 +02:00
commit 01798ad5c5
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
9 changed files with 202 additions and 47 deletions

View file

@ -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"
}

View file

@ -13,7 +13,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -25,6 +25,9 @@
android:theme="@style/StreamTheme"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="userLandscape"/>
<activity android:name=".TestStartActivity"
android:theme="@style/AppTheme.Transparent"/>
</application>
</manifest>

View file

@ -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)

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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())
}
}
}
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
package com.metallic.chiaki.main
import androidx.lifecycle.ViewModel
class MainViewModel: ViewModel()
{
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View file

@ -1,54 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".main.MainActivity">
<EditText
android:id="@+id/hostEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Host"
app:layout_constraintBottom_toTopOf="@+id/registKeyEditText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/consolesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditText
android:id="@+id/registKeyEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Regist Key"
app:layout_constraintBottom_toTopOf="@+id/morningEditText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hostEditText" />
<EditText
android:id="@+id/morningEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Morning (base64)"
app:layout_constraintBottom_toTopOf="@+id/startButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/registKeyEditText" />
<Button
android:id="@+id/startButton"
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@drawable/ic_add"
android:layout_margin="16dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/morningEditText" />
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
tools:context=".main.MainActivity">
<EditText
android:id="@+id/hostEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Host"
app:layout_constraintBottom_toTopOf="@+id/registKeyEditText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"/>
<EditText
android:id="@+id/registKeyEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Regist Key"
app:layout_constraintBottom_toTopOf="@+id/morningEditText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hostEditText" />
<EditText
android:id="@+id/morningEditText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Morning (base64)"
app:layout_constraintBottom_toTopOf="@+id/startButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/registKeyEditText" />
<Button
android:id="@+id/startButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/morningEditText" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -3,6 +3,13 @@
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowActivityTransitions">true</item>
</style>
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="StreamTheme" parent="Theme.AppCompat.Light.NoActionBar">