diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index 1449cb1..edae8ec 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -5,6 +5,7 @@ import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.app.Dialog; +import android.graphics.drawable.ColorDrawable; import android.location.Location; import android.os.Bundle; import android.os.Handler; @@ -12,11 +13,14 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.util.Log; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.animation.LinearInterpolator; import android.widget.Button; import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; @@ -133,6 +137,8 @@ public class MapActivity extends BaseActivity handleBackgroundTaskLifeCycle(); manualLocationUtils = new ManualLocationUtils(MapActivity.this); approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson")); + + findViewById(R.id.mapInfoImageButton).setOnClickListener(this::infoDialog); } @Override @@ -723,27 +729,38 @@ public class MapActivity extends BaseActivity MapUtils.setZoom(mapboxMap, zoom); } - public void infoDialog(View v) { -// 1. Instantiate an AlertDialog.Builder with its constructor - AlertDialog.Builder builder = new AlertDialog.Builder(this); -// 2. Chain together various setter methods to set the dialog characteristics - builder.setTitle("Info") - .setMessage("Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację. \n" + - "\n" + - "Po kliknięciu w marker możemy sprawdzić kto udostępnia lokalizację, oraz status opisowy (jeśli profesor go ustawił).\n" + - "\n" + - "W aplikacji dostępne są 3 rodzaje lokalizacji, które reprezentowane są przez markery różnego koloru.\n" + - "\n3 typy lokalizacji:\n" + - " - dokładna (udostępniana z GPS telefonu)\n" + - " - przybliżona\n" + - "Fioletowy- manualna (wybrana ręcznie)\n"); + public void infoDialog(View anchorView) { - builder.setIcon(R.drawable.ic_info_black_24dp); -// 3. Get the AlertDialog from create() - AlertDialog dialog = builder.create(); - dialog.show(); + View popupView = getLayoutInflater().inflate(R.layout.info_popup_map, null); + + PopupWindow popupWindow = new PopupWindow(popupView, + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + + // Example: If you have a TextView inside `popup_layout.xml` +// TextView tv = (TextView) popupView.findViewById(R.id.textViewAAA); +// +// tv.setText("aaaaa"); + + // Initialize more widgets from `popup_layout.xml` +// .... +// .... + + // If the PopupWindow should be focusable + popupWindow.setFocusable(true); + + // If you need the PopupWindow to dismiss when when touched outside + popupWindow.setBackgroundDrawable(new ColorDrawable()); + + int location[] = new int[2]; + + // Get the View's(the one that was clicked in the Fragment) location + anchorView.getLocationOnScreen(location); + + // Using location, the PopupWindow will be displayed right under anchorView + popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, + location[0], location[1] + anchorView.getHeight()); - Toast.makeText(getApplicationContext(), v.getId() + "", Toast.LENGTH_SHORT).show(); } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/layout_bg.xml b/app/src/main/res/drawable/layout_bg.xml new file mode 100644 index 0000000..574781c --- /dev/null +++ b/app/src/main/res/drawable/layout_bg.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/info_popup_map.xml b/app/src/main/res/layout/info_popup_map.xml new file mode 100644 index 0000000..d65d572 --- /dev/null +++ b/app/src/main/res/layout/info_popup_map.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index db10ac8..3a53422 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -167,6 +167,14 @@ Czekam na studentów Na wakacjach Status + + + Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację. + Po kliknięciu w marker możemy sprawdzić kto udostępnia lokalizację, oraz status opisowy (jeśli profesor go ustawił). + W aplikacji dostępne są 3 rodzaje lokalizacji, które reprezentowane są przez markery różnego koloru. + lokalizacja dokładna (udostępniana z GPS telefonu) + lokalizacja przybliżona + lokalizacja manualna (wybrana ręcznie) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e5219be..d61cfc0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -242,5 +242,13 @@ No note. Search mock location string - Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację. + + On the map there are markers which represents tutors sharing their location right now. + After clicking on a marker, you can check who is sharing it and the descriptive status (if the tutor have set one). + In the app there are 3 possible types of localization, represented by various colors. + exact localization (from mobile GPS) + approximated localization + manual localization (manually picked) + +