From b196b5d71125d5330395c42df12cdad00ed9676b Mon Sep 17 00:00:00 2001 From: Shikibu Date: Thu, 24 May 2018 10:18:10 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20=E3=83=A6=E3=83=BC=E3=82=B6=E5=90=8D?= =?UTF-8?q?=E3=82=84=E3=83=A1=E3=83=BC=E3=83=AB=E3=82=A2=E3=83=89=E3=83=AC?= =?UTF-8?q?=E3=82=B9=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/assetWizardSettings.xml | 182 ++++++++++++++++++ .../cyder/android/syncpod/api/SyncPodApi.kt | 3 + .../syncpod/repository/UserDataRepository.kt | 17 ++ .../syncpod/repository/UserRepository.kt | 2 + .../viewmodel/SettingActivityViewModel.kt | 40 ++-- .../drawable-hdpi/ic_setting_black_32dp.png | Bin 0 -> 831 bytes .../drawable-mdpi/ic_setting_black_32dp.png | Bin 0 -> 552 bytes .../drawable-xhdpi/ic_setting_black_32dp.png | Bin 0 -> 1135 bytes .../drawable-xxhdpi/ic_setting_black_32dp.png | Bin 0 -> 1877 bytes app/src/main/res/layout/activity_setting.xml | 4 +- app/src/main/res/layout/activity_top.xml | 8 +- app/src/main/res/values/strings.xml | 1 + 12 files changed, 226 insertions(+), 31 deletions(-) create mode 100644 .idea/assetWizardSettings.xml create mode 100644 app/src/main/res/drawable-hdpi/ic_setting_black_32dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_setting_black_32dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_setting_black_32dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_setting_black_32dp.png diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 00000000..2f8b0368 --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,182 @@ + + + + + + \ No newline at end of file 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 f8b13b97..a7fcd933 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/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/viewmodel/SettingActivityViewModel.kt b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt index 53d6172d..3850d0ce 100644 --- a/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt +++ b/app/src/main/kotlin/com/cyder/android/syncpod/viewmodel/SettingActivityViewModel.kt @@ -1,8 +1,8 @@ package com.cyder.android.syncpod.viewmodel import android.databinding.ObservableField -import android.os.Build -import com.cyder.android.syncpod.repository.UserReportRepository +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 @@ -13,8 +13,10 @@ import javax.inject.Inject class SettingActivityViewModel @Inject constructor( private val navigator: Navigator, - private val userReportRepository: UserReportRepository + private val repository: UserRepository ) : ActivityViewModel() { + var mailAddress: ObservableField = ObservableField() + var name: ObservableField = ObservableField() var callback: SnackbarCallback? = null var message: ObservableField = ObservableField() @@ -40,29 +42,13 @@ class SettingActivityViewModel @Inject constructor( fun onBackButtonClicked() = navigator.closeActivity() fun onSubmit() { -// Single.create { emitter -> -// if ((message.get() ?: "").isNotBlank()) { -// emitter.onSuccess(message.get()) -// } else { -// emitter.onError(NotFilledFormsException()) -// } -// } -// .map { createDetailMessage(it) } -// .flatMapCompletable { userReportRepository.sendUserReport(it) } -// .subscribe({ -// navigator.closeActivity() -// }, { error -> -// when (error) { -// is NotFilledFormsException -> callback?.onFailed(R.string.form_not_filled) -// else -> callback?.onFailed(R.string.network_error) -// } -// }) - } - - private fun createDetailMessage(message: String): String { - return """$message - ----------------------------------------- -端末: Android ${Build.VERSION.RELEASE}""" + repository.editUser( + mailAddress.get() ?: "", + name.get() ?: "" + ).subscribe({ + navigator.navigateToTopActivity() + }, { + callback?.onFailed(R.string.sign_up_used_email) + }) } } 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 0000000000000000000000000000000000000000..8d82d933f613de3f063518b9efa111008ec5527a GIT binary patch literal 831 zcmV-F1Hk-=P)TL`6~&MuM4zN>o4857`fv5JriZy$icx zL=j3aUuC8E=#Od!=EAv$d-lxi?twi6pIy;kwm~L-$e7kAaD>!`^HoQ{le@M1poFSu)*gyP5a{sWvlGi zW8C0NfQgU^ztXpH4)|jbc#z+~S>OurJ!A}izKSE@s>Q%;b2%z_T<>!Z3-}9EsRTT5 zIQT5RVZrZ7K=8;Cup?jEe3uXb$eUnVJ!yFY+(*MeA1%vF414RSU%;p(r<0Uo%knJI za-dn*cB}Yk+6n}D9uj!aDu7oO=F4eCiYUkGR#gmWg`m=}q$Q?Xy)OcV`5YetehD4U z0F@g3)_RRrlw)k5J_ww)8#Ikwf_dIk|HbZyUNCcVwSj=m%;2%HTP=0o&2Wru zbjm zc#vub%kX$NB1ms-1_C++^JJ)YC~dz+ukw@H1F2QgQBvA#?F(Crtp=?G_Cd=8!DHL; zT63-ix>HI?bAA+$fwhd_*8$Hg9BOiE!6aCZIG=;3)2l;>JVDC%^Ni7!Kbr zDS!7;y_mH;$8j%knKa@h=SVqB$KV{RPmq9JVH@mG0)oG<$`G3zzu21PwC~p)7SPEl zGWd2irAU+Lq{Z@o3bWREx|f|)%w58*l&1rSXson{f#tq2TYw=dDkj(K1A#XPtkR8? zhW(wv2}z%lrf=gK1se7Uf#rNJ@I@ndY{hpgeB-{9=?~rIUc!HBkfM_rSHOhlpmox5bS8pn!|TW#`ww|1=!*6ot5g60002ov JPDHLkV1iBTfDZrw literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..4873d1bfeba2c7fcc21da685800b2d67a46dca2a GIT binary patch literal 552 zcmV+@0@wYCP)a`OACJeH4FXxs~6pb4_vq-ZwygNIS3vJOM|P zM`|HSFm#A96B|LlW6AoMEO{+(Z!?iqZUMhhz=})B1SGd zHnVj_42-|1>IHKqj-Nm?Q$VXiKv?HIrPzKSQ$QK;ZW1R{Y5@~E=UK%o2rvb-(EYMF zGpa$fpee!#Q$SQxg!9JTtOF9vzhRdqc@MLz#whQ%Wh^w0ERANbWCw#Z%DJ&p!Z~iE zji#t?Ow(XV+la9z1O!SjjB+#te{9WV0lx|w3*y102;@^Lq2C0}{CE$9$)qr1-3BiKB({{fA00002JxT( literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..98ad4ba9b8f151902a68f1c5f66d4647063c4cbc GIT binary patch literal 1135 zcmV-#1d#iQP)Z3;^mme6yb67@!klo&fBXO@28#b_Vkma2ZhGSQYGdIdS6Qh$su=cPrp3 z;Cq;7dI2di1T;noW)AQKa0Hion_}0;3+CevU?cV!?HqpVMU&44j0praWgu}CpR5>X zh!nn74-(RiYrF+<7hom^31BN`2haA=6@$r#@HE- z#zFESoO3201dJODU;yXyS>@zKO+kin+#MF(4sEEc2(oH<=sT8~lLSd#>u`se+u8XY3 z0M>;`Nr$gF3m&hf;HXR{7AA@umr%6++HT3^r$fq?k=WT-u0+-GeTn5(pn-rQiP!Qj zh2vKeTTHSB0@5Y6>JAFWy%O7uE`@qbq81q^U|1soqk^&Y#L_E}=G80kK%xldX&_*` z7e%nxlDpwiuYrI@OKy%(B;zcA-PeRd%b7%&{8GRh$ymm5qQyNTTLx$*Xob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WnDt9Wg z)X3a=ER$xKvuJmj>NY0nPR8!vSse;k!|0GNMIG5-q{WQuxfrzV7>Dj=ELV&u^S9Ou zC}QEtbj8Ezdl+rzfU<)I8BJ<+k`&Nyi2{CQS`XIHYIJ0fTqfweB_?PrNhXNf2^Sew zKxxvP@CxQIw9>EwY8cD!7>1ThGrWv`h|3Q&7*@b*%!$|%DMs^Xw|>K%x_2vc@AqIq zu7`O&U6ib{3x5;fH-W+xnzNOL6i_8pjKipE180=*3S+Y3g%1pz0_=<(5?m81_5~HQ zx4j7Pg_3W`VDxaCW(BMj-c;!qw~M1Ni1F-?N?+R!Cx;6)34gxQI{}U*{9D2t%{paf zOtDFWDVjwl&%}-VM{@N(aA)jM=4NLw9+!O0%I~=aT{BN_W;^LPg?3b#pQS|SwL|fD z$b@10 z$8iK?J2|*+ir{R%HFI8hJfn|0r_o}jvz?9!i+6dpjkGJix`&f zcEV!`I~!EQ@tZ}KrtwKaZ`_(ztqV(Ig`E$^tt8H&GPM(EcpO$t_nm8EHfeD96|aU4 zCq!_ARGd5$;~QgP+K@pyNe3f1pKhvRmeMzFw)`|*p1JjA&Rb+EA^WPUBUPvz%`iv09tY`n;`Sz8|H$n#Cu(ofH8S{?6SX%rXi~s7Cu(nc zK$8OQa-#MoUH{N|u@kj76)O2&^r+&0k@0^+nAAwmsP-vymjV-^0O?S)U75d~e@%y? z?!Rg0pn72iY;_{`C#;T2-Ci7}NXtf?6uz4g P00000NkvXXu0mjf8n%XE literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index 05ac5279..0b221df6 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -67,9 +67,9 @@ android:layout_height="55dp" android:layout_marginBottom="20dp" android:layout_marginTop="20dp" - android:background="@color/appGreen" + android:background="@color/appBlue" android:onClick="@{(v) -> viewModel.onSubmit()}" - android:text="@string/send_button" + android:text="@string/update_button" android:textColor="@color/appWhite" android:textSize="18sp" /> diff --git a/app/src/main/res/layout/activity_top.xml b/app/src/main/res/layout/activity_top.xml index 61184674..b65abf3a 100644 --- a/app/src/main/res/layout/activity_top.xml +++ b/app/src/main/res/layout/activity_top.xml @@ -28,11 +28,15 @@ android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:logo="@drawable/toolbar_logo" > -