diff --git a/app/build.gradle b/app/build.gradle index 288b935..c69d09e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,22 +26,22 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) 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 'com.google.android.material:material:1.0.0-rc02' - implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02' - implementation 'androidx.gridlayout:gridlayout:1.0.0-rc02' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'androidx.gridlayout:gridlayout:1.0.0' 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 project(':libaums') implementation project(':dmg2img') implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation 'com.android.support:design:28.0.0-rc02' - implementation 'com.android.support:appcompat-v7:28.0.0-rc02' + implementation 'com.android.support:design:28.0.0' + implementation 'com.android.support:appcompat-v7:28.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' diff --git a/app/src/main/java/eu/depau/etchdroid/activities/ActivityBase.kt b/app/src/main/java/eu/depau/etchdroid/activities/ActivityBase.kt index 899d3d6..4811550 100644 --- a/app/src/main/java/eu/depau/etchdroid/activities/ActivityBase.kt +++ b/app/src/main/java/eu/depau/etchdroid/activities/ActivityBase.kt @@ -1,12 +1,21 @@ package eu.depau.etchdroid.activities import android.content.Intent +import android.os.Bundle import android.view.Menu import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity 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 { // Inflate the menu; this adds items to the action bar if it is present. @@ -24,6 +33,10 @@ abstract class ActivityBase: AppCompatActivity() { startActivity(intent) return true } + R.id.action_nightmode -> { + nightModeHelper.toggle() + return true + } else -> super.onOptionsItemSelected(item) } } diff --git a/app/src/main/java/eu/depau/etchdroid/activities/ConfirmationActivity.kt b/app/src/main/java/eu/depau/etchdroid/activities/ConfirmationActivity.kt index 9c99ade..69b2c4e 100644 --- a/app/src/main/java/eu/depau/etchdroid/activities/ConfirmationActivity.kt +++ b/app/src/main/java/eu/depau/etchdroid/activities/ConfirmationActivity.kt @@ -37,7 +37,7 @@ class ConfirmationActivity : ActivityBase() { fun showDataLossAlertDialog() { - val dialogFragment = DoNotShowAgainDialogFragment() + val dialogFragment = DoNotShowAgainDialogFragment(nightModeHelper.nightMode) dialogFragment.title = getString(R.string.warning) dialogFragment.message = getString(R.string.dataloss_confirmation_dialog_message) dialogFragment.positiveButton = getString(R.string.confirm_flash_image) diff --git a/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt b/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt index 8462d5d..50a35ed 100644 --- a/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt +++ b/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt @@ -1,11 +1,10 @@ package eu.depau.etchdroid.activities import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity import eu.depau.etchdroid.R import kotlinx.android.synthetic.main.activity_error.* -class ErrorActivity : AppCompatActivity() { +class ErrorActivity : ActivityBase() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/eu/depau/etchdroid/activities/StartActivity.kt b/app/src/main/java/eu/depau/etchdroid/activities/StartActivity.kt index 307dd05..a7356f5 100644 --- a/app/src/main/java/eu/depau/etchdroid/activities/StartActivity.kt +++ b/app/src/main/java/eu/depau/etchdroid/activities/StartActivity.kt @@ -1,16 +1,15 @@ package eu.depau.etchdroid.activities import android.Manifest -import android.app.Activity import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle import android.os.Environment import android.view.View +import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat -import com.codekidlabs.storagechooser.StorageChooser import eu.depau.etchdroid.R import eu.depau.etchdroid.StateKeeper import eu.depau.etchdroid.enums.FlashMethod @@ -62,7 +61,7 @@ class StartActivity : ActivityBase() { } fun showDMGBetaAlertDialog() { - val dialogFragment = DoNotShowAgainDialogFragment() + val dialogFragment = DoNotShowAgainDialogFragment(nightModeHelper.nightMode) dialogFragment.title = getString(R.string.here_be_dragons) dialogFragment.message = getString(R.string.dmg_alert_dialog_text) dialogFragment.positiveButton = getString(R.string.i_understand) @@ -145,7 +144,7 @@ class StartActivity : ActivityBase() { } 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. // Instead, a URI to that document will be contained in the return intent // provided to this method as a parameter. diff --git a/app/src/main/java/eu/depau/etchdroid/utils/DoNotShowAgainDialogFragment.kt b/app/src/main/java/eu/depau/etchdroid/utils/DoNotShowAgainDialogFragment.kt index 75da5d7..a135117 100644 --- a/app/src/main/java/eu/depau/etchdroid/utils/DoNotShowAgainDialogFragment.kt +++ b/app/src/main/java/eu/depau/etchdroid/utils/DoNotShowAgainDialogFragment.kt @@ -1,5 +1,6 @@ package eu.depau.etchdroid.utils +import android.annotation.SuppressLint import android.app.Dialog import android.os.Bundle import android.view.LayoutInflater @@ -8,13 +9,21 @@ import androidx.fragment.app.DialogFragment import eu.depau.etchdroid.R import kotlinx.android.synthetic.main.do_not_show_again.view.* - -class DoNotShowAgainDialogFragment() : DialogFragment() { +@SuppressLint("ValidFragment") +class DoNotShowAgainDialogFragment(nightMode: Boolean) : DialogFragment() { var title: String? = null var positiveButton: String? = null var negativeButton: String? = null var message: String? = 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 { fun onDialogPositive(dialog: DoNotShowAgainDialogFragment, showAgain: Boolean) @@ -23,7 +32,7 @@ class DoNotShowAgainDialogFragment() : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { // 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 dnsaLayout = inflater.inflate(R.layout.do_not_show_again, null) val doNotShowAgainCB = dnsaLayout.do_not_show_again @@ -37,7 +46,7 @@ class DoNotShowAgainDialogFragment() : DialogFragment() { } if (negativeButton != null) - builder.setNegativeButton(negativeButton) {_, _ -> + builder.setNegativeButton(negativeButton) { _, _ -> listener?.onDialogNegative(this@DoNotShowAgainDialogFragment, !doNotShowAgainCB.isChecked) } diff --git a/app/src/main/java/eu/depau/etchdroid/utils/NightModeHelper.kt b/app/src/main/java/eu/depau/etchdroid/utils/NightModeHelper.kt new file mode 100644 index 0000000..510313b --- /dev/null +++ b/app/src/main/java/eu/depau/etchdroid/utils/NightModeHelper.kt @@ -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><style name="AppTheme" parent="AppBaseTheme"></style></pre> + * + * * + * **res\values-night\styles.xml** + * <pre><style name="AppBaseTheme" parent="@android:style/Theme.Holo"></style></pre> + * + * * + * **res\values-notnight\styles.xml** + * <pre><style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light"></style></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() + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-night/ic_dmg.xml b/app/src/main/res/drawable-night/ic_dmg.xml new file mode 100644 index 0000000..b185083 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_dmg.xml @@ -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> diff --git a/app/src/main/res/drawable-night/ic_raw.xml b/app/src/main/res/drawable-night/ic_raw.xml new file mode 100644 index 0000000..1812526 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_raw.xml @@ -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> diff --git a/app/src/main/res/drawable-night/ic_usb_200dp.xml b/app/src/main/res/drawable-night/ic_usb_200dp.xml new file mode 100644 index 0000000..44e2387 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_usb_200dp.xml @@ -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> diff --git a/app/src/main/res/drawable/ic_usb_black_200dp.xml b/app/src/main/res/drawable/ic_usb_200dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_usb_black_200dp.xml rename to app/src/main/res/drawable/ic_usb_200dp.xml diff --git a/app/src/main/res/layout/activity_confirmation.xml b/app/src/main/res/layout/activity_confirmation.xml index 7124c65..f49b3cf 100644 --- a/app/src/main/res/layout/activity_confirmation.xml +++ b/app/src/main/res/layout/activity_confirmation.xml @@ -6,12 +6,14 @@ android:id="@+id/linearLayout" android:layout_width="match_parent" android:layout_height="match_parent" + android:theme="@style/DarkThemeOverlay" tools:context=".activities.ConfirmationActivity"> <androidx.core.widget.NestedScrollView android:id="@+id/nestedScrollView" android:layout_width="match_parent" android:layout_height="match_parent" + android:theme="@style/CardContentStyle" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -26,7 +28,7 @@ android:id="@+id/relativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" @@ -58,7 +60,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" @@ -99,7 +101,7 @@ android:id="@+id/relativeLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" @@ -139,7 +141,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" diff --git a/app/src/main/res/layout/activity_error.xml b/app/src/main/res/layout/activity_error.xml index 64f6b8d..b98c659 100644 --- a/app/src/main/res/layout/activity_error.xml +++ b/app/src/main/res/layout/activity_error.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" @@ -10,6 +9,7 @@ android:paddingRight="@dimen/activity_horizontal_margin" android:paddingBottom="@dimen/row_padding" android:orientation="vertical" + android:theme="@style/CardContentStyle" tools:context=".activities.ErrorActivity"> <TextView diff --git a/app/src/main/res/layout/activity_licenses.xml b/app/src/main/res/layout/activity_licenses.xml index 61e2f8c..b0c595e 100644 --- a/app/src/main/res/layout/activity_licenses.xml +++ b/app/src/main/res/layout/activity_licenses.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <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:theme="@style/CardContentStyle" tools:context=".activities.LicensesActivity"> <androidx.recyclerview.widget.RecyclerView diff --git a/app/src/main/res/layout/activity_start.xml b/app/src/main/res/layout/activity_start.xml index c087bc1..b8cf666 100644 --- a/app/src/main/res/layout/activity_start.xml +++ b/app/src/main/res/layout/activity_start.xml @@ -6,6 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" + android:theme="@style/DarkThemeOverlay" tools:context=".activities.StartActivity"> @@ -17,6 +18,7 @@ android:layout_height="match_parent" android:orientation="vertical" tools:context=".fragments.FlashMethodFragment" + android:background="?android:windowBackground" tools:showIn="@layout/activity_start"> <androidx.cardview.widget.CardView @@ -28,13 +30,15 @@ android:layout_marginLeft="@dimen/card_margin" android:layout_marginTop="@dimen/card_margin" android:layout_marginRight="@dimen/card_margin" + android:background="@color/background" android:minHeight="200dp"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/btn_image_raw" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/selectableItemBackground" + android:theme="@style/CardContentStyle" + android:foreground="?attr/selectableItemBackground" android:onClick="onButtonClicked"> <ImageView @@ -89,6 +93,7 @@ android:layout_marginTop="@dimen/card_margin" android:layout_marginRight="@dimen/card_margin" android:layout_marginBottom="@dimen/card_margin" + android:background="@color/background" android:minHeight="200dp"> <!-- android:background="?attr/selectableItemBackground"--> @@ -96,7 +101,8 @@ android:id="@+id/btn_image_dmg" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/selectableItemBackground" + android:theme="@style/CardContentStyle" + android:foreground="?attr/selectableItemBackground" android:onClick="onButtonClicked"> <ImageView diff --git a/app/src/main/res/layout/activity_usb_drive_picker.xml b/app/src/main/res/layout/activity_usb_drive_picker.xml index 071ce4e..eeb02cb 100644 --- a/app/src/main/res/layout/activity_usb_drive_picker.xml +++ b/app/src/main/res/layout/activity_usb_drive_picker.xml @@ -6,12 +6,14 @@ android:id="@+id/usbdevs_swiperefreshlayout" android:layout_width="match_parent" android:layout_height="match_parent" + android:theme="@style/DarkThemeOverlay" tools:context=".activities.UsbDrivePickerActivity"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:theme="@style/CardContentStyle"> <eu.depau.etchdroid.utils.EmptyRecyclerView xmlns:android="http://schemas.android.com/apk/res/android" @@ -35,7 +37,7 @@ app:layout_constraintTop_toTopOf="parent" android:text="@string/no_usb_drives_detected" android:textAlignment="center" - android:drawableTop="@drawable/ic_usb_black_200dp"/> + android:drawableTop="@drawable/ic_usb_200dp"/> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout/do_not_show_again.xml b/app/src/main/res/layout/do_not_show_again.xml index 1c594c7..60c6fba 100644 --- a/app/src/main/res/layout/do_not_show_again.xml +++ b/app/src/main/res/layout/do_not_show_again.xml @@ -4,7 +4,8 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" - android:padding="10dp" > + android:padding="10dp" + android:theme="@style/CardContentStyle"> <CheckBox xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/do_not_show_again" diff --git a/app/src/main/res/layout/license_row.xml b/app/src/main/res/layout/license_row.xml index 7f886a9..4005155 100644 --- a/app/src/main/res/layout/license_row.xml +++ b/app/src/main/res/layout/license_row.xml @@ -2,7 +2,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:foreground="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" diff --git a/app/src/main/res/layout/partition_row.xml b/app/src/main/res/layout/partition_row.xml index 03321d5..86f52df 100644 --- a/app/src/main/res/layout/partition_row.xml +++ b/app/src/main/res/layout/partition_row.xml @@ -1,9 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <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_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:foreground="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="horizontal" diff --git a/app/src/main/res/layout/usb_device_row.xml b/app/src/main/res/layout/usb_device_row.xml index 53bc20c..0f726d3 100644 --- a/app/src/main/res/layout/usb_device_row.xml +++ b/app/src/main/res/layout/usb_device_row.xml @@ -2,7 +2,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" + android:foreground="?attr/selectableItemBackground" android:clickable="true" android:focusable="true" android:orientation="vertical" diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 70407c2..ba5e38f 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -7,4 +7,10 @@ android:orderInCategory="100" android:title="@string/licenses" app:showAsAction="never"/> + + <item + android:id="@+id/action_nightmode" + android:orderInCategory="100" + android:title="@string/nightmode" + app:showAsAction="never"/> </menu> diff --git a/app/src/main/res/values-it-night/strings.xml b/app/src/main/res/values-it-night/strings.xml new file mode 100644 index 0000000..75780d5 --- /dev/null +++ b/app/src/main/res/values-it-night/strings.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="nightmode">Disattiva modalità notturna</string> +</resources> \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7d6b26e..c635e70 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -103,4 +103,5 @@ <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="uncompressed">(decompresso)</string> + <string name="nightmode">Attiva modalità notturna</string> </resources> \ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..a214edf --- /dev/null +++ b/app/src/main/res/values-night/colors.xml @@ -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> \ No newline at end of file diff --git a/app/src/main/res/values-night/strings.xml b/app/src/main/res/values-night/strings.xml new file mode 100644 index 0000000..d51af1c --- /dev/null +++ b/app/src/main/res/values-night/strings.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="nightmode">Disable night mode</string> +</resources> \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..4abe5ca --- /dev/null +++ b/app/src/main/res/values-night/styles.xml @@ -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> \ No newline at end of file diff --git a/app/src/main/res/values-notnight/styles.xml b/app/src/main/res/values-notnight/styles.xml new file mode 100644 index 0000000..b8c3c06 --- /dev/null +++ b/app/src/main/res/values-notnight/styles.xml @@ -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> \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 0000000..ad070ae --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <declare-styleable name="cardStyle"> + <attr name="cardStyle" format="reference"/> + </declare-styleable> +</resources> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f7561ab..5ca2e51 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,4 +5,5 @@ <color name="colorAccent">#408924</color> <color name="info">#999999</color> <color name="name">#222222</color> + <color name="background">#F4F4F6</color> </resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c4cf56..f8df20b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,4 +102,5 @@ <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="uncompressed">(uncompressed)</string> + <string name="nightmode">Enable night mode</string> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 15dad01..364d9da 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,7 +1,6 @@ <resources> - <!-- Base application theme. --> - <style name="MaterialAppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> + <style name="MaterialAppTheme" parent="Theme.AppCompat"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> @@ -9,5 +8,22 @@ <item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item> </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> \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aca2f7c..8b1ff19 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Sep 13 22:30:46 CEST 2018 +#Sat Sep 29 19:40:07 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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