Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 7d82261

Browse files
authored
app: OneUI 4 DetailedColorPicker, GoToTop, Preference text size (#62)
* app: OneUI 4 DetailedColorPicker, GoToTop, Preference text size Signed-off-by: BlackMesa123 <[email protected]> * app: fix SwipeRefreshLayout scale down anim, night mode DetailedColorPicker tabs Signed-off-by: BlackMesa123 <[email protected]> * app: OneUI 4 fast scroller Signed-off-by: BlackMesa123 <[email protected]> * app/SwipeRefreshLayout: fix crashes Signed-off-by: BlackMesa123 <[email protected]> * app/oneuiexample: there's a SwipeRefreshLayout test in case you didn't notice Signed-off-by: BlackMesa123 <[email protected]>
1 parent b70913e commit 7d82261

27 files changed

+697
-30
lines changed

app/src/main/java/de/dlyt/yanndroid/oneuiexample/tabs/NothingTab.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
4040
super.onViewCreated(view, savedInstanceState);
4141

4242
SwipeRefreshLayout swipeRefreshLayout = mRootView.findViewById(R.id.swipe_refresh);
43+
swipeRefreshLayout.seslSetRefreshOnce(true);
4344
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
4445
@Override
4546
public void onRefresh() {
46-
Toast.makeText(mContext, "Refresh", Toast.LENGTH_SHORT).show();
47-
new Handler().postDelayed(() -> {
48-
swipeRefreshLayout.setRefreshing(false);
49-
}, 700);
47+
Toast.makeText(mContext, "onRefresh called", Toast.LENGTH_SHORT).show();
5048
}
5149
});
5250

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
android:layout_width="wrap_content"
2727
android:layout_height="wrap_content"
2828
android:text="@string/nothing"
29-
android:textAlignment="viewStart"
30-
android:textSize="18sp" />
29+
android:textAlignment="viewStart" />
30+
31+
<com.google.android.material.textview.MaterialTextView
32+
style="?android:textAppearanceSmall"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:text="@string/nothing_summary" />
3136

3237
</LinearLayout>
3338

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
android:layout_height="wrap_content" />
1919

2020
<com.google.android.material.textview.MaterialTextView
21-
style="@style/ListSeparatorStyle"
21+
style="@style/OneUI4.ListSeparatorStyle"
2222
android:text="ProgressBar" />
2323

2424

@@ -77,7 +77,7 @@
7777
</com.google.android.material.card.MaterialCardView>
7878

7979
<com.google.android.material.textview.MaterialTextView
80-
style="@style/ListSeparatorStyle"
80+
style="@style/OneUI4.ListSeparatorStyle"
8181
android:text="SeekBar" />
8282

8383
<com.google.android.material.card.MaterialCardView
@@ -117,7 +117,7 @@
117117

118118

119119
<com.google.android.material.textview.MaterialTextView
120-
style="@style/ListSeparatorStyle"
120+
style="@style/OneUI4.ListSeparatorStyle"
121121
android:text="Buttons" />
122122

123123

@@ -234,7 +234,7 @@
234234

235235

236236
<com.google.android.material.textview.MaterialTextView
237-
style="@style/ListSeparatorStyle"
237+
style="@style/OneUI4.ListSeparatorStyle"
238238
android:text="Others" />
239239

240240

@@ -266,7 +266,10 @@
266266
<EditText
267267
android:layout_width="match_parent"
268268
android:layout_height="wrap_content"
269-
android:hint="EditText" />
269+
android:layout_marginTop="14dp"
270+
android:hint="EditText"
271+
android:maxLines="1"
272+
android:inputType="text"/>
270273

271274
<androidx.appcompat.widget.SeslSpinner
272275
android:id="@+id/spinner"
@@ -281,7 +284,7 @@
281284

282285

283286
<com.google.android.material.textview.MaterialTextView
284-
style="@style/ListSeparatorStyle"
287+
style="@style/OneUI4.ListSeparatorStyle"
285288
android:text="Color Pickers" />
286289

