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

Added Nothing OS themes #401

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

* Lightweight (APK ~2MB)
* No unnecessary permissions
* Dark, Light, Amoled and Material You theme
* Dark, Light, Amoled, Material You and Nothing OS themes
* Scientific mode
* History
* Portrait and landscape orientation
Expand All @@ -58,6 +58,12 @@
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/4.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/5.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/6.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/8.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/9.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/10.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/11.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/12.png" width="15%"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/13.png" width="15%"/>

## ☕ Support

Expand Down
39 changes: 37 additions & 2 deletions app/src/main/java/com/darkempire78/opencalculator/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.text.Editable
Expand All @@ -16,11 +17,13 @@ import android.view.View
import android.view.accessibility.AccessibilityEvent
import android.widget.Button
import android.widget.HorizontalScrollView
import android.widget.ImageButton
import android.widget.Toast
import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.PopupMenu
import androidx.core.content.ContextCompat
import androidx.core.view.setPadding
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.darkempire78.opencalculator.databinding.ActivityMainBinding
Expand Down Expand Up @@ -57,6 +60,8 @@ class MainActivity : AppCompatActivity() {
private lateinit var historyAdapter: HistoryAdapter
private lateinit var historyLayoutMgr: LinearLayoutManager

private var isNothingTheme: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -66,11 +71,32 @@ class MainActivity : AppCompatActivity() {
setTheme(themes.getTheme())

currentTheme = themes.getTheme()
isNothingTheme = MyPreferences(this).theme == 3 || MyPreferences(this).theme == 4

binding = ActivityMainBinding.inflate(layoutInflater)
view = binding.root
setContentView(view)

// Set the buttons depending on the theme
if(isNothingTheme){
binding.backspaceButton.setImageResource(R.drawable.nothing_backspace)
binding.scientistModeSwitchButton?.setImageResource(R.drawable.nothing_arrow_down)
binding.exponentButton.setImageResource(R.drawable.nothing_exponent)
//binding.piButton.text = "" // blank the text
//binding.piButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0,R.drawable.nothing_pi,0,0)
//binding.squareButton.text = "" // blank the text
//binding.squareButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0,R.drawable.nothing_square,0,0)
}
else{ // Any other theme
binding.backspaceButton.setImageResource(R.drawable.backspace)
binding.scientistModeSwitchButton?.setImageResource(R.drawable.ic_baseline_keyboard_arrow_down_24)
binding.exponentButton.setImageResource(R.drawable.exponent)
//binding.piButton.setBackgroundResource(0)
//binding.piButton.setText(R.string.pi)
//binding.squareButton.setBackgroundResource(0)
//binding.squareButton.setText(R.string.square)
}

// Disable the keyboard on display EditText
binding.input.showSoftInputOnFocus = false

Expand Down Expand Up @@ -348,6 +374,7 @@ class MainActivity : AppCompatActivity() {
}

val formerValue = binding.input.text.toString()

val cursorPosition = binding.input.selectionStart
val leftValue = formerValue.subSequence(0, cursorPosition).toString()
val leftValueFormatted =
Expand Down Expand Up @@ -430,13 +457,21 @@ class MainActivity : AppCompatActivity() {
if (binding.scientistModeRow2.visibility != View.VISIBLE) {
binding.scientistModeRow2.visibility = View.VISIBLE
binding.scientistModeRow3.visibility = View.VISIBLE
binding.scientistModeSwitchButton?.setImageResource(R.drawable.ic_baseline_keyboard_arrow_up_24)
if (isNothingTheme){
binding.scientistModeSwitchButton?.setImageResource(R.drawable.nothing_arrow_up)
}else{
binding.scientistModeSwitchButton?.setImageResource(R.drawable.ic_baseline_keyboard_arrow_up_24)
}
binding.degreeTextView.visibility = View.VISIBLE
binding.degreeTextView.text = binding.degreeButton.text.toString()
} else {
binding.scientistModeRow2.visibility = View.GONE
binding.scientistModeRow3.visibility = View.GONE
binding.scientistModeSwitchButton?.setImageResource(R.drawable.ic_baseline_keyboard_arrow_down_24)
if (isNothingTheme){
binding.scientistModeSwitchButton?.setImageResource(R.drawable.nothing_arrow_down)
}else{
binding.scientistModeSwitchButton?.setImageResource(R.drawable.ic_baseline_keyboard_arrow_down_24)
}
binding.degreeTextView.visibility = View.GONE
binding.degreeTextView.text = binding.degreeButton.text.toString()
}
Expand Down
34 changes: 29 additions & 5 deletions app/src/main/java/com/darkempire78/opencalculator/Themes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@ class Themes(private val context: Context) {
private const val DEFAULT_THEME_INDEX = 0
private const val AMOLED_THEME_INDEX = 1
private const val MATERIAL_YOU_THEME_INDEX = 2
private const val NOTHING_LIGHT_THEME_INDEX = 3
private const val NOTHING_DARK_THEME_INDEX = 4

// used to go from Preference int value to actual theme
private val themeMap = mapOf(
DEFAULT_THEME_INDEX to R.style.AppTheme,
AMOLED_THEME_INDEX to R.style.AmoledTheme,
MATERIAL_YOU_THEME_INDEX to R.style.MaterialYouTheme
MATERIAL_YOU_THEME_INDEX to R.style.MaterialYouTheme,
NOTHING_LIGHT_THEME_INDEX to R.style.NothingLightTheme,
NOTHING_DARK_THEME_INDEX to R.style.NothingDarkTheme
)

// Styles - Combinations of theme + day/night mode
private const val SYSTEM_STYLE_INDEX = 0
private const val LIGHT_STYLE_INDEX = 1
private const val DARK_STYLE_INDEX = 2
private const val AMOLED_STYLE_INDEX = 3
private const val NOTHING_LIGHT_STYLE_INDEX = 4
private const val NOTHING_DARK_STYLE_INDEX = 5

fun openDialogThemeSelector(context: Context) {

Expand All @@ -47,12 +53,16 @@ class Themes(private val context: Context) {
SYSTEM_STYLE_INDEX to systemName,
LIGHT_STYLE_INDEX to context.getString(R.string.theme_light),
DARK_STYLE_INDEX to context.getString(R.string.theme_dark),
AMOLED_STYLE_INDEX to context.getString(R.string.theme_amoled)
AMOLED_STYLE_INDEX to context.getString(R.string.theme_amoled),
NOTHING_LIGHT_STYLE_INDEX to context.getString(R.string.theme_nothing_light),
NOTHING_DARK_STYLE_INDEX to context.getString(R.string.theme_nothing_dark)
)

val checkedItem = when (preferences.theme) {
AMOLED_THEME_INDEX -> AMOLED_STYLE_INDEX
MATERIAL_YOU_THEME_INDEX -> SYSTEM_STYLE_INDEX
NOTHING_LIGHT_THEME_INDEX -> NOTHING_LIGHT_STYLE_INDEX
NOTHING_DARK_THEME_INDEX -> NOTHING_DARK_STYLE_INDEX
else -> {
when (preferences.forceDayNight) {
AppCompatDelegate.MODE_NIGHT_NO -> LIGHT_STYLE_INDEX
Expand Down Expand Up @@ -81,6 +91,14 @@ class Themes(private val context: Context) {
preferences.theme = AMOLED_THEME_INDEX
preferences.forceDayNight = AppCompatDelegate.MODE_NIGHT_YES
}
NOTHING_LIGHT_STYLE_INDEX -> {
preferences.theme = NOTHING_LIGHT_THEME_INDEX
preferences.forceDayNight = AppCompatDelegate.MODE_NIGHT_NO
}
NOTHING_DARK_STYLE_INDEX -> {
preferences.theme = NOTHING_DARK_THEME_INDEX
preferences.forceDayNight = AppCompatDelegate.MODE_NIGHT_YES
}
}
dialog.dismiss()
reloadActivity(context)
Expand Down Expand Up @@ -115,10 +133,10 @@ class Themes(private val context: Context) {
var theme = "THEME"
when (themeID) {
DEFAULT_THEME_INDEX -> {
if (MyPreferences(this.context).forceDayNight == AppCompatDelegate.MODE_NIGHT_YES) {
theme = context.getString(R.string.theme_dark)
theme = if (MyPreferences(this.context).forceDayNight == AppCompatDelegate.MODE_NIGHT_YES) {
context.getString(R.string.theme_dark)
} else {
theme = context.getString(R.string.theme_light)
context.getString(R.string.theme_light)
}
}
MATERIAL_YOU_THEME_INDEX -> {
Expand All @@ -127,6 +145,12 @@ class Themes(private val context: Context) {
AMOLED_THEME_INDEX -> {
theme = context.getString(R.string.theme_amoled)
}
NOTHING_LIGHT_THEME_INDEX -> {
theme = context.getString(R.string.theme_nothing_light)
}
NOTHING_DARK_THEME_INDEX -> {
theme = context.getString(R.string.theme_nothing_dark)
}
}
return theme
}
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/res/drawable/nothing_arrow_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/text_color"
android:width="20dp"
android:height="15dp"
android:viewportWidth="400"
android:viewportHeight="300">
<group>
<path
android:pathData="M56.5 52Q78.1 52.4 87 65.5Q92.2 71.4 94 80.5L94 94.5Q90.9 108.9 80.5 116L68.5 122L54.5 123Q37.8 120.2 30 108.5Q21.5 99.5 24 79.5Q27.5 66 37.5 59L46.5 54L56.5 52Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M334.5 52Q355.2 52.3 364 64.5Q373.2 73.3 372 92.5Q369.3 107.3 359.5 115L346.5 122L332.5 123L319.5 119L307 107.5Q300.4 99.1 301 83.5L305 70.5L316.5 58L324.5 54L334.5 52Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M120.5 122Q134.2 120.3 142.5 124Q151.5 128 157 135.5L163 148.5L163 165.5Q159.6 178.1 150.5 185Q144.8 190.3 135.5 192L120.5 192Q106.4 188.1 99 177.5Q94.5 171.5 93 162.5L93 151.5L96 141.5L103 131Q109.6 125.1 120.5 122Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M259.5 122Q273.2 120.3 281.5 124L295 134.5Q300.2 140.4 302 149.5L302 164.5Q298.9 176.9 290.5 184L278.5 191Q271 193.5 259.5 192Q245.4 188.1 238 177.5L232 163.5L232 150.5Q234.8 137.3 243.5 130L259.5 122Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M193.5 191L201.5 191L210.5 193Q220.1 196.9 226 204.5L232 215.5L233 232.5Q230.2 245.7 221.5 253Q212.9 261.9 195.5 262Q194 259.5 188.5 261L179.5 257L169 247.5L163 235.5L162 223.5L166 209.5L177.5 197L182.5 194L193.5 191Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
</group>
</vector>
34 changes: 34 additions & 0 deletions app/src/main/res/drawable/nothing_arrow_up.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/text_color"
android:width="20dp"
android:height="15dp"
android:viewportWidth="400"
android:viewportHeight="300">
<group>
<path
android:pathData="M195.5 30Q215.3 30.3 224 41.5Q234.4 50.6 233 71.5Q230 85.5 220.5 93L207.5 100L193.5 101L180.5 97L168 85.5Q161.8 77.7 162 63.5Q164.5 62 163 56.5L167 47.5L176.5 37L185.5 32L195.5 30Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M120.5 100Q134.2 98.3 142.5 102L156 112.5L163 126.5L163 143.5Q159.5 157 149.5 164L135.5 170L120.5 170Q109.6 166.9 103 161L97 152.5L94 144.5L93 129.5Q95.9 113.4 107.5 106L120.5 100Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M259.5 100Q271 98.5 278.5 101Q288 104.5 294 111.5L301 123.5Q303.5 131 302 142.5Q299.1 156.1 289.5 163Q283.8 168.3 274.5 170L259.5 170Q247.1 166.9 240 158.5Q230.4 149.1 232 128.5Q235.4 113.4 246.5 106L259.5 100Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M54.5 169L62.5 169L71.5 171Q81.2 174.8 87 182.5Q92.2 188.4 94 197.5L94 211.5Q91.1 225.1 81.5 232Q73.1 240.1 56.5 240Q55 237.5 49.5 239L40.5 235L30 225.5Q21.5 216.5 24 196.5Q27.9 182.4 38.5 175Q45 170.5 54.5 169Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
<path
android:pathData="M332.5 169L340.5 169L349.5 171Q359.1 174.9 365 182.5Q373.1 191.4 372 209.5Q369.3 224.3 359.5 232L345.5 239L334.5 240Q333 237.5 327.5 239L316.5 234L307 224.5Q300.4 216.1 301 200.5L305 187.5L316.5 175L321.5 172L332.5 169Z"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeWidth="1" />
</group>
</vector>
Loading