diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 63e623f..91e56cf 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -7,11 +7,11 @@ - + - + \ No newline at end of file diff --git a/app/src/main/java/com/example/nemophila/LoginActivity.java b/app/src/main/java/com/example/nemophila/LoginActivity.java index 2366fbf..c724040 100644 --- a/app/src/main/java/com/example/nemophila/LoginActivity.java +++ b/app/src/main/java/com/example/nemophila/LoginActivity.java @@ -40,10 +40,6 @@ nemophila = (Nemophila) this.getApplication(); //Nemophilaにtokenとuidがある場合ログイン画面をスキップ if ((nemophila.getUid() != null) && (nemophila.getToken() != null)){ - //座標指定(仮) - nemophila.setCameraLatitude(defaultLat); - nemophila.setCameraLongitude(defaultLong); - nemophila.setZoom(defaultZoom); Intent intent = new Intent(LoginActivity.this,MapsActivity.class); startActivity(intent); diff --git a/app/src/main/java/com/example/nemophila/PostActivity.java b/app/src/main/java/com/example/nemophila/PostActivity.java index f0ff2cd..e4233bd 100644 --- a/app/src/main/java/com/example/nemophila/PostActivity.java +++ b/app/src/main/java/com/example/nemophila/PostActivity.java @@ -8,6 +8,8 @@ import androidx.lifecycle.ViewModelProvider; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.view.View; @@ -28,7 +30,17 @@ import com.example.nemophila.viewmodels.ShopsViewModel; import com.google.android.material.snackbar.Snackbar; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Base64; import java.util.List; @@ -64,14 +76,26 @@ postImages[1] = findViewById(R.id.imageView2); postImages[2] = findViewById(R.id.imageView3); - System.out.println(uriLists.get(0)); - for(int i = 0; i < 3 && i < uriLists.size(); i++){ postImages[i].setImageURI(uriLists.get(i)); deleteButtons[i].setVisibility(View.VISIBLE); - String s = new String(Base64.getEncoder().encode(uriLists.get(i).toString().getBytes())); - img[i] = s; +// System.out.println(uriLists.get(i)); + + try { + InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(uriLists.get(i)); + Bitmap bitmap = BitmapFactory.decodeStream(new BufferedInputStream(inputStream)); + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); + byte[] byteArray = stream.toByteArray(); + String encoded = Base64.getEncoder().encodeToString(byteArray); +// System.out.println(encoded); +// System.out.println(encoded.length()); + img[i] = encoded; + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } } } @@ -190,11 +214,6 @@ }); - - - - //製作途中 - Button selectPictureButton = (Button)findViewById(R.id.selectpicturebutton); selectPictureButton.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { @@ -203,7 +222,7 @@ } }); -// 写真の削除ボタン +// 写真の削除ボタン 製作途中 deleteButtons[0]= (ImageButton) findViewById(R.id.deleteButton1); @@ -221,6 +240,7 @@ uriLists.set(0, null); // uriLists.remove(1); System.out.println("削除ボタン1"); +// if (postImages.length) for (int i = 0; i < postImages.length-1; i++){ postImages[i].setImageURI(uriLists.get(i+1)); // postImages[i].setImageURI(uriList.get(i)); @@ -229,6 +249,8 @@ uriLists.set(i+1, null); // postImages[i+1] = null; System.out.println(uriLists.get(i)); + } + for (int i = 0; i < postImages.length; i++){ if (uriLists.get(i) == null){ deleteButtons[i].setVisibility(View.INVISIBLE); } @@ -247,7 +269,9 @@ postImages[i].setImageURI(uriLists.get(i+1)); postImages[i+1].setImageURI(null); // postImages[i+1] = null; - if (uriLists.get(i)==null){ + } + for (int i = 0; i < postImages.length; i++){ + if (uriLists.get(i) == null){ deleteButtons[i].setVisibility(View.INVISIBLE); } } @@ -258,7 +282,6 @@ @Override public void onClick(View view) { postImages[2].setImageURI(null); - System.out.println("削除ボタン3"); deleteButtons[2].setVisibility(View.INVISIBLE); } @@ -278,8 +301,8 @@ //評価が未入力の時 - if(rate != 0 && genre != null) { - //評価とジャンル入力済の時 + if(rate != 0 && genre != null) { + //評価とジャンル入力済の時 if (shop == null) { shopsViewModel.createShop(shopName, nemophila.getCurrentLongitude(), nemophila.getCurrentLatitude()); } else { @@ -295,15 +318,15 @@ startActivity(intent); } }else if(rate == 0) { - //評価未入力 + //評価未入力 System.out.println("評価未設定クリック"); Snackbar.make(v, "評価を選択してください", Snackbar.LENGTH_SHORT).show(); // Intent intent = new Intent(getApplication(), ShopActivity.class); // startActivity(intent); }else if (genre == null){ - System.out.println("ジャンル未設定クリック"); - Snackbar.make(v, "ジャンルを選択してください", Snackbar.LENGTH_SHORT).show(); - } + System.out.println("ジャンル未設定クリック"); + Snackbar.make(v, "ジャンルを選択してください", Snackbar.LENGTH_SHORT).show(); + } } }); diff --git a/app/src/main/java/com/example/nemophila/SignUpActivity.java b/app/src/main/java/com/example/nemophila/SignUpActivity.java index 4296898..0cba923 100644 --- a/app/src/main/java/com/example/nemophila/SignUpActivity.java +++ b/app/src/main/java/com/example/nemophila/SignUpActivity.java @@ -27,9 +27,9 @@ private Nemophila nemophila; //座標指定 - private double defaultLat = 34.74; - private double defaultLong = 135.26; - private float defaultZoom = 15f; + private double defaultLat = 38.74; + private double defaultLong = 137.26; + private float defaultZoom = 5f; @Override protected void onCreate(Bundle savedInstanceState) { @@ -41,10 +41,6 @@ //Nemophilaにtokenとuidがある場合サインアップ画面をスキップ if ((nemophila.getUid() != null) && (nemophila.getToken() != null)){ - //座標指定(仮) - nemophila.setCameraLatitude(defaultLat); - nemophila.setCameraLongitude(defaultLong); - nemophila.setZoom(defaultZoom); Intent intent = new Intent(SignUpActivity.this,MapsActivity.class); startActivity(intent); diff --git a/app/src/main/java/com/example/nemophila/resources/AccountsRest.java b/app/src/main/java/com/example/nemophila/resources/AccountsRest.java index 83ab4a8..4d2660a 100644 --- a/app/src/main/java/com/example/nemophila/resources/AccountsRest.java +++ b/app/src/main/java/com/example/nemophila/resources/AccountsRest.java @@ -19,8 +19,6 @@ import retrofit2.http.Path; public interface AccountsRest { - @GET("accounts") - Call getAccounts(); @FormUrlEncoded @POST("accounts") diff --git a/app/src/main/java/com/example/nemophila/resources/FriendsRest.java b/app/src/main/java/com/example/nemophila/resources/FriendsRest.java index 85c6305..a5a4d22 100644 --- a/app/src/main/java/com/example/nemophila/resources/FriendsRest.java +++ b/app/src/main/java/com/example/nemophila/resources/FriendsRest.java @@ -69,5 +69,4 @@ @Path("requested_id") String requested_id, @Field("token") String token ); - } diff --git a/app/src/main/java/com/example/nemophila/resources/ShopsRest.java b/app/src/main/java/com/example/nemophila/resources/ShopsRest.java index c781f22..ec79553 100644 --- a/app/src/main/java/com/example/nemophila/resources/ShopsRest.java +++ b/app/src/main/java/com/example/nemophila/resources/ShopsRest.java @@ -34,24 +34,4 @@ @Field("longitude") double longitude, @Field("latitude") double latitude ); - - @GET("shops/{sid}") - Call getShop( - @Path("sid") String sid - ); - - @GET("shops/{sid}/posts") - Call getPosts( - @Path("sid") String sid - ); - - @FormUrlEncoded - @POST("shops/{sid}/posts/{uid}/{pid}") - Call deletePost( - @Path("sid") String sid, - - @Path("uid") String uid, - @Path("pid") String pid, - @Field("token") String token - ); }