This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns true if the given StorageVolume is an SD card. | |
// This reads the proc/mounts file, which contains mount info for all drives on device. | |
// A USB drive will show on a line like: /dev/block/vold/public:8,1 on /mnt/media_rw/68C9-D020 type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) | |
// An SD card will show on a line like: /dev/block/vold/public:179,65 on /mnt/media_rw/084E-056D type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) | |
// The /dev/block/vold/public:8 indicates a USB drive at 68C9-D020, while /dev/block/vold/public:179 indicates an SD card at 084E-056D. | |
@RequiresApi(ANDROID_7_SDK_24) | |
fun isStorageVolumeAnSdCard(storageVolume: StorageVolume): Boolean { | |
if (storageVolume.uuid == null) return false | |
var bufferedReader: BufferedReader? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns true if this UsbDevice has the necessary interface and endpoints to qualify as a UsbMassStorageDevice. | |
fun UsbDevice.isUsbMassStorageDevice(): Boolean { | |
(0 until this.interfaceCount).map { getInterface(it) } | |
.filter { it.interfaceClass == UsbConstants.USB_CLASS_MASS_STORAGE } | |
.map { usbInterface -> | |
logMessage("Tools", "Found usb interface: $usbInterface") | |
// Every mass storage device has exactly two endpoints | |
// One IN and one OUT endpoint | |
val endpointCount = usbInterface.endpointCount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Detects if user granted permissions to USB drive root, rather than accidentally granting it to some other folder. | |
private fun driveHasRootPermission(uri: Uri): Boolean { | |
val documentFileFromUri = DocumentFile.fromTreeUri(appContext, uri) | |
val nameFromUri = documentFileFromUri?.name ?: "" | |
if (Build.VERSION.SDK_INT >= ANDROID_11_SDK_30) { | |
val recentExternalVolumeNames = getRecentExternalVolumeNames(appContext).map { it.lowercase() } | |
// Checks whether the user-selected Uri points to a writable location and its name matches that of a recently used external volume. | |
if (documentFileFromUri?.canWrite() == true && recentExternalVolumeNames.contains(nameFromUri.lowercase())) return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void unzip(InputStream uriInputStream, String unzipDirectory) throws Exception { | |
//create target location folder if not exist | |
createDirIfNotExist(unzipDirectory); | |
ZipInputStream zipInputStream = new ZipInputStream(uriInputStream); | |
ZipEntry ze; | |
while ((ze = zipInputStream.getNextEntry()) != null) { | |
//create dir if required while unzipping | |
if (ze.isDirectory()) { | |
createDirIfNotExist(ze.getName()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gavinsappcreations.upcominggames.ui.list | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.widget.TextView | |
import androidx.paging.PagedListAdapter | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.RecyclerView | |
import com.gavinsappcreations.upcominggames.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Filter getFilter() { | |
Filter filter = new Filter() { | |
@Override | |
protected FilterResults performFiltering(CharSequence constraint) { | |
FilterResults filterResults = new Filter.FilterResults(); | |
if (constraint != null && constraint.length() > 1) { | |
String inputText = editText.getText().toString().toLowerCase().trim(); | |
List<Address> tempAddressList = new ArrayList<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.custom_classes; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.widget.LinearLayout; | |
import androidx.annotation.Nullable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.custom_classes; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.widget.LinearLayout; | |
import androidx.annotation.Nullable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.custom_classes; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.widget.LinearLayout; | |
import androidx.annotation.Nullable; |