Skip to content

Commit 91df9db

Browse files
author
sushanqiang
committed
android 手写签名
0 parents  commit 91df9db

File tree

110 files changed

+9486
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+9486
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/libraries
5+
/.idea/modules.xml
6+
/.idea/workspace.xml
7+
.DS_Store
8+
/build
9+
/captures
10+
.externalNativeBuild

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 带笔锋效果的手写签字控件
2+
3+
Android平台原生手写签字控件,功能强大的开源项目。
4+
5+
## 预览
6+
7+
<img src='preview/blank.png' width='250' height='450'/> <img src='preview/grid.png' width='250' height='450'/>
8+
9+
## 功能
10+
11+
- 空白画板手写,田字格逐字手写
12+
- 实现笔锋效果
13+
- 支持橡皮擦,撤回/恢复,清空画布功能
14+
- 画笔颜色大小设置
15+
- 支持传入初始图片
16+
- 画布大小设置,文字区域裁剪
17+
- 主题颜色设置
18+
- 支持传入初始显示图片
19+
- 适配手机横竖屏布局
20+

alipay.jpg

97.5 KB
Loading

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
buildToolsVersion "28.0.3"
6+
defaultConfig {
7+
applicationId "android.king.demo"
8+
minSdkVersion 16
9+
targetSdkVersion 28
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
compileOptions {
21+
sourceCompatibility JavaVersion.VERSION_1_8
22+
targetCompatibility JavaVersion.VERSION_1_8
23+
}
24+
}
25+
26+
dependencies {
27+
implementation fileTree(dir: 'libs', include: ['*.jar'])
28+
implementation 'com.android.support:appcompat-v7:28.0.0'
29+
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
30+
testImplementation 'junit:junit:4.12'
31+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
32+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33+
implementation project(':signlibrary')
34+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package android.king.signature.handwritesign;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("android.king.signaturesign", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="android.king.demo">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name="android.king.demo.MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package android.king.demo;
2+
3+
import android.Manifest;
4+
import android.app.Activity;
5+
import android.content.Intent;
6+
import android.content.pm.PackageManager;
7+
import android.graphics.Bitmap;
8+
import android.graphics.BitmapFactory;
9+
import android.graphics.Color;
10+
import android.king.signature.GridPaintActivity;
11+
import android.king.signature.PaintActivity;
12+
import android.king.signature.config.PenConfig;
13+
import android.support.v4.app.ActivityCompat;
14+
import android.support.v4.content.PermissionChecker;
15+
import android.support.v7.app.AppCompatActivity;
16+
import android.os.Bundle;
17+
import android.util.Log;
18+
import android.view.View;
19+
import android.widget.ImageView;
20+
import android.widget.TextView;
21+
22+
/**
23+
* 使用示例
24+
*/
25+
public class MainActivity extends AppCompatActivity {
26+
27+
private TextView tvResult;
28+
private ImageView ivShow;
29+
30+
private boolean isPermissionOk = false;
31+
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_main);
36+
if (PermissionChecker.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
37+
isPermissionOk = false;
38+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
39+
100);
40+
} else {
41+
isPermissionOk = true;
42+
}
43+
initView();
44+
45+
//主题颜色配置
46+
PenConfig.THEME_COLOR = Color.parseColor("#0c53ab");
47+
}
48+
49+
private void initView() {
50+
ivShow = findViewById(R.id.iv_show);
51+
tvResult = findViewById(R.id.tv_result);
52+
}
53+
54+
/**
55+
* 空白签批
56+
* @param view
57+
*/
58+
public void openBlank(View view) {
59+
if (!isPermissionOk) {
60+
return;
61+
}
62+
Intent intent = new Intent(this, PaintActivity.class);
63+
64+
// intent.putExtra("background", Color.WHITE);//画布背景色,默认透明,也是最终生成图片的背景色
65+
66+
// intent.putExtra("width", 800); //画布宽度,最大值3000,默认占满布局
67+
// intent.putExtra("height", 800);//画布高度,最大值3000,默认占满布局
68+
intent.putExtra("crop", false); //最终的图片是否只截取文字区域
69+
intent.putExtra("format", PenConfig.FORMAT_PNG); //图片格式
70+
// intent.putExtra("image", imagePath); //初始图片
71+
72+
startActivityForResult(intent, 100);
73+
}
74+
75+
/**
76+
* 田字格签批
77+
* @param view
78+
*/
79+
public void openGrid(View view) {
80+
if (!isPermissionOk) {
81+
return;
82+
}
83+
Intent intent = new Intent(this, GridPaintActivity.class);
84+
intent.putExtra("background", Color.WHITE);
85+
intent.putExtra("crop", true);
86+
intent.putExtra("fontSize", 50); //手写字体大小
87+
intent.putExtra("format", PenConfig.FORMAT_PNG);
88+
intent.putExtra("lineLength", 10); //每行显示字数(超出屏幕支持横向滚动)
89+
startActivityForResult(intent, 100);
90+
}
91+
92+
@Override
93+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
94+
95+
if (requestCode == 100 && resultCode == Activity.RESULT_OK) {
96+
String savePath = data.getStringExtra(PenConfig.SAVE_PATH);
97+
Log.i("king", savePath);
98+
tvResult.setText(savePath);
99+
Bitmap bitmap = BitmapFactory.decodeFile(savePath);
100+
if (bitmap != null) {
101+
ivShow.setImageBitmap(bitmap);
102+
}
103+
}
104+
}
105+
106+
107+
@Override
108+
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
109+
if (requestCode == 100) {
110+
if (permissions[0].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)
111+
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
112+
//用户同意使用write
113+
isPermissionOk = true;
114+
} else {
115+
//用户不同意,自行处理即可
116+
finish();
117+
}
118+
}
119+
}
120+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1" />
34+
</vector>

0 commit comments

Comments
 (0)