Skip to content

Instantly share code, notes, and snippets.

View jldubz's full-sized avatar
🧙
Working Magic

Jon-Luke West jldubz

🧙
Working Magic
View GitHub Profile
@jldubz
jldubz / ConfluenceQuestionMacro
Last active December 1, 2021 15:38
This is a user macro for Confluence Server. I felt a need to emphasize questions that need to be answered in docs and none of the existing formatting macros did the trick.
## Macro title: Question
## Macro has a body: Y
## Body processing: rendered
## Output: block
##
## Developed by: Jon-Luke West
## Date created: 01/12/2021
## Installed by: Jon-Luke West
## Highlights content as a question with a purple background
@jldubz
jldubz / android-canvas-draw.cs
Created March 26, 2019 15:48
Draw directly to a canvas in Android using a matrix of boolean values for black or white pixels
var canvas = new Canvas();
canvas.SetViewport(256, 256);
var bitMatrix = new bool[256][]; //bool[256][256]
//Generate the bitMatrix
//...
var blackPaint = new Paint {Color = Color.Black};
var whitePaint = new Paint {Color = Color.White};
for (var x = 0; x < 256; x++) {
for (var y = 0; y < 256; y++) {
canvas.DrawPoint(x,y, bitMatrix[x][y] ? blackPaint : whitePaint);
@jldubz
jldubz / HideNavOnly.java
Created August 9, 2016 15:25
Hides just the navigation bar and keeps the status bar.
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
//| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
@jldubz
jldubz / FullscreenWebChromeClient.java
Last active September 15, 2022 19:54
Web Chrome Client for Android. Wraps HTML pages for interaction with Native Android functions. Offers locked down wrapper so external URLs don't load.
/**
* Created by Jon-Luke.West on 4/6/2015.
*/
public class FullscreenWebChromeClient extends WebChromeClient {
private View mVideoProgressView;
private View mCustomView;
private WebView webView;
private FrameLayout customViewContainer;
private WebChromeClient.CustomViewCallback customViewCallback;
@jldubz
jldubz / XMLParse.java
Last active February 16, 2016 21:25
Example generic XML Parser that I used to externalize configurations for an application.
try {
File configFile = new File(Environment.getExternalStorageDirectory().getPath() + "/Android/data/" + getPackageName() + "/config.xml");
InputStream in = new FileInputStream(configFile);
String ns = null;
SharedPreferences.Editor editor = appPreferences.edit();
//editor.clear();
boolean prefsEmpty = false;
if (!appPreferences.contains("pref_key_optionx")) {
prefsEmpty = true;
@jldubz
jldubz / Update JIRA Issue Groovy Listener
Created July 14, 2015 22:33
When updating an Issue in Atlassian JIRA using a Groovy Script Listener, the fields will become out-of-sync with what the GUI says they equal. (Resolution set to Duplicate but the GUI still says it is Unresolved etc) By performing the updates within a new thread, the GUI updates as well. I have no idea why...
class SampleIssueListener extends AbstractIssueEventListener {
@Override
void workflowEvent(IssueEvent event) {
//Prepare and Validate update/transition
//Create a worker thread that waits for 2 seconds before performing the transition.
ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
Runnable runnableUpdate = new Runnable() {
@Override
public void run() {
@jldubz
jldubz / Android FullScreen Application
Last active August 29, 2015 14:24
Set your Android application to fullscreen. This does not hide/lock out the button bar or permanently remove the notification bar. It only hides them.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
@jldubz
jldubz / Android Byte Level File Transfer
Created July 14, 2015 18:41
Slip a new SQLite database file into the application database path for an Android application. This can also be used to copy and paste any file to virtually any other location on an Android device.
try {
File appDbFile = getActivity().getApplicationContext().getDatabasePath("myDatabase");
File sourceDbFile = new File("/sdcard/downloads/myDatabase.db");
//Make sure the directory and file exist
File dir = new File("/data/data/" +getActivity().getPackageName() + "/databases/");
if (!dir.exists()) {
boolean result = dir.mkdir();