自定义编辑水印涉及到控件的自定义,控件位置的移动,图片大小和文字大小缩放,文字的颜色改变,还有水印的透明度。
水印元素包括了
图片水印
文字水印
涉及到的控件
- 模拟屏幕的一个容器控件,用于放置水印元素的
- 图片水印元素控件
- 文字水印元素控件
- 文字选择颜色值控件
水印需要保存的信息:数据库信息
水印透明度alpha
水印宽度widthRatio比例(涉及到横竖屏)
水印高度heightRatio比例(涉及到横竖屏)
水印位置centerX比例(涉及到横竖屏)
水印位置centerY比例(涉及到横竖屏)
文字水印颜色color
文字水印文案信息
文字缩放大小值textSize
图片水印文件路径
水印元素ID(数据库ID自动生成)
/**
* @author jaysen.lin@foxmail.com
* @since 2019/8/8
*/
public class MoveGestureDetector {
private float x = 0, y = 0;
public MoveGestureDetector() {
}
public boolean detectMoveAction(View view, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
return true;
case MotionEvent.ACTION_MOVE:
float x1 = event.getRawX();
float y1 = event.getRawY();
int dx = (int) (x1 - x);
int dy = (int) (y1 - y);
int l = view.getLeft() + dx;
int t = view.getTop() + dy;
int r = view.getRight() + dx;
int b = view.getBottom() + dy;
if (l < 0) {//超出父类控件左边际,重置为0
l = 0;
r = l + view.getWidth();
}
if (t < 0) {//超出父类控件上边际,重置为0
t = 0;
b = t + view.getHeight();
}
ViewParent parent = view.getParent();
ViewGroup p = (ViewGroup) parent;
if (r > p.getWidth()) {//超出父类控件右边际,重置
r = p.getWidth();
l = r - view.getWidth();
}
if (b > p.getHeight()) {//超出父类控件下边际,重置
b = p.getHeight();
t = b - view.getHeight();
}
float halfW = view.getMeasuredWidth() / 2.0f;
float halfH = view.getMeasuredHeight() / 2.0f;
float centerXRatio = (l + halfW) / p.getMeasuredWidth();
float centerYRatio = (t + halfH) / p.getMeasuredHeight();
//todo 把centerXRatio,centerYRatio的横竖屏信息保存起来
//还有就是刷新控件重新计算大小和布局
view.requestLayout();
x = x1;
y = y1;
return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
return true;
}
return false;
}
VRecorder
|--cnpay //支付模块
| |--src
| |--libs
|
|--staticanalysislib//数据打点探针模块
| |--src
| |--libs
|
|---themelibrary//主题配色、字符串资源模块
| |-src
| |-libs
|
|--App//主项目模块
|-src
|-libs
请求服务器接口下订单—>调用本地SDK支付—>SDK返回支付结果—>服务器验证查询订单支付结果
请求服务器接口下订单—>调用本地SDK支付—>SDK返回支付结果—>服务器验证查询订单支付结果
请求服务器接口获得授权信息—>调用支付宝SDK对授权信息进行授权—>获得openID再请求服务器接口获取所有订单购买情况
微信SDK发起授权获取code—>通过请求微信官网的链接接口进行验证授权返回openID—>请求服务接口获取所有订单购买情况
SecurityException
。 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
打开前台服务,需要有通知栏体现:
Intent intent = new Intent(this, ForegroundService.class);
ContextCompat.startForegroundService(this, intent);
要请求让服务运行于前台,在ForegroundService.class
里需要调用如下方法启动通知栏:
startForeground(NOTIFICATION_ID, notification);
对非Android SDK API的调用做了限制,通常会出现类似NoSuchClassException
或NoSuchFieldException
异常。
非SDK API包括Android未公开的底层内部实现细节的API反射调用。还有NDK里未公开的方法调用等。
Android 4.4(API 级别 19)引入了存储访问框架 (SAF)。SAF 让用户能够在其所有首选文档存储提供程序中方便地浏览并打开文档、图像以及其他文件。 用户可以通过易用的标准 UI,以统一方式在所有应用和提供程序中浏览文件和访问最近使用的文件。
自API 19引入SAF后,应用程序无法直接通过java 的File API进行写操作了。需要用到Android 的DocumentFile
API 进行间接处理文件。
DocumentFile.fromTreeUri(context,uri)
Jcenter and MavenCenter are moden time standar maven center. they maintained by Bintray
and sonatype
respectively.
As the artical , we just talk abut Bintray’s JCenter. Cause Android Studio now support Jcenter as default maven center.
First of all , you need create an accunt of Binray at Bintray.com and generate an API Key at
Edit
menu of account profile
buildscript{
dependencies{
//bintray: jcenter publish build plugin
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
}
}
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'// maven publish method to create groups of artifacts
The bintray plugin supports three methods to create groups of artifacts: Configurations, Publications and Copying specific files using filesSpec. For more read, reference gradle-bintray-plugin.
sources.Jar
and javadoc.Jar
artifactscreate task as below for android gradle:
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
在firebse 上注册登陆账号,之后注册应用,填写包名等信息,下载配置文件。
google-services.json
适用于 Gradle 的说明 | UnityC++Gradle 的 Google 服务插件会加载您刚刚下载的 google-services.json 文件。请修改您的 build.gradle 文件以使用该插件。 |
项目级 build.gradle(<项目>/build.gradle
):
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.0.0' }
}
应用级 build.gradle(<项目>/<应用模块>/build.gradle
):
dependencies {
// Add this line
compile 'com.google.firebase:firebase-core:16.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
默认情况下包含 Analytics
最后,按 IDE 中显示的栏中的“立即同步”: