Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0 #30

Open
wants to merge 5 commits into
base: androidx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 34
defaultConfig {
applicationId "com.scwang.wave.app"
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -19,6 +19,14 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
// kotlinOptions {
// jvmTarget '1.8'
// }
namespace 'com.scwang.wave.app'
}

dependencies {
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scwang.wave.app">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:icon="@mipmap/ic_launcher"
Expand All @@ -10,13 +9,15 @@
android:theme="@style/AppTheme">
<activity
android:name=".activity.MainActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name=".activity.FragmentActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.UserLoginActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity android:name=".activity.FragmentActivity"
android:screenOrientation="portrait"/>
<activity android:name=".activity.UserLoginActivity"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FragmentActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mFragmentClazz = intent.getStringExtra(EXTRA_FRAGMENT)
mFragmentClazz = intent.getStringExtra(EXTRA_FRAGMENT).toString()
val frameLayout = FrameLayout(this)
frameLayout.id = widget_frame
setContentView(frameLayout)
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/com/scwang/wave/app/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.appcompat.app.AppCompatActivity
import android.view.MenuItem
import android.widget.FrameLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.scwang.wave.app.R
import com.scwang.wave.app.fragment.WaveConsoleFragment
import kotlinx.android.synthetic.main.activity_main.*
//import kotlinx.android.synthetic.main.activity_main.*
import kotlin.reflect.KClass

class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener {
private val mNavigation by lazy { findViewById<BottomNavigationView>(R.id.navigation) }
private val mContent by lazy { findViewById<FrameLayout>(R.id.content) }
private val mMessage by lazy { findViewById<TextView>(R.id.message) }
private val mContainer by lazy { findViewById<ConstraintLayout>(R.id.container) }

enum class Tabs(val menuId: Int, val clazz: KClass<out androidx.fragment.app.Fragment>) {
WavePair(R.id.navigation_home, WaveConsoleFragment::class),
Expand All @@ -23,8 +31,9 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

navigation.setOnNavigationItemSelectedListener(this)
navigation.selectedItemId = R.id.navigation_home

mNavigation.setOnNavigationItemSelectedListener(this)
mNavigation.selectedItemId = R.id.navigation_home
}

override fun onNavigationItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
package com.scwang.wave.app.activity

import android.os.Bundle
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.scwang.wave.MultiWaveHeader
import com.scwang.wave.app.R
import com.scwang.wave.app.fragment.WaveConsoleFragment
import com.scwang.wave.app.util.StatusBarUtil
import kotlinx.android.synthetic.main.activity_user_login.*
//import kotlinx.android.synthetic.main.activity_user_login.*


class UserLoginActivity : AppCompatActivity() {
private val mVerifyMode by lazy { findViewById<TextView>(R.id.verify_mode) }
private val mTouristMode by lazy { findViewById<TextView>(R.id.tourist_mode) }
private val mRegister by lazy { findViewById<TextView>(R.id.register) }
private val mLogin by lazy { findViewById<TextView>(R.id.login) }
private val mForget by lazy { findViewById<TextView>(R.id.forget) }
private val mDelete by lazy { findViewById<ImageView>(R.id.delete) }
private val mPassword by lazy { findViewById<EditText>(R.id.password) }
private val mUsername by lazy { findViewById<EditText>(R.id.username) }
private val mLogo by lazy { findViewById<ImageView>(R.id.logo) }
private val mWaveHeader by lazy { findViewById<MultiWaveHeader>(R.id.waveHeader) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_login)
//状态栏透明和间距处理
StatusBarUtil.immersive(this)

login.setOnClickListener {
mLogin.setOnClickListener {
// startActivity(Intent(this, MainActivity::class.java))
FragmentActivity.start(this, WaveConsoleFragment::class.java)
}
Expand Down
123 changes: 80 additions & 43 deletions app/src/main/java/com/scwang/wave/app/fragment/WaveConsoleFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,132 @@ package com.scwang.wave.app.fragment

import android.content.res.Resources
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.core.content.ContextCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.larswerkman.lobsterpicker.OnColorListener
import com.larswerkman.lobsterpicker.sliders.LobsterShadeSlider
import com.scwang.wave.MultiWaveHeader
import com.scwang.wave.ShapeType
import com.scwang.wave.app.R
import com.scwang.wave.app.util.StatusBarUtil
import kotlinx.android.synthetic.main.fragment_wave_console.*
import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar

/**
* A simple [Fragment] subclass.
*/
class WaveConsoleFragment : androidx.fragment.app.Fragment(), DiscreteSeekBar.OnProgressChangeListener {
class WaveConsoleFragment : Fragment(), DiscreteSeekBar.OnProgressChangeListener {
private val toolbar by lazy { view?.findViewById<Toolbar>(R.id.toolbar) }
private val sliderCloseColor by lazy { view?.findViewById<LobsterShadeSlider>(R.id.sliderCloseColor) }
private val sliderStartColor by lazy { view?.findViewById<LobsterShadeSlider>(R.id.sliderStartColor) }
private val seekProgress by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekProgress) }
private val seekVelocity by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekVelocity) }
private val seekAlpha by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekAlpha) }
private val seekAngle by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekAngle) }
private val seekWave by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekWave) }
private val seekNumber by lazy { view?.findViewById<DiscreteSeekBar>(R.id.seekNumber) }
private val radioOval by lazy { view?.findViewById<RadioButton>(R.id.radioOval) }
private val radioRoundRect by lazy { view?.findViewById<RadioButton>(R.id.radioRoundRect) }
private val radioRect by lazy { view?.findViewById<RadioButton>(R.id.radioRect) }
private val radioGroup by lazy { view?.findViewById<RadioGroup>(R.id.radioGroup) }
private val checkBoxRunning by lazy { view?.findViewById<CheckBox>(R.id.checkBoxRunning) }
private val checkBoxDirection by lazy { view?.findViewById<CheckBox>(R.id.checkBoxDirection) }
private val multiWaveHeader by lazy { view?.findViewById<MultiWaveHeader>(R.id.multiWaveHeader) }

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_wave_console, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

