@@ -8,129 +8,131 @@ import { getHeightPixels, getWidthPixels } from '@auto.pro/core';
88
99export default {
1010 show : ( myfloaty : MyFloaty , schemeList ?: IScheme [ ] ) => {
11- const customView = ui . inflate (
12- `<androidx.core.widget.NestedScrollView fillViewport="true">
13- <list id="groupList">
14- <vertical w="*">
15- <text textColor="#ababab" textSize="14" text="{{this.groupName}}" layout_gravity="center" />
16- </vertical>
17- </list>
18- </androidx.core.widget.NestedScrollView>`
19- ) ;
20- const title = '选择方案' ;
21- const schemeDialog = dialogs . build ( { title, customView } ) . show ( ) ;
22- const screenWidth = getWidthPixels ( ) ;
23- const screenHeight = getHeightPixels ( ) ;
24- if ( screenWidth > screenHeight ) {
25- schemeDialog . getWindow ( ) . setLayout ( Math . max ( screenWidth * 0.6 , Math . min ( 576 , screenWidth ) ) , android . view . WindowManager . LayoutParams . WRAP_CONTENT ) ;
26- // schemeDialog.getWindow().setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT, android.view.WindowManager.LayoutParams.WRAP_CONTENT);
27- }
11+ ui . post ( ( ) => {
12+ const customView = ui . inflate (
13+ `<androidx.core.widget.NestedScrollView fillViewport="true">
14+ <list id="groupList">
15+ <vertical w="*">
16+ <text textColor="#ababab" textSize="14" text="{{this.groupName}}" layout_gravity="center" />
17+ </vertical>
18+ </list>
19+ </androidx.core.widget.NestedScrollView>`
20+ ) ;
21+ const title = '选择方案' ;
22+ const schemeDialog = dialogs . build ( { title, customView } ) . show ( ) ;
23+ const screenWidth = getWidthPixels ( ) ;
24+ const screenHeight = getHeightPixels ( ) ;
25+ if ( screenWidth > screenHeight ) {
26+ schemeDialog . getWindow ( ) . setLayout ( Math . max ( screenWidth * 0.6 , Math . min ( 576 , screenWidth ) ) , android . view . WindowManager . LayoutParams . WRAP_CONTENT ) ;
27+ // schemeDialog.getWindow().setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT, android.view.WindowManager.LayoutParams.WRAP_CONTENT);
28+ }
2829
29- let groupSchemeNames : GroupSchemeName [ ] = store . get ( 'groupSchemeNames' ) ;
30- if ( ! schemeList ) {
31- schemeList = store . get ( 'schemeList' ) ;
32- }
33- groupSchemeNames = groupSchemeNames . filter ( group => ! group . hidden ) ;
34- groupSchemeNames . forEach ( group => {
35- group . schemeNames = group . schemeNames . filter ( schemeName => {
36- return ! ! schemeList . find ( scheme => scheme . schemeName === schemeName && scheme . star ) ;
30+ let groupSchemeNames : GroupSchemeName [ ] = store . get ( 'groupSchemeNames' ) ;
31+ if ( ! schemeList ) {
32+ schemeList = store . get ( 'schemeList' ) ;
33+ }
34+ groupSchemeNames = groupSchemeNames . filter ( group => ! group . hidden ) ;
35+ groupSchemeNames . forEach ( group => {
36+ group . schemeNames = group . schemeNames . filter ( schemeName => {
37+ return ! ! schemeList . find ( scheme => scheme . schemeName === schemeName && scheme . star ) ;
38+ } ) ;
3739 } ) ;
38- } ) ;
39- groupSchemeNames = groupSchemeNames . filter ( group => group . schemeNames ?. length ) ;
40+ groupSchemeNames = groupSchemeNames . filter ( group => group . schemeNames ?. length ) ;
4041
41- customView . groupList . setDataSource ( groupSchemeNames ) ;
42+ customView . groupList . setDataSource ( groupSchemeNames ) ;
4243
43- customView . groupList . on ( 'item_bind' , function ( itemView , _itemHolder ) {
44- let itemStr = `<list id="groupSchemeList">
45- <horizontal w="*">
46- <vertical w="0dp" layout_weight="1">
47- <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
48- </vertical>
49- <vertical w="0dp" layout_weight="1">
50- <text padding="10 5 10 5" textColor="black" textSize="14" id="rightText" text="{{right}}" layout_gravity="center" />
51- </vertical>
52- </horizontal>
53- </list>`;
54- if ( screenWidth <= screenHeight ) {
55- itemStr = `<list id="groupSchemeList">
56- <horizontal w="*">
57- <vertical w="*">
58- <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
59- </vertical>
60- </horizontal>
61- </list>`;
62- }
63- const schemeListView = ui . inflate ( itemStr , itemView ) ;
64- itemView . addView ( schemeListView ) ;
65- } ) ;
44+ customView . groupList . on ( 'item_bind' , function ( itemView , _itemHolder ) {
45+ let itemStr = `<list id="groupSchemeList">
46+ <horizontal w="*">
47+ <vertical w="0dp" layout_weight="1">
48+ <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
49+ </vertical>
50+ <vertical w="0dp" layout_weight="1">
51+ <text padding="10 5 10 5" textColor="black" textSize="14" id="rightText" text="{{right}}" layout_gravity="center" />
52+ </vertical>
53+ </horizontal>
54+ </list>`;
55+ if ( screenWidth <= screenHeight ) {
56+ itemStr = `<list id="groupSchemeList">
57+ <horizontal w="*">
58+ <vertical w="*">
59+ <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
60+ </vertical>
61+ </horizontal>
62+ </list>`;
63+ }
64+ const schemeListView = ui . inflate ( itemStr , itemView ) ;
65+ itemView . addView ( schemeListView ) ;
66+ } ) ;
6667
67- customView . groupList . on ( 'item_data_bind' , function ( itemView , itemHolder ) {
68+ customView . groupList . on ( 'item_data_bind' , function ( itemView , itemHolder ) {
6869
69- const data : { left : string , right ?: string } [ ] = [ ] ;
70- if ( screenWidth > screenHeight ) {
71- for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i += 2 ) {
72- data . push ( {
73- left : itemHolder . item . schemeNames [ i ] ,
74- right : i + 1 < itemHolder . item . schemeNames . length ? itemHolder . item . schemeNames [ i + 1 ] : ''
75- } ) ;
70+ const data : { left : string , right ?: string } [ ] = [ ] ;
71+ if ( screenWidth > screenHeight ) {
72+ for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i += 2 ) {
73+ data . push ( {
74+ left : itemHolder . item . schemeNames [ i ] ,
75+ right : i + 1 < itemHolder . item . schemeNames . length ? itemHolder . item . schemeNames [ i + 1 ] : ''
76+ } ) ;
77+ }
78+ } else {
79+ for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i ++ ) {
80+ data . push ( {
81+ left : itemHolder . item . schemeNames [ i ] ,
82+ right : ''
83+ } ) ;
84+ }
7685 }
77- } else {
78- for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i ++ ) {
79- data . push ( {
80- left : itemHolder . item . schemeNames [ i ] ,
81- right : ''
86+ itemView . groupSchemeList . setDataSource ( data ) ;
87+ itemView . groupSchemeList . on ( 'item_data_bind' , ( itemView , itemHolder ) => {
88+ const textClick = ( schemeName ) => {
89+ if ( ! schemeName ) return ;
90+ script . setCurrentScheme ( schemeName ) ;
91+ const storeSettings = storeCommon . get ( 'settings' , { } ) ;
92+ if ( storeSettings . floaty_scheme_direct_run ) {
93+ // myfloaty.fy.start();
94+ setTimeout ( ( ) => {
95+ const storeSettings = storeCommon . get ( 'settings' , { } ) ;
96+ if ( storeSettings . floaty_scheme_openApp ) {
97+ script . launchRelatedApp ( ) ;
98+ }
99+ myfloaty . thisRun ( ) ;
100+ } , 1000 ) ;
101+ } else {
102+ toast ( '设置方案[' + schemeName + ']' ) ;
103+ }
104+ schemeDialog . dismiss ( ) ;
105+ }
106+ itemView . leftText . attr ( 'foreground' , '?selectableItemBackground' ) ;
107+ itemView . leftText . click ( ( ) => {
108+ textClick ( itemHolder . item . left ) ;
82109 } ) ;
83- }
84- }
85- itemView . groupSchemeList . setDataSource ( data ) ;
86- itemView . groupSchemeList . on ( 'item_data_bind' , ( itemView , itemHolder ) => {
87- const textClick = ( schemeName ) => {
88- if ( ! schemeName ) return ;
89- script . setCurrentScheme ( schemeName ) ;
90- const storeSettings = storeCommon . get ( 'settings' , { } ) ;
91- if ( storeSettings . floaty_scheme_direct_run ) {
92- // myfloaty.fy.start();
93- setTimeout ( ( ) => {
94- const storeSettings = storeCommon . get ( 'settings' , { } ) ;
95- if ( storeSettings . floaty_scheme_openApp ) {
96- script . launchRelatedApp ( ) ;
97- }
98- myfloaty . thisRun ( ) ;
99- } , 1000 ) ;
100- } else {
101- toast ( '设置方案[' + schemeName + ']' ) ;
110+ if ( screenWidth > screenHeight ) {
111+ itemHolder . item . right && itemView . rightText . attr ( 'foreground' , '?selectableItemBackground' ) ;
112+ itemHolder . item . right && itemView . rightText . click ( ( ) => {
113+ textClick ( itemHolder . item . right ) ;
114+ } ) ;
102115 }
103- schemeDialog . dismiss ( ) ;
104- }
105- itemView . leftText . attr ( 'foreground' , '?selectableItemBackground' ) ;
106- itemView . leftText . click ( ( ) => {
107- textClick ( itemHolder . item . left ) ;
108116 } ) ;
109- if ( screenWidth > screenHeight ) {
110- itemHolder . item . right && itemView . rightText . attr ( 'foreground' , '?selectableItemBackground' ) ;
111- itemHolder . item . right && itemView . rightText . click ( ( ) => {
112- textClick ( itemHolder . item . right ) ;
113- } ) ;
114- }
117+ // itemView.groupSchemeList.on('item_click', function (item, _i, _itemView, _listView) {
118+ // const schemeName = item;
119+ // script.setCurrentScheme(schemeName);
120+ // const storeSettings = storeCommon.get('settings', {});
121+ // if (storeSettings.floaty_scheme_direct_run) {
122+ // // myfloaty.fy.start();
123+ // setTimeout(() => {
124+ // const storeSettings = storeCommon.get('settings', {});
125+ // if (storeSettings.floaty_scheme_openApp) {
126+ // script.launchRelatedApp();
127+ // }
128+ // myfloaty.thisRun();
129+ // }, 1000);
130+ // } else {
131+ // toast('设置方案[' + schemeName + ']');
132+ // }
133+ // schemeDialog.dismiss();
134+ // })
115135 } ) ;
116- // itemView.groupSchemeList.on('item_click', function (item, _i, _itemView, _listView) {
117- // const schemeName = item;
118- // script.setCurrentScheme(schemeName);
119- // const storeSettings = storeCommon.get('settings', {});
120- // if (storeSettings.floaty_scheme_direct_run) {
121- // // myfloaty.fy.start();
122- // setTimeout(() => {
123- // const storeSettings = storeCommon.get('settings', {});
124- // if (storeSettings.floaty_scheme_openApp) {
125- // script.launchRelatedApp();
126- // }
127- // myfloaty.thisRun();
128- // }, 1000);
129- // } else {
130- // toast('设置方案[' + schemeName + ']');
131- // }
132- // schemeDialog.dismiss();
133- // })
134136 } ) ;
135137 } ,
136138}
0 commit comments