map info pop up
This commit is contained in:
parent
b4dd785504
commit
fc428451a9
@ -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 <code><a href="/reference/android/app/AlertDialog.Builder.html">AlertDialog.Builder</a></code> 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" +
|
||||
"<marker> - dokładna (udostępniana z GPS telefonu)\n" +
|
||||
"<marker> - 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 <code><a href="/reference/android/app/AlertDialog.html">AlertDialog</a></code> from <code><a href="/reference/android/app/AlertDialog.Builder.html#create()">create()</a></code>
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
7
app/src/main/res/drawable/layout_bg.xml
Normal file
7
app/src/main/res/drawable/layout_bg.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#e9ffffff"/>
|
||||
<stroke android:width="3dp" android:color="#B1BCBE" />
|
||||
<corners android:radius="10dp"/>
|
||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||
</shape>
|
76
app/src/main/res/layout/info_popup_map.xml
Normal file
76
app/src/main/res/layout/info_popup_map.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/layout_bg">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/map_info_text_p1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP2"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_p2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP3"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_p3" />
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exactMarkerTextView"
|
||||
android:gravity="center"
|
||||
android:drawableLeft="@drawable/exact_localization_marker"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_exact" />
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/approximateTextView"
|
||||
android:drawableLeft="@drawable/approximate_localization_marker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_approximated" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manualMarkerTextView"
|
||||
android:drawableLeft="@drawable/manual_localization_marker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_manual" />
|
||||
|
||||
</LinearLayout>
|
@ -167,6 +167,14 @@
|
||||
<string name="description_awaiting">Czekam na studentów</string>
|
||||
<string name="description_onholidays">Na wakacjach</string>
|
||||
<string name="title_description">Status</string>
|
||||
|
||||
|
||||
<string name="map_info_text_p1">Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację.</string>
|
||||
<string name="map_info_text_p2">Po kliknięciu w marker możemy sprawdzić kto udostępnia lokalizację, oraz status opisowy (jeśli profesor go ustawił).</string>
|
||||
<string name="map_info_text_p3">W aplikacji dostępne są 3 rodzaje lokalizacji, które reprezentowane są przez markery różnego koloru.</string>
|
||||
<string name="map_info_text_marker_exact">lokalizacja dokładna (udostępniana z GPS telefonu)</string>
|
||||
<string name="map_info_text_marker_approximated">lokalizacja przybliżona</string>
|
||||
<string name="map_info_text_marker_manual"> lokalizacja manualna (wybrana ręcznie)</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
@ -242,5 +242,13 @@
|
||||
<string name="lack_note">No note.</string>
|
||||
<string name="search">Search</string>
|
||||
<string name="mockup_location_string" translatable="false">mock location string</string>
|
||||
<string name="map_info_text">Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację.</string>
|
||||
|
||||
<string name="map_info_text_p1">On the map there are markers which represents tutors sharing their location right now.</string>
|
||||
<string name="map_info_text_p2">After clicking on a marker, you can check who is sharing it and the descriptive status (if the tutor have set one).</string>
|
||||
<string name="map_info_text_p3">In the app there are 3 possible types of localization, represented by various colors.</string>
|
||||
<string name="map_info_text_marker_exact">exact localization (from mobile GPS)</string>
|
||||
<string name="map_info_text_marker_approximated">approximated localization</string>
|
||||
<string name="map_info_text_marker_manual">manual localization (manually picked)</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user