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

Issue 917 day night theme #1891

Merged
merged 31 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53de0a2
Switched to use Material Design Theme.| #1870
DenBond7 Jun 24, 2022
a22a086
Refactored code.| #1870
DenBond7 Jun 24, 2022
991027d
Fixed appBarLayout color.| #1870
DenBond7 Jun 25, 2022
cbdf80d
Added some style changes. Refactored code.| #1870
DenBond7 Jun 25, 2022
3de3ab3
Modified FloatingActionButton style.| #1870
DenBond7 Jun 25, 2022
fbcfe5c
Modified buttons style.| #1870
DenBond7 Jun 27, 2022
bb674db
Fixed toolbar size.| #1870
DenBond7 Jun 27, 2022
83aee15
Fixed some UI.| #1870
DenBond7 Jun 27, 2022
c25d5b4
Fixed NavigationView style.| #1870
DenBond7 Jun 27, 2022
fa474e5
Set Theme.Material3.Light as a default theme.| #1870
DenBond7 Jun 27, 2022
ff70320
Fixed nav header style.| #1870
DenBond7 Jun 27, 2022
92bd6b4
Fixed progress bar style.| #1870
DenBond7 Jun 27, 2022
3ed7749
Fixed fragment_create_message.| #1870
DenBond7 Jun 28, 2022
bb4a237
Fixed the last commit.| #1870
DenBond7 Jun 28, 2022
87b6bf0
Removed unused resources.| #1870
DenBond7 Jun 28, 2022
d5b28dc
Switched to use Theme.Material3.DayNight. Fixed use the dark theme in…
DenBond7 Jun 28, 2022
2d824cf
Fixed issue with some buttons background.| #1870
DenBond7 Jun 28, 2022
de23b27
Merge remote-tracking branch 'origin/issue_1870_migrate_to_material_d…
DenBond7 Jun 29, 2022
6084e5b
Fixed DayNight for WebView. Added WebViewExt.kt| #917
DenBond7 Jun 29, 2022
cf14183
Added using colorSurface for some views.| #917
DenBond7 Jun 29, 2022
2ff1b68
Merge branch 'master' into issue_917_day_night_theme
DenBond7 Jul 4, 2022
78fdde7
Fixed issues after merge.| #917
DenBond7 Jul 4, 2022
311bf70
Fixed UI for some views.| #917
DenBond7 Jul 4, 2022
d95d420
Merge branch 'master' into issue_917_day_night_theme
DenBond7 Jul 5, 2022
ff16ee1
Fixed UI for some views. Step 2.| #917
DenBond7 Jul 5, 2022
10a9d2b
Fixed UI for some views. Step 3.| #917
DenBond7 Jul 5, 2022
d081210
Removed redundant code.| #917
DenBond7 Jul 5, 2022
a55be06
Refactored code.| #917
DenBond7 Jul 5, 2022
18c35e4
Fixed a background color in EmailWebView.| #917
DenBond7 Jul 5, 2022
fa0091d
Removed unused resources.| #917
DenBond7 Jul 5, 2022
761db1b
Removed unused comments.| #917
DenBond7 Jul 5, 2022
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
2 changes: 1 addition & 1 deletion FlowCrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
implementation 'androidx.navigation:navigation-runtime-ktx:2.5.0'

implementation 'androidx.webkit:webkit:1.4.0'

