Add night mode

This commit is contained in:
Davide Depau 2018-09-30 18:12:21 +02:00
parent 902acedcd0
commit 23eec4ceb1
Signed by: depau
GPG key ID: C7D999B6A55EFE86
32 changed files with 301 additions and 38 deletions

View file

@ -26,22 +26,22 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-rc02' implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.0.0-rc02' implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02' implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0-rc02' implementation 'androidx.gridlayout:gridlayout:1.0.0'
api 'com.google.guava:guava:26.0-android' api 'com.google.guava:guava:26.0-android'
implementation 'com.github.codekidX:storage-chooser:2.0.4.2' api 'com.github.codekidX:storage-chooser:2.0.4.2'
// implementation 'com.github.mjdev:libaums:0.5.5' // implementation 'com.github.mjdev:libaums:0.5.5'
implementation project(':libaums') implementation project(':libaums')
implementation project(':dmg2img') implementation project(':dmg2img')
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0-rc02' implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02' implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

View file

@ -1,12 +1,21 @@
package eu.depau.etchdroid.activities package eu.depau.etchdroid.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import eu.depau.etchdroid.R import eu.depau.etchdroid.R
import eu.depau.etchdroid.utils.NightModeHelper
abstract class ActivityBase : AppCompatActivity() { abstract class ActivityBase : AppCompatActivity() {
protected lateinit var nightModeHelper: NightModeHelper
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
nightModeHelper = NightModeHelper(this, R.style.AppTheme)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.
@ -24,6 +33,10 @@ abstract class ActivityBase: AppCompatActivity() {
startActivity(intent) startActivity(intent)
return true return true
} }
R.id.action_nightmode -> {
nightModeHelper.toggle()
return true
}
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }

View file

