Change button text
This commit is contained in:
parent
c11d57de2e
commit
20ab2931f2
@ -54,7 +54,7 @@ class Login : AppCompatActivity() {
|
|||||||
.build()
|
.build()
|
||||||
service = retrofit.create(GeofenceService::class.java)
|
service = retrofit.create(GeofenceService::class.java)
|
||||||
|
|
||||||
login = findViewById(R.id.button_create_account)
|
login = findViewById(R.id.button_login)
|
||||||
login.setOnClickListener {
|
login.setOnClickListener {
|
||||||
intent = Intent(this, MainActivity::class.java)
|
intent = Intent(this, MainActivity::class.java)
|
||||||
login()
|
login()
|
||||||
|
@ -19,7 +19,6 @@ import de.hft.geotracker.GeofenceBroadcastReceiver
|
|||||||
import de.hft.geotracker.R
|
import de.hft.geotracker.R
|
||||||
import de.hft.geotracker.retrofit.*
|
import de.hft.geotracker.retrofit.*
|
||||||
import kotlinx.android.synthetic.main.activity_home.*
|
import kotlinx.android.synthetic.main.activity_home.*
|
||||||
import kotlinx.android.synthetic.main.dropdown_menu.*
|
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
@ -36,7 +35,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
lateinit var actionButton: TextView
|
lateinit var actionButton: TextView
|
||||||
var running = false
|
var running = false
|
||||||
var accName: String? = null
|
var accName: String? = null
|
||||||
var username: String? = null
|
|
||||||
lateinit var accounts: ValuesTimetrackAccounts
|
lateinit var accounts: ValuesTimetrackAccounts
|
||||||
lateinit var service: GeofenceService
|
lateinit var service: GeofenceService
|
||||||
lateinit var locationRequest: LocationRequest
|
lateinit var locationRequest: LocationRequest
|
||||||
@ -68,19 +66,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
?.apply()
|
?.apply()
|
||||||
getSharedPreferences("LOCATION", Context.MODE_PRIVATE)
|
getSharedPreferences("LOCATION", Context.MODE_PRIVATE)
|
||||||
.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
|
.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
|
||||||
val btnState = sharedPreferences.getBoolean("ENABLED", false)
|
val isInside = sharedPreferences.getBoolean("ENABLED", false)
|
||||||
|
|
||||||
println("Buttonstate: $btnState")
|
println("Is inside? -> $isInside")
|
||||||
if (btnState) {
|
if (isInside) {
|
||||||
|
button_start_stop?.text = getString(R.string.start)
|
||||||
button_start_stop?.setBackgroundColor(resources.getColor(R.color.logo_blue))
|
button_start_stop?.setBackgroundColor(resources.getColor(R.color.logo_blue))
|
||||||
} else {
|
} else {
|
||||||
button_start_stop?.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark))
|
button_start_stop?.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark))
|
||||||
if (running) {
|
if (running) {
|
||||||
button_start_stop.toggle()
|
|
||||||
callStartStop()
|
callStartStop()
|
||||||
}
|
}
|
||||||
|
button_start_stop?.text = getString(R.string.outside_place)
|
||||||
}
|
}
|
||||||
button_start_stop.isEnabled = btnState
|
button_start_stop.isEnabled = isInside
|
||||||
}
|
}
|
||||||
|
|
||||||
//JWToken lesen
|
//JWToken lesen
|
||||||
@ -106,31 +105,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
service = retrofit.create(GeofenceService::class.java)
|
service = retrofit.create(GeofenceService::class.java)
|
||||||
showUsername()
|
showUsername()
|
||||||
|
|
||||||
//Get Timetrack Accounts
|
|
||||||
/*val accountNames = mutableListOf<String>()
|
|
||||||
// accountNames.add("None")
|
|
||||||
val call = service.getAccounts(username!!)
|
|
||||||
call.enqueue(object: Callback<EmbeddedAccounts> {
|
|
||||||
override fun onResponse(
|
|
||||||
call: Call<EmbeddedAccounts>,
|
|
||||||
response: Response<EmbeddedAccounts>
|
|
||||||
) {
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
accounts = response.body()!!.accounts
|
|
||||||
accounts.entries.forEach {
|
|
||||||
accountNames.add(it.name + "")
|
|
||||||
}
|
|
||||||
initializeDropdown(accountNames)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
override fun onFailure(call: Call<EmbeddedAccounts>, t: Throwable) {
|
|
||||||
accountNames.add("None")
|
|
||||||
initializeDropdown(accountNames)
|
|
||||||
Toast.makeText(this@MainActivity, "You dont have any Timetrack Accounts ", Toast.LENGTH_LONG)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
|
|
||||||
actionButton = findViewById(R.id.button_start_stop)
|
actionButton = findViewById(R.id.button_start_stop)
|
||||||
actionButton.setOnClickListener {
|
actionButton.setOnClickListener {
|
||||||
callStartStop()
|
callStartStop()
|
||||||
@ -158,8 +132,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
running = !running
|
running = !running
|
||||||
if (running) {
|
if (running) {
|
||||||
account_spinner.visibility = View.GONE
|
account_spinner.visibility = View.GONE
|
||||||
|
button_start_stop?.text = getString(R.string.stop)
|
||||||
} else {
|
} else {
|
||||||
account_spinner.visibility = View.VISIBLE
|
account_spinner.visibility = View.VISIBLE
|
||||||
|
button_start_stop?.text = getString(R.string.start)
|
||||||
}
|
}
|
||||||
if (!accName.isNullOrEmpty()) {
|
if (!accName.isNullOrEmpty()) {
|
||||||
val call = service.triggerTracking(accName!!)
|
val call = service.triggerTracking(accName!!)
|
||||||
@ -186,16 +162,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
val firstname = response.body()?.firstname
|
val firstname = response.body()?.firstname
|
||||||
val location = response.body()?.location
|
val location = response.body()?.location
|
||||||
username = response.body()?.username
|
val username = response.body()?.username
|
||||||
getTimetrackAccounts(username!!)
|
getTimetrackAccounts(username!!)
|
||||||
/* println("Username response: " + response.body()?.username)
|
|
||||||
if (!username.equals(null)) {
|
|
||||||
getTimetrackAccounts(username!!)
|
|
||||||
println("Your name: $username")
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this@MainActivity, "Not able to read your username", Toast.LENGTH_LONG)
|
|
||||||
.show()
|
|
||||||
}*/
|
|
||||||
lbl_username.text = "Hello " + firstname
|
lbl_username.text = "Hello " + firstname
|
||||||
if (location?.latitude == null) {
|
if (location?.latitude == null) {
|
||||||
Toast.makeText(this@MainActivity, "No geofence set for you", Toast.LENGTH_LONG)
|
Toast.makeText(this@MainActivity, "No geofence set for you", Toast.LENGTH_LONG)
|
||||||
@ -219,7 +187,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private fun getTimetrackAccounts(user: String) {
|
private fun getTimetrackAccounts(user: String) {
|
||||||
val accountNames = mutableListOf<String>()
|
val accountNames = mutableListOf<String>()
|
||||||
// accountNames.add("None")
|
// accountNames.add("None")
|
||||||
val call = service.getAccounts(username!!)
|
val call = service.getAccounts(user)
|
||||||
call.enqueue(object: Callback<EmbeddedAccounts> {
|
call.enqueue(object: Callback<EmbeddedAccounts> {
|
||||||
override fun onResponse(
|
override fun onResponse(
|
||||||
call: Call<EmbeddedAccounts>,
|
call: Call<EmbeddedAccounts>,
|
||||||
@ -237,6 +205,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onFailure(call: Call<EmbeddedAccounts>, t: Throwable) {
|
override fun onFailure(call: Call<EmbeddedAccounts>, t: Throwable) {
|
||||||
accountNames.add("None")
|
accountNames.add("None")
|
||||||
initializeDropdown(accountNames)
|
initializeDropdown(accountNames)
|
||||||
|
button_start_stop?.text = "No Timetrack Accounts"
|
||||||
Toast.makeText(this@MainActivity, "You dont have any Timetrack Accounts ", Toast.LENGTH_LONG)
|
Toast.makeText(this@MainActivity, "You dont have any Timetrack Accounts ", Toast.LENGTH_LONG)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class Register : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_register)
|
setContentView(R.layout.activity_register)
|
||||||
reg = findViewById(R.id.button_create_account)
|
reg = findViewById(R.id.button_login)
|
||||||
reg.setOnClickListener {
|
reg.setOnClickListener {
|
||||||
createAccount()
|
createAccount()
|
||||||
}
|
}
|
||||||
|
@ -68,23 +68,20 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/divider2"
|
app:layout_constraintTop_toBottomOf="@+id/divider2"
|
||||||
app:layout_constraintVertical_bias="0.0" />
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
<ToggleButton
|
<Button
|
||||||
android:id="@+id/button_start_stop"
|
android:id="@+id/button_start_stop"
|
||||||
style="@style/Widget.MaterialComponents.Button"
|
style="@style/Widget.MaterialComponents.Button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="55dp"
|
||||||
android:layout_marginStart="@dimen/margin16"
|
android:layout_marginStart="@dimen/margin16"
|
||||||
android:layout_marginEnd="@dimen/margin16"
|
android:layout_marginEnd="@dimen/margin16"
|
||||||
android:layout_marginBottom="@dimen/margin16"
|
android:layout_marginBottom="@dimen/margin16"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:checked="true"
|
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
|
android:text="@string/outside_place"
|
||||||
android:textAppearance="@style/text_style"
|
android:textAppearance="@style/text_style"
|
||||||
android:textColor="@color/logo_white"
|
android:textColor="@color/logo_white"
|
||||||
android:textOff="@string/stop"
|
|
||||||
android:textOn="@string/btn_start_text"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:cornerRadius="8dp"
|
|
||||||
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" />
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
android:textColorHint="@color/logo_white"
|
android:textColorHint="@color/logo_white"
|
||||||
app:boxBackgroundColor="@color/common_google_signin_btn_text_dark_disabled"
|
app:boxBackgroundColor="@color/common_google_signin_btn_text_dark_disabled"
|
||||||
app:boxBackgroundMode="outline"
|
app:boxBackgroundMode="outline"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button_create_account"
|
app:layout_constraintBottom_toTopOf="@+id/button_login"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@ -81,7 +81,7 @@
|
|||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_create_account"
|
android:id="@+id/button_login"
|
||||||
style="@style/Widget.MaterialComponents.Button"
|
style="@style/Widget.MaterialComponents.Button"
|
||||||
android:layout_width="240dp"
|
android:layout_width="240dp"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp"
|
||||||
@ -112,7 +112,7 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.497"
|
app:layout_constraintHorizontal_bias="0.497"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/button_create_account"
|
app:layout_constraintTop_toBottomOf="@+id/button_login"
|
||||||
app:layout_constraintVertical_bias="0.0" />
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -33,7 +33,7 @@
|
|||||||
android:hint="@string/confirm_password"
|
android:hint="@string/confirm_password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button_create_account"
|
app:layout_constraintBottom_toTopOf="@+id/button_login"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/input_email_register"
|
app:layout_constraintEnd_toEndOf="@+id/input_email_register"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/input_password_layout" />
|
app:layout_constraintTop_toBottomOf="@+id/input_password_layout" />
|
||||||
|
|
||||||
@ -87,7 +87,7 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/input_email_register" />
|
app:layout_constraintTop_toBottomOf="@+id/input_email_register" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_create_account"
|
android:id="@+id/button_login"
|
||||||
style="@style/Widget.MaterialComponents.Button"
|
style="@style/Widget.MaterialComponents.Button"
|
||||||
android:layout_width="240dp"
|
android:layout_width="240dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<string name="btn_start_text">START</string>
|
<string name="btn_start_text">START</string>
|
||||||
<string name="pause">PAUSE</string>
|
<string name="pause">PAUSE</string>
|
||||||
<string name="stop">STOP</string>
|
<string name="stop">STOP</string>
|
||||||
|
<string name="start">START</string>
|
||||||
<string name="username_email">Your Username or E-Mail</string>
|
<string name="username_email">Your Username or E-Mail</string>
|
||||||
<string name="username">Username</string>
|
<string name="username">Username</string>
|
||||||
<string name="choose_username">Choose a Username</string>
|
<string name="choose_username">Choose a Username</string>
|
||||||
@ -37,4 +38,5 @@
|
|||||||
<string name="submit">Submit</string>
|
<string name="submit">Submit</string>
|
||||||
<string name="logout">Logout</string>
|
<string name="logout">Logout</string>
|
||||||
<string name="hello">Hello</string>
|
<string name="hello">Hello</string>
|
||||||
|
<string name="outside_place">Outside your working place</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user