diff --git a/entry/build.gradle b/entry/build.gradle index 17c72fd6504d638fc83ca6950e2cc610ec869758..0ce0515550dd575e56d5471e75f8133e16982d00 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -13,7 +13,6 @@ ohos { } } } - } dependencies { @@ -21,7 +20,8 @@ dependencies { testImplementation 'junit:junit:4.13' ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' implementation 'io.openharmony.tpc.thirdlib:XPopup:1.0.3' - implementation('com.gitee.chinasoft_ohos:vntNumber_PickerPre:0.0.2-SNAPSHOT') +// implementation('com.gitee.chinasoft_ohos:vntNumber_PickerPre:0.0.2-SNAPSHOT') + implementation project(path: ':library') implementation 'io.openharmony.tpc.thirdlib:RippleEffect:1.0.1' } decc { diff --git a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MainAbility.java b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MainAbility.java index 4f8434b34aa83e8d401d28695ae270062e90b287..c4d6d6be936edb808211f7de09faba862c6ef5a2 100644 --- a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MainAbility.java +++ b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MainAbility.java @@ -1,17 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.vanniktech.vntnumberpickerpreference.sample; import com.vanniktech.vntnumberpickerpreference.sample.slice.MainAbilitySlice; import ohos.aafwk.ability.Ability; import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; import ohos.agp.window.service.WindowManager; +/** + * MainAbility + * + * @since 2021-06-15 + */ public class MainAbility extends Ability { + private static final int STATUSBARCOLOR = 0xff283593; + @Override public void onStart(Intent intent) { super.onStart(intent); super.setMainRoute(MainAbilitySlice.class.getName()); - // 状态栏颜色 - WindowManager.getInstance().getTopWindow().get().setStatusBarColor(0xff283593); + /* + * 状态栏颜色 + */ + WindowManager.getInstance().getTopWindow().get().setStatusBarColor(STATUSBARCOLOR); } } diff --git a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MyApplication.java b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MyApplication.java index b8c937a19425be186811137307eca9ac1d6746cf..2d889714ae2223f7d4e88b76b92a52b2bbff7ed3 100644 --- a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MyApplication.java +++ b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/MyApplication.java @@ -1,9 +1,28 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.vanniktech.vntnumberpickerpreference.sample; import ohos.aafwk.ability.AbilityPackage; +/** + * MyApplication + * + * @since 2021-06-15 + */ public class MyApplication extends AbilityPackage { - @Override public void onInitialize() { super.onInitialize(); diff --git a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/SettingsAbility.java b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/SettingsAbility.java index 3c34f3300b527b1cf781f7823ed73f0a775f161c..bfd0336ba721a66fcb81ac4b74ae274d0f852cc9 100644 --- a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/SettingsAbility.java +++ b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/SettingsAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.vanniktech.vntnumberpickerpreference.sample; import com.vanniktech.vntnumberpickerpreference.sample.slice.SettingsAbilitySlice; @@ -5,12 +20,21 @@ import ohos.aafwk.ability.Ability; import ohos.aafwk.content.Intent; import ohos.agp.window.service.WindowManager; +/** + * SettingsAbility + * + * @since 2021-06-15 + */ public class SettingsAbility extends Ability { + private static final int STATUSBARCOLOR = 0xff283593; + @Override public void onStart(Intent intent) { super.onStart(intent); super.setMainRoute(SettingsAbilitySlice.class.getName()); - // 状态栏颜色 - WindowManager.getInstance().getTopWindow().get().setStatusBarColor(0xff283593); + /* + * 状态栏颜色 + */ + WindowManager.getInstance().getTopWindow().get().setStatusBarColor(STATUSBARCOLOR); } } diff --git a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/MainAbilitySlice.java b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/MainAbilitySlice.java index df1ea3989bf4ecef85a347f93158102b01001375..01f0451c50faf9476bd30fab572ed5f2959fc508 100644 --- a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/MainAbilitySlice.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.vanniktech.vntnumberpickerpreference.sample.slice; import com.vanniktech.vntnumberpickerpreference.Constants; @@ -22,11 +37,21 @@ import ohos.agp.window.service.DisplayManager; import ohos.utils.IntentConstants; import ohos.utils.net.Uri; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.Optional; +/** + * MainAbilitySlice + * + * @since 2021-06-15 + */ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener { - private Image settingImage; - private Text checkItOutOnGitHubTextView; + private static final int TWO = 2; + private static final int TEN = 10; + private static final int FOUR = 4; + private static final int OFFSET = 130; private Text bodySizeTextView; @Override @@ -37,16 +62,19 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL initData(); } - public void initComponent() { - settingImage = (Image) findComponentById(ResourceTable.Id_settingImage);checkItOutOnGitHubTextView = (Text) findComponentById(ResourceTable.Id_check_it_out_on_github); + private void initComponent() { + Image settingImage = (Image) findComponentById(ResourceTable.Id_settingImage); + Text checkItOutOnGitHubTextView = (Text) findComponentById(ResourceTable.Id_check_it_out_on_github); bodySizeTextView = (Text) findComponentById(ResourceTable.Id_body_size); - settingImage.setClickedListener(this::onClick); - checkItOutOnGitHubTextView.setClickedListener(this::onClick); + settingImage.setClickedListener(this); + checkItOutOnGitHubTextView.setClickedListener(this); } - public void initData() { - bodySizeTextView.setText("Body size - " + PreferenceUtils.getString(getApplicationContext(), Constants.BODY_SIZE, "180")); - bodySizeTextView.setTextSize(AttrHelper.vp2px(Integer.parseInt(PreferenceUtils.getString(getApplicationContext(), Constants.FONT_SIZE, "25")), getContext())); + private void initData() { + bodySizeTextView.setText("Body size - " + PreferenceUtils. + getString(getApplicationContext(), Constants.BODY_SIZE, "180")); + bodySizeTextView.setTextSize(AttrHelper.vp2px(Integer.parseInt(PreferenceUtils. + getString(getApplicationContext(), Constants.FONT_SIZE, "25")), getContext())); } @Override @@ -63,23 +91,20 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL public void onClick(Component component) { switch (component.getId()) { case ResourceTable.Id_settingImage: - Optional - display = DisplayManager.getInstance().getDefaultDisplay(this); - DisplayAttributes displayAttributes = display.get().getAttributes(); - PopupDialog menuDialog = new PopupDialog(this, null); DirectionalLayout menuComponent = (DirectionalLayout) LayoutScatter.getInstance(this) .parse(ResourceTable.Layout_custom_setting_popup, null, false); Text textSetting = (Text) menuComponent.findComponentById(ResourceTable.Id_text); - DirectionalLayout dl = (DirectionalLayout) menuComponent.findComponentById(ResourceTable.Id_dl); - textSetting.setWidth(getWindow().getLayoutConfig().get().width / 2); + textSetting.setWidth(getWindow().getLayoutConfig().get().width / TWO); ShapeElement element = new ShapeElement(); - element.setCornerRadius(10); - dl.setBackground(element); + element.setCornerRadius(TEN); textSetting.setBackground(element); - menuDialog.setCornerRadius(10); - + Optional display = DisplayManager.getInstance().getDefaultDisplay(this); + DisplayAttributes displayAttributes = display.get().getAttributes(); + PopupDialog menuDialog = new PopupDialog(this, null); + menuDialog.setCornerRadius(TEN); menuDialog.setCustomComponent(menuComponent); - menuDialog.showOnCertainPosition(1, displayAttributes.width / 4 - AttrHelper.vp2px(10, getContext()), -displayAttributes.width + 130); + menuDialog.showOnCertainPosition(1, displayAttributes.width / FOUR + - AttrHelper.vp2px(TEN, getContext()), -displayAttributes.width + OFFSET); menuDialog.setAutoClosable(true); menuDialog.setAlignment(LayoutAlignment.RIGHT | LayoutAlignment.TOP); menuDialog.show(); @@ -99,7 +124,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL }); break; case ResourceTable.Id_check_it_out_on_github: - initWeb("https://github.com/vanniktech/VNTNumberPickerPreference"); + initWeb(getUrl()); break; default: } @@ -117,4 +142,21 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL intents.setOperation(operation); startAbility(intents); } + + private String getUrl() { + ohos.global.resource.ResourceManager resManager = this.getResourceManager(); + ohos.global.resource.RawFileEntry rawFileEntry = resManager.getRawFileEntry("resources/rawfile/url.text"); + StringBuffer stringBuffer = new StringBuffer(); + try { + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(rawFileEntry.openRawFile())); + String line; + while ((line = bufferedReader.readLine()) != null) { + stringBuffer.append(line); + } + return stringBuffer.toString(); + } catch (IOException e) { + e.getMessage(); + } + return ""; + } } diff --git a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/SettingsAbilitySlice.java b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/SettingsAbilitySlice.java index 96d05bdd1ad53382464948649a12f7dbe39314f9..4c6f1edc2a606a00f41aa5b5d4515ce5b0aca212 100644 --- a/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/SettingsAbilitySlice.java +++ b/entry/src/main/java/com/vanniktech/vntnumberpickerpreference/sample/slice/SettingsAbilitySlice.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.vanniktech.vntnumberpickerpreference.sample.slice; import com.andexert.library.RippleView; @@ -10,7 +25,6 @@ import com.vanniktech.vntnumberpickerpreference.CustomPickerPopup; import com.vanniktech.vntnumberpickerpreference.ParameterEntity; import com.vanniktech.vntnumberpickerpreference.PreferenceUtils; import com.vanniktech.vntnumberpickerpreference.sample.MainAbility; -import com.vanniktech.vntnumberpickerpreference.sample.MyApplication; import com.vanniktech.vntnumberpickerpreference.sample.ResourceTable; import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.content.Intent; @@ -19,12 +33,17 @@ import ohos.agp.components.Component; import ohos.agp.components.Image; import ohos.agp.components.Text; +/** + * SettingsAbilitySlice + * + * @since 2021-06-15 + */ public class SettingsAbilitySlice extends AbilitySlice implements Component.ClickedListener { - private Image imageFinish; - private RippleView rvFont; - private RippleView rvBody; - private RippleView rvCallback; - private RippleView rvCustom; + private static final int FONTMINVALUE = 8; + private static final int FONTMAXVALUE = 100; + private static final int BODYMINVALUE = 40; + private static final int BODYMAXVALUE = 250; + private static final int CALLBACKMAXVALUE = 10; private Text fontTitle; private Text bodyTitle; private Text callbackTitle; @@ -33,7 +52,7 @@ public class SettingsAbilitySlice extends AbilitySlice implements Component.Clic private Text bodyContent; private Text callbackContent; private Text customContent; - private ParameterEntity parameterEntity = new ParameterEntity(); + private final ParameterEntity parameterEntity = new ParameterEntity(); @Override public void onStart(Intent intent) { @@ -43,12 +62,17 @@ public class SettingsAbilitySlice extends AbilitySlice implements Component.Clic initData(); } - public void initComponent() { - imageFinish = (Image) findComponentById(ResourceTable.Id_image_finish); - rvFont = (RippleView) findComponentById(ResourceTable.Id_rv_font); - rvBody = (RippleView) findComponentById(ResourceTable.Id_rv_body); - rvCallback = (RippleView) findComponentById(ResourceTable.Id_rv_callback); - rvCustom = (RippleView) findComponentById(ResourceTable.Id_rv_custom); + private void initComponent() { + Image imageFinish = (Image) findComponentById(ResourceTable.Id_image_finish); + imageFinish.setClickedListener(this); + RippleView rvFont = (RippleView) findComponentById(ResourceTable.Id_rv_font); + rvFont.setClickedListener(this); + RippleView rvBody = (RippleView) findComponentById(ResourceTable.Id_rv_body); + rvBody.setClickedListener(this); + RippleView rvCallback = (RippleView) findComponentById(ResourceTable.Id_rv_callback); + rvCallback.setClickedListener(this); + RippleView rvCustom = (RippleView) findComponentById(ResourceTable.Id_rv_custom); + rvCustom.setClickedListener(this); fontTitle = (Text) findComponentById(ResourceTable.Id_font_title); bodyTitle = (Text) findComponentById(ResourceTable.Id_body_title); callbackTitle = (Text) findComponentById(ResourceTable.Id_callback_title); @@ -57,14 +81,9 @@ public class SettingsAbilitySlice extends AbilitySlice implements Component.Clic bodyContent = (Text) findComponentById(ResourceTable.Id_body_content); callbackContent = (Text) findComponentById(ResourceTable.Id_callback_content); customContent = (Text) findComponentById(ResourceTable.Id_custom_content); - imageFinish.setClickedListener(this::onClick); - rvFont.setClickedListener(this::onClick); - rvBody.setClickedListener(this::onClick); - rvCallback.setClickedListener(this::onClick); - rvCustom.setClickedListener(this::onClick); } - public void initData() { + private void initData() { fontContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.FONT_SIZE, "25")); bodyContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.BODY_SIZE, "180")); callbackContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.CALLBACK, "1")); @@ -87,92 +106,117 @@ public class SettingsAbilitySlice extends AbilitySlice implements Component.Clic public void onClick(Component component) { switch (component.getId()) { case ResourceTable.Id_image_finish: - Intent intent = new Intent(); - Operation operation = new Intent.OperationBuilder() - .withDeviceId("") - .withBundleName(getAbilityPackageContext().getBundleName()) - .withAbilityName(MainAbility.class.getName()) - .build(); - intent.setOperation(operation); - startAbility(intent); - terminateAbility(); + finish(); break; case ResourceTable.Id_rv_font: - parameterEntity.setKey(Constants.FONT_SIZE); - parameterEntity.setMinValue(8); - parameterEntity.setMaxValue(100); - parameterEntity.setWheelModeEnabled(true); - parameterEntity.setValue(fontContent.getText()); - parameterEntity.setTitle(fontTitle.getText()); - new XPopup.Builder(getContext()) - .popupAnimation(PopupAnimation.NoAnimation) - .setPopupCallback(new SimpleCallback() { - @Override - public void onDismiss(BasePopupView basePopupView) { - // 完全隐藏的时候执行 - fontContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.FONT_SIZE, "25")); - } - }) - .asCustom(new CustomPickerPopup(parameterEntity)) - .show(); + font(); break; case ResourceTable.Id_rv_body: - parameterEntity.setKey(Constants.BODY_SIZE); - parameterEntity.setMinValue(40); - parameterEntity.setMaxValue(250); - parameterEntity.setWheelModeEnabled(false); - parameterEntity.setValue(bodyContent.getText()); - parameterEntity.setTitle(bodyTitle.getText()); - new XPopup.Builder(getContext()) - .popupAnimation(PopupAnimation.NoAnimation) - .setPopupCallback(new SimpleCallback() { - @Override - public void onDismiss(BasePopupView basePopupView) { - // 完全隐藏的时候执行 - bodyContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.BODY_SIZE, "180")); - } - }) - .asCustom(new CustomPickerPopup(parameterEntity)) - .show(); + body(); break; case ResourceTable.Id_rv_callback: - parameterEntity.setKey(Constants.CALLBACK); - parameterEntity.setMinValue(0); - parameterEntity.setMaxValue(10); - parameterEntity.setWheelModeEnabled(false); - parameterEntity.setValue(callbackContent.getText()); - parameterEntity.setTitle(callbackTitle.getText()); - new XPopup.Builder(getContext()) - .popupAnimation(PopupAnimation.NoAnimation) - .setPopupCallback(new SimpleCallback() { - @Override - public void onDismiss(BasePopupView basePopupView) { - // 完全隐藏的时候执行 - callbackContent.setText(PreferenceUtils.getString(getApplicationContext(), Constants.CALLBACK, "1")); - } - }) - .asCustom(new CustomPickerPopup(parameterEntity)) - .show(); + callback(); break; case ResourceTable.Id_rv_custom: - parameterEntity.setKey(Constants.CUSTOM_SUMMARY); - parameterEntity.setMinValue(0); - parameterEntity.setMaxValue(100); - parameterEntity.setWheelModeEnabled(false); - parameterEntity.setValue(customContent.getText()); - parameterEntity.setTitle(customTitle.getText()); - new XPopup.Builder(getContext()) - .popupAnimation(PopupAnimation.NoAnimation) - .setPopupCallback(new SimpleCallback() { - @Override - public void onDismiss(BasePopupView basePopupView) { - // 完全隐藏的时候执行 - customContent.setText("My custom summary text. Value is " + PreferenceUtils.getString(getApplicationContext(), Constants.CUSTOM_SUMMARY, "10")); - } - }) - .asCustom(new CustomPickerPopup(parameterEntity)) - .show(); + custom(); break; + default: } } + + private void finish() { + Intent intent = new Intent(); + Operation operation = new Intent.OperationBuilder() + .withDeviceId("") + .withBundleName(getAbilityPackageContext().getBundleName()) + .withAbilityName(MainAbility.class.getName()) + .build(); + intent.setOperation(operation); + startAbility(intent); + terminateAbility(); + } + + private void font() { + parameterEntity.setKey(Constants.FONT_SIZE); + parameterEntity.setMinValue(FONTMINVALUE); + parameterEntity.setMaxValue(FONTMAXVALUE); + parameterEntity.setWheelModeEnabled(true); + parameterEntity.setValue(fontContent.getText()); + parameterEntity.setTitle(fontTitle.getText()); + new XPopup.Builder(getContext()) + .popupAnimation(PopupAnimation.NoAnimation) + .setPopupCallback(new SimpleCallback() { + @Override + public void onDismiss(BasePopupView basePopupView) { + // 完全隐藏的时候执行 + fontContent.setText(PreferenceUtils.getString(getApplicationContext(), + Constants.FONT_SIZE, "25")); + } + }) + .asCustom(new CustomPickerPopup(parameterEntity)) + .show(); + } + + private void body() { + parameterEntity.setKey(Constants.BODY_SIZE); + parameterEntity.setMinValue(BODYMINVALUE); + parameterEntity.setMaxValue(BODYMAXVALUE); + parameterEntity.setWheelModeEnabled(false); + parameterEntity.setValue(bodyContent.getText()); + parameterEntity.setTitle(bodyTitle.getText()); + new XPopup.Builder(getContext()) + .popupAnimation(PopupAnimation.NoAnimation) + .setPopupCallback(new SimpleCallback() { + @Override + public void onDismiss(BasePopupView basePopupView) { + // 完全隐藏的时候执行 + bodyContent.setText(PreferenceUtils.getString(getApplicationContext(), + Constants.BODY_SIZE, "180")); + } + }) + .asCustom(new CustomPickerPopup(parameterEntity)) + .show(); + } + + private void callback() { + parameterEntity.setKey(Constants.CALLBACK); + parameterEntity.setMinValue(0); + parameterEntity.setMaxValue(CALLBACKMAXVALUE); + parameterEntity.setWheelModeEnabled(false); + parameterEntity.setValue(callbackContent.getText()); + parameterEntity.setTitle(callbackTitle.getText()); + new XPopup.Builder(getContext()) + .popupAnimation(PopupAnimation.NoAnimation) + .setPopupCallback(new SimpleCallback() { + @Override + public void onDismiss(BasePopupView basePopupView) { + // 完全隐藏的时候执行 + callbackContent.setText(PreferenceUtils.getString(getApplicationContext(), + Constants.CALLBACK, "1")); + } + }) + .asCustom(new CustomPickerPopup(parameterEntity)) + .show(); + } + + private void custom() { + parameterEntity.setKey(Constants.CUSTOM_SUMMARY); + parameterEntity.setMinValue(0); + parameterEntity.setMaxValue(FONTMAXVALUE); + parameterEntity.setWheelModeEnabled(false); + parameterEntity.setValue(customContent.getText()); + parameterEntity.setTitle(customTitle.getText()); + new XPopup.Builder(getContext()) + .popupAnimation(PopupAnimation.NoAnimation) + .setPopupCallback(new SimpleCallback() { + @Override + public void onDismiss(BasePopupView basePopupView) { + // 完全隐藏的时候执行 + customContent.setText("My custom summary text. Value is " + + PreferenceUtils.getString(getApplicationContext(), Constants.CUSTOM_SUMMARY, "10")); + } + }) + .asCustom(new CustomPickerPopup(parameterEntity)) + .show(); + } } diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index a1b7d42087dd759ad6095b80bd9321dddfbf1a32..5311a0cd0c342ee8b44395c0c9f1405e83c36e1a 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -19,6 +19,10 @@ { "name": "settingsability_HelloWorld", "value": "Hello World" + }, + { + "name": "url", + "value": "https://github.com/vanniktech/VNTNumberPickerPreference" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/url.text b/entry/src/main/resources/rawfile/url.text new file mode 100644 index 0000000000000000000000000000000000000000..13d816e50d21b67e0ac1f526b88705329668229f --- /dev/null +++ b/entry/src/main/resources/rawfile/url.text @@ -0,0 +1 @@ +https://github.com/vanniktech/VNTNumberPickerPreference \ No newline at end of file diff --git a/entry/src/ohosTest/java/com/vanniktech/vntnumberpickerpreference/sample/PreferenceUtilsTest.java b/entry/src/ohosTest/java/com/vanniktech/vntnumberpickerpreference/sample/PreferenceUtilsTest.java index d9b11d737e6c192291d80c56d6ff474b9169cf3e..50a8f00419afa3fa762c0a682e90ba18131fd6b6 100644 --- a/entry/src/ohosTest/java/com/vanniktech/vntnumberpickerpreference/sample/PreferenceUtilsTest.java +++ b/entry/src/ohosTest/java/com/vanniktech/vntnumberpickerpreference/sample/PreferenceUtilsTest.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain an copy of the License at + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * diff --git a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/Constants.java b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/Constants.java index 62dfe46afb5af8c903dec0aadd7ad28aa9c03f92..50ac42d652b3fe3312dc9cf5c4a3f351594bc96f 100644 --- a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/Constants.java +++ b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/Constants.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain an copy of the License at + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * diff --git a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/CustomPickerPopup.java b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/CustomPickerPopup.java index d9d56c32aeeda5efe38beac8d3737a91ee09108c..10a8bca4d57b02d8e7970672a51c4fb674d8b8dd 100644 --- a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/CustomPickerPopup.java +++ b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/CustomPickerPopup.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain an copy of the License at + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * diff --git a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/ParameterEntity.java b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/ParameterEntity.java index 3376e6755de161a667716548f42848f919ddc1c3..0839b09d1194c1fa63a9795fc1ab87dd912ff1ce 100644 --- a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/ParameterEntity.java +++ b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/ParameterEntity.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain an copy of the License at + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * diff --git a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/PreferenceUtils.java b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/PreferenceUtils.java index 73c648d302f6dee7fbd1c2bcf4b52911c337fef3..09baea755b256f2d8217261e4cc94bacd5817f69 100644 --- a/library/src/main/java/com/vanniktech/vntnumberpickerpreference/PreferenceUtils.java +++ b/library/src/main/java/com/vanniktech/vntnumberpickerpreference/PreferenceUtils.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain an copy of the License at + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 *