diff --git a/.idea/misc.xml b/.idea/misc.xml index 9422e84..d5d35ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index b5469e8..b361bc7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,5 +48,6 @@ implementation "com.squareup.retrofit2:retrofit:2.5.0" implementation 'com.squareup.retrofit2:converter-jackson:2.5.0' implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' - implementation 'com.github.bumptech.glide:glide:3.6.1' + implementation 'com.github.bumptech.glide:glide:4.10.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f34e315..a8a64b0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,9 @@ + + + + @@ -19,16 +23,12 @@ - - - - + + + - - - \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/Acanthus.java b/app/src/main/java/org/ntlab/acanthus_client/Acanthus.java index d6b03a5..b58060b 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/Acanthus.java +++ b/app/src/main/java/org/ntlab/acanthus_client/Acanthus.java @@ -3,95 +3,125 @@ import android.app.Application; import android.content.SharedPreferences; -import org.ntlab.acanthus_client.entities.Account; +import org.ntlab.acanthus_client.entities.Animation; +import org.ntlab.acanthus_client.entities.AnimationJson; + +import java.util.ArrayList; //----------------------------------------------------------------- // ユーザーアカウント public class Acanthus extends Application { - private Integer uid; - private String name; - private String email; - private String password; - private String token; + //----------------------------------------------------------------- + private Integer preferenceUid; + private String preferenceName; + private String preferenceEmail; + private String preferencePassword; + private String preferenceToken; + //----------------------------------------------------------------- + private Integer aid; + private Animation currentAnimation; + private ArrayList animationJsonList; //----------------------------------------------------------------- - // setter - public Integer getUid(){ - if(uid == null){ - SharedPreferences preferences = getSharedPreferences("prefData",MODE_PRIVATE); - uid = preferences.getInt("uid", 0); + // getter + public Integer getPreferenceUid() { + if (preferenceUid == null) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + preferenceUid = preferences.getInt("uid", 0); } - return uid; + return preferenceUid; } - public String getName() { - if(name == null){ - SharedPreferences preferences = getSharedPreferences("prefData",MODE_PRIVATE); - name = preferences.getString("name", ""); + public String getPreferenceName() { + if (preferenceName == null) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + preferenceName = preferences.getString("name", ""); } - return name; + return preferenceName; } - public String getEmail() { - if(email == null){ - SharedPreferences preferences = getSharedPreferences("prefData",MODE_PRIVATE); - email = preferences.getString("email", ""); + public String getPreferenceEmail() { + if (preferenceEmail == null) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + preferenceEmail = preferences.getString("email", ""); } - return email; + return preferenceEmail; } - public String getPassword() { - if(password == null){ - SharedPreferences preferences = getSharedPreferences("prefData",MODE_PRIVATE); - password = preferences.getString("password", ""); + public String getPreferencePassword() { + if (preferencePassword == null) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + preferencePassword = preferences.getString("password", ""); } - return password; + return preferencePassword; } - public String getToken() { - if(token == null){ - SharedPreferences preferences = getSharedPreferences("prefData",MODE_PRIVATE); - token = preferences.getString("token", ""); + public String getPreferenceToken() { + if (preferenceToken == null) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + preferenceToken = preferences.getString("token", ""); } - return token; + return preferenceToken; + } + + public Integer getAid() { + if (this.aid == null) this.aid = 1111; + return aid; + } + + public Animation getCurrentAnimation() { + return currentAnimation; } //----------------------------------------------------------------- // setter - public void setUid(Integer uid){ + public void setPreferenceUid(Integer preferenceUid) { SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putInt("uid", uid); + editor.putInt("uid", preferenceUid); editor.commit(); } - public void setName(String name){ + public void setPreferenceName(String preferenceName) { SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putString("name", name); + editor.putString("name", preferenceName); editor.commit(); } - public void setEmail(String email) { + public void setPreferenceEmail(String preferenceEmail) { SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putString("email", email); + editor.putString("email", preferenceEmail); editor.commit(); } - public void setPassword(String password){ + public void setPreferencePassword(String preferencePassword) { SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putString("password", password); + editor.putString("password", preferencePassword); editor.commit(); } - public void setToken(String token){ + public void setPreferenceToken(String preferenceToken) { SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putString("token", token); + editor.putString("token", preferenceToken); editor.commit(); } + public void setAid(Integer aid) { + this.aid = aid; + } + + public void setCurrentAnimation(Animation currentAnimation) { + this.currentAnimation = currentAnimation; + } + + //----------------------------------------------------------------- + // + public void addAnimationJsonList(AnimationJson animationJson) { + this.animationJsonList.add(animationJson); + } //----------------------------------------------------------------- } diff --git a/app/src/main/java/org/ntlab/acanthus_client/entities/Animation.java b/app/src/main/java/org/ntlab/acanthus_client/entities/Animation.java index fea8f51..db26207 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/entities/Animation.java +++ b/app/src/main/java/org/ntlab/acanthus_client/entities/Animation.java @@ -27,7 +27,7 @@ private ArrayList hashTag = new ArrayList<>(); private ArrayList editors = new ArrayList<>(); private ArrayList invites = new ArrayList<>(); - private HashMap pageMap = new HashMap<>(); + private HashMap pageMap = new HashMap<>(); private Boolean isDummy; //----------------------------------------------------------------- @@ -90,7 +90,7 @@ return this.editors; } - public HashMap getPageMap() { + public HashMap getPageMap() { return this.pageMap; } diff --git a/app/src/main/java/org/ntlab/acanthus_client/entities/Layer.java b/app/src/main/java/org/ntlab/acanthus_client/entities/Layer.java index 99927bc..702ba20 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/entities/Layer.java +++ b/app/src/main/java/org/ntlab/acanthus_client/entities/Layer.java @@ -1,6 +1,23 @@ package org.ntlab.acanthus_client.entities; +import java.util.ArrayList; + //----------------------------------------------------------------- // レイヤー情報 public class Layer { + private ArrayList strokes; + + //----------------------------------------------------------------- + // getter + public ArrayList getStrokes() { + return strokes; + } + + //----------------------------------------------------------------- + // setter + public void setStrokes(ArrayList strokes) { + this.strokes = strokes; + } + //----------------------------------------------------------------- + } diff --git a/app/src/main/java/org/ntlab/acanthus_client/entities/Page.java b/app/src/main/java/org/ntlab/acanthus_client/entities/Page.java index 61b4502..baf5612 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/entities/Page.java +++ b/app/src/main/java/org/ntlab/acanthus_client/entities/Page.java @@ -3,4 +3,19 @@ //----------------------------------------------------------------- // ページ情報 public class Page { + private Layer layers; + + //----------------------------------------------------------------- + // getter + public Layer getLayers() { + return layers; + } + + //----------------------------------------------------------------- + // setter + public void setLayers(Layer layers) { + this.layers = layers; + } + //----------------------------------------------------------------- + } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/InvitedRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/InvitedRest.java index 71cf72f..7edc2bd 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/InvitedRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/InvitedRest.java @@ -1,4 +1,42 @@ package org.ntlab.acanthus_client.resources.accounts; +import retrofit2.Call; +import retrofit2.http.DELETE; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface InvitedRest { + //----------------------------------------------------------------- + + @GET("accounts/{uid}/invited") + Call checkAccountInvited( + @Path("uid") Integer ownerUid, + @Query("aid") Integer aid + ); + + //----------------------------------------------------------------- + + @FormUrlEncoded + @PUT("accounts/{uid}/invited") + Call addAccountInvited( + @Path("uid") Integer invitedUid, + @Field("ownerUid") Integer ownerUid, + @Field("ownerToken") String ownerToken, + @Field("aid") Integer aid + ); + + //----------------------------------------------------------------- + + @FormUrlEncoded + @DELETE("accounts/{uid}/invited") + Call deleteInvite( + @Path("uid") Integer invitedUid, + @Field("invitedToken") String invitedToken, + @Field("aid") Integer aid + ); + } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/WorkRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/WorkRest.java index 68c559c..6924959 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/WorkRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/accounts/WorkRest.java @@ -1,4 +1,45 @@ package org.ntlab.acanthus_client.resources.accounts; +import org.ntlab.acanthus_client.entities.AidJson; +import org.ntlab.acanthus_client.entities.Work; +import org.ntlab.acanthus_client.entities.WorkJson; + +import java.util.Collection; + +import retrofit2.Call; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface WorkRest { + //----------------------------------------------------------------- + // 各ユーザーの作品を取得する + @GET("accounts/{uid}/work") + Call getWork( + @Path("uid") Integer uid, + @Query("token") String token + ); + //----------------------------------------------------------------- + // 新しい作品を制作する + @FormUrlEncoded + @POST("accounts/{uid}/work") + Call createWork( + @Path("uid") Integer uid, + @Field("name") String animationName, + @Field("token") String token + ); + //----------------------------------------------------------------- + // 作品への参加を許可する + @FormUrlEncoded + @PUT("accounts/{uid}/work") + Call updateWork( + @Path("uid")Integer invitedUid, + @Field("token") String invitedToken, + @Field("aid") Integer aid + ); + //----------------------------------------------------------------- } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/EditorsRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/EditorsRest.java index 39d721a..8fd0447 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/EditorsRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/EditorsRest.java @@ -1,4 +1,29 @@ package org.ntlab.acanthus_client.resources.gallery; +import org.ntlab.acanthus_client.entities.EditorJson; +import retrofit2.Call; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface EditorsRest { + //----------------------------------------------------------------- + //galleryのinvitesにいるか確認 + @GET("gallery/{aid}/Editors") + Call getEditors( + @Path("aid") Integer aid + ); + //----------------------------------------------------------------- + //Editorに追加 + @FormUrlEncoded + @PUT("gallery/{aid}/Editors") + Call addEditors( + @Path("aid") Integer aid, + @Field("uid") Integer uid, + @Field("token") String token + ); + //----------------------------------------------------------------- } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/GalleryRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/GalleryRest.java index 50610d5..3018d83 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/GalleryRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/GalleryRest.java @@ -1,4 +1,44 @@ package org.ntlab.acanthus_client.resources.gallery; +import org.ntlab.acanthus_client.entities.Animation; +import org.ntlab.acanthus_client.entities.AnimationJson; + +import java.util.Collection; + +import retrofit2.Call; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface GalleryRest { + + //すべての作品情報を返す。 + @GET("gallery") + Call> getGallery( + @Query("animationName") String animationName + ); +/* + @GET("gallery") + Call> getAnimationByAnimationName( + @Query("name") String name + ); +*/ + //作品の更新 + @FormUrlEncoded + @POST("gallery") + Call createAnimation( + @Field("name") String animationName, + @Field("token") String token, + @Field("uid") Integer uid + ); + + //特定の作品の表示 + @GET("gallery/{aid}") + Call getAnimationInformation( + @Path("aid") Integer aid + ); + } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/InvitesRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/InvitesRest.java index f05d6bc..e0d5cef 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/InvitesRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/InvitesRest.java @@ -1,4 +1,50 @@ package org.ntlab.acanthus_client.resources.gallery; +import org.ntlab.acanthus_client.entities.Account; + +import java.util.Collection; + +import retrofit2.Call; +import retrofit2.http.DELETE; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface InvitesRest { + + //----------------------------------------------------------------- + + @GET("gallery/{aid}/invites") + Call> isGalleryInvites( + @Path("aid") Integer aid, + @Query("invited") String invitedUid, + @Query("invitedUserToken") String invitedUserToken, + @Query("ownerToken") String ownerToken + ); + + //----------------------------------------------------------------- + + @FormUrlEncoded + @PUT("gallery/{aid}/invites") + Call addInvite( + @Path("aid") Integer aid, + @Field("ownerUid") String ownerUid, + @Field("invitedUid") String invitedUid, + @Field("ownerToken") String ownerToken + ); + + //----------------------------------------------------------------- + + @FormUrlEncoded + @DELETE("gallery/{aid}/incites") + Call deleteInvite( + @Path("aid") Integer aid, + @Field("invitedUid") String incitedUid, + @Field("invitedToken") String invitedToken + ); + + //----------------------------------------------------------------- } diff --git a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/StrokesRest.java b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/StrokesRest.java index 827ca44..a1032b0 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/StrokesRest.java +++ b/app/src/main/java/org/ntlab/acanthus_client/resources/gallery/StrokesRest.java @@ -1,4 +1,56 @@ package org.ntlab.acanthus_client.resources.gallery; +import org.ntlab.acanthus_client.entities.Position; +import org.ntlab.acanthus_client.entities.Stroke; + +import java.util.ArrayList; +import java.util.Collection; + +import kotlin.jvm.JvmDefaultWithoutCompatibility; +import retrofit2.Call; +import retrofit2.http.DELETE; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Path; + +//----------------------------------------------------------------- +// RestAPI: /gallery/{aid}/pageMap/{pid}/layers/{layerNo}/ public interface StrokesRest { + + //----------------------------------------------------------------- + // + @GET("gallery/{aid}/pageMap/0/layers/0/strokes") + Call> getStrokes(@Path("aid") Integer aid); + + //----------------------------------------------------------------- + // + @FormUrlEncoded + @POST("gallery/{aid}/pageMap/0/layers/0/strokes") + Call addStroke(@Path("aid") Integer aid, @Field("uid") Integer uid, @Field("uidToken") String uidToken, + @Field("pen") Integer pen, @Field("color") Integer color, @Field("thick") Integer thick); + + //----------------------------------------------------------------- + // + @GET("gallery/{aid}/pageMap/0/layers/0/strokes/{strokeNo}/position") + Call> getPositions(@Path("aid") Integer aid, @Path("strokeNo") Integer strokeNo); + + //----------------------------------------------------------------- + // + @FormUrlEncoded + @POST("gallery/{aid}/pageMap/0/layers/0/strokes/{strokeNo}/position") + Call addPositions(@Path("aid") Integer aid, @Path("strokeNo") Integer strokeNo, + @Field("x") double x, @Field("y") double y); + + //----------------------------------------------------------------- + // + @DELETE("gallery/{aid}/pageMap/0/layers/0/strokes") + Call deleteStrokes(@Path("aid") Integer aid, @Field("uid") Integer uid); + + //----------------------------------------------------------------- + // + @GET("gallery/{aid}/pageMap/0/layers/0/strokes/{strokeNo}/position") + Call deleteStrokeNo(@Path("aid") Integer aid, @Path("strokeNo") Integer strokeNo); + //----------------------------------------------------------------- } diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java new file mode 100644 index 0000000..10e455e --- /dev/null +++ b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java @@ -0,0 +1,15 @@ +package org.ntlab.acanthus_client.views.animation; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import org.ntlab.acanthus_client.R; + +public class AnimationActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_animation); + } +} \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/login/LoginScreenViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/login/LoginScreenViewModel.java index cffc864..9e78106 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/login/LoginScreenViewModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/login/LoginScreenViewModel.java @@ -49,7 +49,7 @@ String password = passwordForm.getText().toString(); // ログイン - Call call = loginRest.issueLoginToken(emailAddress, password); + Call call = loginRest.issueLoginToken(emailAddress,password); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { @@ -91,9 +91,9 @@ //----------------------------------------------------------------- // ログイン成功時に値の変更を行う private void setVariableFromResponse(Acanthus acanthus, String token, String email,String password ) { - acanthus.setToken(token); - acanthus.setEmail(email); - acanthus.setPassword(password); + acanthus.setPreferenceToken(token); + acanthus.setPreferenceEmail(email); + acanthus.setPreferencePassword(password); acanthusMutableLiveData.setValue(acanthus); } //----------------------------------------------------------------- diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditFragment.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditFragment.java index bddc5b4..68bcb63 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditFragment.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditFragment.java @@ -6,11 +6,14 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.EditText; import android.widget.TextView; +import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.R; import org.ntlab.acanthus_client.databinding.FragmentEditBinding; +import org.ntlab.acanthus_client.entities.WorkJson; import org.ntlab.acanthus_client.views.paint.PaintActivity; import androidx.annotation.NonNull; @@ -19,6 +22,8 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; +import java.util.ArrayList; + public class EditFragment extends Fragment { private EditViewModel editViewModel; @@ -31,17 +36,27 @@ binding = FragmentEditBinding.inflate(inflater, container, false); View root = binding.getRoot(); + TextView textView = binding.textMake; - final TextView textView = binding.textMake; - editViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { + Acanthus acanthus = (Acanthus) getActivity().getApplication(); + Integer uid = acanthus.getPreferenceUid(); + String token = acanthus.getPreferenceToken(); + editViewModel.getWorkList(uid, token); + + editViewModel.getWorkJson().observe(getViewLifecycleOwner(), new Observer() { @Override - public void onChanged(@Nullable String s) { - textView.setText(s); + public void onChanged(@Nullable WorkJson workJson) { + textView.setText(workJson.getAid().toString()); } }); return root; } + //----------------------------------------------------------------- + + //----------------------------------------------------------------- + + @Override public void onDestroyView() { super.onDestroyView(); @@ -51,12 +66,22 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Button appButton = view.findViewById(R.id.Paint_button); - appButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(getActivity(), PaintActivity.class); - startActivity(intent); - } + appButton.setOnClickListener(v -> { + Acanthus acanthus = (Acanthus) getActivity().getApplication(); + Integer uid = acanthus.getPreferenceUid(); + String name = ((EditText)view.findViewById(R.id.AnimationName)).getText().toString(); + String token = acanthus.getPreferenceToken(); + Integer aid = editViewModel.startWorkEdit(uid, name, token); + acanthus.setAid(aid); + transitionPaintActivity(); }); } + + //----------------------------------------------------------------- + // 画面遷移 + private void transitionPaintActivity() { + Acanthus acanthus = (Acanthus) getActivity().getApplication(); + Intent intent = new Intent(acanthus, PaintActivity.class); + startActivity(intent); + } } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditViewModel.java index e5fb17b..1ef9fef 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditViewModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/edit/EditViewModel.java @@ -1,19 +1,94 @@ package org.ntlab.acanthus_client.views.main_menu_ui.edit; +import org.ntlab.acanthus_client.entities.AidJson; +import org.ntlab.acanthus_client.entities.WorkJson; +import org.ntlab.acanthus_client.resources.accounts.WorkRest; + import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; public class EditViewModel extends ViewModel { - private MutableLiveData mText; + private MutableLiveData workJsonMutableLiveData; + private MutableLiveData aidJsonMutableLiveData; public EditViewModel() { - mText = new MutableLiveData<>(); - mText.setValue("This is edit fragment"); + this.workJsonMutableLiveData = new MutableLiveData<>(); + this.aidJsonMutableLiveData = new MutableLiveData<>(); } - public LiveData getText() { - return mText; + //getter + public LiveData getWorkJson() { + return this.workJsonMutableLiveData; } + + public LiveData getAidJson() { + return this.aidJsonMutableLiveData; + } + + //新規作品作成APIの呼び出し + public Integer startWorkEdit(Integer uid, String animationName, String token) { + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + final WorkRest workRest = retrofit.create(WorkRest.class); + + final Integer[] aid = new Integer[1]; + + //作品の新規作成 + Call call = workRest.createWork(uid, animationName, token); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()){ + if (response.body()!=null){ + aid[0] = response.body().getAid(); + aidJsonMutableLiveData.setValue(response.body()); + } + } + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + + return aid[0]; + } + + //ユーザーの作成した作品の表示APIの呼び出し + public void getWorkList(Integer uid, String token){ + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + final WorkRest workRest = retrofit.create(WorkRest.class); + + //制作作品の表示 + Call call = workRest.getWork(uid, token); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()){ + if (response.body()!=null){ + workJsonMutableLiveData.setValue(response.body()); + } + } + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + } + } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java index bdf1830..b21b548 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java @@ -2,12 +2,18 @@ import android.widget.EditText; +import org.ntlab.acanthus_client.Acanthus; +import org.ntlab.acanthus_client.entities.AnimationJson; import org.ntlab.acanthus_client.resources.HelloWorldRest; +import org.ntlab.acanthus_client.resources.accounts.LoginRest; +import org.ntlab.acanthus_client.resources.gallery.GalleryRest; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; +import java.util.Collection; + import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -17,6 +23,7 @@ public class HomeViewModel extends ViewModel { private EditText editEmailTextView; + private MutableLiveData> animationMutableLiveData; private MutableLiveData mText; private HomeModel homeModel; @@ -30,4 +37,33 @@ public LiveData getText() { return mText; } + + public LiveData> getAnimationJson(){return this.animationMutableLiveData;} + + + public void updateGallery(EditText animationForm){ + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + final GalleryRest galleryRest = retrofit.create(GalleryRest.class); + + String animationName = animationForm.getText().toString(); + Call> call = galleryRest.getGallery(animationName); + + call.enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + Collection animList = response.body(); + animationMutableLiveData.setValue(animList); + } + + @Override + public void onFailure(Call> call, Throwable t) { + + } + }); + + } + } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/search/SearchFragment.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/search/SearchFragment.java index aef01f9..4d5365b 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/search/SearchFragment.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/search/SearchFragment.java @@ -4,8 +4,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.SearchView; import android.widget.TextView; +import org.ntlab.acanthus_client.R; import org.ntlab.acanthus_client.databinding.FragmentSearchBinding; import androidx.annotation.NonNull; @@ -18,6 +20,7 @@ private SearchViewModel searchViewModel; private FragmentSearchBinding binding; + private SearchView searchView; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -27,15 +30,16 @@ binding = FragmentSearchBinding.inflate(inflater, container, false); View root = binding.getRoot(); - final TextView textView = binding.textSearch; - searchViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(@Nullable String s) { - textView.setText(s); - } - }); +// final TextView textView = binding.textSearch; +// searchViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { +// @Override +// public void onChanged(@Nullable String s) { +// textView.setText(s); +// } +// }); return root; } + @Override public void onDestroyView() { diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java deleted file mode 100644 index f86f8b1..0000000 --- a/app/src/main/java/org/ntlab/acanthus_client/views/paint/MyPaint.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.ntlab.acanthus_client.views.paint; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; - -import androidx.annotation.Nullable; - -public class MyPaint extends View { - - private Path path; - private Paint paint; - - public MyPaint(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - - //1)コンストラクタ(≒必需品) - path = new Path();//線を引いたり、図形を描いたり、要するにグラフィック - - paint = new Paint();//筆の種類 - paint.setColor(Color.RED);//色の指定 - paint.setStyle(Paint.Style.STROKE);//線をひく - paint.setStrokeWidth(20);//幅 - - } - - //2)onDraw(描画の準備/プロペラが回りだした状態) - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - canvas.drawPath(path,paint); - } - - - //3)実際の操縦 (条件分岐:押したとき、動かしたとき、放した時) - - @Override - public boolean onTouchEvent(MotionEvent event) { - //(3-1)座標を取得(x座標、y座標) - float x = event.getX(); - float y = event.getY(); - - //(3-2)タッチの処理 - switch (event.getAction()){ - case MotionEvent.ACTION_DOWN: - path.moveTo(x,y); - invalidate(); - break; - case MotionEvent.ACTION_MOVE: - path.lineTo(x,y); - invalidate(); - break; - case MotionEvent.ACTION_UP: - break; - } - - //return super.onTouchEvent(event); - return true; - } - - - //4)クリア処理 - public void clearCanvas(){ - path.reset(); - invalidate(); - } - -} \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java index fc4abe0..b2c1073 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintActivity.java @@ -1,28 +1,48 @@ package org.ntlab.acanthus_client.views.paint; import androidx.appcompat.app.AppCompatActivity; +import androidx.lifecycle.ViewModelProvider; import android.os.Bundle; import android.view.View; +import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.R; public class PaintActivity extends AppCompatActivity { - private MyPaint myPaint; + private PaintCanvas paintCanvas; + private PaintViewModel paintViewModel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + init(); + } + + //----------------------------------------------------------------- + // 描画全体のクリア + public void onClear(View view) { + paintCanvas.clearCanvas(); + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // + private void init() { setContentView(R.layout.activity_paint); + Acanthus acanthus = (Acanthus) getApplication(); + paintViewModel = new ViewModelProvider(this).get(PaintViewModel.class); + paintViewModel.init(acanthus); - //6)描画のid取得 - myPaint =(MyPaint) findViewById(R.id.myCanvas); + initView(); } - //5)クリアメソッド(4)呼び出し - public void onClear(View view){ - myPaint.clearCanvas(); + //----------------------------------------------------------------- + // + private void initView() { + paintCanvas = (PaintCanvas) findViewById(R.id.myCanvas); + paintCanvas.setPaintViewModel(paintViewModel); } - + //----------------------------------------------------------------- } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintCanvas.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintCanvas.java new file mode 100644 index 0000000..5a89afe --- /dev/null +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintCanvas.java @@ -0,0 +1,116 @@ +package org.ntlab.acanthus_client.views.paint; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + +import org.ntlab.acanthus_client.Acanthus; +import org.ntlab.acanthus_client.resources.HelloWorldRest; +import org.ntlab.acanthus_client.resources.gallery.StrokesRest; + +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.Nullable; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; +import retrofit2.converter.scalars.ScalarsConverterFactory; + +//----------------------------------------------------------------- +// 描画キャンバスの本体 +public class PaintCanvas extends View { + + private Path path; + private Paint paint; + private PaintViewModel paintViewModel; + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + public PaintCanvas(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + + path = new Path(); // 図形描画 + paint = new Paint();//筆の種類 + paint.setColor(Color.RED);//色の指定 + paint.setStyle(Paint.Style.STROKE);//線をひく + paint.setStrokeWidth(20);//幅 + } + + //----------------------------------------------------------------- + // setter + public void setPaintViewModel(PaintViewModel paintViewModel) { + this.paintViewModel = paintViewModel; + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + canvas.drawPath(path, paint); + } + + //----------------------------------------------------------------- + // 描画操作 (条件分岐:押したとき、動かしたとき、放した時) + @Override + public boolean onTouchEvent(MotionEvent event) { + //(3-1)座標を取得(x座標、y座標) + float x = event.getX(); + float y = event.getY(); + + //(3-2)タッチの処理 + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + onTouched(x, y); + break; + + case MotionEvent.ACTION_MOVE: + onTouchedMove(x, y); + break; + + case MotionEvent.ACTION_UP: + break; + } + + paintViewModel.drawStrokeRequest(event); + + return true; + } + + //----------------------------------------------------------------- + // 描画クリア + public void clearCanvas() { + path.reset(); + invalidate(); + } + + //----------------------------------------------------------------- + // 押した瞬間の処理 + private void onTouched(float x, float y) { + path.moveTo(x, y); + invalidate(); + } + + //----------------------------------------------------------------- + // 押した後動かした時の処理 + private void onTouchedMove(float x, float y) { + path.lineTo(x, y); + invalidate(); + } + + //----------------------------------------------------------------- + + +} \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintModel.java new file mode 100644 index 0000000..e500459 --- /dev/null +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintModel.java @@ -0,0 +1,90 @@ +package org.ntlab.acanthus_client.views.paint; + +import androidx.navigation.ActivityNavigator; + +import org.ntlab.acanthus_client.Acanthus; +import org.ntlab.acanthus_client.entities.Animation; +import org.ntlab.acanthus_client.resources.gallery.GalleryRest; +import org.ntlab.acanthus_client.resources.gallery.StrokesRest; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; +import retrofit2.converter.scalars.ScalarsConverterFactory; + +//----------------------------------------------------------------- +// +public class PaintModel { + private Animation editedAnimation; + private Integer currentStrokeNo; + private Retrofit retrofit; + private Acanthus acanthus; + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // + public PaintModel() { + retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") + .addConverterFactory(ScalarsConverterFactory.create()) + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + } + + //----------------------------------------------------------------- + // setter + public void setEditedAnimation(Animation editedAnimation) { + this.editedAnimation = editedAnimation; + } + + private void setCurrentStrokeNo(int strokeNo) { + this.currentStrokeNo = strokeNo; + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // init + public void init(Acanthus acanthus) { + this.acanthus = acanthus; + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // ローカルでのストロークの追加(POST) + public void addLocalStroke() { + final StrokesRest strokesRest = retrofit.create(StrokesRest.class); + + //----------------------------------------------------------------- + // ストローク追加API + Call call = strokesRest.addStroke( + acanthus.getAid(), acanthus.getPreferenceUid(), acanthus.getPreferenceToken(), + 0, 0, 10); + + // strokeNoを更新 + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) setCurrentStrokeNo(response.body()); + } + + @Override + public void onFailure(Call call, Throwable t) { + + } + }); + } + + //----------------------------------------------------------------- + // ローカルでの筆跡追加(POST) + public void addPosition(float x, float y) { + final StrokesRest strokesRest = retrofit.create(StrokesRest.class); + + //----------------------------------------------------------------- + // 筆跡追加API + Call call = strokesRest.addPositions(acanthus.getAid(), this.currentStrokeNo, x, y); + } + //----------------------------------------------------------------- + +} diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintViewModel.java new file mode 100644 index 0000000..98115b6 --- /dev/null +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/PaintViewModel.java @@ -0,0 +1,77 @@ +package org.ntlab.acanthus_client.views.paint; + +import android.graphics.Paint; +import android.view.MotionEvent; +import android.view.View; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintSet; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import org.ntlab.acanthus_client.Acanthus; +import org.ntlab.acanthus_client.entities.Account; +import org.ntlab.acanthus_client.entities.Animation; +import org.ntlab.acanthus_client.entities.Stroke; +import org.ntlab.acanthus_client.resources.accounts.LoginRest; +import org.ntlab.acanthus_client.resources.gallery.StrokesRest; + +import java.text.CollationElementIterator; +import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import kotlinx.coroutines.sync.Mutex; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; +import retrofit2.converter.scalars.ScalarsConverterFactory; + + +//----------------------------------------------------------------- +// 描画 +public class PaintViewModel extends ViewModel { + + private PaintModel paintModel; + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + public PaintViewModel() { + paintModel = new PaintModel(); + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // + public void init(Acanthus acanthus) { + paintModel.init(acanthus); + } + + //----------------------------------------------------------------- + // 描画APIの通信リクエスト + public void drawStrokeRequest(MotionEvent motionEvent) { + float x = motionEvent.getX(); + float y = motionEvent.getY(); + + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + paintModel.addLocalStroke(); + break; + + case MotionEvent.ACTION_MOVE: + paintModel.addPosition(x, y); + break; + } + } + + //----------------------------------------------------------------- + // 一定間隔でサーバー上の筆跡を取得する(GET) + public void startObservationOfChangedStroke() { + } + + //----------------------------------------------------------------- +} diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/sign_up/SignUpActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/sign_up/SignUpActivity.java index c87643a..8d4d1fa 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/sign_up/SignUpActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/sign_up/SignUpActivity.java @@ -4,10 +4,12 @@ import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.widget.Button; import android.widget.TextView; import org.ntlab.acanthus_client.R; +import org.ntlab.acanthus_client.databinding.ActivitySignUpBinding; import org.ntlab.acanthus_client.entities.AccountUidJson; import org.ntlab.acanthus_client.resources.accounts.AccountsRest; import org.ntlab.acanthus_client.views.login.LoginScreenActivity; @@ -23,84 +25,49 @@ //----------------------------------------------------------------- // public class SignUpActivity extends AppCompatActivity { - //----------------------------------------------------------------- - // 各Viewの列挙型 - public enum EditTexts { - nameForm(0), emailForm(1), passwordForm(2), signUpButton(3), loginButton(4); - - private int textId; - - //----------------------------------------------------------------- - private EditTexts(int textId) { - this.textId = textId; - } - - //----------------------------------------------------------------- - // getter - public int getTextId() { - return this.textId; - } - } - - //----------------------------------------------------------------- - private ArrayList views = new ArrayList<>(); + private ActivitySignUpBinding binding; //----------------------------------------------------------------- // @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_sign_up); - initView(); + init(); + } + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + // サインアップ時押下時 + public void onClickSignUp(View view) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") .addConverterFactory(JacksonConverterFactory.create()) .build(); final AccountsRest accountsRest = retrofit.create(AccountsRest.class); - onClickSignUp(accountsRest); - onClickAlreadyLoggedIn(); - } + // 各フォーム取得 + String name = binding.editTextTextSignUpPersonName.getText().toString(); + String emailAddress = binding.editTextTextSignUpEmailAddress.getText().toString(); + String password = binding.editTextTextSignUpPassword.getText().toString(); - //----------------------------------------------------------------- - //----------------------------------------------------------------- - // サインアップ時押下時 - private void onClickSignUp(AccountsRest accountsRest) { - Button signUpButton = (Button) views.get(EditTexts.signUpButton.getTextId()); + Call call = accountsRest.createAccount(name, emailAddress, password); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) transitionLoginActivity(); + else clearForm(); + } - // - signUpButton.setOnClickListener(v -> { - String name = views.get(EditTexts.nameForm.getTextId()).getText().toString(); - ; - String emailAddress = views.get(EditTexts.emailForm.getTextId()).getText().toString(); - ; - String password = views.get(EditTexts.passwordForm.getTextId()).getText().toString(); - ; - - Call call = accountsRest.createAccount(name, emailAddress, password); - call.enqueue(new Callback() { - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful()) transitionLoginActivity(); - else clearForm(); - } - - @Override - public void onFailure(Call call, Throwable t) { - } - }); + @Override + public void onFailure(Call call, Throwable t) { + } }); } //----------------------------------------------------------------- // アカウント所持ボタン押下処理 - private void onClickAlreadyLoggedIn() { - Button alreadyLoggedInButton = (Button) views.get(EditTexts.loginButton.getTextId()); - - // ログイン画面に遷移 - alreadyLoggedInButton.setOnClickListener(v -> { - transitionLoginActivity(); - }); + public void onClickAlreadyLoggedIn(View view) { + transitionLoginActivity(); } //----------------------------------------------------------------- @@ -115,20 +82,17 @@ //----------------------------------------------------------------- // 登録内容のクリア private void clearForm() { - for (int i = EditTexts.nameForm.getTextId(); i <= EditTexts.passwordForm.getTextId(); i++) { - views.get(i).getEditableText().clear(); - } - + binding.editTextTextSignUpPersonName.getEditableText().clear(); + binding.editTextTextSignUpEmailAddress.getEditableText().clear(); + binding.editTextTextSignUpPassword.getEditableText().clear(); } //----------------------------------------------------------------- //----------------------------------------------------------------- - // - private void initView() { - views.add(findViewById(R.id.editTextTextSignUpPersonName)); - views.add(findViewById(R.id.editTextTextSignUpEmailAddress)); - views.add(findViewById(R.id.editTextTextSignUpPassword)); - views.add(findViewById(R.id.buttonSignUpRegister)); - views.add(findViewById(R.id.buttonAlreadyLoggedIn)); + // 初期化 + private void init() { + setContentView(R.layout.activity_sign_up); + binding = ActivitySignUpBinding.inflate(getLayoutInflater()); } + //----------------------------------------------------------------- } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleActivity.java index 52e1cc8..02a8149 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleActivity.java @@ -3,6 +3,11 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.Observer; @@ -10,9 +15,11 @@ import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.R; + import org.ntlab.acanthus_client.databinding.ActivityTitleBinding; import org.ntlab.acanthus_client.views.MainActivity; import org.ntlab.acanthus_client.views.sign_up.SignUpActivity; +import org.w3c.dom.Text; public class TitleActivity extends AppCompatActivity { private TitleViewModel titleViewModel; @@ -24,28 +31,45 @@ setTheme(R.style.AppTheme_NoTitleBar);//タイトルバーを消す setContentView(R.layout.activity_title); //ここに画像処理を記載する - /* ImageView imageView = (ImageView) findViewById(R.id.gifImage); - GlideDrawableImageViewTarget target = new GlideDrawableImageViewTarget(imageView); - Glide.with(this).load(R.drawable.load).into(target); + Glide.with(this).load(R.drawable.load).into(imageView); + TextView textView = (TextView)findViewById(R.id.textView3); + loadimg(imageView,textView); - */ + init(); HandlerTest(); } //////////////////////////////////////////////////////////////////// + public void loadimg(ImageView imageView,TextView textView) { + Handler handler = new Handler(); + Runnable runnable = new Runnable() { + @Override + public void run() { + imageView.setVisibility(View.VISIBLE); + textView.setText("アカウント情報取得中"); + } + }; + handler.postDelayed(runnable, 2000); + } + + + + ////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////// public void HandlerTest() { Handler handler = new Handler(); Runnable runnable = new Runnable() { @Override public void run() { Acanthus acanthus = (Acanthus) getApplication(); - titleViewModel.LoginToken(acanthus, acanthus.getEmail(), acanthus.getPassword()); + titleViewModel.LoginToken(acanthus, acanthus.getPreferenceEmail(), acanthus.getPreferencePassword()); } }; - handler.postDelayed(runnable, 5000); + handler.postDelayed(runnable, 10000); } ///////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleViewModel.java index ebd9c5c..d768851 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleViewModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/title/TitleViewModel.java @@ -1,13 +1,7 @@ package org.ntlab.acanthus_client.views.title; -import android.os.Handler; -import android.view.View; -import android.view.animation.AlphaAnimation; -import android.widget.ImageView; - import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.entities.AccountTokenJson; -import org.ntlab.acanthus_client.resources.accounts.AccountsRest; import org.ntlab.acanthus_client.resources.accounts.LoginRest; import androidx.lifecycle.LiveData; @@ -74,9 +68,9 @@ //----------------------------------------------------------------- // ログイン成功時に値の変更を行う private void setVariableFromResponse(Acanthus acanthus, String token, String email,String password ) { - acanthus.setToken(token); - acanthus.setEmail(email); - acanthus.setPassword(password); + acanthus.setPreferenceToken(token); + acanthus.setPreferenceEmail(email); + acanthus.setPreferencePassword(password); acanthusMutableLiveData.setValue(acanthus); } //----------------------------------------------------------------- diff --git a/app/src/main/res/img/title.jpg b/app/src/main/res/img/title.jpg deleted file mode 100644 index e77fa87..0000000 --- a/app/src/main/res/img/title.jpg +++ /dev/null Binary files differ diff --git a/app/src/main/res/layout/activity_animation.xml b/app/src/main/res/layout/activity_animation.xml new file mode 100644 index 0000000..86095c2 --- /dev/null +++ b/app/src/main/res/layout/activity_animation.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_paint.xml b/app/src/main/res/layout/activity_paint.xml index ceaab77..1e36f75 100644 --- a/app/src/main/res/layout/activity_paint.xml +++ b/app/src/main/res/layout/activity_paint.xml @@ -8,7 +8,7 @@ tools:context=".views.paint.PaintActivity"> - + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_edit.xml b/app/src/main/res/layout/fragment_edit.xml index 2387242..7b89dbf 100644 --- a/app/src/main/res/layout/fragment_edit.xml +++ b/app/src/main/res/layout/fragment_edit.xml @@ -13,6 +13,7 @@ android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" + android:text="This is edit fragment" android:textAlignment="center" android:textSize="20sp" app:layout_constraintBottom_toBottomOf="parent" @@ -31,4 +32,16 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index 6cab28c..57a8112 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -6,17 +6,74 @@ android:layout_height="match_parent" tools:context=".views.main_menu_ui.search.SearchFragment"> - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.023" /> + + + + + + + + + + + + + + \ No newline at end of file