Skip to content

Instantly share code, notes, and snippets.

View ananthrajsingh's full-sized avatar
🏗️

Ananth Raj Singh ananthrajsingh

🏗️
View GitHub Profile
@ananthrajsingh
ananthrajsingh / android-version-and-tag-automation.sh
Created January 31, 2022 08:36 — forked from drilonrecica/android-version-and-tag-automation.sh
Bash script for automating versioning (versionCode & versionName) and setting git Tag in an android project
# Proccess:
# 1. Go into app directory
# 2. Get current versionCode and print it
# 3. Increment versionCode by one and print it
# 4. Get current versionName and print it
# 5. Ask user for new versionName and set it then print it
# 6. Stage changes to build.gradle
# 7. Go back one directory to project root
# 8. Commit version update with message Bumped up version
# 9. Tag with versionName
import requests
from bs4 import BeautifulSoup
import smtplib, ssl
URL = "https://www.zomato.com/bareilly/momo-hut-subhash-nagar-colony/order"
headers = {
'authority': 'www.zomato.com',
'sec-ch-ua': '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"',
'sec-ch-ua-mobile': '?0',
private fun createCameraPreviewSessionFront() {
try {
val texture = textureViewFront.surfaceTexture
texture.setDefaultBufferSize(previewSizeFront.width, previewSizeFront.height)
val surface = Surface(texture)
previewRequestBuilderFront = cameraDeviceFront!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
previewRequestBuilderFront.addTarget(surface)
// Here, we create a CameraCaptureSession for camera preview.
private val stateCallbackFront = object : CameraDevice.StateCallback() {
override fun onOpened(cameraDevice: CameraDevice) {
this@CameraFragment.cameraDeviceFront = cameraDevie
createCameraPreviewSessionFront()
}
override fun onDisconnected(cameraDevice: CameraDevice) {
cameraDevice.close()
this@CameraFragment.cameraDeviceFront = null
}
override fun onError(cameraDevice: CameraDevice, error: Int) {
private fun openCameraFront(width: Int, height: Int) {
setUpCameraOutputsFront(width, height)
configureTransformFront(width, height)
val manager = activity?.getSystemService(Context.CAMERA_SERVICE) as CameraManager
try {
manager.openCamera(cameraIdFront, stateCallbackFront, backgroundHandler)
} catch (e: CameraAccessException) {
Log.e(TAG, e.toString())
}
}
/**
* Sets up member variables related to front camera.
* @param width The width of available size for camera preview
* @param height The height of available size for camera preview
*/
private fun setUpCameraOutputsFront(width: Int, height: Int) {
val manager = activity?.getSystemService(Context.CAMERA_SERVICE) as CameraManager
try {
for (cameraId in manager.cameraIdList) {
val characteristics = manager.getCameraCharacteristics(cameraId)
private val surfaceTextureListenerFront = object : TextureView.SurfaceTextureListener {
override fun onSurfaceTextureAvailable(texture: SurfaceTexture, width: Int, height: Int) {
openCameraFront(width, height)
}
override fun onSurfaceTextureSizeChanged(texture: SurfaceTexture, width: Int, height: Int) {
configureTransformFront(width, height)
}
override fun onSurfaceTextureDestroyed(texture: SurfaceTexture) = true
override fun onSurfaceTextureUpdated(texture: SurfaceTexture) = Unit
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--This is a custom TextureView, generic TextureView can be used as well-->
<com.ananth.frontrearcamera.view.AutoFitTextureView
android:layout_weight="1"
android:id="@+id/texture1"
/**
* This function talks to server and helps logging a returning user in. Here we will not be
* doing any checks on username and password strings, as they have already been checked
* and tailored for this function.
* @param username the username entered by user
* @param password password as entered by user
*/
private void login(String username ,String password) {
/* Get client with the help of helper function of your own */