super.onViewCreated(view, savedInstanceState)


StatusBarUtil.immersive(activity)
StatusBarUtil.setPaddingSmart(context, toolbar)
toolbar.setNavigationOnClickListener {
toolbar?.setNavigationOnClickListener {
activity?.finish()
}

seekAngle.progress = multiWaveHeader.gradientAngle
seekVelocity.progress = (multiWaveHeader.velocity * 10).toInt()
seekAlpha.progress = (multiWaveHeader.colorAlpha * 100).toInt()
seekProgress.progress = (multiWaveHeader.progress * 100).toInt()
seekWave.progress = (multiWaveHeader.waveHeight / Resources.getSystem().displayMetrics.density).toInt()
checkBoxRunning.isChecked = multiWaveHeader.isRunning
checkBoxDirection.isChecked = multiWaveHeader.scaleY == -1f

seekWave.setOnProgressChangeListener(this)
seekAngle.setOnProgressChangeListener(this)
seekVelocity.setOnProgressChangeListener(this)
seekProgress.setOnProgressChangeListener(this)
seekAlpha.setOnProgressChangeListener(this)
seekNumber.setOnProgressChangeListener(this)
checkBoxRunning.setOnCheckedChangeListener {_,value->
seekAngle?.progress = multiWaveHeader?.gradientAngle ?: 0
seekVelocity?.progress = ((multiWaveHeader?.velocity ?: 1f) * 10).toInt()
seekAlpha?.progress = ((multiWaveHeader?.colorAlpha ?: 1f) * 100).toInt()
seekProgress?.progress = ((multiWaveHeader?.progress ?: 1f) * 100).toInt()
seekWave?.progress = ((multiWaveHeader?.waveHeight
?: 0) / Resources.getSystem().displayMetrics.density).toInt()
checkBoxRunning?.isChecked = multiWaveHeader?.isRunning ?: false
checkBoxDirection?.isChecked = multiWaveHeader?.scaleY == -1f

seekWave?.setOnProgressChangeListener(this)
seekAngle?.setOnProgressChangeListener(this)
seekVelocity?.setOnProgressChangeListener(this)
seekProgress?.setOnProgressChangeListener(this)
seekAlpha?.setOnProgressChangeListener(this)
seekNumber?.setOnProgressChangeListener(this)
checkBoxRunning?.setOnCheckedChangeListener { _, value ->
if (value) {
multiWaveHeader.start()
multiWaveHeader?.start()
} else {
multiWaveHeader.stop()
multiWaveHeader?.stop()
}
}
checkBoxDirection.setOnCheckedChangeListener{_,value->
multiWaveHeader.scaleY = if (value) -1f else 1f
checkBoxDirection?.setOnCheckedChangeListener { _, value ->
multiWaveHeader?.scaleY = if (value) -1f else 1f
context?.also {
toolbar.setBackgroundColor(if (value) ContextCompat.getColor(it, R.color.colorPrimary) else 0)
toolbar?.setBackgroundColor(
if (value) ContextCompat.getColor(
it,
R.color.colorPrimary
) else 0
)
}
}

sliderStartColor.addOnColorListener(object : OnColorListener{
sliderStartColor?.addOnColorListener(object : OnColorListener {
override fun onColorChanged(color: Int) {
onColorSelected(color)
}

override fun onColorSelected(color: Int) {
multiWaveHeader.startColor = color
multiWaveHeader?.startColor = color
}
})
sliderCloseColor.addOnColorListener(object : OnColorListener{
sliderCloseColor?.addOnColorListener(object : OnColorListener {
override fun onColorChanged(color: Int) {
onColorSelected(color)
}

override fun onColorSelected(color: Int) {
multiWaveHeader.closeColor = color
multiWaveHeader?.closeColor = color
}
})

radioGroup.setOnCheckedChangeListener { _, checkedId ->
radioGroup?.setOnCheckedChangeListener { _, checkedId ->
when (checkedId) {
R.id.radioRect -> multiWaveHeader.shape = ShapeType.Rect
R.id.radioOval -> multiWaveHeader.shape = ShapeType.Oval
R.id.radioRoundRect -> multiWaveHeader.shape = ShapeType.RoundRect
R.id.radioRect -> multiWaveHeader?.shape = ShapeType.Rect
R.id.radioOval -> multiWaveHeader?.shape = ShapeType.Oval
R.id.radioRoundRect -> multiWaveHeader?.shape = ShapeType.RoundRect
}
}

}

override fun onProgressChanged(seekBar: DiscreteSeekBar, value: Int, fromUser: Boolean) {
when (seekBar) {
seekProgress -> multiWaveHeader.progress = 1f * value / 100
seekVelocity -> multiWaveHeader.velocity = 1f * value / 10
seekAlpha -> multiWaveHeader.colorAlpha = 1f * value / 100
seekAngle -> multiWaveHeader.gradientAngle = value
seekProgress -> multiWaveHeader?.progress = 1f * value / 100
seekVelocity -> multiWaveHeader?.velocity = 1f * value / 10
seekAlpha -> multiWaveHeader?.colorAlpha = 1f * value / 100
seekAngle -> multiWaveHeader?.gradientAngle = value
}
}

Expand All @@ -103,18 +137,21 @@ class WaveConsoleFragment : androidx.fragment.app.Fragment(), DiscreteSeekBar.On

override fun onStopTrackingTouch(seekBar: DiscreteSeekBar) {
if (seekWave == seekBar) {
multiWaveHeader.waveHeight = seekBar.progress
multiWaveHeader?.waveHeight = seekBar.progress
} else if (seekNumber == seekBar) {
if (seekBar.progress == 2) {
/**
* 格式-format
* offsetX offsetY scaleX scaleY velocity(dp/s)
* 水平偏移量 竖直偏移量 水平拉伸比例 竖直拉伸比例 速度
*/
multiWaveHeader.setWaves("0,0,1,1,25\n90,0,1,1,25")
multiWaveHeader?.setWaves("0,0,1,1,25\n90,0,1,1,25")
} else {
val waves = "70,25,1.4,1.4,-26\n100,5,1.4,1.2,15\n420,0,1.15,1,-10\n520,10,1.7,1.5,20\n220,0,1,1,-15".split("\n")
multiWaveHeader.setWaves(waves.subList(0, seekBar.progress).joinToString("\n"))
val waves =
"70,25,1.4,1.4,-26\n100,5,1.4,1.2,15\n420,0,1.15,1,-10\n520,10,1.7,1.5,20\n220,0,1,1,-15".split(
"\n"
)
multiWaveHeader?.setWaves(waves.subList(0, seekBar.progress).joinToString("\n"))
}
}
}
Expand Down
Loading