-
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.
- Loading branch information
Showing
41 changed files
with
926 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<resources> | ||
|
||
<!-- Preference keys --> | ||
<string name="pref_login_manger" translatable="false">pref_login_manger</string> | ||
<string name="pref_key_voice" translatable="false">pref_voice</string> | ||
|
||
</resources> |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/deliner/mosfauna/activity/CommonActivity.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,43 @@ | ||
package com.deliner.mosfauna.activity | ||
|
||
import android.os.Bundle | ||
import android.os.Message | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.FragmentManager | ||
import com.deliner.mosfauna.dialog.CommonDialogFragment | ||
import com.deliner.mosfauna.dialog.DialogManager | ||
import com.deliner.mosfauna.utils.StaticHandler | ||
import java.lang.Exception | ||
|
||
abstract class CommonActivity : AppCompatActivity(), StaticHandler.Callback, DialogManager.Callback { | ||
|
||
private lateinit var dialogManager: DialogManager | ||
|
||
override fun handleServiceMessage(msg: Message) { | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
dialogManager = DialogManager(this) | ||
} | ||
|
||
override fun onPause() { | ||
dialogManager.onPause() | ||
super.onPause() | ||
} | ||
|
||
override fun onPostResume() { | ||
dialogManager.onPostResume() | ||
super.onPostResume() | ||
} | ||
|
||
override fun getSupportManager(): FragmentManager { | ||
return supportFragmentManager | ||
} | ||
|
||
override fun onCreateDialogEx(tag: String, args: Bundle?): CommonDialogFragment { | ||
throw Exception("No dialog implementation for this tag $tag") | ||
} | ||
|
||
protected fun showDialogEx(tag: String, args: Bundle? = null) = dialogManager.showDialogEx(tag, args) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/deliner/mosfauna/activity/GreetActivity.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,30 @@ | ||
package com.deliner.mosfauna.activity | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.widget.Button | ||
import com.deliner.mosfauna.R | ||
import com.deliner.mosfauna.utils.LoginManager | ||
|
||
class GreetActivity : AppCompatActivity() { | ||
private lateinit var loginButton: Button | ||
private lateinit var joinButton: Button | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_greet) | ||
|
||
if (LoginManager.getInstance(applicationContext).getCurrentUser() != null) { | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) | ||
startActivity(Intent(this, StartActivity::class.java)) | ||
return | ||
} | ||
|
||
joinButton = findViewById(R.id.activity_greet_join) | ||
loginButton = findViewById(R.id.activity_greet_login) | ||
|
||
joinButton.setOnClickListener { startActivity(Intent(this, JoinActivity::class.java)) } | ||
loginButton.setOnClickListener { startActivity(Intent(this, LoginActivity::class.java)) } | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
app/src/main/java/com/deliner/mosfauna/activity/JoinActivity.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,116 @@ | ||
package com.deliner.mosfauna.activity | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.Message | ||
import android.view.MenuItem | ||
import android.widget.Button | ||
import android.widget.CheckBox | ||
import android.widget.EditText | ||
import android.widget.Toast | ||
import com.deliner.mosfauna.R | ||
import com.deliner.mosfauna.dialog.CommonDialogFragment | ||
import com.deliner.mosfauna.dialog.DialogTags | ||
import com.deliner.mosfauna.dialog.RequestCodeDialog | ||
import com.deliner.mosfauna.system.CoreConst | ||
import com.deliner.mosfauna.utils.LoginManager | ||
import com.deliner.mosfauna.utils.StaticHandler | ||
|
||
class JoinActivity : UserActivity() { | ||
|
||
private lateinit var passwordText: EditText | ||
private lateinit var emailText: EditText | ||
private lateinit var loginText: EditText | ||
private lateinit var checkBox: CheckBox | ||
|
||
private lateinit var loginButton: Button | ||
|
||
private var pendingRequest = false | ||
|
||
private var user: LoginManager.User? = null | ||
|
||
override fun handleServiceMessage(msg: Message) { | ||
when (msg.what) { | ||
CoreConst.ON_SEND_REQUEST_CODE -> onSendRequestCode(msg.obj as String) | ||
CoreConst.ON_CANCEL_REQUEST_CODE -> pendingRequest = false | ||
else -> super.handleServiceMessage(msg) | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_join) | ||
|
||
setSupportActionBar(findViewById(R.id.toolbar)) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
loginButton = findViewById(R.id.activity_join_button_join) | ||
passwordText = findViewById(R.id.activity_join_password) | ||
emailText = findViewById(R.id.activity_join_email) | ||
loginText = findViewById(R.id.activity_join_login) | ||
checkBox = findViewById(R.id.activity_join_checkbox) | ||
|
||
checkBox.isChecked = false | ||
loginButton.isEnabled = false | ||
checkBox.setOnClickListener { loginButton.isEnabled = (it as CheckBox).isChecked } | ||
|
||
loginButton.setOnClickListener { | ||
if (checkEmail(emailText.text.toString()) && checkLogin(loginText.text.toString()) && checkPassword( | ||
passwordText.text.toString() | ||
) && !pendingRequest | ||
) { | ||
user = LoginManager.User( | ||
loginText.text.toString(), | ||
passwordText.text.toString(), | ||
emailText.text.toString() | ||
) | ||
pendingRequest = true | ||
showDialogEx(DialogTags.REQUEST_CODE) | ||
} | ||
} | ||
} | ||
|
||
private fun onSendRequestCode(code: String) { | ||
if (code == "0000") { | ||
LoginManager.getInstance(applicationContext).setCurrentUser(user!!) | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) | ||
startActivity(Intent(this, MainActivity::class.java)) | ||
} else { | ||
Toast.makeText(applicationContext, "Invalid code format", Toast.LENGTH_SHORT).show() | ||
pendingRequest = false | ||
} | ||
} | ||
|
||
override fun onCreateDialogEx(tag: String, args: Bundle?): CommonDialogFragment { | ||
return when (tag) { | ||
DialogTags.REQUEST_CODE -> RequestCodeDialog.getInstance().setDialogResult(handler) | ||
else -> super.onCreateDialogEx(tag, args) | ||
} | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
if (item.itemId == android.R.id.home) { | ||
onBackPressed() | ||
return true | ||
} | ||
return super.onOptionsItemSelected(item) | ||
} | ||
|
||
override fun onBackPressed() { | ||
startActivity(Intent(this, GreetActivity::class.java)) | ||
} | ||
|
||
override fun onPause() { | ||
handler.dropCallback(this) | ||
super.onPause() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
handler.setCallback(this) | ||
} | ||
|
||
companion object { | ||
private val handler = StaticHandler() | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/deliner/mosfauna/activity/LoginActivity.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,54 @@ | ||
package com.deliner.mosfauna.activity | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import android.widget.Button | ||
import android.widget.EditText | ||
import com.deliner.mosfauna.R | ||
import com.deliner.mosfauna.utils.LoginManager | ||
|
||
class LoginActivity : UserActivity() { | ||
|
||
private lateinit var passwordText: EditText | ||
private lateinit var loginText: EditText | ||
|
||
private lateinit var loginButton: Button | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_login) | ||
|
||
setSupportActionBar(findViewById(R.id.toolbar)) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
loginButton = findViewById(R.id.activity_login_button_login) | ||
passwordText = findViewById(R.id.activity_login_password) | ||
loginText = findViewById(R.id.activity_login_login) | ||
|
||
loginButton.setOnClickListener { | ||
if (checkLogin(loginText.text.toString()) && checkPassword(passwordText.text.toString())) { | ||
val user = LoginManager.User( | ||
loginText.text.toString(), | ||
passwordText.text.toString(), | ||
"default@gmail.com" | ||
) | ||
LoginManager.getInstance(applicationContext).setCurrentUser(user) | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) | ||
startActivity(Intent(this, MainActivity::class.java)) | ||
} | ||
} | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
if (item.itemId == android.R.id.home) { | ||
onBackPressed() | ||
return true | ||
} | ||
return super.onOptionsItemSelected(item) | ||
} | ||
|
||
override fun onBackPressed() { | ||
startActivity(Intent(this, GreetActivity::class.java)) | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
...java/com/deliner/mosfauna/MainActivity.kt → ...deliner/mosfauna/activity/MainActivity.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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
package com.deliner.mosfauna | ||
package com.deliner.mosfauna.activity | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import com.deliner.mosfauna.R | ||
import com.deliner.mosfauna.utils.LoginManager | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
|
||
|
||
} | ||
} |
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.