//https://developers.google.com/android/guides/setup
implementation 'com.google.android.gms:play-services-base:18.1.0'
Expand Down
5 changes: 0 additions & 5 deletions FlowCrypt/src/main/assets/html/pass_phrase_hint.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
/* dimensions: handling large content */
max-height: 100%;
max-width: 95%;
/* styling */
background: #fff;
/* reset white-space wrapping */
white-space: normal;
}
Expand All @@ -25,9 +23,6 @@
.good { color: #088447; }
.bad { color: #A44; }




</style>
<div class="featherlight-content">
<div class="lightboxed featherlight-inner">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected]
* Contributors: DenBond7
*/

package com.flowcrypt.email.extensions.android.webkit

import android.content.res.Configuration
import android.graphics.Color
import android.webkit.WebView
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature

/**
* @author Denis Bondarenko
* Date: 6/29/22
* Time: 1:47 PM
* E-mail: [email protected]
*/
fun WebView.setupDayNight() {
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
setBackgroundColor(Color.TRANSPARENT)
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> {
WebSettingsCompat.setForceDark(settings, WebSettingsCompat.FORCE_DARK_ON)
}
Configuration.UI_MODE_NIGHT_NO, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
WebSettingsCompat.setForceDark(settings, WebSettingsCompat.FORCE_DARK_OFF)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ import kotlin.random.Random

object PgpMsg {
private const val GENERAL_CSS =
"background: white;padding-left: 8px;min-height: 50px;padding-top: 4px;" +
"padding-bottom: 4px;width: 100%;"
"padding-left: 8px;min-height: 50px;padding-top: 4px;padding-bottom: 4px;width: 100%;"
private const val SEAMLESS_LOCK_BG = "iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAh1BMVEXw" +
"8PD////w8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PD" +
"w8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8P" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -73,8 +72,6 @@ class AttesterSettingsFragment : BaseFragment<FragmentAttesterSettingsBinding>()
context?.let {
val manager = LinearLayoutManager(it)
val decoration = DividerItemDecoration(it, manager.orientation)
val drawable = ResourcesCompat.getDrawable(resources, R.drawable.divider_1dp_grey, it.theme)
drawable?.let { decoration.setDrawable(drawable) }
rVAttester?.addItemDecoration(decoration)
rVAttester?.layoutManager = manager
rVAttester?.adapter = attesterKeyAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.navArgs
import com.flowcrypt.email.databinding.FragmentHtmlViewFromAssetsRawBinding
import com.flowcrypt.email.extensions.android.webkit.setupDayNight
import com.flowcrypt.email.extensions.supportActionBar
import com.flowcrypt.email.ui.activity.fragment.base.BaseFragment

Expand All @@ -29,6 +30,8 @@ class HtmlViewFromAssetsRawFragment : BaseFragment<FragmentHtmlViewFromAssetsRaw
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
supportActionBar?.title = args.title

binding?.webView?.setupDayNight()
binding?.webView?.loadUrl("file:///android_asset/" + args.resourceIdAsString)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.flowcrypt.email.Constants
import com.flowcrypt.email.R
import com.flowcrypt.email.databinding.FragmentLegalBinding
import com.flowcrypt.email.databinding.SwipeToRefrechWithWebviewBinding
import com.flowcrypt.email.extensions.android.webkit.setupDayNight
import com.flowcrypt.email.extensions.androidx.viewpager2.widget.reduceDragSensitivity
import com.flowcrypt.email.ui.activity.fragment.base.BaseFragment
import com.google.android.material.tabs.TabLayoutMediator
Expand Down Expand Up @@ -124,7 +125,10 @@ class LegalSettingsFragment : BaseFragment<FragmentLegalBinding>() {
binding?.swipeRefreshLayout?.isRefreshing = false
}
}
assetsPath?.let { binding?.webView?.loadUrl(it) }
assetsPath?.let {
binding?.webView?.setupDayNight()
binding?.webView?.loadUrl(it)
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResultListener
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -167,9 +166,6 @@ class PrivateKeysListFragment : BaseFragment<FragmentPrivateKeysBinding>(), List
setHasFixedSize(true)
val manager = LinearLayoutManager(context)
val decoration = DividerItemDecoration(context, manager.orientation)
val drawable =
ResourcesCompat.getDrawable(resources, R.drawable.divider_1dp_grey, requireContext().theme)
drawable?.let { decoration.setDrawable(drawable) }
addItemDecoration(decoration)
layoutManager = manager
adapter = recyclerViewAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
Expand Down Expand Up @@ -76,9 +75,6 @@ class RecipientsListFragment : BaseFragment<FragmentRecipientsListBinding>(),
private fun initViews() {
val manager = LinearLayoutManager(context)
val decoration = DividerItemDecoration(context, manager.orientation)
val drawable =
ResourcesCompat.getDrawable(resources, R.drawable.divider_1dp_grey, requireContext().theme)
drawable?.let { decoration.setDrawable(drawable) }
binding?.rVRecipients?.addItemDecoration(decoration)
binding?.rVRecipients?.layoutManager = manager
binding?.rVRecipients?.adapter = recipientsRecyclerViewAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView
import androidx.core.content.res.ResourcesCompat
import androidx.core.os.bundleOf
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
Expand Down Expand Up @@ -125,9 +124,6 @@ class SelectRecipientsFragment : BaseFragment<FragmentSelectRecipientsBinding>()
private fun initViews() {
val manager = LinearLayoutManager(requireContext())
val decoration = DividerItemDecoration(requireContext(), manager.orientation)
val drawable =
ResourcesCompat.getDrawable(resources, R.drawable.divider_1dp_grey, requireActivity().theme)
drawable?.let { decoration.setDrawable(drawable) }
binding?.recyclerViewContacts?.addItemDecoration(decoration)
binding?.recyclerViewContacts?.layoutManager = manager
binding?.recyclerViewContacts?.adapter = recipientsRecyclerViewAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class EditScreenshotDialogFragment : BaseDialogFragment() {
binding?.radioGroupColors?.setOnCheckedChangeListener { _, checkedId ->
when (checkedId) {
R.id.radioButtonFullColor -> {
photoEditor.brushColor = ContextCompat.getColor(requireContext(), R.color.black)
photoEditor.brushColor = ContextCompat.getColor(requireContext(), android.R.color.black)
photoEditor.setOpacity(100)
}

Expand All @@ -98,7 +98,7 @@ class EditScreenshotDialogFragment : BaseDialogFragment() {

photoEditor = PhotoEditor.Builder(context, binding?.photoEditorView).build()
photoEditor.setBrushDrawingMode(true)
photoEditor.brushColor = ContextCompat.getColor(requireContext(), R.color.black)
photoEditor.brushColor = ContextCompat.getColor(requireContext(), android.R.color.black)
photoEditor.setOpacity(100)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.setFragmentResult
import androidx.navigation.fragment.navArgs
import com.flowcrypt.email.R
import com.flowcrypt.email.extensions.android.webkit.setupDayNight
import com.flowcrypt.email.extensions.navController
import com.flowcrypt.email.util.GeneralUtil
import com.flowcrypt.email.util.UIUtil
Expand Down Expand Up @@ -58,6 +59,8 @@ class InfoDialogFragment : BaseDialogFragment() {
if (args.useWebViewToRender) {
val webView = WebView(requireContext())
webView.id = R.id.webView
webView.setupDayNight()

args.dialogMsg?.let {
webView.loadDataWithBaseURL(
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.flowcrypt.email.ui.adapter

import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.text.SpannableString
import android.text.Spanned
Expand Down Expand Up @@ -34,7 +35,7 @@ import com.flowcrypt.email.database.MessageState
import com.flowcrypt.email.database.entity.MessageEntity
import com.flowcrypt.email.util.DateTimeUtil
import com.flowcrypt.email.util.LogsUtil
import com.flowcrypt.email.util.UIUtil
import com.google.android.material.color.MaterialColors
import jakarta.mail.internet.InternetAddress
import java.util.regex.Pattern

Expand Down Expand Up @@ -168,17 +169,20 @@ class MsgsPagedListAdapter(private val onMessageClickListener: OnMessageClickLis

if (messageEntity.isSeen) {
changeViewsTypeface(viewHolder, Typeface.NORMAL)
viewHolder.textViewSenderAddress?.setTextColor(UIUtil.getColor(context, R.color.dark))
viewHolder.textViewDate?.setTextColor(UIUtil.getColor(context, R.color.gray))
viewHolder.textViewSenderAddress?.setTextColor(
MaterialColors.getColor(context, R.attr.colorOnSurfaceVariant, Color.BLACK)
)
viewHolder.textViewDate?.setTextColor(
MaterialColors.getColor(context, R.attr.itemSubTitleColor, Color.BLACK)
)
} else {
changeViewsTypeface(viewHolder, Typeface.BOLD)
viewHolder.textViewSenderAddress?.setTextColor(
UIUtil.getColor(
context,
android.R.color.black
)
MaterialColors.getColor(context, R.attr.itemTitleColor, Color.BLACK)
)
viewHolder.textViewDate?.setTextColor(
MaterialColors.getColor(context, R.attr.itemTitleColor, Color.BLACK)
)
viewHolder.textViewDate?.setTextColor(UIUtil.getColor(context, android.R.color.black))
}

viewHolder.imageViewAtts?.visibility =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import com.flowcrypt.email.R
import com.flowcrypt.email.extensions.android.webkit.setupDayNight
import com.flowcrypt.email.model.MessageType
import com.flowcrypt.email.ui.activity.CreateMessageActivity

Expand Down Expand Up @@ -67,6 +68,8 @@ class EmailWebView : WebView {
webSettings.loadsImagesAutomatically = true
webSettings.blockNetworkLoads = true
webSettings.javaScriptEnabled = false

setupDayNight()
}

fun setOnPageLoadingListener(onPageLoadingListener: OnPageLoadingListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/silver" android:state_activated="true" />
<item android:color="?attr/colorControlHighlight" android:state_activated="true" />
<item android:color="@android:color/transparent" />
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<item android:gravity="left">
<shape>
<solid android:color="@android:color/white" />
<solid android:color="?attr/colorSurface" />
</shape>
</item>

Expand Down
12 changes: 0 additions & 12 deletions FlowCrypt/src/main/res/drawable/divider_1dp_grey.xml

This file was deleted.

3 changes: 2 additions & 1 deletion FlowCrypt/src/main/res/layout/contact_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
android:id="@+id/cL"
android:layout_width="0dp"
android:layout_height="@dimen/default_button_height"
android:layout_marginTop="@dimen/default_margin_content_small"
android:layout_marginEnd="@dimen/default_margin_content_small"
android:orientation="vertical"
app:layout_constraintEnd_toStartOf="@+id/iBtDeleteContact"
Expand All @@ -31,6 +30,7 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?attr/itemTitleColor"
android:textSize="@dimen/default_text_size_big"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/tVEmail"
Expand All @@ -44,6 +44,7 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?attr/itemSubTitleColor"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:gravity="center"
android:lineSpacingExtra="@dimen/default_margin_small"
android:text="@string/connect_your_email_account_using_oauth_2_0"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
android:textSize="@dimen/default_text_size_big"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -66,7 +66,7 @@
android:gravity="center"
android:lineSpacingExtra="@dimen/default_margin_small"
android:text="@string/or_use_your_credentials_to_connect"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
android:textSize="@dimen/default_text_size_big"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_marginTop="@dimen/default_margin_content_big"
android:layout_weight="1"
android:gravity="center"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
app:layout_constraintEnd_toStartOf="@+id/guidelineRight"
app:layout_constraintStart_toStartOf="@+id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@+id/tVTitle"
Expand Down
2 changes: 1 addition & 1 deletion FlowCrypt/src/main/res/layout/fragment_check_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
android:textSize="@dimen/default_text_size_medium"
tools:text="No backups found on this account" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:layout_weight="1"
android:gravity="center"
android:text="@string/see_choosing_secure_pass_phrases"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
app:layout_constraintBottom_toBottomOf="@+id/iBShowPasswordHint"
app:layout_constraintEnd_toStartOf="@+id/iBShowPasswordHint"
app:layout_constraintHorizontal_bias="0.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:layout_weight="1"
android:gravity="center"
android:text="@string/see_choosing_secure_pass_phrases"
android:textColor="@android:color/black" />
android:textColor="?attr/colorOnSurface" />

<ImageButton
android:id="@+id/imageButtonShowPasswordHint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:layout_weight="1"
android:gravity="center"
android:text="@string/repeat_passphrase_hint"
android:textColor="@android:color/black"
android:textColor="?attr/colorOnSurface"
app:layout_constraintEnd_toStartOf="@+id/guidelineRightSecond"
app:layout_constraintStart_toStartOf="@+id/guidelineLeftSecond"
app:layout_constraintTop_toBottomOf="@+id/textViewSecondPasswordCheckTitle" />
Expand Down
Loading