Skip to content

Commit

Permalink
- Remove Save config button:
Browse files Browse the repository at this point in the history
 Now config saves when application is closed

 - Added clear log:
 Still WIP as miner is not added, but will clear miner log if user wishes to
  • Loading branch information
Nugetzrul3 committed Jan 6, 2020
1 parent f58338d commit 2edb048
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand Down
49 changes: 29 additions & 20 deletions app/src/main/java/com/example/myapplication/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

changeButtonText()
saveConfig()
setText()
clearLog()



Expand All @@ -39,6 +39,11 @@ class MainActivity : AppCompatActivity() {
Handler().postDelayed(Runnable { doublebackpressedonce = false }, 1000)
}

override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(!hasFocus)
saveConfig()
}

private fun changeButtonText() {
val start_button: Button = findViewById(R.id.button)
start_button.setText("Start")
Expand Down Expand Up @@ -70,31 +75,26 @@ class MainActivity : AppCompatActivity() {
var thrdstxt = findViewById(R.id.editText5) as EditText


val save_button: Button = findViewById(R.id.button3)
save_button.setOnClickListener {
val changeTextView2: TextView = findViewById(R.id.textView6)

var Settings = JSONObject()
Settings.put("URL", Pooltxt.text)
Settings.put("User", Usertxt.text)
Settings.put("Passwd", Passwdtxt.text)
Settings.put("CPU", thrdstxt.text)
var Settings = JSONObject()
Settings.put("URL", Pooltxt.text)
Settings.put("User", Usertxt.text)
Settings.put("Passwd", Passwdtxt.text)
Settings.put("CPU", thrdstxt.text)

changeTextView2.setText("Pool:" + Settings.get("URL").toString() + ", Username:" + Settings.get("User").toString() + ", Password: " + Settings.get("Passwd").toString() + ", Threads: " + Settings.get("CPU").toString())



var context = applicationContext.filesDir.path
var file = File(context + "config.json")
if(!file.exists()){
file.createNewFile()
file.writeText(Settings.toString())
}
else if(file.exists()){
file.writeText(Settings.toString())
}

var context = applicationContext.filesDir.path
var file = File(context + "config.json")
if(!file.exists()){
file.createNewFile()
file.writeText(Settings.toString())
}
else if(file.exists()){
file.writeText(Settings.toString())
}

}

fun setText() {
Expand Down Expand Up @@ -137,6 +137,15 @@ class MainActivity : AppCompatActivity() {

}

fun clearLog() {
val logclear: TextView = findViewById(R.id.textView6)
val clear_button: Button = findViewById(R.id.button3)

clear_button.setOnClickListener{
logclear.setText("")
}
}

}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
android:layout_height="48dp"
android:background="@drawable/roundshapebutton"
android:fadingEdge="horizontal"
android:text="Save Config"
android:text="Clear Log"
android:textColor="@color/colorText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand Down

0 comments on commit 2edb048

Please sign in to comment.