Skip to content

Commit 71034bf

Browse files
Merge pull request #155 from appdevforall/feat/ADFA-4593-help-mechanism-fixes
ADFA-4593: help mechanism fixes (LOHS wiring + smart tooltip placement)
2 parents e6916df + 1ef4612 commit 71034bf

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎controller/app/src/main/java/org/iiab/controller/help/TooltipManager.java‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.os.Handler;
2525
import android.os.Looper;
2626
import android.util.Log;
27+
import android.view.Gravity;
2728
import android.view.LayoutInflater;
2829
import android.view.View;
2930
import android.view.ViewGroup;
@@ -270,7 +271,7 @@ public void onClick(View v) {
270271
linksBox.setVisibility(View.GONE);
271272
}
272273

273-
popup.showAsDropDown(anchor);
274+
showPopupSmart(popup, anchor);
274275
} catch (Exception e) {
275276
Log.e(TAG, "showPopup failed: " + e.getMessage());
276277
}
@@ -284,6 +285,26 @@ private static boolean isDebuggable(Context context) {
284285
}
285286
}
286287

288+
// Show the popup below the anchor, or above it when the anchor sits low on
289+
// screen (e.g. a bottom navigation/close button) so it isn't clipped off the
290+
// bottom. Anchor-position based, so it works even while the WebView content
291+
// is still laying out.
292+
private static void showPopupSmart(PopupWindow popup, View anchor) {
293+
try {
294+
int screenH = anchor.getResources().getDisplayMetrics().heightPixels;
295+
int[] loc = new int[2];
296+
anchor.getLocationOnScreen(loc);
297+
int anchorTop = loc[1];
298+
if (anchorTop > screenH * 0.55f) {
299+
popup.showAtLocation(anchor, Gravity.BOTTOM | Gravity.START, loc[0], screenH - anchorTop);
300+
} else {
301+
popup.showAsDropDown(anchor);
302+
}
303+
} catch (Exception e) {
304+
try { popup.showAsDropDown(anchor); } catch (Exception ignored) {}
305+
}
306+
}
307+
287308
public static void dismissActive() {
288309
try {
289310
if (activePopup != null) {

‎controller/app/src/main/java/org/iiab/controller/help/TooltipTag.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ private TooltipTag() {}
104104
public static final String USAGE_CLEAR_LOG = "usage.clear_log";
105105
public static final String USAGE_COPY_LOG = "usage.copy_log";
106106
public static final String USAGE_SERVER_CONTROL = "usage.server_control";
107+
public static final String USAGE_LOHS_TOGGLE = "usage.lohs_toggle";
108+
public static final String USAGE_LOHS_SHOW_QR = "usage.lohs_show_qr";
107109

108110
// main
109111
public static final String MAIN_SHARE_QR = "main.share_qr";

‎controller/app/src/main/java/org/iiab/controller/help/TooltipWiring.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ private TooltipWiring() {}
105105
MAP.put(R.id.btn_clear_log, TooltipTag.USAGE_CLEAR_LOG);
106106
MAP.put(R.id.btn_copy_log, TooltipTag.USAGE_COPY_LOG);
107107
MAP.put(R.id.btn_server_control, TooltipTag.USAGE_SERVER_CONTROL);
108+
MAP.put(R.id.lohs_toggle, TooltipTag.USAGE_LOHS_TOGGLE);
109+
MAP.put(R.id.lohs_show_qr, TooltipTag.USAGE_LOHS_SHOW_QR);
108110
// main
109111
MAP.put(R.id.btn_share_qr, TooltipTag.MAIN_SHARE_QR);
110112
MAP.put(R.id.btn_settings, TooltipTag.MAIN_SETTINGS);

0 commit comments

Comments
 (0)