Skip to content

Commit c7c095d

Browse files
committed
添加循环滑动开关
1 parent c8c3859 commit c7c095d

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

res/values/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<bool name="is_tablet">false</bool>
55
<bool name="is_large_tablet">false</bool>
66
<bool name="allow_rotation">false</bool>
7+
<bool name="allow_circle_scroll">false</bool>
78

89
<integer name="extracted_color_gradient_alpha">153</integer>
910

res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,6 @@
362362

363363
<string name="widget_count_format">(%1$d)</string>
364364
<string name="widget_span_format">(%1$dx%2$d)</string>
365+
366+
<string name="allow_circle_scroll_title">允许循环滑动</string>
365367
</resources>

res/xml/launcher_preferences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
android:defaultValue="@bool/allow_rotation"
4444
android:persistent="true"/>
4545

46+
<SwitchPreference
47+
android:key="pref_allowCircleScroll"
48+
android:title="@string/allow_circle_scroll_title"
49+
android:defaultValue="@bool/allow_circle_scroll"
50+
android:persistent="true"/>
51+
4652
<ListPreference
4753
android:key="pref_override_icon_shape"
4854
android:title="@string/icon_shape_override_label"

src/com/android/launcher3/CircularSlidePagedView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private void drawCircularPageIfNeed(Canvas canvas) {
223223

224224
@Override
225225
protected boolean isPagedViewCircledScroll() {
226-
return MxSettings.sIsPagedViewCircleScroll;
226+
return MxSettings.getInstance().isPageViewCircleScroll();
227227
}
228228

229229
}

src/com/android/launcher3/SettingsActivity.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import android.preference.Preference;
3434
import android.preference.PreferenceFragment;
3535
import android.preference.PreferenceScreen;
36+
import android.preference.SwitchPreference;
3637
import android.provider.Settings;
3738
import android.text.TextUtils;
3839
import android.view.View;
@@ -41,6 +42,7 @@
4142

4243
import com.android.launcher3.graphics.IconShapeOverride;
4344
import com.android.launcher3.notification.NotificationListener;
45+
import com.android.launcher3.setting.MxSettings;
4446
import com.android.launcher3.util.ListViewHighlighter;
4547
import com.android.launcher3.util.SettingsObserver;
4648
import com.android.launcher3.views.ButtonPreference;
@@ -56,6 +58,9 @@
5658
public class SettingsActivity extends Activity {
5759

5860
private static final String ICON_BADGING_PREFERENCE_KEY = "pref_icon_badging";
61+
62+
public static final String ALLOW_CIRCLE_SCROLL_PREFERENCE_KEY = "pref_allowCircleScroll";
63+
5964
/**
6065
* Hidden field MxSettings.Secure.NOTIFICATION_BADGING
6166
*/
@@ -141,6 +146,17 @@ public void onCreate(Bundle savedInstanceState) {
141146
// Initialize the UI once
142147
rotationPref.setDefaultValue(getAllowRotationDefaultValue());
143148
}
149+
150+
SwitchPreference circleScroll = (SwitchPreference) findPreference(ALLOW_CIRCLE_SCROLL_PREFERENCE_KEY);
151+
circleScroll.setDefaultValue(MxSettings.getInstance().isPageViewCircleScroll());
152+
circleScroll.setChecked(MxSettings.getInstance().isPageViewCircleScroll());
153+
circleScroll.setOnPreferenceChangeListener((preference, newValue) -> {
154+
boolean isChecked = (boolean) newValue;
155+
MxSettings.getInstance().setPagedViewCircleScroll(isChecked);
156+
circleScroll.setChecked(isChecked);
157+
return true;
158+
});
159+
144160
}
145161

146162
@Override

src/com/android/launcher3/setting/MxSettings.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class MxSettings {
1919
/**
2020
* PagedView can scroll circle-endless.
2121
*/
22-
public static boolean sIsPagedViewCircleScroll = FeatureFlags.LAUNCHER3_CIRCLE_SCROLL;
22+
private boolean isPagedViewCircleScroll = FeatureFlags.LAUNCHER3_CIRCLE_SCROLL;
2323
private Context mContext;
2424

2525

@@ -34,15 +34,20 @@ public static MxSettings getInstance() {
3434
public void loadSettings(Context context) {
3535
mContext = context.getApplicationContext();
3636
// sLauncherEffect = LauncherSpUtil.getIntData(mContext, LauncherSpUtil.KEY_SCROLL_EFFECT, TransitionEffect.TRANSITION_EFFECT_NONE);
37+
loadScreenCycle();
3738
}
3839

3940
public void setPagedViewCircleScroll(boolean isPagedViewCircleScroll) {
40-
MxSettings.sIsPagedViewCircleScroll = isPagedViewCircleScroll;
41+
this.isPagedViewCircleScroll = isPagedViewCircleScroll;
4142
LauncherSpUtil.saveBooleanData(mContext, LauncherSpUtil.KEY_PAGE_CIRCLE, isPagedViewCircleScroll);
4243
}
4344

4445
public void loadScreenCycle() {
45-
sIsPagedViewCircleScroll = LauncherSpUtil.getBooleanData(mContext, LauncherSpUtil.KEY_PAGE_CIRCLE);
46+
isPagedViewCircleScroll = LauncherSpUtil.getBooleanData(mContext, LauncherSpUtil.KEY_PAGE_CIRCLE);
47+
}
48+
49+
public boolean isPageViewCircleScroll() {
50+
return isPagedViewCircleScroll;
4651
}
4752

4853
public void setLauncherEffect(int effect) {

0 commit comments

Comments
 (0)