Loading app/build.gradle +4 −1 Original line number Diff line number Diff line Loading @@ -148,4 +148,7 @@ dependencies { // WorkManager implementation 'androidx.work:work-runtime-ktx:2.7.1' // JSoup implementation 'org.jsoup:jsoup:1.13.1' } app/src/main/assets/terms_of_use.css 0 → 100644 +62 −0 Original line number Diff line number Diff line body { font-family: 'Roboto', sans-serif; margin-left: 16px; margin-right: 16px; padding-top: 16px; background-color: #FBFBFB; } body > p > strong { font-size: 24px; line-height: 24px; letter-spacing: 0.18px; font-weight: normal; color: #000000; } h1 { font-weight: normal; color: #000000; margin-left: 0px; font-size: 16px; margin-top: 30px; line-height: 24px; } p { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; color: #00000098; } body > p:nth-child(1), body > p:nth-child(7), ol { margin-top: 16px; margin-bottom: 16px; } ol { padding-left: 16px; } body > p:nth-child(3), body > p:nth-child(5), body > p:nth-child(8), body > p:nth-child(9), body > p:nth-child(10), ol ~ p { margin-top: 16px; margin-bottom: 16px; } ol li::marker { color: #000000; font-weight: normal; font-size: 16px; } ol:nth-of-type(9) ~ ol { margin-left: 16px; } ul { padding-left: 16px; color: #00000098 } No newline at end of file app/src/main/assets/terms_of_use_dark.css 0 → 100644 +62 −0 Original line number Diff line number Diff line body { font-family: 'Roboto', sans-serif; margin-left: 16px; margin-right: 16px; padding-top: 16px; background-color: #121212; } body > p > strong { font-size: 24px; line-height: 24px; letter-spacing: 0.18px; font-weight: normal; color: #FFFFFF; } h1 { font-weight: normal; color: #FFFFFF; margin-left: 0px; font-size: 16px; margin-top: 30px; line-height: 24px; } p { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; color: #FFFFFF98; } body > p:nth-child(1), body > p:nth-child(7), ol { margin-top: 16px; margin-bottom: 16px; } ol { padding-left: 16px; } body > p:nth-child(3), body > p:nth-child(5), body > p:nth-child(8), body > p:nth-child(9), body > p:nth-child(10), ol ~ p { margin-top: 16px; margin-bottom: 16px; } ol li::marker { color: #FFFFFF; font-weight: normal; font-size: 16px; } ol:nth-of-type(9) ~ ol { margin-left: 16px; } ul { padding-left: 16px; color: #FFFFFF98 } No newline at end of file app/src/main/java/foundation/e/apps/setup/tos/TOSFragment.kt +51 −9 Original line number Diff line number Diff line package foundation.e.apps.setup.tos import android.content.res.Configuration import android.os.Bundle import android.text.Html import android.view.View import androidx.constraintlayout.widget.ConstraintSet import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.navigation.findNavController import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R import foundation.e.apps.databinding.FragmentTosBinding import org.jsoup.Jsoup @AndroidEntryPoint class TOSFragment : Fragment(R.layout.fragment_tos) { Loading @@ -33,17 +35,20 @@ class TOSFragment : Fragment(R.layout.fragment_tos) { binding.TOSButtons.visibility = View.GONE binding.toolbar.visibility = View.VISIBLE binding.acceptDateTV.visibility = View.VISIBLE val constraintSet = ConstraintSet() constraintSet.clone(binding.root) constraintSet.connect( binding.tosWebView.id, ConstraintSet.TOP, binding.acceptDateTV.id, ConstraintSet.BOTTOM, 20 ) constraintSet.applyTo(binding.root) } } val tosHtml = resources.openRawResource(R.raw.terms_of_use) val tosHtmlData = tosHtml.reader().readText() binding.TOSTextView.text = Html.fromHtml( tosHtmlData, Html.FROM_HTML_MODE_COMPACT and Html.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING and Html.FROM_HTML_OPTION_USE_CSS_COLORS ) loadTos() binding.toolbar.setNavigationOnClickListener { view.findNavController().navigateUp() Loading @@ -63,4 +68,41 @@ class TOSFragment : Fragment(R.layout.fragment_tos) { super.onDestroyView() _binding = null } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) loadTos() } private fun loadTos() { val isNightMode = requireContext().resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES var css = "terms_of_use.css" if (isNightMode) { css = "terms_of_use_dark.css" } val tosHtml = resources.openRawResource(R.raw.terms_of_use).reader().readText() val body = Jsoup.parse(tosHtml).body() val sb = StringBuilder() .append( "<HTML><HEAD><LINK href=\"$css\" rel=\"stylesheet\"/></HEAD>" ) .append(body.toString()) .append("</HTML>") binding.tosWebView.loadDataWithBaseURL( "file:///android_asset/", sb.toString(), "text/html", "utf-8", null ) binding.tosWebView.setOnScrollChangeListener { _, scrollX, scrollY, _, _ -> if (scrollX == 0 && scrollY == 0 && viewModel.tocStatus.value == true) { binding.acceptDateTV.visibility = View.VISIBLE } else { binding.acceptDateTV.visibility = View.GONE } } } } app/src/main/res/layout/fragment_tos.xml +64 −70 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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" android:orientation="vertical" tools:context=".setup.tos.TOSFragment"> android:orientation="vertical"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorNavBar" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:navigationIcon="@drawable/ic_arrow_back" /> <com.google.android.material.textview.MaterialTextView android:id="@+id/acceptDateTV" android:layout_width="wrap_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="16dp" Loading @@ -24,58 +26,51 @@ android:drawablePadding="5dp" android:text="@string/tos_agree_date" android:textColor="?android:textColorPrimary" android:visibility="gone" /> android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/toolbar" /> <com.google.android.material.textview.MaterialTextView android:id="@+id/TOSWarning" android:layout_width="match_parent" android:layout_height="80dp" android:background="@color/tos_warning" android:background="@color/colorAccent" android:padding="20dp" android:text="@string/tos_warning" android:textColor="@android:color/white" android:textSize="15sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> android:textSize="15sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <ScrollView <WebView android:id="@+id/tosWebView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="20dp" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_weight="1"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="10dp"> <com.google.android.material.textview.MaterialTextView android:id="@+id/TOSTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:lineSpacingExtra="4dp" android:textColor="?android:textColorPrimary" android:textSize="15sp" /> </LinearLayout> </ScrollView> app:layout_constraintBottom_toTopOf="@id/divider" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/TOSWarning" /> <View android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorGrey" /> android:background="@color/colorGrey" app:layout_constraintBottom_toTopOf="@id/TOSButtons" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/TOSButtons" android:layout_width="match_parent" android:layout_height="70dp" android:orientation="horizontal"> android:background="@color/tos_bottom" android:orientation="horizontal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <Button android:id="@+id/disagreeBT" Loading @@ -101,6 +96,5 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> Loading
app/build.gradle +4 −1 Original line number Diff line number Diff line Loading @@ -148,4 +148,7 @@ dependencies { // WorkManager implementation 'androidx.work:work-runtime-ktx:2.7.1' // JSoup implementation 'org.jsoup:jsoup:1.13.1' }
app/src/main/assets/terms_of_use.css 0 → 100644 +62 −0 Original line number Diff line number Diff line body { font-family: 'Roboto', sans-serif; margin-left: 16px; margin-right: 16px; padding-top: 16px; background-color: #FBFBFB; } body > p > strong { font-size: 24px; line-height: 24px; letter-spacing: 0.18px; font-weight: normal; color: #000000; } h1 { font-weight: normal; color: #000000; margin-left: 0px; font-size: 16px; margin-top: 30px; line-height: 24px; } p { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; color: #00000098; } body > p:nth-child(1), body > p:nth-child(7), ol { margin-top: 16px; margin-bottom: 16px; } ol { padding-left: 16px; } body > p:nth-child(3), body > p:nth-child(5), body > p:nth-child(8), body > p:nth-child(9), body > p:nth-child(10), ol ~ p { margin-top: 16px; margin-bottom: 16px; } ol li::marker { color: #000000; font-weight: normal; font-size: 16px; } ol:nth-of-type(9) ~ ol { margin-left: 16px; } ul { padding-left: 16px; color: #00000098 } No newline at end of file
app/src/main/assets/terms_of_use_dark.css 0 → 100644 +62 −0 Original line number Diff line number Diff line body { font-family: 'Roboto', sans-serif; margin-left: 16px; margin-right: 16px; padding-top: 16px; background-color: #121212; } body > p > strong { font-size: 24px; line-height: 24px; letter-spacing: 0.18px; font-weight: normal; color: #FFFFFF; } h1 { font-weight: normal; color: #FFFFFF; margin-left: 0px; font-size: 16px; margin-top: 30px; line-height: 24px; } p { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; color: #FFFFFF98; } body > p:nth-child(1), body > p:nth-child(7), ol { margin-top: 16px; margin-bottom: 16px; } ol { padding-left: 16px; } body > p:nth-child(3), body > p:nth-child(5), body > p:nth-child(8), body > p:nth-child(9), body > p:nth-child(10), ol ~ p { margin-top: 16px; margin-bottom: 16px; } ol li::marker { color: #FFFFFF; font-weight: normal; font-size: 16px; } ol:nth-of-type(9) ~ ol { margin-left: 16px; } ul { padding-left: 16px; color: #FFFFFF98 } No newline at end of file
app/src/main/java/foundation/e/apps/setup/tos/TOSFragment.kt +51 −9 Original line number Diff line number Diff line package foundation.e.apps.setup.tos import android.content.res.Configuration import android.os.Bundle import android.text.Html import android.view.View import androidx.constraintlayout.widget.ConstraintSet import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.navigation.findNavController import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R import foundation.e.apps.databinding.FragmentTosBinding import org.jsoup.Jsoup @AndroidEntryPoint class TOSFragment : Fragment(R.layout.fragment_tos) { Loading @@ -33,17 +35,20 @@ class TOSFragment : Fragment(R.layout.fragment_tos) { binding.TOSButtons.visibility = View.GONE binding.toolbar.visibility = View.VISIBLE binding.acceptDateTV.visibility = View.VISIBLE val constraintSet = ConstraintSet() constraintSet.clone(binding.root) constraintSet.connect( binding.tosWebView.id, ConstraintSet.TOP, binding.acceptDateTV.id, ConstraintSet.BOTTOM, 20 ) constraintSet.applyTo(binding.root) } } val tosHtml = resources.openRawResource(R.raw.terms_of_use) val tosHtmlData = tosHtml.reader().readText() binding.TOSTextView.text = Html.fromHtml( tosHtmlData, Html.FROM_HTML_MODE_COMPACT and Html.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING and Html.FROM_HTML_OPTION_USE_CSS_COLORS ) loadTos() binding.toolbar.setNavigationOnClickListener { view.findNavController().navigateUp() Loading @@ -63,4 +68,41 @@ class TOSFragment : Fragment(R.layout.fragment_tos) { super.onDestroyView() _binding = null } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) loadTos() } private fun loadTos() { val isNightMode = requireContext().resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES var css = "terms_of_use.css" if (isNightMode) { css = "terms_of_use_dark.css" } val tosHtml = resources.openRawResource(R.raw.terms_of_use).reader().readText() val body = Jsoup.parse(tosHtml).body() val sb = StringBuilder() .append( "<HTML><HEAD><LINK href=\"$css\" rel=\"stylesheet\"/></HEAD>" ) .append(body.toString()) .append("</HTML>") binding.tosWebView.loadDataWithBaseURL( "file:///android_asset/", sb.toString(), "text/html", "utf-8", null ) binding.tosWebView.setOnScrollChangeListener { _, scrollX, scrollY, _, _ -> if (scrollX == 0 && scrollY == 0 && viewModel.tocStatus.value == true) { binding.acceptDateTV.visibility = View.VISIBLE } else { binding.acceptDateTV.visibility = View.GONE } } } }
app/src/main/res/layout/fragment_tos.xml +64 −70 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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" android:orientation="vertical" tools:context=".setup.tos.TOSFragment"> android:orientation="vertical"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorNavBar" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:navigationIcon="@drawable/ic_arrow_back" /> <com.google.android.material.textview.MaterialTextView android:id="@+id/acceptDateTV" android:layout_width="wrap_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="16dp" Loading @@ -24,58 +26,51 @@ android:drawablePadding="5dp" android:text="@string/tos_agree_date" android:textColor="?android:textColorPrimary" android:visibility="gone" /> android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/toolbar" /> <com.google.android.material.textview.MaterialTextView android:id="@+id/TOSWarning" android:layout_width="match_parent" android:layout_height="80dp" android:background="@color/tos_warning" android:background="@color/colorAccent" android:padding="20dp" android:text="@string/tos_warning" android:textColor="@android:color/white" android:textSize="15sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> android:textSize="15sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <ScrollView <WebView android:id="@+id/tosWebView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="20dp" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_weight="1"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="10dp"> <com.google.android.material.textview.MaterialTextView android:id="@+id/TOSTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:lineSpacingExtra="4dp" android:textColor="?android:textColorPrimary" android:textSize="15sp" /> </LinearLayout> </ScrollView> app:layout_constraintBottom_toTopOf="@id/divider" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/TOSWarning" /> <View android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorGrey" /> android:background="@color/colorGrey" app:layout_constraintBottom_toTopOf="@id/TOSButtons" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/TOSButtons" android:layout_width="match_parent" android:layout_height="70dp" android:orientation="horizontal"> android:background="@color/tos_bottom" android:orientation="horizontal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <Button android:id="@+id/disagreeBT" Loading @@ -101,6 +96,5 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>