diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2ec2afb9..198a1e2b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -61,6 +61,9 @@
+
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/api/SyncPodApi.kt b/app/src/main/kotlin/com/cyder/android/syncpod/api/SyncPodApi.kt
index 1d136ea1..2bdfb9c2 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/api/SyncPodApi.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/api/SyncPodApi.kt
@@ -20,6 +20,9 @@ interface SyncPodApi {
@POST("users")
fun signUp(@Body user: SignUp): Single
+ @POST("users")
+ fun editUser(@Query("email") email: String, @Query("name") name: String): Single
+
@GET("joined_rooms")
fun getEnteredRooms(@Header("Authorization") token: String): Single
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/di/ActivityComponent.kt b/app/src/main/kotlin/com/cyder/android/syncpod/di/ActivityComponent.kt
index 9256776a..854f7b97 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/di/ActivityComponent.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/di/ActivityComponent.kt
@@ -22,5 +22,6 @@ interface ActivityComponent {
fun inject(activity: SearchVideoActivity)
fun inject(activity: UserReportActivity)
fun inject(activity: ContactActivity)
+ fun inject(activity: SettingActivity)
fun plus(module: FragmentModule): FragmentComponent
}
\ No newline at end of file
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserDataRepository.kt b/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserDataRepository.kt
index c9d59187..28611304 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserDataRepository.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserDataRepository.kt
@@ -41,6 +41,13 @@ class UserDataRepository @Inject constructor(
.toCompletable()
}
+ override fun editUser(email: String, name: String): Completable {
+ return editUserValidate(email, name)
+ .andThen(syncPodApi.editUser(email, name))
+ .subscribeOn(Schedulers.computation())
+ .toCompletable()
+ }
+
override fun getAccessToken(): Single {
val token = sharedPreferences.getString(STATE_USER_TOKEN, null)
return Single.create { emitter ->
@@ -97,6 +104,16 @@ class UserDataRepository @Inject constructor(
}
}
+ private fun editUserValidate(email: String, name: String): Completable {
+ return Completable.create { emitter ->
+ if (email.isBlank() || name.isBlank()) {
+ emitter.onError(NotFilledFormsException())
+ } else {
+ emitter.onComplete()
+ }
+ }
+ }
+
private fun saveSharedPreferences(user: User) {
sharedPreferences.edit {
putString(STATE_USER_TOKEN, user.accessToken)
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserRepository.kt b/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserRepository.kt
index 31f8d925..b7838201 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserRepository.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/repository/UserRepository.kt
@@ -13,6 +13,8 @@ interface UserRepository {
fun signIn(email: String, password: String, isAgreeTerms: Boolean): Completable
@CheckResult
fun signUp(email: String, name: String, password:String, passwordConfirm: String, isAgreeTerms: Boolean): Completable
+ @CheckResult
+ fun editUser(email: String, name: String): Completable
fun getAccessToken(): Single
fun getMyselfId(): Single
}
\ No newline at end of file
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/view/activity/SettingActivity.kt b/app/src/main/kotlin/com/cyder/android/syncpod/view/activity/SettingActivity.kt
new file mode 100644
index 00000000..de6c75d8
--- /dev/null
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/view/activity/SettingActivity.kt
@@ -0,0 +1,42 @@
+package com.cyder.android.syncpod.view.activity
+
+import android.content.Context
+import android.content.Intent
+import android.databinding.DataBindingUtil
+import android.os.Bundle
+import com.cyder.android.syncpod.R
+import com.cyder.android.syncpod.databinding.ActivitySettingBinding
+import com.cyder.android.syncpod.view.helper.setUpSnackbar
+import com.cyder.android.syncpod.viewmodel.SettingActivityViewModel
+import javax.inject.Inject
+
+/**
+ * Created by shikibu on 2018/05/21.
+ */
+
+class SettingActivity: BaseActivity() {
+ @Inject
+ lateinit var viewModel: SettingActivityViewModel
+ private lateinit var binding: ActivitySettingBinding
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ getComponent().inject(this)
+ bindViewModel(viewModel)
+
+ binding = DataBindingUtil.setContentView(this, R.layout.activity_setting)
+ binding.viewModel = viewModel
+
+ viewModel.callback = setUpSnackbar()
+ }
+
+ override fun onDestroy() {
+ viewModel.callback = null
+ super.onDestroy()
+ }
+
+
+ companion object {
+ fun createIntent(context: Context): Intent = Intent(context, SettingActivity::class.java)
+ }
+}
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/view/helper/Navigator.kt b/app/src/main/kotlin/com/cyder/android/syncpod/view/helper/Navigator.kt
index 641fb417..0fae1d29 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/view/helper/Navigator.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/view/helper/Navigator.kt
@@ -27,5 +27,6 @@ class Navigator @Inject constructor(
fun navigateToSearchVideoActivity() = activity.startActivity(SearchVideoActivity.createIntent(activity))
fun navigateToUserReportActivity(roomKey: String) = activity.startActivity(UserReportActivity.createIntent(activity, roomKey))
fun navigateToContactActivity() = activity.startActivity(ContactActivity.createIntent(activity))
+ fun navigateToSettingActivity() = activity.startActivity(SettingActivity.createIntent(activity))
fun closeActivity() = activity.finish()
}
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt
new file mode 100644
index 00000000..3850d0ce
--- /dev/null
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt
@@ -0,0 +1,54 @@
+package com.cyder.android.syncpod.viewmodel
+
+import android.databinding.ObservableField
+import com.cyder.android.syncpod.R
+import com.cyder.android.syncpod.repository.UserRepository
+import com.cyder.android.syncpod.view.helper.Navigator
+import com.cyder.android.syncpod.viewmodel.base.ActivityViewModel
+import javax.inject.Inject
+
+/**
+ * Created by shikibu on 2018/05/21.
+ */
+
+class SettingActivityViewModel @Inject constructor(
+ private val navigator: Navigator,
+ private val repository: UserRepository
+) : ActivityViewModel() {
+ var mailAddress: ObservableField = ObservableField()
+ var name: ObservableField = ObservableField()
+ var callback: SnackbarCallback? = null
+ var message: ObservableField = ObservableField()
+
+ override fun onStart() {
+
+ }
+
+ override fun onResume() {
+
+ }
+
+ override fun onPause() {
+
+ }
+
+ override fun onStop() {
+
+ }
+
+ override fun onDestroy() {
+ }
+
+ fun onBackButtonClicked() = navigator.closeActivity()
+
+ fun onSubmit() {
+ repository.editUser(
+ mailAddress.get() ?: "",
+ name.get() ?: ""
+ ).subscribe({
+ navigator.navigateToTopActivity()
+ }, {
+ callback?.onFailed(R.string.sign_up_used_email)
+ })
+ }
+}
diff --git a/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/TopActivityViewModel.kt b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/TopActivityViewModel.kt
index d26f2241..feae53af 100644
--- a/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/TopActivityViewModel.kt
+++ b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/TopActivityViewModel.kt
@@ -59,6 +59,8 @@ class TopActivityViewModel @Inject constructor(
fun onContactUs() = navigator.navigateToContactActivity()
+ fun onSetting() = navigator.navigateToSettingActivity()
+
fun onRefresh() {
isLoading.set(true)
getRooms()
diff --git a/app/src/main/res/drawable-hdpi/ic_setting_black_32dp.png b/app/src/main/res/drawable-hdpi/ic_setting_black_32dp.png
new file mode 100644
index 00000000..8d82d933
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_setting_black_32dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_setting_black_32dp.png b/app/src/main/res/drawable-mdpi/ic_setting_black_32dp.png
new file mode 100644
index 00000000..4873d1bf
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_setting_black_32dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_setting_black_32dp.png b/app/src/main/res/drawable-xhdpi/ic_setting_black_32dp.png
new file mode 100644
index 00000000..98ad4ba9
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_setting_black_32dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_setting_black_32dp.png b/app/src/main/res/drawable-xxhdpi/ic_setting_black_32dp.png
new file mode 100644
index 00000000..00427f15
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_setting_black_32dp.png differ
diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml
new file mode 100644
index 00000000..0b221df6
--- /dev/null
+++ b/app/src/main/res/layout/activity_setting.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_top.xml b/app/src/main/res/layout/activity_top.xml
index ada0edc4..2e7b9803 100644
--- a/app/src/main/res/layout/activity_top.xml
+++ b/app/src/main/res/layout/activity_top.xml
@@ -26,7 +26,18 @@
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
- app:logo="@drawable/toolbar_logo" />
+ app:logo="@drawable/toolbar_logo" >
+
+
+
ルーム作成
送信
キャンセル
+ 更新
登録
ようこそ。\n\n
@@ -88,4 +89,7 @@
ご意見・お問い合わせ
ご意見・お問い合わせ内容を記述して下さい。
公開設定
-
\ No newline at end of file
+ 設定
+ ユーザ名
+ メールアドレス
+