diff --git a/.idea/misc.xml b/.idea/misc.xml index 8de8a6e..2980051 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,17 +3,6 @@ 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 21252da..899c755 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 @@ -63,4 +63,16 @@ // @GET("gallery/{aid}/images") Call> getPageUrls(@Path("aid") Integer aid); + + //----------------------------------------------------------------- + // + @GET("gallery/{aid}/pageMap/{pid}/image") + Call getLayers(@Path("aid") Integer aid, @Path("pid") Integer pid); + + //----------------------------------------------------------------- + // + @FormUrlEncoded + @POST("gallery/{aid}/pageMap/{pid}/image") + Call addImage(@Path("aid") Integer aid, @Path("pid") Integer pid, @Field("image") String image); + } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/MainActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/MainActivity.java index fc7e634..0697841 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/MainActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/MainActivity.java @@ -3,18 +3,28 @@ import android.content.Intent; import android.os.Bundle; import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ImageView; +import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; import org.ntlab.acanthus_client.R; import org.ntlab.acanthus_client.databinding.ActivityMainBinding; +import org.ntlab.acanthus_client.views.main_menu_ui.mypage.MyPageFragment; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ShareCompat; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; +import java.util.Random; + public class MainActivity extends AppCompatActivity { @@ -40,22 +50,47 @@ NavigationUI.setupWithNavController(binding.navView, navController); } - // ツールバーにIconを表示 + // ツールバーにbotton_nav_topを表示 @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.botton_nav_icon, menu); + getMenuInflater().inflate(R.menu.botton_nav_top, menu); return true; } - // Iconを押したときMyPageに遷移させたい -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.icon: -// intent = new Intent(getApplication(), MyPageFragment.class); -// startActivity(intent); -// return true; -// } -// return super.onOptionsItemSelected(item); -// } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + // shareボタンの処理 + case R.id.editMenuShare: + ShareCompat.IntentBuilder builder + = ShareCompat.IntentBuilder.from(this); + String subject = "サブジェクト"; + String bodyText = "アプリ名とかストアページURLとか..."; + builder.setSubject(subject) /// 件名 + .setText(bodyText) /// 本文 + .setType("text/plain"); + Intent intent = builder.createChooserIntent(); + + /// 結果を受け取らずに起動 + builder.startChooser(); + return true; + + // Iconを押したときMyPageに遷移 + case R.id.icon: + String[] poptext = { "I LOVE JENKINS", "わけわからん", "そうだ、新田研に行こう。", "大吉", "中吉", "吉", "凶" }; + Random random = new Random(); + Toast myToast = Toast.makeText( + getApplicationContext(), + poptext[random.nextInt(7)], + Toast.LENGTH_SHORT + ); + myToast.show(); + return true; + + default: + return super.onOptionsItemSelected(item); + + } + } } \ No newline at end of file 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 index 692022a..fd13098 100644 --- 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 @@ -7,6 +7,8 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -22,16 +24,25 @@ import org.ntlab.acanthus_client.views.paint.PaintViewModel; import java.util.HashMap; +import java.util.Timer; +import java.util.TimerTask; // 表示ページ public class AnimationActivity extends AppCompatActivity { private AnimationCanvas animationCanvas; private AnimationViewModel animationViewModel; - private View view; + //アニメーション用の変数 private WebView webView; private HashMap pages; + private int pageNo = 0; + + //タイマー用の変数 + private Timer timer; + private CountUpTimerTask timerTask; + private Handler handler = new Handler(Looper.getMainLooper()); + private int msec = 1000; //ボタン系 private boolean buttonView = true; @@ -46,13 +57,12 @@ //animationCanvasの表示 @Override protected void onCreate(Bundle savedInstanceState) { - init(); - super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation); - animationCanvas = this.findViewById(R.id.animationMyCanvas); + //animationCanvas = this.findViewById(R.id.animationMyCanvas); + init(); - //wecView + //wecView初期設定 webView = this.findViewById(R.id.animationWebview); webView .getSettings().setLoadWithOverviewMode(true); webView .getSettings().setUseWideViewPort(true); @@ -62,15 +72,14 @@ return false; } }); -// url = animationViewModel.getAnimationPage().getValue(); -// //url = "http://nitta-lab-www.is.konan-u.ac.jp/gallery/300/0/a300p0.png"; -// webView.loadUrl(url); + ////////////////////////////////////////////////////////////////////////// + //以下アニメーションボタン関連 //アニメーションの再生停止 buttonPlayback = findViewById(R.id.button_playback); buttonPlayback.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { - if(animationCanvas.onClickPlayback() == 0){ + if(onClickPlayback()){ buttonPlayback.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_play_arrow)); } else { @@ -83,7 +92,7 @@ buttonReset = findViewById(R.id.button_reset); buttonReset.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { - animationCanvas.resetAnimationPage(); + resetAnimationPage(); } }); @@ -91,7 +100,7 @@ buttonSkip = findViewById(R.id.button_skip); buttonSkip.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { - animationCanvas.setAnimationSkip(1); + setAnimationSkip(1); } }); @@ -99,7 +108,7 @@ buttonBack = findViewById(R.id.button_back); buttonBack.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { - animationCanvas.setAnimationSkip(-1); + setAnimationSkip(-1); } }); @@ -121,30 +130,6 @@ } }); } - - public void init(){ - //初期化 - Acanthus acanthus = (Acanthus) getApplication(); - animationViewModel = new ViewModelProvider(this).get(AnimationViewModel.class); - animationViewModel.init(acanthus); - startObserver(); - } - - //startobserve - private void startObserver(){ - animationViewModel.getAnimationPage().observe(this, new Observer>() { - @Override - public void onChanged(HashMap s) { - pages = animationViewModel.getAnimationPage().getValue(); - //url = "http://nitta-lab-www.is.konan-u.ac.jp/gallery/300/0/a300p0.png"; - webView.loadUrl(pages.get(1)); - Log.d("a", "onFailure: -----------------------OK:Obs"); - //animationCanvas.init(pages); - } - }); - } - - //Activity内のボタンの表示/非表示 @Override public boolean onTouchEvent(MotionEvent motionEvent) { @@ -175,4 +160,80 @@ return false; } + + //////////////////////////////////////////////////////////////////////////// + //以下アニメーション操作画面 + public void init(){ + //初期化 + Acanthus acanthus = (Acanthus) getApplication(); + animationViewModel = new ViewModelProvider(this).get(AnimationViewModel.class); + animationViewModel.init(acanthus); + startObserver(); + } + + //startobserve + private void startObserver(){ + animationViewModel.getAnimationPage().observe(this, new Observer>() { + @Override + public void onChanged(HashMap s) { + pages = animationViewModel.getAnimationPage().getValue(); + animationView(); + //animationCanvas.init(pages); + } + }); + } + + private void animationView(){ + webView.loadUrl(pages.get(pageNo+1)); + } + + //アニメーションの再生停止 + public boolean onClickPlayback(){ + if(timer != null){ + //timerの終了 + timer.cancel(); + timer = null; + return true; + } + else{ + //timerの生成 + this.timer = new Timer(); + this.timerTask = new CountUpTimerTask(); + this.timer.schedule(timerTask,0, this.msec);//スケジュールを100ms毎に設定する。 + return false; + } + } + + //ページを進める(ループ) + class CountUpTimerTask extends TimerTask { + @Override + public void run(){ + handler.post(new Runnable(){ + public void run() { + pageNo = (pageNo + 1) % pages.size(); + animationView(); + } + }); + } + } + + //最初のページに戻す。 + public void resetAnimationPage(){ + this.pageNo = 0; + animationView(); + } + + + //再生速度の変更 + public void setAnimationSpeed(float speed){ + this.msec *= speed; + } + + //2秒スキップ + public void setAnimationSkip(int x){ + this.pageNo += x * 2000 / this.msec; + if(this.pageNo < 0) this.pageNo = 0; + else if(this.pageNo >= pages.size()) this.pageNo = pages.size() - 1; + animationView(); + } } \ No newline at end of file diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationCanvas.java b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationCanvas.java index 7ff99bb..6c89c27 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationCanvas.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationCanvas.java @@ -78,7 +78,6 @@ // bmp.add(getBitmapFromURL(pages.get(i))); // } // } - //URLをとる // public void setPages(HashMap pages){ // this.pages = pages; @@ -142,14 +141,7 @@ public void run(){ handler.post(new Runnable(){ public void run(){ - //ループする pageNo = (pageNo + 1) % bmp.size(); - - //ループさせない - /* - if(timer != null) onClickPlayback(); - this.pageNo = bmp.size() - 1; - */ postInvalidate(); } }); @@ -173,10 +165,6 @@ this.pageNo += x * 2000 / this.msec; if(this.pageNo < 0) this.pageNo = 0; else if(this.pageNo >= bmp.size()) this.pageNo = bmp.size() - 1; - /*else if(this.pageNo >= bmp.size()) { - if(timer != null) onClickPlayback(); - this.pageNo = bmp.size() - 1; - }*/ postInvalidate(); } diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationConnectionModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationConnectionModel.java index ded1ff7..d5d059f 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationConnectionModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationConnectionModel.java @@ -38,7 +38,6 @@ public void getPage(MutableLiveData> pages) { final StrokesRest strokesRest = retrofit.create(StrokesRest.class); - //----------------------------------------------------------------- // 筆跡追加API Call> call = strokesRest.getPageUrls(1111); call.enqueue(new Callback>() { @@ -46,7 +45,6 @@ public void onResponse(Call> call, Response> response) { if (response.isSuccessful()){ pages.setValue(response.body()); - Log.d("a", "onFailure: -----------------------OK:Serv"); } } 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 index 52124ec..d5a1cb6 100644 --- 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 @@ -218,6 +218,12 @@ } //----------------------------------------------------------------- + //サーバーに画像データ(BASE64)を送る + public void setImage(String image){ + paintModelContainer.getPaintConnectionModel().setImage(image); + } + + //----------------------------------------------------------------- // public void stop() { thread.shutdown(); diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/paint/models/PaintConnectionModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/paint/models/PaintConnectionModel.java index cd68e96..2db430c 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/paint/models/PaintConnectionModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/paint/models/PaintConnectionModel.java @@ -193,5 +193,25 @@ } //----------------------------------------------------------------- + // "screenssc()"が実行されたとき、エンコードした文字列(BASE64)をサーバに送る + public void setImage(String image){ + final StrokesRest strokesRest = retrofit.create(StrokesRest.class); + + //----------------------------------------------------------------- + Call call = strokesRest.addImage(acanthus.getAid(), acanthus.getEditingPageId(), image); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + } + + @Override + public void onFailure(Call call, Throwable t) { + } + }); + + } + + + //----------------------------------------------------------------- } \ No newline at end of file diff --git a/app/src/main/res/drawable/nitta_naoya.jpg b/app/src/main/res/drawable/nitta_naoya.jpg new file mode 100644 index 0000000..6c4b9e5 --- /dev/null +++ b/app/src/main/res/drawable/nitta_naoya.jpg Binary files differ diff --git a/app/src/main/res/menu/botton_nav_icon.xml b/app/src/main/res/menu/botton_nav_icon.xml deleted file mode 100644 index fc8a6d4..0000000 --- a/app/src/main/res/menu/botton_nav_icon.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/botton_nav_top.xml b/app/src/main/res/menu/botton_nav_top.xml new file mode 100644 index 0000000..6f7127a --- /dev/null +++ b/app/src/main/res/menu/botton_nav_top.xml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4cfd5d..c29a8d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,4 +24,5 @@ button_create paint_button edit_button + editActionBarShare \ No newline at end of file