-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from mplekunov/Version_In_Progress
Version 3.0
- Loading branch information
Showing
42 changed files
with
1,482 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
.cxx | ||
local.properties | ||
/app/release/ | ||
/app/CalculatorApp/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,70 @@ | ||
package com.example.calculator | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.os.PersistableBundle | ||
import android.view.View | ||
import android.util.TypedValue | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.navigation.NavController | ||
import androidx.navigation.fragment.NavHostFragment | ||
import androidx.navigation.ui.setupActionBarWithNavController | ||
import androidx.core.content.ContextCompat | ||
import androidx.navigation.findNavController | ||
import androidx.preference.PreferenceManager | ||
import com.example.calculator.model.settings.SettingsManager | ||
|
||
class MainActivity : AppCompatActivity(R.layout.activity_main) { | ||
private lateinit var navController: NavController | ||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { | ||
super.onCreate(savedInstanceState, persistentState) | ||
loadDefaultSettings() | ||
setSupportActionBar(findViewById(R.id.toolbar)) | ||
} | ||
|
||
private fun loadDefaultSettings() { | ||
val settingsManager = SettingsManager(this) | ||
|
||
val typedValue = TypedValue() | ||
theme.resolveAttribute(com.google.android.material.R.attr.colorOnPrimary, typedValue, true) | ||
|
||
// settingsManager.setColor(R.string.saved_input_font_color_key, ContextCompat.getColor(this, typedValue.resourceId)) | ||
settingsManager.setColor(R.string.saved_output_font_color_key, ContextCompat.getColor(this, typedValue.resourceId)) | ||
|
||
settingsManager.setColor(R.string.saved_number_button_color_key, ContextCompat.getColor(this, typedValue.resourceId)) | ||
settingsManager.setColor(R.string.saved_function_button_color_key, resources.getColor(R.color.calc_function_button, theme)) | ||
settingsManager.setColor(R.string.saved_operator_button_color_key, resources.getColor(R.color.calc_operation_button, theme)) | ||
|
||
settingsManager.setColor(R.string.saved_clear_button_color_key, resources.getColor(R.color.calc_clear_button, theme)) | ||
settingsManager.setColor(R.string.saved_clear_all_button_color_key, resources.getColor(R.color.calc_clear_all_button, theme)) | ||
|
||
// val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment | ||
// navController = navHostFragment.navController | ||
// | ||
// setupActionBarWithNavController(navController) | ||
settingsManager.setColor(R.string.saved_disabled_button_color_key, resources.getColor(R.color.calc_disabled_button, theme)) | ||
settingsManager.setColor(R.string.saved_highlighting_color_key, resources.getColor(R.color.highlighted_text, theme)) | ||
|
||
// settingsManager.setString(R.string.saved_input_font_size_key, "35") | ||
// settingsManager.setString(R.string.saved_output_font_size_key, "20") | ||
} | ||
|
||
|
||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | ||
menuInflater.inflate(R.menu.menu, menu) | ||
return true | ||
} | ||
|
||
// override fun onSupportNavigateUp(): Boolean { | ||
// return navController.navigateUp() || super.onSupportNavigateUp() | ||
// } | ||
} | ||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return when(item.itemId) { | ||
R.id.settings_item -> { | ||
findNavController(R.id.nav_host_fragment).navigate(R.id.action_calculatorFragment_to_settingsFragment) | ||
true | ||
} | ||
R.id.about_item -> { | ||
val intent = Intent(Intent.ACTION_VIEW) | ||
intent.data = Uri.parse("https://github.com/mplekunov/CalculatorApp") | ||
|
||
startActivity(intent) | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/example/calculator/converter/ColorConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.example.calculator.converter | ||
|
||
import androidx.core.graphics.* | ||
|
||
object ColorConverter { | ||
fun toHexColor(color: Int): String { | ||
var alpha = color.alpha.toString(16) | ||
if (alpha.length == 1) | ||
alpha = "0$alpha" | ||
|
||
var red = color.red.toString(16) | ||
if (red.length == 1) | ||
red = "0$red" | ||
|
||
var green = color.green.toString(16) | ||
if (green.length == 1) | ||
green = "0$green" | ||
|
||
var blue = color.blue.toString(16) | ||
if (blue.length == 1) | ||
blue = "0$blue" | ||
|
||
return "#$alpha$red$green$blue" | ||
} | ||
|
||
fun toIntColor(color: String): Int { | ||
return color.toColorInt() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.