Merge pull request 'fix/fix_child_uinfo' (#167) from fix/fix_child_uinfo into main

Reviewed-on: #167
This commit is contained in:
Fujimatsu 2024-07-12 02:57:10 +00:00
commit 05e8d15a20
3 changed files with 37 additions and 5 deletions

View File

@ -177,10 +177,12 @@ public class MainActivity extends AppCompatActivity {
boolean isEditMode = false; boolean isEditMode = false;
View view = getLayoutInflater().inflate(R.layout.user_info_dialog_layout, null); View view = getLayoutInflater().inflate(R.layout.user_info_dialog_layout, null);
if (userSettings.getAppCommonSetting().isChildMode()) { if (userSettings.getAppCommonSetting().isChildMode()) {
((TextView) view.findViewById(R.id.userNameTextView)).setText( childData.getChild(userSettings.getAppCommonSetting().getChildId()).thenAccept(childModel -> {
childData.getChild(userSettings.getAppCommonSetting().getChildId()).join().getName()); ((TextView) view.findViewById(R.id.userNameTextView)).setText(childModel.getName());
((TextView) view.findViewById(R.id.emailTextView)).setText("子供モードはメールアドレスを設定できません"); logger.debug("ChildModel: " + childModel.getName());
((Chip) view.findViewById(R.id.chip)).setText("子供/Child"); ((TextView) view.findViewById(R.id.emailTextView)).setText("子供ユーザーはメールアドレスを設定できません");
((Chip) view.findViewById(R.id.chip)).setText("子供/Child");
}).join();
} else { } else {
parentData.getParentDirect().thenAccept(parentModel -> { parentData.getParentDirect().thenAccept(parentModel -> {
((TextView) view.findViewById(R.id.userNameTextView)).setText(parentModel.getName()); ((TextView) view.findViewById(R.id.userNameTextView)).setText(parentModel.getName());
@ -190,6 +192,13 @@ public class MainActivity extends AppCompatActivity {
}).join(); }).join();
} }
// Workaround
if (userSettings.getAppCommonSetting().isChildMode()) {
view.findViewById(R.id.userNameEditButton).setVisibility(View.GONE);
} else {
view.findViewById(R.id.userNameEditButton).setVisibility(View.VISIBLE);
}
view.findViewById(R.id.userNameEditButton).setOnClickListener(v -> { view.findViewById(R.id.userNameEditButton).setOnClickListener(v -> {
EditText editText = new EditText(this); EditText editText = new EditText(this);
editText.setText(((TextView) view.findViewById(R.id.userNameTextView)).getText()); editText.setText(((TextView) view.findViewById(R.id.userNameTextView)).getText());

View File

@ -36,7 +36,21 @@ public class ChildDataImpl implements ChildData {
@Override @Override
public CompletableFuture<ChildModel> getChild(String childId) { public CompletableFuture<ChildModel> getChild(String childId) {
return null; return CompletableFuture.supplyAsync(() -> {
Call<ChildResponse> call = kidShiftApiService.getChild(childId);
try {
Response<ChildResponse> response = call.execute();
if (response.isSuccessful()) {
assert response.body() != null;
logger.info("子供取得成功(childId: " + response.body().getId() + ")");
return ChildModelConverter.childResponseToChildModel(response.body());
} else {
throw new RuntimeException("HTTP Status: " + response.code());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
} }
@Override @Override

View File

@ -137,6 +137,15 @@ public interface KidShiftApiService {
@Headers(AuthorizationInterceptor.HEADER_PLACEHOLDER) @Headers(AuthorizationInterceptor.HEADER_PLACEHOLDER)
Call<ChildListResponse> getChildList(); Call<ChildListResponse> getChildList();
/**
* 子供情報取得
* @param id 子供ID
* @return ChildResponse
*/
@GET("/child/{id}")
@Headers(AuthorizationInterceptor.HEADER_PLACEHOLDER)
Call<ChildResponse> getChild(@Path("id") String id);
/** /**
* 子供追加 * 子供追加
* @param request ChildAddRequest * @param request ChildAddRequest