Skip to content

Commit 0cb1c7d

Browse files
author
osfunapps
committed
Initial commit
0 parents  commit 0cb1c7d

File tree

9 files changed

+189
-0
lines changed

9 files changed

+189
-0
lines changed

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 YOUR NAME
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# file GENERATED by distutils, do NOT edit
2+
setup.cfg
3+
setup.py
4+
os_android_files_injector/AppFilesInjector.py
5+
os_android_files_injector/AppFilesInjectorBp.py
6+
os_android_files_injector/__init__.py

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Introduction
2+
------------
3+
4+
Thi script will inject:
5+
* strings.xml
6+
* google-services.json
7+
* logo.png
8+
* assets\
9+
and more files into an android app programmatically (dynamically).
10+
11+
## Installation
12+
Install via pip:
13+
14+
pip install os-android-files-injector
15+
16+
## Usage
17+
From Python:
18+
19+
import os_android_files_injector.AppFilesInjector as fi
20+
21+
fi.run('/path/to/android/project',
22+
'/path/to/strings.xml',
23+
'/path/to/logo.png',
24+
'/path/to//google-services.json',
25+
['/path/to/asset_file_1.png', '/path/to/asset_file_2.mov', '/path/to/asset_file_3.txt'],
26+
clear_old_assets=False)
27+
28+
Or from the command line:
29+
30+
python3 -c 'import os_android_files_injector.AppFilesInjector as fi;
31+
fi.run("/path/to/android/app",
32+
"/path/to/strings.xml",
33+
"/path/to/logo.png",
34+
"/path/to//google-services.json",
35+
["/path/to/asset_file_1.png", "/path/to/asset_file_2.mov", "/path/to/asset_file_3.txt"],
36+
clear_old_assets=False)'
37+
38+
39+
## Licence
40+
MIT

os-android-files-injector.iml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="PYTHON_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$" />
6+
<orderEntry type="inheritedJdk" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import ostools.LoggerHandler as lh
2+
import os_android_files_injector.AppFilesInjectorBp as bp
3+
4+
5+
##################################################################################
6+
#
7+
# this module meant to inject android app files into a designated android project.
8+
#
9+
##################################################################################
10+
11+
def run(project_path, strings_file=None, logo_file=None, google_services_file=None, asset_paths_list=None, clear_old_assets=False):
12+
"""
13+
Will inject files into an android project.
14+
15+
Args:
16+
project_path: your android's app path
17+
strings_file: the path to the new strings.xml file
18+
logo_file: the path to the new logo file
19+
google_services_file: the path to the new Firebase json file
20+
asset_paths_list: an array of all of the assets you want to inject to the app
21+
clear_old_assets: toggle to true to remove old assets from your project
22+
"""
23+
24+
logger = lh.Logger(__file__)
25+
26+
# copy all of the stuff
27+
if strings_file is not None:
28+
bp.inject_strings(project_path, strings_file)
29+
logger.info('strings.xml injected')
30+
31+
if google_services_file is not None:
32+
bp.inject_google_services(project_path, google_services_file)
33+
logger.info('google_services.json injected')
34+
35+
if logo_file is not None:
36+
bp.inject_logo(project_path, logo_file)
37+
logger.info('logo injected')
38+
39+
if clear_old_assets is True:
40+
bp.clear_old_assets(project_path)
41+
logger.info('old assets cleared')
42+
43+
if asset_paths_list is not None:
44+
bp.inject_assets(project_path, asset_paths_list)
45+
logger.info('all ' + str(len(asset_paths_list)) + ' assets injected')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import ostools.FileHandler as fh
2+
3+
4+
# this is just a boiler plate script for the files injector.
5+
6+
# inject the strings.xml into the project_path + /app/src/main/res/values/strings.xml
7+
def inject_strings(project_path, strings_file):
8+
project_strings_file = project_path + "/app/src/main/res/values"
9+
fh.copy_file(strings_file, project_strings_file)
10+
11+
12+
# inject the google-services.json into project_path + /app/google-services.json
13+
def inject_google_services(project_path, google_services_file):
14+
project_google_services_file = project_path + "/app/"
15+
fh.copy_file(google_services_file, project_google_services_file)
16+
17+
18+
# inject the logo into project_path + /app/src/main/res/drawable/logo.png
19+
def inject_logo(project_path, logo_file):
20+
project_logo_file = project_path + "/app/src/main/res/drawable"
21+
fh.copy_file(logo_file, project_logo_file)
22+
23+
24+
def clear_old_assets(project_path):
25+
assets_dir = project_path + '/app/src/main/assets'
26+
if fh.is_dir_exists(assets_dir):
27+
fh.clear_dir_content(assets_dir)
28+
29+
30+
# inject the assets into project_path + /app/src/main/assets
31+
def inject_assets(project_path, asset_paths_list):
32+
project_assets_dir = project_path + "/app/src/main/assets"
33+
34+
if not fh.is_dir_exists(project_assets_dir):
35+
fh.create_dir(project_assets_dir)
36+
37+
fh.copy_list_of_files(asset_paths_list, project_assets_dir)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import os_android_files_injector.AppFilesInjector

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Inside of setup.cfg
2+
# [metadata]
3+
# description-file = README.md

setup.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from distutils.core import setup
2+
3+
setup(
4+
name='os-android-files-injector',
5+
packages=['os_android_files_injector'],
6+
version='1.0',
7+
license='MIT',
8+
description='Will inject strings.xml, google-services.json, logo.png, assets and more files into an android app programmatically (dynamically)',
9+
author='Oz Shabat',
10+
author_email='osfunapps@gmail.com',
11+
url='https://github.com/osfunapps',
12+
keywords=['python', 'osfunapps', 'injector', 'android', 'files', 'strings', 'logo', 'assets'],
13+
install_requires=['ostools'],
14+
classifiers=[
15+
'Development Status :: 5 - Production/Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
16+
17+
'Intended Audience :: Developers', # Define that your audience are developers
18+
'Topic :: Software Development :: Build Tools',
19+
20+
'License :: OSI Approved :: MIT License', # Again, pick a license
21+
22+
'Programming Language :: Python :: 3', # Specify which pyhton versions that you want to support
23+
'Programming Language :: Python :: 3.4',
24+
'Programming Language :: Python :: 3.5',
25+
'Programming Language :: Python :: 3.6',
26+
],
27+
)

0 commit comments

Comments
 (0)