Skip to content

Instantly share code, notes, and snippets.

View johnjeremih's full-sized avatar

John J johnjeremih

View GitHub Profile
@johnjeremih
johnjeremih / generateModuleGraphs.sh
Created July 8, 2024 22:00
Module map generator
#!/bin/bash
#
# Script to generate dependency graphs for each of the modules. The --exclude-module parameter can
# be used to exclude modules which are not part of the root dependency graph (and which, if included
# would cause the script to fail.
#
# Usage: generateModuleGraphs.sh --exclude-module :benchmarks --exclude-module :lint --exclude-module :ui-test-hilt-manifest
# Check if the dot command is available
if ! command -v dot &> /dev/null
@johnjeremih
johnjeremih / GoogleFormToSheetsScript.js
Created August 28, 2023 20:32
this receive the data from a google form then it get the string from the checkbox and split it by "," then it put them back in a google sheet in a different column
function onFormSubmit(event) {
record_array = []
var form = FormApp.openById('1kpoqfzJ4QGlYU5iDkeeTNheCe3AfeTZ4Eu-AmnbIQv4'); // Form ID
var formResponses = form.getResponses();
var formCount = formResponses.length;
var formResponse = formResponses[formCount - 1];
var itemResponses = formResponse.getItemResponses();
class ConnectionLiveData(context: Context) : LiveData<Boolean>() {
private lateinit var networkCallback: ConnectivityManager.NetworkCallback
private val cm = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
private val validNetworks: MutableSet<Network> = HashSet()
private fun checkValidNetworks() {
postValue(validNetworks.size > 0)
}
@johnjeremih
johnjeremih / LoginActivity.java
Created March 25, 2022 13:49
this is the login activity from salesforce
public class LoginActivity extends AccountAuthenticatorActivity
implements OAuthWebviewHelperEvents {
public static final int PICK_SERVER_REQUEST_CODE = 10;
private static final String TAG = "LoginActivity";
private boolean wasBackgrounded;
private OAuthWebviewHelper webviewHelper;
private ChangeServerReceiver changeServerReceiver;
private boolean receiverRegistered;
@johnjeremih
johnjeremih / DaggerAuthenticatorActivity.kt
Last active March 24, 2022 17:40
Salesforce custom Login Activity
open class DaggerAuthenticatorActivity : DaggerAppCompatActivity() {
private var mAccountAuthenticatorResponse: AccountAuthenticatorResponse? = null
private var mResultBundle: Bundle? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mAccountAuthenticatorResponse =
intent.getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)
if (mAccountAuthenticatorResponse != null) {
mAccountAuthenticatorResponse!!.onRequestContinued()
}
@johnjeremih
johnjeremih / AddressFragment.kt
Last active February 16, 2022 18:43
This is how the Custom result contract AddressAutoComplete.kt is called.
class AddressFragment : Fragment() {
private lateinit var binding: AddressFragmentBinding
private var launcher = registerForActivityResult(AddressAutoComplete()) { place ->
if (place != null) {
val geocoder = Geocoder(activity)
var address : Address? = null
try {
@johnjeremih
johnjeremih / AddressAutoComplete.kt
Created February 16, 2022 17:56
This is a custom Result Contract to retrieve the address from an overlay Google Map Address Auto Completer
class AddressAutoComplete : ActivityResultContract<Unit, Place?>() {
override fun createIntent(context: Context, input: Unit?): Intent {
val fields = listOf(Place.Field.ADDRESS, Place.Field.NAME)
return Autocomplete.IntentBuilder(
AutocompleteActivityMode.OVERLAY, fields)
.build(context)
}
class OAuthActivity : DaggerAuthenticatorActivity(), OAuthWebviewHelperEvents, EventsObserver {
private val timeoutHandler = Handler(Looper.myLooper()!!)
private var webViewHelper: OAuthWebviewHelper? = null
private lateinit var binding: ActivityOauthBinding
private var wasBackgrounded = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
abstract class SalesforceActivityCompat : AppCompatActivity(), SalesforceActivityInterface {
private lateinit var delegate: SalesforceActivityDelegate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
delegate = SalesforceActivityDelegate(this)
delegate.onCreate()
}
@johnjeremih
johnjeremih / Helper.kt
Last active November 28, 2019 16:44
Handeling Roation
/*
* handleSamplingAndRotationBitmap We
*
* @param context: we use the parameter context to get content resolver
* @selectedImage: this is an Uri that we later convert into a bitmap
*/
@Throws(IOException::class)
fun handleSamplingAndRotationBitmap(
context: Context?,