Skip to content

Commit d82c79b

Browse files
committed
docs: add full NekoBox UI as a non-building reference
- Copy NekoBox's complete UI into reference/nekobox-ui/: all res (49 layouts, drawables, menus, values, fonts, raw) plus the ui/, widget/ and com.neko source packages. - Lives outside app/src, so it is never compiled or packaged and does not affect the app or the build; a README explains why screens are ported one at a time rather than pasted wholesale.
1 parent 06d65a1 commit d82c79b

361 files changed

Lines changed: 26034 additions & 0 deletions

File tree

Some content is hidden

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

reference/nekobox-ui/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# NekoBox UI reference
2+
3+
A verbatim copy of the **NekoBox for Android** UI, kept here purely as a
4+
reference for porting screens into MikuBox. **Nothing in this folder is part of
5+
the Gradle build** — it lives outside `app/src`, so it is never compiled,
6+
linked, or packaged. It will not affect the app or the build.
7+
8+
## Contents
9+
10+
- `res/` — the complete NekoBox `app/src/main/res` (all 49 layouts, ~141
11+
drawables, menus, `values` (themes/attrs/styles/colors/strings/dimens),
12+
fonts, raw animations, etc.).
13+
- `java/ui/` — activities, fragments and bottom sheets
14+
(`io.nekohasekai.sagernet.ui`).
15+
- `java/widget/` — custom views used by the layouts
16+
(`io.nekohasekai.sagernet.widget`).
17+
- `java/neko/` — MikuRay/`com.neko` UI helpers (particles, shape image views,
18+
marquee text, blur, etc.).
19+
20+
## Why it can't just be dropped into the app
21+
22+
NekoBox's UI is welded to its **sing-box** stack:
23+
24+
- ~97 of its source files use the sing-box data model (`Room SagerDatabase`,
25+
`DataStore`, `ProxyEntity`, `ProfileManager`); MikuBox has none of these — it
26+
uses the Mihomo core with a simple `SharedPreferences`-backed profile store.
27+
- Its `res/values` (theme, `attrs`, `colors`, `strings`) collide by name with
28+
MikuBox's own resources.
29+
- ~28 files call the sing-box/libbox native core directly.
30+
31+
So screens are ported **one at a time**, re-skinned onto MikuBox's Mihomo-backed
32+
data layer and Material3 theme, rather than pasted wholesale. Use these files to
33+
copy layouts/drawables and match the visual design.
34+
35+
Source: <https://github.com/MatsuriDayo/NekoBoxForAndroid> (GPL-3.0).
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)