Skip to content

Instantly share code, notes, and snippets.

View MathiasSeguy-Android2EE's full-sized avatar
😉
In translation [open sourcing my works]

MathiasSeguy-Android2EE MathiasSeguy-Android2EE

😉
In translation [open sourcing my works]
View GitHub Profile
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / androidx_migration.py
Last active July 1, 2020 08:57
This python script will migrate your package to the AndroidX new package. Dec2018. [https://medium.com/@android2ee/simple-androidx-migration-with-python-4e354ba6c945]
# -*- coding: utf-8 -*-
# python
# script for multiple find/replace old android package with the ones of AndroidX new packaging.
import os,sys
from os import walk
inputDir = "../app/src/"
fileExtension = [".xml",".java",".kt"]
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / projectsRulesChecker.py
Created August 17, 2019 12:28
Does the Android project has an old Eclipse's files structure
global SPLIT_CHARACTER
if platform.system() == "Windows":
SPLIT_CHARACTER = '\\'
else:
SPLIT_CHARACTER = '/'
#Detect if your project is in an Eclipse structure
def isEclipseLegacy(directory):
hasRes=path.isdir(directory+SPLIT_CHARACTER+'res')
hasSrc=path.isdir(directory+SPLIT_CHARACTER+'src')
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / dependenciesBlock.txt
Created August 17, 2019 13:46
5.2 Dependencies management$dependenciesBlock.txt
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${androidxAppcompat_appcompat_Version}"
implementation "androidx.recyclerview:recyclerview:${androidxRecyclerview_recyclerview_Version}"
implementation "androidx.cardview:cardview:${androidxCardview_cardview_Version}"
implementation "com.google.android.material:material:${comGoogleAndroidMaterial_material_Version}"
implementation "androidx.room:room-runtime:${androidxRoom_roomRuntime_Version}"
implementation "androidx.constraintlayout:constraintlayout:${androidxConstraintlayout_constraintlayout_Version}"
annotationProcessor "androidx.room:room-compiler:${androidxRoom_roomCompiler_Version}"
kapt "androidx.room:room-compiler:${androidxRoom_roomCompiler_Version}"
implementation "androidx.lifecycle:lifecycle-extensions:${androidxLifecycle_lifecycleExtensions_Version}"
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / var_def_lib.gradle
Created August 19, 2019 08:31
Extracted list of version of libraries of the project (Google libraries excluded)
//This is the list of the version of library you use
project.ext {
orgJetbrainsKotlinx_kotlinxCoroutinesCore_Version='1.3.0-M2'
orgJetbrainsKotlinx_kotlinxCoroutinesAndroid_Version='1.3.0-M2'
netDanlew_androidJoda_Version= '2.9.2'
orgMockito_mockitoAndroid_Version= '2.12.0'//1.10.19
}
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / var_definition.gradle
Created August 19, 2019 08:35
Definition list of well known external libraries versions (Google excluded)
project.ext{
compileSdk = 28
// min SDK is set to 18
minSdk = 18
targetSdk = 28
//You have the definiton
//Please use the support library and use
useSupportLibVectorDrawable = true
//build var
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / google_lib_version.gradle
Created August 19, 2019 08:38
Extract of the file listing the version of the Google libraries. Automatically updated by python script.
//Last version of Google Lib are listed below, to update run from_maven_to_version_uptodate.py and then your migration script
project.ext{
comAndroidSupportConstraint_constraintLayoutSolver_Version = "1.1.3"
comAndroidSupportConstraint_constraintLayout_Version = "1.1.3"
comAndroidDatabinding_library_Version = "3.5.0-rc01"
comAndroidDatabinding_adapters_Version = "3.5.0-rc01"
comAndroidDatabinding_compiler_Version = "3.1.4"
comAndroidDatabinding_compilerCommon_Version = "3.1.4"
comAndroidDatabinding_baseLibrary_Version = "3.5.0-rc01"
comAndroidDatabinding_viewbindingSupport_Version = "3.6.0-alpha02"
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / build.gradle
Last active August 19, 2019 08:52
The final dependencies block of your build.gradle after migration
apply from: 'gradle/var_definition.gradle'
apply from: 'gradle/var_def_lib.gradle'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${androidxAppcompat_appcompat_Version}"
implementation "androidx.recyclerview:recyclerview:${androidxRecyclerview_recyclerview_Version}"
implementation "androidx.cardview:cardview:${androidxCardview_cardview_Version}"
implementation "com.google.android.material:material:${comGoogleAndroidMaterial_material_Version}"
implementation "androidx.room:room-runtime:${androidxRoom_roomRuntime_Version}"
implementation "androidx.constraintlayout:constraintlayout:${androidxConstraintlayout_constraintlayout_Version}"
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / git_init.py
Created August 19, 2019 13:10
Github: Actor creation using python
# First create a Github instance:
g = Github(githubAccessToken)
actor = Actor(githubActorName, githubActorEMail)
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / git_init.py
Created August 19, 2019 13:12
Github: Find if a repo exists using python
def isGitHubRepoExisting(name):
# Then play with your Github objects:
for repo in g.get_user().get_repos():
if(repo.name in REPO_NAME):
return True
return False
@MathiasSeguy-Android2EE
MathiasSeguy-Android2EE / git_init.py
Created August 19, 2019 13:19
Github: Pushing with fallback when id_rsa failed (asking for credential again) in python
#Import dependencies
from subprocess import call
from os import path
from ownStyle import GREEN,BLUE,BOLD,GREEN,RED,RESET,CYAN
#Push the new or update files
# call('git push origin master', shell = True)
#The command line will prompt you
def runGitPushInCommandLine(repository):
# print(repository)
absRepo=path.abspath(repository)