diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1de6c3b..9919eb8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,23 +2,24 @@
-
+
+
+ android:label="グループメンバー" />
@@ -71,13 +72,17 @@
-
+ android:theme="@style/AppTheme.NoActionBar">
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/cosmosclient/services/CosomosBackgroundService.java b/app/src/main/java/com/example/cosmosclient/services/CosomosBackgroundService.java
new file mode 100644
index 0000000..4ce93a6
--- /dev/null
+++ b/app/src/main/java/com/example/cosmosclient/services/CosomosBackgroundService.java
@@ -0,0 +1,178 @@
+package com.example.cosmosclient.services;
+
+import android.Manifest;
+import android.app.IntentService;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.RequiresApi;
+import android.support.v4.app.ActivityCompat;
+import android.util.Log;
+
+import com.example.cosmosclient.R;
+
+
+public class CosomosBackgroundService extends IntentService implements LocationListener {
+ private Context context;
+ private LocationManager locationManager;
+
+ public CosomosBackgroundService() {
+ super("CosomosBackgroundService");
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.d("debug", "onCreate");
+ context = getApplicationContext();
+ // LocationManager インスタンス生成
+ locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.O)
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+
+ Log.d("debug", "onStartCommand");
+
+// Thread thread = new Thread() {
+// public void run() {
+// int count = 10;
+//
+// try {
+// for(int i=0 ; i< count ; i++) {
+// Thread.sleep(1000);
+//
+// Log.d("debug", "sleep: " + String.valueOf(i));
+// }
+//
+// } catch (InterruptedException e) {
+// Thread.currentThread().interrupt();
+// }
+// }
+// };
+// thread.start();
+ int requestCode = 0;
+ String channelId = "default";
+ String title = context.getString(R.string.app_name);
+ PendingIntent pendingIntent =
+ PendingIntent.getActivity(context, requestCode,
+ intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ // ForegroundにするためNotificationが必要、Contextを設定
+ NotificationManager notificationManager =
+ (NotificationManager)context.
+ getSystemService(Context.NOTIFICATION_SERVICE);
+ // Notification Channel 設定
+ NotificationChannel channel = new NotificationChannel(
+ channelId, title , NotificationManager.IMPORTANCE_DEFAULT);
+ channel.setDescription("Silent Notification");
+ // 通知音を消さないと毎回通知音が出てしまう
+ // この辺りの設定はcleanにしてから変更
+ channel.setSound(null,null);
+ // 通知ランプを消す
+ channel.enableLights(false);
+ channel.setLightColor(Color.BLUE);
+ // 通知バイブレーション無し
+ channel.enableVibration(false);
+ if(notificationManager != null) {
+ notificationManager.createNotificationChannel(channel);
+ Notification notification = new Notification.Builder(context, channelId)
+ .setContentTitle(title)
+ // 本来なら衛星のアイコンですがandroid標準アイコンを設定
+ .setSmallIcon(android.R.drawable.btn_star)
+ .setContentText("GPS")
+ .setAutoCancel(true)
+ .setContentIntent(pendingIntent)
+ .setWhen(System.currentTimeMillis())
+ .build();
+
+ // startForeground
+ startForeground(1, notification);
+ }
+// startGPS();
+
+ return super.onStartCommand(intent,flags,startId);
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+
+ Log.d("debug", "onHandleIntent");
+ int count = 10;
+
+ try {
+ for(int i=0 ; i< count ; i++) {
+ Thread.sleep(1000);
+
+ Log.d("debug", "sleep: " + String.valueOf(i));
+ }
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+// protected void startGPS() {
+// StringBuilder strBuf = new StringBuilder();
+// strBuf.append("startGPS\n");
+//
+// final boolean gpsEnabled
+// = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
+// if (!gpsEnabled) {
+// // GPSを設定するように促す
+// enableLocationSettings();
+// }
+//
+// if (locationManager != null) {
+// try {
+// if (ActivityCompat.checkSelfPermission(this,
+// Manifest.permission.ACCESS_FINE_LOCATION)!=
+// PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+//
+// locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
+// MinTime, MinDistance, this);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// } else {
+// strBuf.append("locationManager=null\n");
+// }
+// }
+ @Override
+ public void onDestroy() {
+ Log.d("debug", "onDestroy");
+
+ super.onDestroy();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+
+ }
+}
diff --git a/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java b/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java
index 45588fd..9c9374c 100644
--- a/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java
+++ b/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java
@@ -5,6 +5,7 @@
import android.graphics.BitmapFactory;
import android.nfc.Tag;
import android.os.Bundle;
+import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.util.Base64;
import android.util.Log;
@@ -22,6 +23,7 @@
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.GridView;
+import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
@@ -87,24 +89,30 @@
if (response.isSuccessful()) {
UserResponse result = response.body();
- //ユーザ名とユーザIDを表示したい
+ //アイコンとユーザ名とユーザIDを表示したい
+ final String uName;
+ final String uIcon;
NavigationView navView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navView.getHeaderView(0);
TextView userNameTextView = navView.getHeaderView(0).findViewById(R.id.userName);
TextView userIDTextView = navView.getHeaderView(0).findViewById(R.id.userID);
+ ImageView userIcon = navView.getHeaderView(0).findViewById(R.id.userIcon);
userIDTextView.setText("ユーザID:"+uId);
- final String uName;
uName = result.name;
+ uIcon = result.iconUri;
userNameTextView.setText("ユーザ名:"+uName);
+ if (uIcon != null) {
+ byte[] decodedByte = Base64.decode(uIcon, 0);
+ userIcon.setImageBitmap(BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length));
+ }
-
- //画像をBase64に変換
- Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.default_icon_image);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- icon.compress(Bitmap.CompressFormat.JPEG,100, baos);
- byte[] b = baos.toByteArray();
- String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);
-// Toast.makeText(GroupListActivity.this,"接続できたよ",Toast.LENGTH_LONG).show();
+// //画像をBase64に変換
+// Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.default_icon_image);
+// ByteArrayOutputStream baos = new ByteArrayOutputStream();
+// icon.compress(Bitmap.CompressFormat.JPEG,100, baos);
+// byte[] b = baos.toByteArray();
+// String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);
+//// Toast.makeText(GroupListActivity.this,"接続できたよ",Toast.LENGTH_LONG).show();
//アイコンが未設定ならデフォルト画像を設定
diff --git a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java
index aac4424..b9769aa 100644
--- a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java
+++ b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java
@@ -2,7 +2,10 @@
import android.content.Intent;
import android.content.SharedPreferences;
+import android.os.Build;
import android.os.Handler;
+import android.os.HandlerThread;
+import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
@@ -12,10 +15,12 @@
import android.widget.EditText;
import android.widget.Toast;
+import com.example.cosmosclient.MainActivity;
import com.example.cosmosclient.R;
import com.example.cosmosclient.app.Cosmos;
import com.example.cosmosclient.entities.SigninResponse;
import com.example.cosmosclient.resources.UsersRest;
+import com.example.cosmosclient.services.CosomosBackgroundService;
import retrofit2.Call;
import retrofit2.Callback;
@@ -27,12 +32,40 @@
private boolean uIdEnable;
private boolean pwEnable;
private Button SigninButton;
+ private Intent intentservice;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
+// // 別スレ生成 -> 開始
+// HandlerThread handlerThread = new HandlerThread("other");
+// handlerThread.start();
+//
+// //作成したHandlerThread(別スレ)内部のLooperを引数として、HandlerThread(のLooper)にメッセージを送るHandlerを生成する。
+// Handler handler = new Handler(handlerThread.getLooper());
+// //Handlerのpostメソッドでメッセージ(タスク:重たい処理)を送信する。
+// handler.post(new Runnable() {
+// @RequiresApi(api = Build.VERSION_CODES.O)
+// @Override
+// public void run() {
+// //重たい処理を記述
+// intentservice = new Intent(SigninActivity.this, CosomosBackgroundService.class);
+// startForegroundService(intentservice);
+// }
+// });
+
+ Thread thread = new Thread() {
+ @RequiresApi(api = Build.VERSION_CODES.O)
+ public void run() {
+ intentservice = new Intent(SigninActivity.this, CosomosBackgroundService.class);
+ startForegroundService(intentservice);
+
+ }
+ };
+ thread.start();
//各種IDを取得
SigninButton = findViewById(R.id.SigninButton);
Button SignupButton = findViewById(R.id.SignupButton);
@@ -148,6 +181,8 @@
}
});
}
+
+
private class GenericTextWatcher implements TextWatcher{
private View view;
diff --git a/app/src/main/res/layout/nav_header_group_list.xml b/app/src/main/res/layout/nav_header_group_list.xml
index 649c531..81a5cda 100644
--- a/app/src/main/res/layout/nav_header_group_list.xml
+++ b/app/src/main/res/layout/nav_header_group_list.xml
@@ -14,9 +14,9 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark">