Skip to content

Commit adf457f

Browse files
wintmainwosys
authored andcommitted
[wBasis][style]Reformat module
1 parent 9f858b0 commit adf457f

File tree

62 files changed

+581
-565
lines changed

Some content is hidden

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

62 files changed

+581
-565
lines changed

app-catalog/samples/wBasis/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2023-2025 wintmain
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+
* https://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+
117
apply from: "$rootDir/gradle/sample-build.gradle"
218

319
apply plugin: 'kotlin-parcelize'

app-catalog/samples/wBasis/libwBasis/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2023-2025 wintmain
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+
* https://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+
117
apply from: "$rootDir/gradle/sample-build.gradle"
218

319
android {

app-catalog/samples/wBasis/libwBasis/src/main/java/lib/wintmain/wBasis/view/SlidingTabLayout.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,15 @@
4747
* providing the layout ID of your custom layout.
4848
*/
4949
public class SlidingTabLayout extends HorizontalScrollView {
50-
/**
51-
* Allows complete control over the colors drawn in the tab layout. Set with
52-
* {@link #setCustomTabColorizer(TabColorizer)}.
53-
*/
54-
public interface TabColorizer {
55-
56-
/**
57-
* @return return the color of the indicator used when {@code position} is selected.
58-
*/
59-
int getIndicatorColor(int position);
60-
61-
/**
62-
* @return return the color of the divider drawn to the right of {@code position}.
63-
*/
64-
int getDividerColor(int position);
65-
66-
}
67-
6850
private static final int TITLE_OFFSET_DIPS = 24;
6951
private static final int TAB_VIEW_PADDING_DIPS = 16;
7052
private static final int TAB_VIEW_TEXT_SIZE_SP = 12;
71-
7253
private final int mTitleOffset;
7354
private final SlidingTabStrip mTabStrip;
74-
7555
private int mTabViewLayoutId;
7656
private int mTabViewTextViewId;
77-
7857
private ViewPager mViewPager;
7958
private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;
80-
8159
public SlidingTabLayout(Context context) {
8260
this(context, null);
8361
}
@@ -112,7 +90,8 @@ public void setCustomTabColorizer(TabColorizer tabColorizer) {
11290

11391
/**
11492
* Sets the colors to be used for indicating the selected tab. These colors are treated as a
115-
* circular array. Providing one color will mean that all tabs are indicated with the same color.
93+
* circular array. Providing one color will mean that all tabs are indicated with the same
94+
* color.
11695
*/
11796
public void setSelectedIndicatorColors(int... colors) {
11897
mTabStrip.setSelectedIndicatorColors(colors);
@@ -141,7 +120,7 @@ public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
141120
* Set the custom layout to be inflated for the tab views.
142121
*
143122
* @param layoutResId Layout id to be inflated
144-
* @param textViewId id of the {@link TextView} in the inflated view
123+
* @param textViewId id of the {@link TextView} in the inflated view
145124
*/
146125
public void setCustomTabView(int layoutResId, int textViewId) {
147126
mTabViewLayoutId = layoutResId;
@@ -250,6 +229,24 @@ private void scrollToTab(int tabIndex, int positionOffset) {
250229
}
251230
}
252231

232+
/**
233+
* Allows complete control over the colors drawn in the tab layout. Set with
234+
* {@link #setCustomTabColorizer(TabColorizer)}.
235+
*/
236+
public interface TabColorizer {
237+
238+
/**
239+
* @return return the color of the indicator used when {@code position} is selected.
240+
*/
241+
int getIndicatorColor(int position);
242+
243+
/**
244+
* @return return the color of the divider drawn to the right of {@code position}.
245+
*/
246+
int getDividerColor(int position);
247+
248+
}
249+
253250
private class InternalViewPagerListener implements ViewPager.OnPageChangeListener {
254251
private int mScrollState;
255252

app-catalog/samples/wBasis/libwBasis/src/main/java/lib/wintmain/wBasis/view/SlidingTabStrip.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,14 @@ public class SlidingTabStrip extends LinearLayout {
3434
private static final int DEFAULT_DIVIDER_THICKNESS_DIPS = 1;
3535
private static final byte DEFAULT_DIVIDER_COLOR_ALPHA = 0x20;
3636
private static final float DEFAULT_DIVIDER_HEIGHT = 0.5f;
37-
38-
private SlidingTabLayout.TabColorizer mCustomTabColorizer;
3937
private final SimpleTabColorizer mDefaultTabColorizer;
40-
4138
private final int mBottomBorderThickness;
4239
private final Paint mBottomBorderPaint;
43-
4440
private final int mSelectedIndicatorThickness;
4541
private final Paint mSelectedIndicatorPaint;
46-
4742
private final Paint mDividerPaint;
4843
private final float mDividerHeight;
49-
44+
private SlidingTabLayout.TabColorizer mCustomTabColorizer;
5045
private int mSelectedPosition;
5146
private float mSelectionOffset;
5247

@@ -92,6 +87,20 @@ private static int setColorAlpha(int color, byte alpha) {
9287
return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
9388
}
9489

90+
/**
91+
* Blend {@code color1} and {@code color2} using the given ratio.
92+
*
93+
* @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
94+
* 0.0 will return {@code color2}.
95+
*/
96+
private static int blendColors(int color1, int color2, float ratio) {
97+
final float inverseRation = 1f - ratio;
98+
float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
99+
float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
100+
float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
101+
return Color.rgb((int) r, (int) g, (int) b);
102+
}
103+
95104
void setCustomTabColorizer(SlidingTabLayout.TabColorizer customTabColorizer) {
96105
mCustomTabColorizer = customTabColorizer;
97106
invalidate();
@@ -166,20 +175,6 @@ protected void onDraw(Canvas canvas) {
166175
}
167176
}
168177

169-
/**
170-
* Blend {@code color1} and {@code color2} using the given ratio.
171-
*
172-
* @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
173-
* 0.0 will return {@code color2}.
174-
*/
175-
private static int blendColors(int color1, int color2, float ratio) {
176-
final float inverseRation = 1f - ratio;
177-
float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
178-
float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
179-
float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
180-
return Color.rgb((int) r, (int) g, (int) b);
181-
}
182-
183178
private static class SimpleTabColorizer implements SlidingTabLayout.TabColorizer {
184179
private int[] mIndicatorColors;
185180
private int[] mDividerColors;

app-catalog/samples/wBasis/src/main/AndroidManifest.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright 2023-2024 wintmain
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -73,10 +72,10 @@
7372
<!-- gesture detect END-->
7473

7574
<!-- slidingpanelayout START-->
76-
<activity android:name=".ui.layout.slidingpanelayout.SlidingPaneLayoutMain"
77-
android:theme="@style/Theme.AppCompat.DayNight"
78-
android:exported="true">
79-
</activity>
75+
<activity
76+
android:name=".ui.layout.slidingpanelayout.SlidingPaneLayoutMain"
77+
android:exported="true"
78+
android:theme="@style/Theme.AppCompat.DayNight"></activity>
8079
<!-- slidingpanelayout END-->
8180

8281
<activity
@@ -355,9 +354,9 @@
355354

356355
<service
357356
android:name=".aidl.PeopleRemoteService"
358-
android:process=":remote"
359357
android:enabled="true"
360-
android:exported="true" />
358+
android:exported="true"
359+
android:process=":remote" />
361360

362361
<activity
363362
android:name=".aidl.AidlSampleActivity"

app-catalog/samples/wBasis/src/main/java/com/wintmain/wBasis/PlaceHolderActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class PlaceHolderActivity extends AppCompatActivity {
4040
@Override
4141
protected void onCreate(Bundle savedInstanceState) {
4242
super.onCreate(savedInstanceState);
43-
setContentView(R.layout.pft_activity_main);
43+
setContentView(R.layout.activity_pft_main);
4444

4545
// 初始化一些三方库
4646
initLibs(getApplication());
@@ -61,7 +61,8 @@ public void onTitleClick(TitleBarExt titleBar) {
6161
newIntent.putExtra(AlarmClock.EXTRA_MINUTES, 30);
6262
newIntent.setAction(AlarmClock.ACTION_SET_ALARM);
6363
newIntent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
64-
newIntent.setComponent(new ComponentName("com.android.deskclock", "com.android.deskclock.HandleApiCalls"));
64+
newIntent.setComponent(new ComponentName("com.android.deskclock",
65+
"com.android.deskclock.HandleApiCalls"));
6566
try {
6667
startActivity(newIntent);
6768
ToastUtils.show("你点击了中间,并且新建了一个9:30的闹钟");

app-catalog/samples/wBasis/src/main/java/com/wintmain/wBasis/aidl/AidlSampleActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ import androidx.appcompat.app.AppCompatActivity
2727
import com.google.android.catalog.framework.annotations.Sample
2828
import lib.wintmain.wToaster.toast.ToastUtils
2929

30-
@Sample(name = "AIDL-SampleActivity", description = "AIDL简单示例", tags =["A-Self_demos"])
31-
class AidlSampleActivity: AppCompatActivity() {
30+
@Sample(name = "AIDL-SampleActivity", description = "AIDL简单示例", tags = ["A-Self_demos"])
31+
class AidlSampleActivity : AppCompatActivity() {
3232
companion object {
3333
private const val TAG = "AidlSampleActivity"
3434
}
35+
3536
var peopleManager: IPeopleManager? = null
3637

3738
override fun onCreate(savedInstanceState: Bundle?) {

app-catalog/samples/wBasis/src/main/java/com/wintmain/wBasis/aidl/People.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222

2323
public class People implements Parcelable {
2424

25+
// 反序列化功能由CREATOR来完成,其内部标明了如何创建序列化对象和数组,
26+
// 并通过Parcel的一系列read方法来完成反序列化过程。
27+
public static final Parcelable.Creator<People> CREATOR = new Parcelable.Creator<>() {
28+
public People createFromParcel(Parcel in) {
29+
return new People(in);
30+
}
31+
32+
public People[] newArray(int size) {
33+
return new People[size];
34+
}
35+
};
2536
public int pId;
2637
public String pName;
2738

@@ -65,19 +76,6 @@ public void writeToParcel(@NonNull Parcel dest, int flags) {
6576
dest.writeString(pName);
6677
}
6778

68-
// 反序列化功能由CREATOR来完成,其内部标明了如何创建序列化对象和数组,
69-
// 并通过Parcel的一系列read方法来完成反序列化过程。
70-
public static final Parcelable.Creator<People> CREATOR = new Parcelable.Creator<>() {
71-
public People createFromParcel(Parcel in) {
72-
return new People(in);
73-
}
74-
75-
public People[] newArray(int size) {
76-
return new People[size];
77-
}
78-
};
79-
80-
8179
@NonNull
8280
@Override
8381
public String toString() {

app-catalog/samples/wBasis/src/main/java/com/wintmain/wBasis/aidl/PeopleRemoteService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import java.util.concurrent.CopyOnWriteArrayList
2727
// 服务端代码,客户端见[AidlSampleActivity.java]
2828
class PeopleRemoteService : Service() {
2929
val mPeopleList = CopyOnWriteArrayList<People>()
30+
3031
// 客户端注册和移除注册过程中使用的虽是同一个客户端对象,
3132
// 但通过Binder传递到服务端后,产生了两个不同的对象。
3233
// 因为对象是不能跨进程直接传输的,对象的跨进程传输本质上都是反序列化的过程

app-catalog/samples/wBasis/src/main/java/com/wintmain/wBasis/gesture/GestureDetectActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class GestureDetectActivity : AppCompatActivity() {
4040

4141
override fun onCreate(savedInstanceState: Bundle?) {
4242
super.onCreate(savedInstanceState)
43-
setContentView(R.layout.gesture_detect_main)
43+
setContentView(R.layout.activity_gesture_detect_main)
4444

4545
val transaction = supportFragmentManager.beginTransaction()
4646
transaction.add(GestureDetectFragment(), FRAG).commit()

0 commit comments

Comments
 (0)