Skip to content

lanzhihong6/Fuck-Hard-Code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Document for Chinese

Chinese

Build Status

Android hardcoding extraction tool

Extraction string and dimens from layout,Merge into strings.xml and dimens.xml

Download

Usage

Example

Fuck-Hard-Code -input="{layout path}" -output="{layout output path}"

after that you will see strings.xml and dimens.xml in {layout output path}/out and all xml file in {layout output path}

Example

Create New Android Application and modify main layout

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:orientation="horizontal">
	<TextView
		android:id="@+id/content"
		android:layout_width="wrap_content"
		android:layout_height="40dp"
		android:text="Hello Word"
		android:textSize="20sp" />
</LinearLayout>

Now We Run This Tool

> Fuck-Hard-Code -input="{project path/app/src/main/res/layout}" -output="{out path/layout}"

Ok,This Over,we Can See the file in {out path/layout} with

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:orientation="horizontal"
	android:gravity="top">
	<TextView
		android:id="@+id/content"
		android:layout_width="wrap_content"
		android:layout_height="@dimen/dp_0040_0"
		android:text="@string/strings_0"
		android:textSize="@dimen/sp_0020_0" />
</LinearLayout>

And {out path/layout/out} has two file ,strings.xml and dimens.xml

<!--strings.xml-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
	<string	name="strings_0">Hello Word</string>
</resources>
<!--dimens.xml-->
<?xml version="1.0" encoding="utf-8"?>

<resources>
	<dimen	name="dp_0040_0">40.0dp</dimen>
	<dimen	name="sp_0020_0">20.0sp</dimen>
</resources>

Before Copy New file to Replace original File,Please make sure everything is OK!!!!

About

This is a Tool to extract hard code from android layout

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%