From e34642fd6e01cf2cc0eddaab9dc4be7f60f8f9f4 Mon Sep 17 00:00:00 2001 From: Domagalski Date: Tue, 11 Dec 2018 00:04:01 +0100 Subject: [PATCH] info popups without on off switch --- .idea/misc.xml | 2 +- app/build.gradle | 2 + .../com/uam/wmi/findmytutor/FindMyTutor.java | 2 + .../wmi/findmytutor/activity/MapActivity.java | 2 +- .../wmi/findmytutor/activity/TutorTab.java | 2 + .../activity/UsersListFragment.java | 2 +- .../findmytutor/utils/InfoHelperUtils.java | 30 +++--- .../SharingInfoPopupButtonPreference.java | 44 +++++++++ app/src/main/res/layout/activity_map.xml | 15 ++- app/src/main/res/layout/content_tutor_tab.xml | 8 ++ app/src/main/res/layout/info_popup_map.xml | 4 +- .../res/layout/info_popup_sharing_tab.xml | 98 +++++++++++++++++++ .../main/res/layout/info_popup_tutor_tab.xml | 45 +++++++++ .../main/res/layout/info_popup_userlist.xml | 14 +-- app/src/main/res/layout/pref_main.xml | 6 ++ app/src/main/res/layout/pref_sharing.xml | 3 +- .../preference_popup_info_button_widget.xml | 14 +++ app/src/main/res/values-pl/strings.xml | 12 +-- app/src/main/res/values/strings.xml | 18 ++-- 19 files changed, 270 insertions(+), 53 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/utils/SharingInfoPopupButtonPreference.java create mode 100644 app/src/main/res/layout/info_popup_sharing_tab.xml create mode 100644 app/src/main/res/layout/info_popup_tutor_tab.xml create mode 100644 app/src/main/res/layout/preference_popup_info_button_widget.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index b0c7b20..dc44dda 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 5a09b18..ce425eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,8 @@ dependencies { implementation "ch.acra:acra-http:$acraVersion" implementation "ch.acra:acra-toast:$acraVersion" implementation "ch.acra:acra-notification:$acraVersion" + implementation "ch.acra:acra-limiter:$acraVersion" + implementation fileTree(include: ['*.jar'], dir: 'libs') diff --git a/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java b/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java index 763c4b5..0c2298f 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java @@ -7,6 +7,7 @@ import android.content.res.Configuration; import static org.acra.ReportField.*; import org.acra.ACRA; +import org.acra.annotation.AcraLimiter; import org.acra.annotation.AcraNotification; import org.acra.config.CoreConfigurationBuilder; import org.acra.config.HttpSenderConfigurationBuilder; @@ -20,6 +21,7 @@ import java.util.Map; @AcraNotification(resText = R.string.notification_text, resTitle = R.string.notification_title, resChannelName = R.string.notification_channel) +@AcraLimiter(failedReportLimit = 2) public class FindMyTutor extends Application { @Override protected void attachBaseContext(Context base) { 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 ce57f75..4c67438 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 @@ -131,7 +131,7 @@ public class MapActivity extends BaseActivity }; - findViewById(R.id.mapInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(this,v, R.layout.info_popup_map)); + findViewById(R.id.mapInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v, R.layout.info_popup_map)); selectLocationButton = findViewById(R.id.select_location_button); removeLocationButton = findViewById(R.id.remove_location_button); Mapbox.getInstance(this, getString(R.string.access_token)); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/TutorTab.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/TutorTab.java index d98a4f5..f96a2b0 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/TutorTab.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/TutorTab.java @@ -18,6 +18,7 @@ import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.network.ApiClient; import com.uam.wmi.findmytutor.service.TutorTabApi; import com.uam.wmi.findmytutor.service.UserService; +import com.uam.wmi.findmytutor.utils.InfoHelperUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.RestApiHelper; @@ -60,6 +61,7 @@ public class TutorTab extends AppCompatActivity { TextView userEmail = findViewById(R.id.userEmail); TextView department = findViewById(R.id.userDepartment); Button saveButon = findViewById(R.id.saveButon); + findViewById(R.id.contentTutorTabInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_tutor_tab)); userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext()))); disposable.add( diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java index 1b83e8b..cb62642 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java @@ -84,7 +84,7 @@ public class UsersListFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { ButterKnife.bind(this, view); - view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> InfoHelperUtils.infoPopUp(getActivity(),v,R.layout.info_popup_userlist)); + view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_userlist)); userService = ApiClient.getClient(getApplicationContext()) .create(UserService.class); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java index b6e61ca..232e3ae 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java @@ -21,22 +21,22 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; public class InfoHelperUtils { - public static void infoPopUp(Activity activity, View anchorView, int layoutId) { - View popupView = LayoutInflater.from(activity).inflate(layoutId, null); - PopupWindow popupWindow = new PopupWindow(popupView, - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - // 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] + anchorView.getWidth(), location[1] + anchorView.getHeight()); + public static void infoPopUp(View anchorView, int layoutId) { + LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); + View popupView = layoutInflater.inflate(layoutId, null); - Toast.makeText(getApplicationContext(), anchorView.getId() + "", Toast.LENGTH_SHORT).show(); + PopupWindow popupWindow = new PopupWindow(popupView, + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + // 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] + anchorView.getWidth() / 2, location[1] + anchorView.getHeight()); } } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingInfoPopupButtonPreference.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingInfoPopupButtonPreference.java new file mode 100644 index 0000000..88aad9d --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingInfoPopupButtonPreference.java @@ -0,0 +1,44 @@ +package com.uam.wmi.findmytutor.utils; + +import android.content.Context; +import android.graphics.drawable.ColorDrawable; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.PopupWindow; +import android.widget.Toast; + +import com.uam.wmi.findmytutor.R; + +import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; + +public class SharingInfoPopupButtonPreference extends Preference { + + public SharingInfoPopupButtonPreference(Context context, AttributeSet attrs) { + super(context, attrs); + setWidgetLayoutResource(R.layout.preference_popup_info_button_widget); + } + @Override + protected View onCreateView(ViewGroup parent) { + View view = super.onCreateView(parent); +// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); +// View temp =li.inflate( R.layout.preference_button_widget, parent, false); + return view; + } + @Override + protected void onBindView(View view) + { + super.onBindView(view); + ImageButton button = view.findViewById(R.id.sharingTabInfoImageButton); + button.setOnClickListener(v-> { + InfoHelperUtils.infoPopUp(v,R.layout.info_popup_sharing_tab); + }); + } + +} diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index e4d5a34..20477f0 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -2,21 +2,12 @@ - - + + + + + android:background="@drawable/layout_bg"> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/info_popup_tutor_tab.xml b/app/src/main/res/layout/info_popup_tutor_tab.xml new file mode 100644 index 0000000..7f5feb8 --- /dev/null +++ b/app/src/main/res/layout/info_popup_tutor_tab.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/info_popup_userlist.xml b/app/src/main/res/layout/info_popup_userlist.xml index f1d60c9..b06a52c 100644 --- a/app/src/main/res/layout/info_popup_userlist.xml +++ b/app/src/main/res/layout/info_popup_userlist.xml @@ -3,24 +3,24 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:padding="5dp" + android:padding="20dp" android:background="@drawable/layout_bg"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/pref_sharing.xml b/app/src/main/res/layout/pref_sharing.xml index 0f03421..e41a88d 100644 --- a/app/src/main/res/layout/pref_sharing.xml +++ b/app/src/main/res/layout/pref_sharing.xml @@ -1,12 +1,13 @@ + + diff --git a/app/src/main/res/layout/preference_popup_info_button_widget.xml b/app/src/main/res/layout/preference_popup_info_button_widget.xml new file mode 100644 index 0000000..0a12f86 --- /dev/null +++ b/app/src/main/res/layout/preference_popup_info_button_widget.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 797c877..ea104ae 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -168,15 +168,13 @@ 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) - - Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację. W tym panelu możesz dodać użytkowników do swojej czarnej listy. Użytkownicy z czarnej listy nie będą widzieć żadnych danych które udostępniasz - lokalizacji, twojego statusu online, czy informacji o obecności. @@ -198,10 +196,10 @@ W tej zakładce możesz włączyć/wyłączyć udostępnianie swojej lokalizacji oraz ją skonfigurować. Niektóre zmiany mogą nie być widoczne od razu! Odświeżanie informacji zajmuje do 2 minut. Udostępniać możesz na jednym z 4 poziomów: - - dokładny - lokalizacja wyświetlana na mapie na podstawie GPS - - przybliżony - przybliżona lokalizacja wyświetlana na podstawie GPS - - manualny - udostępnianie z ręcznie wybranego punktu na mapie - - tylko obecność - udostępnianie jedynie informacji o pojawieniu się na wydziale (aktywny na liście), bez udostępniania lokalizacji + dokładny - lokalizacja wyświetlana na mapie na podstawie GPS + przybliżony - przybliżona lokalizacja wyświetlana na podstawie GPS + manualny - udostępnianie z ręcznie wybranego punktu na mapie + tylko obecność - udostępnianie jedynie informacji o pojawieniu się na wydziale (aktywny na liście), bez udostępniania lokalizacji Każdy poziom z wyjątkiem manualnie wybranej lokalizacji automatycznie zaczyna udostępniać po wejściu na wydział i przestaje udostępniać po jego opuszczeniu. Wystarczy włączyć udostępnianie, a lokalizacja nie będzie udostępniana tylko przy obecności na wydziale. Udostępnianie w dowolnym momencie można wyłączyć za pomocą przełącznika. Dodatkowo, do Twojej lokalizacji możesz dodać status opisowy (będzie on widoczny dla użytkowników po kliknięciu w marker). diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 97a6be4..e42c681 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -243,6 +243,12 @@ Search mock location string + + Allow to send raport to developers is ON + Allow to send raport to developers is OFF + App issues reporting + + 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. @@ -250,10 +256,6 @@ approximated localization manual localization (manually picked) - - - There are markers on the map which represent tutors sharing their location at the very moment. - In this panel you can add users to your blacklist. Users from the blacklist can’t see any data that you share - localization, online status, or information about presence. The only thing which remains public is the note in your profile. @@ -274,10 +276,10 @@ In this tab you can turn on/off sharing your localization and configure it. Some of the changes may not happen immediately! Refreshing information takes up to 2 minutes. You can share your localization on one of the 4 levels: - - exact - localization displayed on a map, based on GPS - - approximated - approximated localization based on GPS - - manual - sharing from manually picked point - - presence only - sharing only information whether you are present on the faculty or not, without sharing your localization + exact - localization displayed on a map, based on GPS + approximated - approximated localization based on GPS + manual - sharing from manually picked point + presence only - sharing only information whether you are present on the faculty or not, without sharing your localization Each level, except from manual, will be automatically turned on when entering, and turn off when leaving the faculty. You only need to make sure that sharing is on, and the localization will be shared only when on the faculty. Sharing can be turned off at any time with the switch. Additionally, you can add descriptive status to your localization (visible for users after clicking on a marker).