Skip to content

Commit 653a3ec

Browse files
committed
Import Particlesdrawable library from https://github.com/Doctoror/ParticlesDrawable
1 parent d37bdc5 commit 653a3ec

24 files changed

+2023
-11
lines changed

app/libs/particlesview-1.0.9.aar

-14.8 KB
Binary file not shown.

app/src/main/res/layout/activity_server_custom_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_shadowsocks.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_socks.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_trojan.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_vless.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_vmess.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_server_wireguard.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_sub_edit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/activity_user_asset_url.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
android:layout_width="match_parent"
116116
android:layout_height="match_parent"
117117
android:alpha="0.2" />
118-
<com.doctoror.particlesdrawable.ParticlesView
118+
<com.neko.particlesdrawable.ParticlesView
119119
android:background="#00000000"
120120
android:layout_width="match_parent"
121121
android:layout_height="match_parent"

app/src/main/res/layout/changelog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
android:layout_width="match_parent"
4040
android:layout_height="match_parent"
4141
android:alpha="0.2" />
42-
<com.doctoror.particlesdrawable.ParticlesView
42+
<com.neko.particlesdrawable.ParticlesView
4343
android:background="#00000000"
4444
android:layout_width="match_parent"
4545
android:layout_height="match_parent"

app/src/main/res/layout/fragment_settings_theme.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
android:layout_width="match_parent"
4747
android:layout_height="match_parent"
4848
android:alpha="0.2" />
49-
<com.doctoror.particlesdrawable.ParticlesView
49+
<com.neko.particlesdrawable.ParticlesView
5050
android:background="#00000000"
5151
android:layout_width="match_parent"
5252
android:layout_height="match_parent"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2017 Yaroslav Mytkalyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.neko.particlesdrawable;
17+
18+
import android.graphics.Canvas;
19+
import android.graphics.ColorFilter;
20+
import android.graphics.Paint;
21+
22+
import androidx.annotation.ColorInt;
23+
import androidx.annotation.NonNull;
24+
import androidx.annotation.Nullable;
25+
26+
/**
27+
* {@link IParticlesView} that draws on {@link Canvas}
28+
*/
29+
final class CanvasParticlesView implements IParticlesView {
30+
31+
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
32+
33+
@Nullable
34+
private Canvas mCanvas;
35+
36+
void setCanvas(@Nullable final Canvas canvas) {
37+
mCanvas = canvas;
38+
}
39+
40+
@NonNull
41+
Paint getPaint() {
42+
return mPaint;
43+
}
44+
45+
void setColorFilter(final ColorFilter colorFilter) {
46+
mPaint.setColorFilter(colorFilter);
47+
}
48+
49+
@Override
50+
public void drawLine(final float startX, final float startY, final float stopX,
51+
final float stopY, final float strokeWidth, @ColorInt final int color) {
52+
if (mCanvas == null) {
53+
throw new IllegalStateException("Called in wrong state");
54+
}
55+
mPaint.setStrokeWidth(strokeWidth);
56+
mPaint.setColor(color);
57+
mCanvas.drawLine(startX, startY, stopX, stopY, mPaint);
58+
}
59+
60+
@Override
61+
public void fillCircle(final float cx, final float cy, final float radius,
62+
@ColorInt final int color) {
63+
if (mCanvas == null) {
64+
throw new IllegalStateException("Called in wrong state");
65+
}
66+
mPaint.setColor(color);
67+
mCanvas.drawCircle(cx, cy, radius, mPaint);
68+
}
69+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2017 Yaroslav Mytkalyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.neko.particlesdrawable;
17+
18+
import android.content.res.Resources;
19+
import android.graphics.Color;
20+
import android.util.TypedValue;
21+
22+
import androidx.annotation.ColorInt;
23+
24+
/**
25+
* Default values are here.
26+
*/
27+
final class Defaults {
28+
29+
private Defaults() {
30+
throw new UnsupportedOperationException();
31+
}
32+
33+
static final int DEFAULT_DOT_NUMBER = 60;
34+
static final float DEFAULT_MAX_DOT_RADIUS = TypedValue.applyDimension(
35+
TypedValue.COMPLEX_UNIT_DIP, 3f, Resources.getSystem().getDisplayMetrics());
36+
static final float DEFAULT_MIN_DOT_RADIUS = TypedValue.applyDimension(
37+
TypedValue.COMPLEX_UNIT_DIP, 1f, Resources.getSystem().getDisplayMetrics());
38+
static final float DEFAULT_LINE_THICKNESS = TypedValue.applyDimension(
39+
TypedValue.COMPLEX_UNIT_DIP, 1, Resources.getSystem().getDisplayMetrics());
40+
@ColorInt
41+
static final int DEFAULT_DOT_COLOR = Color.WHITE;
42+
@ColorInt
43+
static final int DEFAULT_LINE_COLOR = Color.WHITE;
44+
static final float DEFAULT_LINE_DISTANCE = TypedValue.applyDimension(
45+
TypedValue.COMPLEX_UNIT_DIP, 86, Resources.getSystem().getDisplayMetrics());
46+
static final float DEFAULT_STEP_MULTIPLIER = 1f;
47+
static final int DEFAULT_DELAY = 10;
48+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (C) 2017 Yaroslav Mytkalyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.neko.particlesdrawable;
17+
18+
import androidx.annotation.ColorInt;
19+
20+
/**
21+
* Particles View
22+
*/
23+
interface IParticlesView {
24+
25+
void drawLine(float startX, float startY, float stopX, float stopY, float strokeWidth,
26+
@ColorInt int color);
27+
28+
void fillCircle(float cx, float cy, float radius, @ColorInt int color);
29+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (C) 2017 Yaroslav Mytkalyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.neko.particlesdrawable;
17+
18+
/**
19+
* Represents a Particle by holding x and y coordinates, travel direction and step multiplier
20+
*/
21+
final class Particle {
22+
23+
/**
24+
* Direction cosine
25+
*/
26+
float dCos;
27+
28+
/**
29+
* Direction sine
30+
*/
31+
float dSin;
32+
33+
/**
34+
* Current X
35+
*/
36+
float x;
37+
38+
/**
39+
* Current Y
40+
*/
41+
float y;
42+
43+
/**
44+
* Step multiplier for this dot
45+
*/
46+
float stepMultiplier;
47+
48+
/**
49+
* Radius multiplier for this dot
50+
*/
51+
float radius;
52+
}

0 commit comments

Comments
 (0)