aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/me/texx
diff options
context:
space:
mode:
authorMarvin Borner2018-08-31 00:17:00 +0200
committerMarvin Borner2018-08-31 00:17:00 +0200
commite9dcc2b88ec1cb4a09e5f82e6aa91ad46ca13037 (patch)
treebc51b4e86e63f3f3a4f9b106b863175ab448d9a9 /app/src/main/java/me/texx
parent3df3c2faedf287fadf526f52c8aba8d1f567416a (diff)
Started implementing camera for posting media
Diffstat (limited to 'app/src/main/java/me/texx')
-rw-r--r--app/src/main/java/me/texx/Texx/CameraActivity.kt54
-rw-r--r--app/src/main/java/me/texx/Texx/LoginActivity.kt1
-rw-r--r--app/src/main/java/me/texx/Texx/MainActivity.kt2
-rw-r--r--app/src/main/java/me/texx/Texx/RoutingActivity.kt12
4 files changed, 62 insertions, 7 deletions
diff --git a/app/src/main/java/me/texx/Texx/CameraActivity.kt b/app/src/main/java/me/texx/Texx/CameraActivity.kt
new file mode 100644
index 0000000..df03164
--- /dev/null
+++ b/app/src/main/java/me/texx/Texx/CameraActivity.kt
@@ -0,0 +1,54 @@
+package me.texx.Texx
+
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.Window
+import android.view.WindowManager
+import com.otaliastudios.cameraview.CameraListener
+import daio.io.dresscode.dressCodeName
+import daio.io.dresscode.matchDressCode
+import kotlinx.android.synthetic.main.activity_camera.*
+import me.texx.Texx.util.ThemeUtil.getThemeName
+import org.jetbrains.anko.toast
+
+class CameraActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ matchDressCode()
+ super.onCreate(savedInstanceState)
+ dressCodeName = getThemeName(this)
+ requestWindowFeature(Window.FEATURE_NO_TITLE)
+ window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ setContentView(R.layout.activity_camera)
+
+ initCameraLayout()
+ }
+
+ private fun initCameraLayout() {
+ camera.addCameraListener(object : CameraListener() {
+ override fun onPictureTaken(jpeg: ByteArray?) {
+ toast("Photo taken")
+ }
+ })
+
+ photo_button.setOnClickListener {
+ camera.capturePicture()
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ camera.start()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ camera.stop()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ camera.destroy()
+ }
+}
diff --git a/app/src/main/java/me/texx/Texx/LoginActivity.kt b/app/src/main/java/me/texx/Texx/LoginActivity.kt
index 3674593..baa91ae 100644
--- a/app/src/main/java/me/texx/Texx/LoginActivity.kt
+++ b/app/src/main/java/me/texx/Texx/LoginActivity.kt
@@ -269,6 +269,7 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
.responseJson()
result.fold(success = {
+ // TODO: Fix password incorrect on server down/no internet connection at login
val accessToken = result.get().obj().getString("access_token")
val userID = result.get().obj().getString("user_id")
diff --git a/app/src/main/java/me/texx/Texx/MainActivity.kt b/app/src/main/java/me/texx/Texx/MainActivity.kt
index 8473efa..730f6b2 100644
--- a/app/src/main/java/me/texx/Texx/MainActivity.kt
+++ b/app/src/main/java/me/texx/Texx/MainActivity.kt
@@ -40,7 +40,7 @@ class MainActivity : AppCompatActivity() {
longToast("No internet connection!")
fab.setOnClickListener { view ->
- // TODO: Add camera support
+ startActivity<CameraActivity>()
}
}
diff --git a/app/src/main/java/me/texx/Texx/RoutingActivity.kt b/app/src/main/java/me/texx/Texx/RoutingActivity.kt
index bed9973..3ef5486 100644
--- a/app/src/main/java/me/texx/Texx/RoutingActivity.kt
+++ b/app/src/main/java/me/texx/Texx/RoutingActivity.kt
@@ -17,7 +17,7 @@ import java.io.IOException
* should be started next
*/
class RoutingActivity : AppCompatActivity() {
- private val serverAddress = "192.168.0.104"
+ private val serverAddress = "192.168.137.1"
override fun onCreate(savedInstanceState: Bundle?) {
matchDressCode()
@@ -49,12 +49,12 @@ class RoutingActivity : AppCompatActivity() {
.header("Authorization" to "Bearer $accessToken")
.responseJson { _, response, result ->
val (_, serverError) = result
- when {
- response.httpStatusCode == 200 -> startActivity<MainActivity>()
- response.httpStatusCode == 401 -> startActivity<LoginActivity>()
- !isConnected() -> startActivity<MainActivity>("notConnected" to true)
+ when { // TODO: Cleaner task solution
+ response.httpStatusCode == 200 -> startActivity(intentFor<MainActivity>().newTask().clearTask().noAnimation().excludeFromRecents())
+ response.httpStatusCode == 401 -> startActivity(intentFor<LoginActivity>().newTask().clearTask().noAnimation().excludeFromRecents())
+ !isConnected() -> startActivity(intentFor<MainActivity>("notConnected" to true).newTask().clearTask().noAnimation().excludeFromRecents())
serverError != null -> startActivity(intentFor<MainActivity>("serverDown" to true).newTask().clearTask().noAnimation().excludeFromRecents())
- else -> startActivity<LoginActivity>()
+ else -> startActivity(intentFor<LoginActivity>().newTask().clearTask().noAnimation().excludeFromRecents())
}
}
} else {