|
2 | 2 |
|
3 | 3 | import android.content.Context;
|
4 | 4 | import android.view.View;
|
| 5 | +import android.widget.Toast; |
5 | 6 |
|
6 | 7 | import androidx.annotation.CallSuper;
|
7 | 8 | import androidx.annotation.LayoutRes;
|
|
20 | 21 | import rocks.tbog.tblauncher.result.ResultHelper;
|
21 | 22 | import rocks.tbog.tblauncher.ui.LinearAdapter;
|
22 | 23 | import rocks.tbog.tblauncher.ui.ListPopup;
|
| 24 | +import rocks.tbog.tblauncher.utils.ClipboardUtils; |
23 | 25 | import rocks.tbog.tblauncher.utils.DebugInfo;
|
24 | 26 | import rocks.tbog.tblauncher.utils.FuzzyScore;
|
25 | 27 | import rocks.tbog.tblauncher.utils.Utilities;
|
@@ -273,27 +275,31 @@ ListPopup inflatePopupMenu(@NonNull Context context, @NonNull LinearAdapter adap
|
273 | 275 | }
|
274 | 276 |
|
275 | 277 | if (DebugInfo.itemRelevance(context)) {
|
276 |
| - String debugTitle = context.getString(R.string.popup_title_debug); |
277 |
| - int pos = -1; |
278 |
| - // find title |
279 |
| - for (int i = 0; i < adapter.getCount(); i += 1) { |
280 |
| - if (debugTitle.equals(adapter.getItem(i).toString())) { |
281 |
| - pos = i + 1; |
282 |
| - break; |
283 |
| - } |
284 |
| - } |
285 |
| - // if title not found, add title |
286 |
| - if (pos == -1) { |
287 |
| - adapter.add(new LinearAdapter.ItemTitle(debugTitle)); |
288 |
| - pos = adapter.getCount(); |
289 |
| - } |
290 |
| - // add debug data after title |
| 278 | + int pos = addDebugTitleOnce(context, adapter); |
291 | 279 | adapter.add(pos, new LinearAdapter.ItemString("Relevance: " + getRelevance()));
|
292 | 280 | }
|
293 | 281 |
|
| 282 | + if (DebugInfo.itemShowId(context)) { |
| 283 | + int pos = addDebugTitleOnce(context, adapter); |
| 284 | + adapter.add(pos, new LinearAdapter.ItemString(id)); |
| 285 | + } |
| 286 | + |
294 | 287 | return menu;
|
295 | 288 | }
|
296 | 289 |
|
| 290 | + int addDebugTitleOnce(@NonNull Context context, @NonNull LinearAdapter adapter) { |
| 291 | + String debugTitle = context.getString(R.string.popup_title_debug); |
| 292 | + // find title |
| 293 | + for (int i = 0; i < adapter.getCount(); i += 1) { |
| 294 | + if (debugTitle.equals(adapter.getItem(i).toString())) { |
| 295 | + return i + 1; |
| 296 | + } |
| 297 | + } |
| 298 | + // if title not found, add title |
| 299 | + adapter.add(new LinearAdapter.ItemTitle(debugTitle)); |
| 300 | + return adapter.getCount(); |
| 301 | + } |
| 302 | + |
297 | 303 | /**
|
298 | 304 | * How to display the popup menu
|
299 | 305 | *
|
@@ -343,6 +349,10 @@ boolean popupMenuClickHandler(@NonNull View view, @NonNull LinearAdapter.MenuIte
|
343 | 349 | } else if (R.string.menu_popup_quick_list_customize == stringId) {
|
344 | 350 | TBApplication.behaviour(context).launchEditQuickListDialog(context);
|
345 | 351 | return true;
|
| 352 | + } else if (id.equals(item.toString())) { |
| 353 | + ClipboardUtils.setClipboard(context, id); |
| 354 | + Toast.makeText(context, context.getString(R.string.copy_confirmation, id), Toast.LENGTH_SHORT).show(); |
| 355 | + return true; |
346 | 356 | }
|
347 | 357 |
|
348 | 358 | // FullscreenActivity mainActivity = (FullscreenActivity) context;
|
|
0 commit comments