@ -37,7 +37,7 @@ class ConfirmationActivity : ActivityBase() {
fun showDataLossAlertDialog() { fun showDataLossAlertDialog() {
val dialogFragment = DoNotShowAgainDialogFragment() val dialogFragment = DoNotShowAgainDialogFragment(nightModeHelper.nightMode)
dialogFragment.title = getString(R.string.warning) dialogFragment.title = getString(R.string.warning)
dialogFragment.message = getString(R.string.dataloss_confirmation_dialog_message) dialogFragment.message = getString(R.string.dataloss_confirmation_dialog_message)
dialogFragment.positiveButton = getString(R.string.confirm_flash_image) dialogFragment.positiveButton = getString(R.string.confirm_flash_image)

View file

@ -1,11 +1,10 @@
package eu.depau.etchdroid.activities package eu.depau.etchdroid.activities
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import eu.depau.etchdroid.R import eu.depau.etchdroid.R
import kotlinx.android.synthetic.main.activity_error.* import kotlinx.android.synthetic.main.activity_error.*
class ErrorActivity : AppCompatActivity() { class ErrorActivity : ActivityBase() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View file

@ -1,16 +1,15 @@
package eu.depau.etchdroid.activities package eu.depau.etchdroid.activities
import android.Manifest import android.Manifest
import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.codekidlabs.storagechooser.StorageChooser
import eu.depau.etchdroid.R import eu.depau.etchdroid.R
import eu.depau.etchdroid.StateKeeper import eu.depau.etchdroid.StateKeeper
import eu.depau.etchdroid.enums.FlashMethod import eu.depau.etchdroid.enums.FlashMethod
@ -62,7 +61,7 @@ class StartActivity : ActivityBase() {
} }
fun showDMGBetaAlertDialog() { fun showDMGBetaAlertDialog() {
val dialogFragment = DoNotShowAgainDialogFragment() val dialogFragment = DoNotShowAgainDialogFragment(nightModeHelper.nightMode)
dialogFragment.title = getString(R.string.here_be_dragons) dialogFragment.title = getString(R.string.here_be_dragons)
dialogFragment.message = getString(R.string.dmg_alert_dialog_text) dialogFragment.message = getString(R.string.dmg_alert_dialog_text)
dialogFragment.positiveButton = getString(R.string.i_understand) dialogFragment.positiveButton = getString(R.string.i_understand)
@ -145,7 +144,7 @@ class StartActivity : ActivityBase() {
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) { if (requestCode == READ_REQUEST_CODE && resultCode == AppCompatActivity.RESULT_OK) {
// The document selected by the user won't be returned in the intent. // The document selected by the user won't be returned in the intent.
// Instead, a URI to that document will be contained in the return intent // Instead, a URI to that document will be contained in the return intent
// provided to this method as a parameter. // provided to this method as a parameter.

View file

@ -1,5 +1,6 @@
package eu.depau.etchdroid.utils package eu.depau.etchdroid.utils
import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -8,13 +9,21 @@ import androidx.fragment.app.DialogFragment
import eu.depau.etchdroid.R import eu.depau.etchdroid.R
import kotlinx.android.synthetic.main.do_not_show_again.view.* import kotlinx.android.synthetic.main.do_not_show_again.view.*
@SuppressLint("ValidFragment")
class DoNotShowAgainDialogFragment() : DialogFragment() { class DoNotShowAgainDialogFragment(nightMode: Boolean) : DialogFragment() {
var title: String? = null var title: String? = null
var positiveButton: String? = null var positiveButton: String? = null
var negativeButton: String? = null var negativeButton: String? = null
var message: String? = null var message: String? = null
var listener: DialogListener? = null var listener: DialogListener? = null
val dialogTheme: Int
constructor() : this(false)
init {
dialogTheme = if (nightMode) R.style.DialogThemeDark else R.style.DialogThemeLight
setStyle(DialogFragment.STYLE_NORMAL, dialogTheme)
}
interface DialogListener { interface DialogListener {
fun onDialogPositive(dialog: DoNotShowAgainDialogFragment, showAgain: Boolean) fun onDialogPositive(dialog: DoNotShowAgainDialogFragment, showAgain: Boolean)
@ -23,7 +32,7 @@ class DoNotShowAgainDialogFragment() : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
// Build the dialog and set up the button click handlers // Build the dialog and set up the button click handlers
val builder = AlertDialog.Builder(activity!!) val builder = AlertDialog.Builder(activity!!, dialogTheme)
val inflater = LayoutInflater.from(this.context) val inflater = LayoutInflater.from(this.context)
val dnsaLayout = inflater.inflate(R.layout.do_not_show_again, null) val dnsaLayout = inflater.inflate(R.layout.do_not_show_again, null)
val doNotShowAgainCB = dnsaLayout.do_not_show_again val doNotShowAgainCB = dnsaLayout.do_not_show_again

View file

@ -0,0 +1,121 @@
package eu.depau.etchdroid.utils
import android.content.SharedPreferences
import android.content.res.Configuration
import android.preference.PreferenceManager
import androidx.appcompat.app.AppCompatActivity
import java.lang.ref.WeakReference
/**
* Night Mode Helper
*
* Adapted from https://gist.github.com/slightfoot/c508cdc8828a478572e0
*
* Helps use utilise the night and notnight resource qualifiers without
* being in car or dock mode.
*
*
* Implementation is simple. Add the follow line at the top of your
* activity's onCreate just after the super.onCreate(); The idea here
* is to do it before we create any views. So the new views will use
* the correct Configuration.
*
* <pre>
* mNightModeHelper = new NightModeHelper(this, R.style.AppTheme);
</pre> *
*
* You can now use your instance of NightModeHelper to control which mode
* you are in. You can choose to persist the current setting and hand
* it back to this class as the defaultUiMode, otherwise this is done
* for you automatically.
*
*
* I'd suggest you setup your Theme as follows:
*
* *
* **res\values\styles.xml**
* <pre>&lt;style name=&quot;AppTheme&quot; parent=&quot;AppBaseTheme&quot;&gt;&lt;/style&gt;</pre>
*
* *
* **res\values-night\styles.xml**
* <pre>&lt;style name=&quot;AppBaseTheme&quot; parent=&quot;@android:style/Theme.Holo&quot;&gt;&lt;/style&gt;</pre>
*
* *
* **res\values-notnight\styles.xml**
* <pre>&lt;style name=&quot;AppBaseTheme&quot; parent=&quot;@android:style/Theme.Holo.Light&quot;&gt;&lt;/style&gt;</pre>
*
* @author Simon Lightfoot <simon></simon>@demondevelopers.com>
*/
class NightModeHelper {
private var mActivity: WeakReference<AppCompatActivity>? = null
lateinit var mPrefs: SharedPreferences
val nightMode: Boolean
get() = uiNightMode == Configuration.UI_MODE_NIGHT_YES
private val PREF_KEY = "nightModeState"
companion object {
var uiNightMode = Configuration.UI_MODE_NIGHT_UNDEFINED
}
/**
* Default behaviour is to automatically save the setting and restore it.
*/
constructor(activity: AppCompatActivity, theme: Int) {
val currentMode = activity.resources.configuration
.uiMode and Configuration.UI_MODE_NIGHT_MASK
mPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
init(activity, theme, mPrefs.getInt(PREF_KEY, currentMode))
}
/**
* If you don't want the autoSave feature and instead want to provide
* your own persisted storage for the mode, use the defaultUiMode for it.
*/
constructor(activity: AppCompatActivity, theme: Int, defaultUiMode: Int) {
init(activity, theme, defaultUiMode)
}
private fun init(activity: AppCompatActivity, theme: Int, defaultUiMode: Int) {
mActivity = WeakReference(activity)
if (uiNightMode == Configuration.UI_MODE_NIGHT_UNDEFINED) {
uiNightMode = defaultUiMode
}
updateConfig(uiNightMode)
// This may seem pointless but it forces the Theme to be reloaded
// with new styles that would change due to new Configuration.
activity.setTheme(theme)
}
private fun updateConfig(uiNightMode: Int) {
val activity = mActivity!!.get()
?: throw IllegalStateException("Activity went away while switching theme")
val newConfig = Configuration(activity.resources.configuration)
newConfig.uiMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()
newConfig.uiMode = newConfig.uiMode or uiNightMode
activity.resources.updateConfiguration(newConfig, null)
Companion.uiNightMode = uiNightMode
mPrefs.edit()?.putInt(PREF_KEY, Companion.uiNightMode)?.apply()
}
fun toggle() {
when (uiNightMode) {
Configuration.UI_MODE_NIGHT_YES -> notNight()
else -> night()
}
}
fun notNight() {
updateConfig(Configuration.UI_MODE_NIGHT_NO)
mActivity!!.get()!!.recreate()
}
fun night() {
updateConfig(Configuration.UI_MODE_NIGHT_YES)
mActivity!!.get()!!.recreate()
}
}

View file

@ -0,0 +1,16 @@
<vector android:height="96dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="0.3" android:fillColor="#FFFFFFFF"
android:pathData="m170.667,341.333h256v-256h-256z"
android:strokeAlpha="0.3" android:strokeWidth="21.33333206"/>
<path android:fillColor="#FFFFFFFF"
android:pathData="m426.667,42.667h-256c-23.467,0 -42.667,19.2 -42.667,42.667v256C128,364.8 147.2,384 170.667,384h256c23.467,0 42.667,-19.2 42.667,-42.667v-256c0,-23.467 -19.2,-42.667 -42.667,-42.667zM426.667,341.333h-256v-256h256z" android:strokeWidth="21.33333206"/>
<path android:fillColor="#FFFFFFFF"
android:pathData="M85.333,128L42.667,128v298.667c0,23.467 19.2,42.667 42.667,42.667L384,469.333L384,426.667L85.333,426.667Z" android:strokeWidth="21.33333206"/>
<path android:fillColor="#FFFFFF"
android:pathData="m277.992,209.953l11.969,0l0,41.891l17.953,0l0,-42.011l11.969,0L319.883,263.814l17.953,0L337.837,203.969C337.837,197.386 332.451,192 325.868,192l-53.86,0C265.424,192 260.038,197.386 260.038,203.969L260.038,263.814l17.953,0z" android:strokeWidth="0.83333331"/>
<path android:fillAlpha="1" android:fillColor="#FFFFFF"
android:pathData="M394.169,191.68L358.263,191.68c-7.181,0 -11.969,5.985 -11.969,11.969l0,47.876c0,5.984 4.788,11.969 11.969,11.969l35.907,0c7.181,0 11.969,-5.985 11.969,-11.969l0,-23.938l-17.953,0l0,17.953l-23.938,0l0,-35.907l41.891,0L406.139,203.649c0,-5.984 -4.788,-11.969 -11.969,-11.969z" android:strokeWidth="0.83333331"/>
<path android:fillColor="#FFFFFF"
android:pathData="M233.098,192L191.195,192L191.195,263.814l41.903,0c10.24,0 17.92,-7.815 17.92,-17.92L251.017,209.92c0,-10.105 -7.68,-17.92 -17.92,-17.92zM233.098,245.894L209.115,245.894L209.115,209.92l23.983,0z" android:strokeWidth="0.93808633"/>
</vector>

View file

@ -0,0 +1,13 @@
<vector android:height="96dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="0.3" android:fillColor="#FFFFFFFF"
android:pathData="M171.1,340.9L427.3,340.9L427.3,84.7L171.1,84.7Z" android:strokeAlpha="0.3"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M427.3,42L171.1,42C147.615,42 128.4,61.215 128.4,84.7l0,256.2c0,23.485 19.215,42.7 42.7,42.7l256.2,0c23.485,0 42.7,-19.215 42.7,-42.7L470,84.7C470,61.215 450.785,42 427.3,42ZM427.3,340.9L171.1,340.9L171.1,84.7l256.2,0z"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M85.7,127.4L43,127.4l0,298.9c0,23.485 19.215,42.7 42.7,42.7L384.6,469L384.6,426.3L85.7,426.3Z"/>
<path android:fillColor="#FFFFFFFF"
android:pathData="M253.711,221.384L253.711,209.384c0,-10.247 -7.82,-17.932 -17.932,-17.932L193.847,191.451L193.847,263.316l17.932,0l0,-24l13.753,0l10.247,24l17.932,0l-10.786,-25.213c5.932,-2.966 10.786,-9.573 10.786,-16.719zM235.779,221.384L211.779,221.384L211.779,209.384l24,0z" android:strokeWidth="0.63151968"/>
<path android:fillColor="#FFFFFFFF"
android:pathData="m280.71,245.35l23.955,0l0,17.966l17.966,0L322.631,203.429c0,-6.588 -5.39,-11.977 -11.977,-11.977l-35.932,0c-6.588,0 -11.977,5.39 -11.977,11.977L262.744,263.316l17.966,0zM280.71,209.418l23.955,0L304.665,227.384l-23.955,0z" android:strokeWidth="0.56099999"/>
<path android:fillColor="#FFFFFFFF"
android:pathData="m332.835,191.451l0,59.935c0,6.546 5.383,11.929 11.929,11.929l47.861,0c6.546,0 11.929,-5.383 11.929,-11.929L404.553,191.451L389.57,191.451L389.57,245.422L376.186,245.422L376.186,203.38l-14.984,0l0,42.187l-13.529,0L347.673,191.451Z" android:strokeWidth="0.68137652"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:alpha="0.9" android:height="200dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="200dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M15,7v4h1v2h-3V5h2l-3,-4 -3,4h2v8H8v-2.07c0.7,-0.37 1.2,-1.08 1.2,-1.93 0,-1.21 -0.99,-2.2 -2.2,-2.2 -1.21,0 -2.2,0.99 -2.2,2.2 0,0.85 0.5,1.56 1.2,1.93V13c0,1.11 0.89,2 2,2h3v3.05c-0.71,0.37 -1.2,1.1 -1.2,1.95 0,1.22 0.99,2.2 2.2,2.2 1.21,0 2.2,-0.98 2.2,-2.2 0,-0.85 -0.49,-1.58 -1.2,-1.95V15h3c1.11,0 2,-0.89 2,-2v-2h1V7h-4z"/>
</vector>

View file

@ -6,12 +6,14 @@
android:id="@+id/linearLayout" android:id="@+id/linearLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:theme="@style/DarkThemeOverlay"
tools:context=".activities.ConfirmationActivity"> tools:context=".activities.ConfirmationActivity">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView" android:id="@+id/nestedScrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:theme="@style/CardContentStyle"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -26,7 +28,7 @@
android:id="@+id/relativeLayout" android:id="@+id/relativeLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
@ -58,7 +60,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
@ -99,7 +101,7 @@
android:id="@+id/relativeLayout2" android:id="@+id/relativeLayout2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
@ -139,7 +141,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -10,6 +9,7 @@
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/row_padding" android:paddingBottom="@dimen/row_padding"
android:orientation="vertical" android:orientation="vertical"
android:theme="@style/CardContentStyle"
tools:context=".activities.ErrorActivity"> tools:context=".activities.ErrorActivity">
<TextView <TextView

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:theme="@style/CardContentStyle"
tools:context=".activities.LicensesActivity"> tools:context=".activities.LicensesActivity">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View file

@ -6,6 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:theme="@style/DarkThemeOverlay"
tools:context=".activities.StartActivity"> tools:context=".activities.StartActivity">
@ -17,6 +18,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".fragments.FlashMethodFragment" tools:context=".fragments.FlashMethodFragment"
android:background="?android:windowBackground"
tools:showIn="@layout/activity_start"> tools:showIn="@layout/activity_start">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
@ -28,13 +30,15 @@
android:layout_marginLeft="@dimen/card_margin" android:layout_marginLeft="@dimen/card_margin"
android:layout_marginTop="@dimen/card_margin" android:layout_marginTop="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin" android:layout_marginRight="@dimen/card_margin"
android:background="@color/background"
android:minHeight="200dp"> android:minHeight="200dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/btn_image_raw" android:id="@+id/btn_image_raw"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:theme="@style/CardContentStyle"
android:foreground="?attr/selectableItemBackground"
android:onClick="onButtonClicked"> android:onClick="onButtonClicked">
<ImageView <ImageView
@ -89,6 +93,7 @@
android:layout_marginTop="@dimen/card_margin" android:layout_marginTop="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin" android:layout_marginRight="@dimen/card_margin"
android:layout_marginBottom="@dimen/card_margin" android:layout_marginBottom="@dimen/card_margin"
android:background="@color/background"
android:minHeight="200dp"> android:minHeight="200dp">
<!-- <!--
android:background="?attr/selectableItemBackground"--> android:background="?attr/selectableItemBackground"-->
@ -96,7 +101,8 @@
android:id="@+id/btn_image_dmg" android:id="@+id/btn_image_dmg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:theme="@style/CardContentStyle"
android:foreground="?attr/selectableItemBackground"
android:onClick="onButtonClicked"> android:onClick="onButtonClicked">
<ImageView <ImageView

View file

@ -6,12 +6,14 @@
android:id="@+id/usbdevs_swiperefreshlayout" android:id="@+id/usbdevs_swiperefreshlayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:theme="@style/DarkThemeOverlay"
tools:context=".activities.UsbDrivePickerActivity"> tools:context=".activities.UsbDrivePickerActivity">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:theme="@style/CardContentStyle">
<eu.depau.etchdroid.utils.EmptyRecyclerView <eu.depau.etchdroid.utils.EmptyRecyclerView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
@ -35,7 +37,7 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:text="@string/no_usb_drives_detected" android:text="@string/no_usb_drives_detected"
android:textAlignment="center" android:textAlignment="center"
android:drawableTop="@drawable/ic_usb_black_200dp"/> android:drawableTop="@drawable/ic_usb_200dp"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -4,7 +4,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp" > android:padding="10dp"
android:theme="@style/CardContentStyle">
<CheckBox <CheckBox
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/do_not_show_again" android:id="@+id/do_not_show_again"

View file

@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"

View file

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="horizontal" android:orientation="horizontal"

View file

@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"

View file

@ -7,4 +7,10 @@
android:orderInCategory="100" android:orderInCategory="100"
android:title="@string/licenses" android:title="@string/licenses"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/action_nightmode"
android:orderInCategory="100"
android:title="@string/nightmode"
app:showAsAction="never"/>
</menu> </menu>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="nightmode">Disattiva modalità notturna</string>
</resources>

View file

@ -103,4 +103,5 @@
<string name="write_failed">Scrittura fallita</string> <string name="write_failed">Scrittura fallita</string>
<string name="unknown_error">Errore sconosciuto. Prova a ricollegare il dispositivo USB o a riavviare il dispositivo. Per favore, segnala il problema su GitHub.</string> <string name="unknown_error">Errore sconosciuto. Prova a ricollegare il dispositivo USB o a riavviare il dispositivo. Per favore, segnala il problema su GitHub.</string>
<string name="uncompressed">(decompresso)</string> <string name="uncompressed">(decompresso)</string>
<string name="nightmode">Attiva modalità notturna</string>
</resources> </resources>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#303138</color>
<color name="colorPrimaryDark">#23242a</color>
<color name="colorAccent">#a5d6a7</color>
<color name="info">#888888</color>
<color name="name">#dddddd</color>
<color name="background">#23242a</color>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="nightmode">Disable night mode</string>
</resources>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Dark application theme. -->
<style name="MaterialAppBaseTheme" parent="Theme.AppCompat">
<item name="cardStyle">@style/CardViewStyle.Dark</item>
</style>
<style name="DarkThemeOverlayBase" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:windowBackground">@color/background</item>
</style>
<style name="CardViewStyle.Dark" parent="CardView.Dark">
<item name="cardBackgroundColor">@android:color/background_dark</item>
</style>
<style name="CardContentStyleBase" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:background">@color/colorPrimary</item>
</style>
</resources>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Light application theme. -->
<style name="MaterialAppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
<style name="DarkThemeOverlayBase">
<item name="android:windowBackground">@color/background</item>
</style>
<style name="CardContentStyleBase"/>
</resources>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="cardStyle">
<attr name="cardStyle" format="reference"/>
</declare-styleable>
</resources>

View file

@ -5,4 +5,5 @@
<color name="colorAccent">#408924</color> <color name="colorAccent">#408924</color>
<color name="info">#999999</color> <color name="info">#999999</color>
<color name="name">#222222</color> <color name="name">#222222</color>
<color name="background">#F4F4F6</color>
</resources> </resources>

View file

@ -102,4 +102,5 @@
<string name="write_failed">Write failed</string> <string name="write_failed">Write failed</string>
<string name="unknown_error">Unknown error. Try to reattach the USB drive or reboot the device. Please file an issue on GitHub.</string> <string name="unknown_error">Unknown error. Try to reattach the USB drive or reboot the device. Please file an issue on GitHub.</string>
<string name="uncompressed">(uncompressed)</string> <string name="uncompressed">(uncompressed)</string>
<string name="nightmode">Enable night mode</string>
</resources> </resources>

View file

@ -1,7 +1,6 @@
<resources> <resources>
<!-- Base application theme. --> <style name="MaterialAppTheme" parent="Theme.AppCompat">
<style name="MaterialAppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
@ -9,5 +8,22 @@
<item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item> <item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>
</style> </style>
<style name="DarkThemeOverlay" parent="DarkThemeOverlayBase"/>
<style name="CardContentStyle" parent="CardContentStyleBase"/>
<style name="DialogThemeDark" parent="Theme.MaterialComponents.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:background">@color/colorPrimary</item>
<item name="android:windowBackground">@color/colorPrimary</item>
</style>
<style name="DialogThemeLight" parent="Theme.MaterialComponents.Light.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources> </resources>

View file

@ -1,6 +1,6 @@
#Thu Sep 13 22:30:46 CEST 2018 #Sat Sep 29 19:40:07 CEST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip