Skip to content

Commit

Permalink
Update the design to be somewhat Material You compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Jun 25, 2021
1 parent bbe325c commit 76b10b4
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 134 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
implementation 'com.artemchep.config:config:2.2.0'
implementation 'com.afollestad.material-dialogs:core:3.1.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0-rc01'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation 'com.eightbitlab:blurview:1.6.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.TypedValue
import android.view.View
import android.widget.SeekBar
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.graphics.ColorUtils
import androidx.core.net.toUri
import androidx.core.view.*
import androidx.lifecycle.Observer
Expand Down Expand Up @@ -59,30 +60,18 @@ class MainActivity : BaseActivity(),
private var isAnalyticsSwitchBroadcasting = false

private val viewBinding by lazy {
ActivityMainBinding.bind(findViewById(android.R.id.content))
ActivityMainBinding.bind(findViewById(R.id.content))
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

viewBinding.toolbarBlurView
.setupWith(viewBinding.root)
.setBlurAlgorithm(RenderScriptBlur(this))
.setBlurRadius(5f)
.setBlurAutoUpdate(true)
.setHasFixedTransformationMatrix(true)

ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets ->
viewBinding.statusBar.layoutParams.height = insets.systemWindowInsetTop
viewBinding.statusBarBg.layoutParams.height = insets.systemWindowInsetTop
viewBinding.scrollView.updatePadding(
top = insets.systemWindowInsetTop,
bottom = insets.systemWindowInsetBottom
)
viewBinding.toolbarContent.updatePadding(
left = insets.systemWindowInsetLeft,
right = insets.systemWindowInsetRight
)
viewBinding.scrollViewContent.updatePadding(
left = insets.systemWindowInsetLeft,
right = insets.systemWindowInsetRight
Expand Down Expand Up @@ -202,7 +191,7 @@ class MainActivity : BaseActivity(),
isAnalyticsSwitchBroadcasting = false
}

viewBinding.toolbar.setOnClickListener(this)
viewBinding.masterSwitchText.setOnClickListener(this)
viewBinding.accessStub.accessibilityServiceBtn.setOnClickListener(this)
viewBinding.accessStub.callStateBtn.setOnClickListener(this)
viewBinding.mainStub.codeBtn.setOnClickListener(this)
Expand Down Expand Up @@ -289,8 +278,13 @@ class MainActivity : BaseActivity(),
viewBinding.aboutAppVersionInfo.text = it
})
// Permissions
isAccessibilityGranted.observe(this@MainActivity, Observer {
viewBinding.accessStub.accessibilityServiceBtn.isGone = it
isAccessibilityGranted.observe(this@MainActivity, Observer { isGranted ->
viewBinding.accessStub.accessibilityServiceBtn.isGone = isGranted
viewBinding.accessContainer.strokeColor = viewBinding.accessContainer.strokeColor
.let { color ->
val alpha = if (isGranted) 0 else 255
ColorUtils.setAlphaComponent(color, alpha)
}
})
isReadPhoneCallGranted.observe(this@MainActivity, Observer {
viewBinding.accessStub.callStateBtn.isGone = it
Expand All @@ -299,8 +293,8 @@ class MainActivity : BaseActivity(),
viewBinding.accessContainer.isGone = it
})
isRequiredGranted.observe(this@MainActivity, Observer {
viewBinding.toolbar.isEnabled = it
viewBinding.troubleshootingStub.lockScreenBtn.isEnabled = it
viewBinding.masterSwitchText.isEnabled = it
viewBinding.masterSwitch.isEnabled = it
})
// Events
Expand Down Expand Up @@ -384,6 +378,7 @@ class MainActivity : BaseActivity(),
override fun onClick(view: View) {
when (view.id) {
R.id.toolbar -> viewBinding.masterSwitch.isChecked = !viewBinding.masterSwitch.isChecked
R.id.masterSwitchText -> viewBinding.masterSwitch.performClick()
R.id.lockScreenBtn -> mainViewModel.lockScreen()
R.id.lockScreenDelayResetBtn -> mainViewModel.setLockScreenDelay()
// Help
Expand Down
44 changes: 14 additions & 30 deletions app/src/main/res/layout/activity_lab.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -19,37 +18,22 @@
android:paddingTop="@dimen/actionBarSize"
android:paddingBottom="16dp">

<com.google.android.material.card.MaterialCardView
android:id="@+id/sensorsContainer"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="0dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/lab_sensors"
android:textAppearance="@style/TextSection" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sensorsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:nestedScrollingEnabled="false" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/lab_sensors"
android:textAppearance="@style/TextSection" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sensorsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:nestedScrollingEnabled="false" />

</LinearLayout>

Expand Down
Loading

0 comments on commit 76b10b4

Please sign in to comment.