287290

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<resources>
22
<string name="app_name" translatable="false">OneUI Sample</string>
33
<string name="nothing"><![CDATA[>Nothing<]]></string>
4+
<string name="nothing_summary">Swipe down and see the magic :D</string>
45
</resources>

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/dialog/DetailedColorPickerDialog.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
@TargetApi(17)
3333
public class DetailedColorPickerDialog extends Dialog {
34+
private boolean mIsOneUI4;
3435
public static final int VIEW_MODE_GRADIENT = 1;
3536
public static final int VIEW_MODE_SWATCH = 2;
3637
private static final int TYPE_CUSTOMIZE = 0;
@@ -97,7 +98,8 @@ public void onClick(View view) {
9798
};
9899

99100
public DetailedColorPickerDialog(Context context, int mode, float[] fArr) {
100-
super(context, R.style.ColorPickerPopupDialog);
101+
super(context,
102+
context.getTheme().obtainStyledAttributes(new int[]{R.attr.isOneUI4}).getBoolean(0, false) ? R.style.OneUI4_ColorPickerPopupDialog : R.style.ColorPickerPopupDialog);
101103
SpenSettingUtil.initDialogWindow(this, 5376, -1);
102104
getWindow().setFlags(256, 256);
103105
getWindow().setSoftInputMode(33);
@@ -106,14 +108,16 @@ public DetailedColorPickerDialog(Context context, int mode, float[] fArr) {
106108
}
107109

108110
public DetailedColorPickerDialog(Context context, float[] fArr) {
109-
super(context, R.style.ColorPickerPopupDialog);
111+
super(context,
112+
context.getTheme().obtainStyledAttributes(new int[]{R.attr.isOneUI4}).getBoolean(0, false) ? R.style.OneUI4_ColorPickerPopupDialog : R.style.ColorPickerPopupDialog);
110113
SpenSettingUtil.initDialogWindow(this, 4096, -1);
111114
this.mIsSupportRGBCode = false;
112115
construct(context, 2, fArr);
113116
}
114117

115118
private void construct(Context context, int i, float[] fArr) {
116119
this.mContext = context;
120+
mIsOneUI4 = context.getTheme().obtainStyledAttributes(new int[]{R.attr.isOneUI4}).getBoolean(0, false);
117121
this.mColorTheme = new SpenColorPickerTheme(context, fArr);
118122
this.mPickerControl = new SpenColorPickerControl(i, fArr);
119123
}
@@ -353,7 +357,7 @@ private void setListener() {
353357
private void initView() {
354358
SpenColorPickerViewInfo spenColorPickerViewInfo = new SpenColorPickerViewInfo();
355359

356-
spenColorPickerViewInfo.layoutId = R.layout.setting_color_picker_view_oneui30;
360+
spenColorPickerViewInfo.layoutId = mIsOneUI4 ? R.layout.setting_color_picker_view_oneui40 : R.layout.setting_color_picker_view_oneui30;
357361
spenColorPickerViewInfo.modeType = 1;
358362
spenColorPickerViewInfo.itemLayoutId = R.layout.setting_color_swatch_item;
359363
spenColorPickerViewInfo.gradientCursorSizeDimen = R.dimen.color_picker_popup_content_point_size;
@@ -372,7 +376,7 @@ private void initView() {
372376

373377
LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
374378
Resources mSdkResources = mContext.getResources();
375-
this.mParentLayout = (RelativeLayout) mInflater.inflate(mSdkResources.getLayout(R.layout.setting_color_picker_layout), null);
379+
this.mParentLayout = (RelativeLayout) mInflater.inflate(mSdkResources.getLayout(mIsOneUI4 ? R.layout.setting_color_picker_oui4_layout : R.layout.setting_color_picker_layout), null);
376380

377381
FrameLayout frameLayout = this.mParentLayout.findViewById(R.id.popup_content_view);
378382
float[] fArr = new float[3];

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/layout/SwipeRefreshLayout.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ public void setRefreshing(boolean refreshing) {
373373

374374
private void startScaleUpAnimation(AnimationListener listener) {
375375
mCircleView.setVisibility(View.VISIBLE);
376-
mOUI4Progress.setAlpha(MAX_ALPHA);
376+
if (mIsOneUI4) {
377+
mOUI4Progress.setAlpha(MAX_ALPHA);
378+
}
377379
mScaleAnimation = new Animation() {
378380
@Override
379381
public void applyTransformation(float interpolatedTime, Transformation t) {
@@ -441,7 +443,7 @@ public void applyTransformation(float interpolatedTime, Transformation t) {
441443
}
442444
}
443445
};
444-
mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
446+
mScaleDownAnimation.setDuration(END_SCALE_DOWN_DURATION);
445447
mScaleDownAnimation.setInterpolator(SINE_OUT_60);
446448
} else {
447449
mScaleDownAnimation = new Animation() {
@@ -450,7 +452,7 @@ public void applyTransformation(float interpolatedTime, Transformation t) {
450452
setAnimationProgress((mStartingScale + ((-mStartingScale) * interpolatedTime)));
451453
}
452454
};
453-
mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
455+
mScaleDownAnimation.setDuration(END_SCALE_DOWN_DURATION);
454456
mScaleDownAnimation.setInterpolator(SINE_IN_80);
455457
}
456458
mCircleView.setAnimationListener(listener);

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/menu/PopupMenu.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.widget.TextView;
1515

1616
import androidx.annotation.MenuRes;
17+
import androidx.core.content.res.ResourcesCompat;
1718

1819
import java.util.ArrayList;
1920

@@ -161,7 +162,7 @@ private TextView createTitleView() {
161162
context.getResources().getDimensionPixelSize(R.dimen.sesl_menu_popup_bottom_padding));
162163
titleView.setTextDirection(View.TEXT_DIRECTION_LOCALE);
163164
titleView.setTextColor(context.getResources().getColor(R.color.item_color));
164-
titleView.setTypeface(Typeface.DEFAULT_BOLD);
165+
titleView.setTypeface(ResourcesCompat.getFont(context, R.font.sesl_roboto), Typeface.BOLD);
165166
titleView.setEllipsize(TextUtils.TruncateAt.END);
166167
titleView.setMaxLines(1);
167168
titleView.setTextSize(16);

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/sesl/recyclerview/SeslRecyclerViewFastScroller.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import de.dlyt.yanndroid.oneui.view.RecyclerView;
3434

3535
public class SeslRecyclerViewFastScroller {
36+
private boolean mIsOneUI4;
3637
public static final int EFFECT_STATE_CLOSE = 0;
3738
public static final int EFFECT_STATE_OPEN = 1;
3839
private static final int DURATION_CROSS_FADE = 0;
@@ -104,6 +105,7 @@ public Integer get(View object) {
104105
private float mAdditionalTouchArea = 0.0f;
105106
private boolean mAlwaysShow;
106107
private int mColorPrimary = -1;
108+
private int mThumbBackgroundColor = -1;
107109
private Context mContext;
108110
private int mCurrentSection = -1;
109111
private AnimatorSet mDecorAnimation;
@@ -169,6 +171,7 @@ public SeslRecyclerViewFastScroller(RecyclerView recyclerView, int styleResId) {
169171
mOldItemCount = recyclerView.getAdapter().getItemCount();
170172
mOldChildCount = recyclerView.getChildCount();
171173
mContext = recyclerView.getContext();
174+
mIsOneUI4 = mContext.getTheme().obtainStyledAttributes(new int[]{R.attr.isOneUI4}).getBoolean(0, false);
172175
mScaledTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
173176
mScrollBarStyle = recyclerView.getScrollBarStyle();
174177
mScrollCompleted = true;
@@ -261,13 +264,15 @@ private void updateAppearance() {
261264
mContext.getTheme().resolveAttribute(R.attr.colorPrimary, outValue, true);
262265
mColorPrimary = outValue.data;
263266

267+
mThumbBackgroundColor = mContext.getResources().getColor(R.color.sesl_fast_scrollbar_bg_color);
268+
264269
mTrackImage.setImageDrawable(mTrackDrawable);
265270
if (mTrackDrawable != null) {
266271
width = Math.max(0, mTrackDrawable.getIntrinsicWidth());
267272
}
268273

269274
if (mThumbDrawable != null) {
270-
mThumbDrawable.setTint(mColorPrimary);
275+
mThumbDrawable.setTint(mIsOneUI4 ? mThumbBackgroundColor : mColorPrimary);
271276
}
272277
mThumbImage.setImageDrawable(mThumbDrawable);
273278
mThumbImage.setMinimumWidth(mThumbMinWidth);

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/view/OptionButton.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import androidx.annotation.Nullable;
1515
import androidx.appcompat.util.SeslMisc;
1616
import androidx.core.content.ContextCompat;
17+
import androidx.core.content.res.ResourcesCompat;
1718

1819
import com.google.android.material.textview.MaterialTextView;
1920

@@ -102,7 +103,7 @@ public void setIcon(Drawable icon) {
102103
public void setButtonSelected(Boolean selected) {
103104
this.mSelected = selected;
104105
setTextColor(mSelected);
105-
textView.setTypeface(null, mSelected ? Typeface.BOLD : Typeface.NORMAL);
106+
textView.setTypeface(ResourcesCompat.getFont(getContext(), R.font.sesl_roboto), mSelected ? Typeface.BOLD : Typeface.NORMAL);
106107
}
107108

108109
public void toggleButtonSelected() {

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/view/RecyclerView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public float getInterpolation(float var1) {
279279
private boolean mFastScrollerEnabled;
280280
private RecyclerView.SeslFastScrollerEventListener mFastScrollerEventListener;
281281
private int mGoToTopBottomPadding;
282-
private int mGoToTopElevation;
282+
private float mGoToTopElevation;
283283
private ValueAnimator mGoToTopFadeInAnimator;
284284
private ValueAnimator mGoToTopFadeOutAnimator;
285285
private Drawable mGoToTopImage;
@@ -6379,7 +6379,7 @@ public void seslInitConfigurations(Context var1) {
63796379
this.mGoToTopBottomPadding = var3.getDimensionPixelSize(R.dimen.sesl_go_to_top_scrollable_view_gap);
63806380
this.mGoToTopImmersiveBottomPadding = 0;
63816381
this.mGoToTopSize = var3.getDimensionPixelSize(R.dimen.sesl_go_to_top_scrollable_view_size);
6382-
this.mGoToTopElevation = var3.getDimensionPixelSize(R.dimen.sesl_go_to_top_elevation);
6382+
this.mGoToTopElevation = var3.getDimension(R.dimen.sesl_go_to_top_elevation);
63836383
this.mNavigationBarHeight = var3.getDimensionPixelSize(R.dimen.sesl_navigation_bar_height);
63846384
}
63856385

@@ -6464,7 +6464,7 @@ public void seslSetGoToTopEnabled(boolean var1, boolean var2) {
64646464
if (VERSION.SDK_INT >= 26) {
64656465
var3 = this.mContext.getResources().getDrawable(R.drawable.sesl_go_to_top_background, (Resources.Theme) null);
64666466
this.mGoToTopView.setBackground(var3);
6467-
this.mGoToTopView.setElevation((float) this.mGoToTopElevation);
6467+
this.mGoToTopView.setElevation(this.mGoToTopElevation);
64686468
}
64696469

64706470
this.mGoToTopView.setImageDrawable(this.mGoToTopImage);

0 commit comments

Comments
 (0)