diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..14b660e489ec28bf53cfa8d2c5d52dd361458b8b
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,15 @@
+## 0.0.1-SNAPSHOT
+
+StoriesProgressView组件openharmony beta版本
+
+#### api差异
+
+- 无
+
+#### 已实现功能
+
+- 该库基本功能已全部实现
+
+#### 未实现功能
+
+- 无
\ No newline at end of file
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..9a485f67f38c43682e664e242d6388deb0763ba3
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,10 @@
+[
+ {
+ "Name": "StoriesProgressView",
+ "License": "Apache-2.0",
+ "License File": "LICENSE",
+ "Version Number": "Release 3.0.0",
+ "Upstream URL": "https://github.com/shts/StoriesProgressView",
+ "Description": "Library that shows a horizontal progress like Instagram stories."
+ }
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 630e880a86f64994ed504542d7c401ec78322665..c4033637144ffbadb9ffb0195110f5ff51a6a62b 100644
--- a/README.md
+++ b/README.md
@@ -1,40 +1,67 @@
-StoriesProgressView
-====
+# StoriesProgressView
-Library that shows a horizontal progress like Instagram stories.
-[](https://jitpack.io/#shts/StoriesProgressView)
+#### 项目介绍
+- 项目名称:StoriesProgressView
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:像Instagram stories那样展示横向进度的库
+- 项目移植状态:已完成
+- 调用差异:无
+- 开发版本:sdk5,DevEco Studio2.1 beta4
+- 基线版本: tags 3.0.0
-
-
+#### 效果演示
+
-^She is [Yui Kobayashi](http://www.keyakizaka46.com/s/k46o/artist/07)
+#### 安装教程
-How to Use
-----
-To see how a StoriesProgressView can be added to your xml layouts, check the sample project.
+1.在项目根目录下的build.gradle文件中
+
+```groovy
+allprojects {
+ repositories {
+ ...
+ maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
+ }
+}
+
+```
+
+2.在entry模块的build.gradle文件中
+
+```
+dependencies {
+ implementation('com.gitee.chinasoft_ohos:StoriesProgressView:0.0.1-SNAPSHOT')
+}
+
+```
+
+#### 使用说明
+
+要查看如何将StoriesProgressView添加到xml布局,请查看示例项目.
```xml
-
+
```
-Overview
+在 AbilitySlice 中
```java
-public class YourActivity extends AppCompatActivity implements StoriesProgressView.StoriesListener {
+public class YourAbilitySlice extends AbilitySlice implements StoriesProgressView.StoriesListener {
private StoriesProgressView storiesProgressView;
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_ability_main);
- storiesProgressView = (StoriesProgressView) findViewById(R.id.stories);
+ storiesProgressView = (StoriesProgressView) findComponentById(R.id.stories);
storiesProgressView.setStoriesCount(PROGRESS_COUNT); // <- set stories
storiesProgressView.setStoryDuration(1200L); // <- set a story duration
storiesProgressView.setStoriesListener(this); // <- set listener
@@ -58,60 +85,43 @@ public class YourActivity extends AppCompatActivity implements StoriesProgressVi
}
@Override
- protected void onDestroy() {
- // Very important !
- storiesProgressView.destroy();
- super.onDestroy();
+ protected void onStop() {
+ // Very important !
+ storiesProgressView.destroy();
+ super.onStop();
}
}
```
-Skip and Reverse story
----
-
-
+跳过和反向
```java
storiesProgressView.skip();
storiesProgressView.reverse();
```
-Pause and Resume story
----
-
+暂停并继续
```java
storiesProgressView.pause();
storiesProgressView.resume();
```
+#### 测试信息
-Install
----
+CodeCheck代码测试无异常
-Add it in your root build.gradle at the end of repositories:
+CloudTest代码测试无异常
-```groovy
-allprojects {
- repositories {
- ...
- maven { url "https://jitpack.io" }
- }
-}
+火绒安全病毒安全检测通过
-```
+当前版本demo功能与原组件基本无差异
-Add the dependency
+#### 版本迭代
-```
-dependencies {
- implementation 'com.github.shts:StoriesProgressView:3.0.0'
-}
-
-```
+- 0.0.1-SNAPSHOT
-License
----
+#### 版权和许可信息
```
Copyright (C) 2017 Shota Saito(shts)
diff --git a/app/build.gradle b/app/build.gradle
index 9c6e3abcb4dc0a40a9dcfbb45d15ce009ddeea3f..7d9b70feb2ce680e9da32a655f12d8b6d4e77d98 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,31 +1,27 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 28
- buildToolsVersion '28.0.3'
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- applicationId "jp.shts.android.storyprogressbar"
- minSdkVersion 15
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- implementation project(':library')
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ compile project(path: ':library')
+}
+decc {
+ supportType = ['html', 'xml']
}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 2ad715d44ff935090341bc21f1ba8c79f90d0907..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -1,25 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/a/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 9505e53d6448628a1382a7f26a94c33bae5f9d22..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/config.json b/app/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..38ffd6c3d3f6dafe9b4ce82d072fd343f5e58fdf
--- /dev/null
+++ b/app/src/main/config.json
@@ -0,0 +1,59 @@
+{
+ "app": {
+ "bundleName": "jp.shts.ability.storyprogressbar",
+ "vendor": "shts",
+ "version": {
+ "code": 1,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "jp.shts.ability.storyprogressbar",
+ "name": "jp.shts.ability.storyprogressbar.MyApplication",
+ "deviceType": [
+ "phone",
+ "tv"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "app",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "jp.shts.ability.storyprogressbar.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard",
+ "metaData": {
+ "customizeData": [
+ {
+ "extra": "",
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar"
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/jp/shts/ability/storyprogressbar/MainAbility.java b/app/src/main/java/jp/shts/ability/storyprogressbar/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..0bcbaf50f16f26e772c618fadc80b215de140f12
--- /dev/null
+++ b/app/src/main/java/jp/shts/ability/storyprogressbar/MainAbility.java
@@ -0,0 +1,13 @@
+package jp.shts.ability.storyprogressbar;
+
+import jp.shts.ability.storyprogressbar.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/app/src/main/java/jp/shts/ability/storyprogressbar/MyApplication.java b/app/src/main/java/jp/shts/ability/storyprogressbar/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..cf551d132ff8b9ca4770f0fc4de70fc75655ed8b
--- /dev/null
+++ b/app/src/main/java/jp/shts/ability/storyprogressbar/MyApplication.java
@@ -0,0 +1,10 @@
+package jp.shts.ability.storyprogressbar;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/app/src/main/java/jp/shts/android/storyprogressbar/MainActivity.java b/app/src/main/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySlice.java
similarity index 39%
rename from app/src/main/java/jp/shts/android/storyprogressbar/MainActivity.java
rename to app/src/main/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySlice.java
index 986b5193d1da92f21a1927d18214a58b6faf2c44..bf520ad55484b5ea939c0bbc707221c346f8537d 100644
--- a/app/src/main/java/jp/shts/android/storyprogressbar/MainActivity.java
+++ b/app/src/main/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySlice.java
@@ -1,29 +1,29 @@
-package jp.shts.android.storyprogressbar;
+package jp.shts.ability.storyprogressbar.slice;
-import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.ImageView;
+import jp.shts.ability.storiesprogressview.StoriesProgressView;
+import jp.shts.ability.storyprogressbar.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.window.service.WindowManager;
+import ohos.multimodalinput.event.TouchEvent;
-import jp.shts.android.storiesprogressview.StoriesProgressView;
-
-public class MainActivity extends AppCompatActivity implements StoriesProgressView.StoriesListener {
+public class MainAbilitySlice extends AbilitySlice implements StoriesProgressView.StoriesListener {
private static final int PROGRESS_COUNT = 6;
private StoriesProgressView storiesProgressView;
- private ImageView image;
+ private Image image;
private int counter = 0;
private final int[] resources = new int[]{
- R.drawable.sample1,
- R.drawable.sample2,
- R.drawable.sample3,
- R.drawable.sample4,
- R.drawable.sample5,
- R.drawable.sample6,
+ ResourceTable.Media_sample1,
+ ResourceTable.Media_sample2,
+ ResourceTable.Media_sample3,
+ ResourceTable.Media_sample4,
+ ResourceTable.Media_sample5,
+ ResourceTable.Media_sample6,
};
private final long[] durations = new long[]{
@@ -33,82 +33,95 @@ public class MainActivity extends AppCompatActivity implements StoriesProgressVi
long pressTime = 0L;
long limit = 500L;
- private View.OnTouchListener onTouchListener = new View.OnTouchListener() {
+ private Component.TouchEventListener onTouchListener = new Component.TouchEventListener() {
@Override
- public boolean onTouch(View v, MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
+ public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
+ switch (touchEvent.getAction()) {
+ case TouchEvent.PRIMARY_POINT_DOWN:
pressTime = System.currentTimeMillis();
storiesProgressView.pause();
- return false;
- case MotionEvent.ACTION_UP:
+ return true;
+ case TouchEvent.PRIMARY_POINT_UP:
long now = System.currentTimeMillis();
storiesProgressView.resume();
return limit < now - pressTime;
}
- return false;
+ return true;
}
};
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_main);
+ public void onStart(Intent intent) {
+ getWindow().addFlags(WindowManager.LayoutConfig.MARK_FULL_SCREEN);
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_ability_main);
- storiesProgressView = (StoriesProgressView) findViewById(R.id.stories);
+ storiesProgressView = (StoriesProgressView) findComponentById(ResourceTable.Id_stories);
storiesProgressView.setStoriesCount(PROGRESS_COUNT);
storiesProgressView.setStoryDuration(3000L);
// or
- // storiesProgressView.setStoriesCountWithDurations(durations);
+// storiesProgressView.setStoriesCountWithDurations(durations);
storiesProgressView.setStoriesListener(this);
// storiesProgressView.startStories();
counter = 2;
storiesProgressView.startStories(counter);
- image = (ImageView) findViewById(R.id.image);
- image.setImageResource(resources[counter]);
+ image = (Image) findComponentById(ResourceTable.Id_image);
+ image.setPixelMap(resources[counter]);
// bind reverse view
- View reverse = findViewById(R.id.reverse);
- reverse.setOnClickListener(new View.OnClickListener() {
+ Component reverse = findComponentById(ResourceTable.Id_reverse);
+ reverse.setTouchEventListener(onTouchListener);
+ reverse.setClickedListener(new Component.ClickedListener() {
@Override
- public void onClick(View v) {
+ public void onClick(Component component) {
storiesProgressView.reverse();
}
});
- reverse.setOnTouchListener(onTouchListener);
+
// bind skip view
- View skip = findViewById(R.id.skip);
- skip.setOnClickListener(new View.OnClickListener() {
+ Component skip = findComponentById(ResourceTable.Id_skip);
+ skip.setTouchEventListener(onTouchListener);
+ skip.setClickedListener(new Component.ClickedListener() {
@Override
- public void onClick(View v) {
+ public void onClick(Component component) {
storiesProgressView.skip();
}
});
- skip.setOnTouchListener(onTouchListener);
+
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
}
@Override
public void onNext() {
- image.setImageResource(resources[++counter]);
+ image.setPixelMap(resources[++counter]);
}
@Override
public void onPrev() {
if ((counter - 1) < 0) return;
- image.setImageResource(resources[--counter]);
+ image.setPixelMap(resources[--counter]);
}
@Override
public void onComplete() {
+
}
@Override
- protected void onDestroy() {
+ protected void onStop() {
// Very important !
storiesProgressView.destroy();
- super.onDestroy();
+ super.onStop();
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 6568439e30f4e635092678fb45743cb0a3f49402..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 9a078e3e1a42d474c78470a73c7987cf7ac5d9a0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index efc028a636dd690a51db5a525cf781a5a7daba68..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 3af2608a4492ef9ae63a77ec3305aedda89594cb..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9bec2e623103ac9713b00cad8502a057c1efda61..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 34947cd6bbf9c729be83edc96ad08a1d42b82bc9..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 47e712f81da2f2310ab4ac2ed84c2136401c03e4..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #9E9E9E
- #616161
- #FF4081
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index e8e22a49dd824deec81e75204b26209be23dafe9..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- StoryProgressBar
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 5e404d91d4f0049491920c10141e038d697d0e4c..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/app/src/main/resources/base/element/color.json b/app/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..319d59090eead256a07f79c016c4c5274549a1e0
--- /dev/null
+++ b/app/src/main/resources/base/element/color.json
@@ -0,0 +1,16 @@
+{
+ "color": [
+ {
+ "name": "progress_secondary",
+ "value": "#8affffff"
+ },
+ {
+ "name": "progress_primary",
+ "value": "#ffffff"
+ },
+ {
+ "name": "progress_max_active",
+ "value": "#ffffff"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/app/src/main/resources/base/element/string.json b/app/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1e4dc8ab30a2065ab477e084be25a598ecddc9f9
--- /dev/null
+++ b/app/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "StoryProgressBar"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/app/src/main/resources/base/graphic/background_ability_main.xml b/app/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/app/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/resources/base/layout/ability_main.xml b/app/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..15bfd7a4185d5909accf087401e5e70e75c3b1fe
--- /dev/null
+++ b/app/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/resources/base/layout/pausable_progress.xml b/app/src/main/resources/base/layout/pausable_progress.xml
new file mode 100644
index 0000000000000000000000000000000000000000..392e4adc0c434daf81538bd4d0f33c5d131fdfea
--- /dev/null
+++ b/app/src/main/resources/base/layout/pausable_progress.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/resources/base/media/icon.png b/app/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/app/src/main/resources/base/media/icon.png differ
diff --git a/app/src/main/res/drawable/sample1.jpg b/app/src/main/resources/base/media/sample1.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample1.jpg
rename to app/src/main/resources/base/media/sample1.jpg
diff --git a/app/src/main/res/drawable/sample2.jpg b/app/src/main/resources/base/media/sample2.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample2.jpg
rename to app/src/main/resources/base/media/sample2.jpg
diff --git a/app/src/main/res/drawable/sample3.jpg b/app/src/main/resources/base/media/sample3.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample3.jpg
rename to app/src/main/resources/base/media/sample3.jpg
diff --git a/app/src/main/res/drawable/sample4.jpg b/app/src/main/resources/base/media/sample4.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample4.jpg
rename to app/src/main/resources/base/media/sample4.jpg
diff --git a/app/src/main/res/drawable/sample5.jpg b/app/src/main/resources/base/media/sample5.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample5.jpg
rename to app/src/main/resources/base/media/sample5.jpg
diff --git a/app/src/main/res/drawable/sample6.jpg b/app/src/main/resources/base/media/sample6.jpg
similarity index 100%
rename from app/src/main/res/drawable/sample6.jpg
rename to app/src/main/resources/base/media/sample6.jpg
diff --git a/app/src/ohosTest/config.json b/app/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..671ed54165b3155f6794aa9499aaf6ceb66ba2fe
--- /dev/null
+++ b/app/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "jp.shts.ability.storyprogressbar",
+ "vendor": "shts",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "jp.shts.ability.storyprogressbar",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/ExampleOhosTest.java b/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..84cc6f033d2803f18fdbce0fbf93bd15bb43e739
--- /dev/null
+++ b/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/ExampleOhosTest.java
@@ -0,0 +1,14 @@
+package jp.shts.ability.storyprogressbar;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("jp.shts.ability.storyprogressbar", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySliceOhosTest.java b/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySliceOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..76a0c8eb46ec9b655c0b1f5dc5c4407fe37ac953
--- /dev/null
+++ b/app/src/ohosTest/java/jp/shts/ability/storyprogressbar/slice/MainAbilitySliceOhosTest.java
@@ -0,0 +1,34 @@
+package jp.shts.ability.storyprogressbar.slice;
+
+import org.junit.Test;
+
+public class MainAbilitySliceOhosTest {
+
+ @Test
+ public void onStart() {
+ }
+
+ @Test
+ public void onActive() {
+ }
+
+ @Test
+ public void onForeground() {
+ }
+
+ @Test
+ public void onNext() {
+ }
+
+ @Test
+ public void onPrev() {
+ }
+
+ @Test
+ public void onComplete() {
+ }
+
+ @Test
+ public void onStop() {
+ }
+}
\ No newline at end of file
diff --git a/app/src/test/java/jp/shts/ability/storyprogressbar/ExampleTest.java b/app/src/test/java/jp/shts/ability/storyprogressbar/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ebdd0eec2912a9672259b69dda457b81372fea0b
--- /dev/null
+++ b/app/src/test/java/jp/shts/ability/storyprogressbar/ExampleTest.java
@@ -0,0 +1,9 @@
+package jp.shts.ability.storyprogressbar;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/build.gradle b/build.gradle
index 68e19b3f15d9c08efa1079ffc7ef08a9a53b47fe..1dc510ffd5a8d3abe3f2758e193a2619aca86563 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,26 +1,37 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
+
buildscript {
repositories {
- jcenter()
- mavenCentral()
- google()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.1'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.2.7'
+ classpath 'com.huawei.ohos:decctest:1.0.0.7'
}
}
allprojects {
repositories {
- jcenter()
- google()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/gradle.properties b/gradle.properties
index 9e6fce102d11ffba5aae545fe7b688386407e699..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,19 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-android.enableJetifier=true
-android.useAndroidX=true
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 631a2b55e00687c2438d26f49be5da3a7fe7f8df..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Thu Oct 24 21:57:42 EEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec99730b4e8fcd90b57a0e8e01544fea7c31a89..9109989e3cbf666b0a3c8f48fd92bd03bb53b968 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/library/build.gradle b/library/build.gradle
index 5c2dd287612b02cb0c5f296b69608ee9ed7eb556..25ddf0cf1daa8f1533639ebc05ce352f4019b8ff 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,31 +1,21 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 28
- buildToolsVersion '28.0.3'
-
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- implementation 'androidx.appcompat:appcompat:1.1.0'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index 2ad715d44ff935090341bc21f1ba8c79f90d0907..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,25 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/a/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/androidTest/java/jp/shts/android/storiesprogressview/ExampleInstrumentedTest.java b/library/src/androidTest/java/jp/shts/android/storiesprogressview/ExampleInstrumentedTest.java
deleted file mode 100644
index 8d9312f7d231a179ee7982ac46669023f2306182..0000000000000000000000000000000000000000
--- a/library/src/androidTest/java/jp/shts/android/storiesprogressview/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package jp.shts.android.storiesprogressview;
-
-import android.content.Context;
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
-
- assertEquals("jp.shts.android.storiesprogressview.test", appContext.getPackageName());
- }
-}
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index 4309c5f7e1767a0b2a8797e6bd3d61a48ba074b2..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..b7fb7b4a0366fe4904affb789820f3615a86bd59
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,29 @@
+{
+ "app": {
+ "bundleName": "jp.shts.ability.storiesprogressview",
+ "vendor": "shts",
+ "version": {
+ "code": 1,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "jp.shts.ability.storiesprogressview",
+ "deviceType": [
+ "phone",
+ "tv"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/jp/shts/android/storiesprogressview/PausableProgressBar.java b/library/src/main/java/jp/shts/ability/storiesprogressview/PausableProgressBar.java
similarity index 32%
rename from library/src/main/java/jp/shts/android/storiesprogressview/PausableProgressBar.java
rename to library/src/main/java/jp/shts/ability/storiesprogressview/PausableProgressBar.java
index af7e472c6d6db1bac78e3c59da5970199b564feb..5af579fc16b222418528c6d7151d5fabceea5d9c 100644
--- a/library/src/main/java/jp/shts/android/storiesprogressview/PausableProgressBar.java
+++ b/library/src/main/java/jp/shts/ability/storiesprogressview/PausableProgressBar.java
@@ -1,34 +1,37 @@
-package jp.shts.android.storiesprogressview;
-
-import android.content.Context;
-import androidx.annotation.AttrRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.LinearInterpolator;
-import android.view.animation.ScaleAnimation;
-import android.view.animation.Transformation;
-import android.widget.FrameLayout;
-
-final class PausableProgressBar extends FrameLayout {
-
+package jp.shts.ability.storiesprogressview;
+
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.StackLayout;
+import ohos.agp.components.element.Element;
+import ohos.agp.components.element.ShapeElement;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+
+public class PausableProgressBar extends StackLayout {
/***
* progress満了タイマーのデフォルト時間
*/
private static final int DEFAULT_PROGRESS_DURATION = 2000;
+ HiLogLabel TAG = new HiLogLabel(HiLog.LOG_APP, 0, "PausableProgressBar");
+ private Component backProgressView;
+ private Component frontProgressView;
+ private Component maxProgressView;
- private View frontProgressView;
- private View maxProgressView;
-
- private PausableScaleAnimation animation;
+ private AnimatorValue animation;
private long duration = DEFAULT_PROGRESS_DURATION;
private Callback callback;
+ private int progressWidth = 0;
interface Callback {
void onStartProgress();
+
void onFinishProgress();
}
@@ -36,22 +39,35 @@ final class PausableProgressBar extends FrameLayout {
this(context, null);
}
- public PausableProgressBar(@NonNull Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
+ public PausableProgressBar(Context context, AttrSet attrs) {
+ this(context, attrs, "");
}
- public PausableProgressBar(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- LayoutInflater.from(context).inflate(R.layout.pausable_progress, this);
- frontProgressView = findViewById(R.id.front_progress);
- maxProgressView = findViewById(R.id.max_progress); // work around
+ public PausableProgressBar(Context context, AttrSet attrs, String styleName) {
+ super(context, attrs, styleName);
+ LayoutScatter.getInstance(context).parse(ResourceTable.Layout_pausable_progress, this, true);
+ backProgressView = findComponentById(ResourceTable.Id_back_progress);
+ frontProgressView = findComponentById(ResourceTable.Id_front_progress);
+ maxProgressView = findComponentById(ResourceTable.Id_max_progress); // work around
+ setBindStateChangedListener(new BindStateChangedListener() {
+ @Override
+ public void onComponentBoundToWindow(Component component) {
+ progressWidth = backProgressView.getEstimatedWidth();
+ removeBindStateChangedListener(this);
+ }
+
+ @Override
+ public void onComponentUnboundFromWindow(Component component) {
+
+ }
+ });
}
public void setDuration(long duration) {
this.duration = duration;
}
- public void setCallback(@NonNull Callback callback) {
+ public void setCallback(Callback callback) {
this.callback = callback;
}
@@ -64,30 +80,31 @@ final class PausableProgressBar extends FrameLayout {
}
void setMinWithoutCallback() {
- maxProgressView.setBackgroundResource(R.color.progress_secondary);
+ maxProgressView.setBackground(getColorDrawable(ResourceTable.Color_progress_secondary));
maxProgressView.setVisibility(VISIBLE);
if (animation != null) {
- animation.setAnimationListener(null);
+ animation.setStateChangedListener(null);
animation.cancel();
}
}
void setMaxWithoutCallback() {
- maxProgressView.setBackgroundResource(R.color.progress_max_active);
+ maxProgressView.setBackground(getColorDrawable(ResourceTable.Color_progress_max_active));
maxProgressView.setVisibility(VISIBLE);
if (animation != null) {
- animation.setAnimationListener(null);
+ animation.setStateChangedListener(null);
animation.cancel();
}
}
private void finishProgress(boolean isMax) {
- if (isMax) maxProgressView.setBackgroundResource(R.color.progress_max_active);
- maxProgressView.setVisibility(isMax ? VISIBLE : GONE);
+ if (isMax) maxProgressView.setBackground(getColorDrawable(ResourceTable.Color_progress_max_active));
+
+ maxProgressView.setVisibility(isMax ? VISIBLE : HIDE);
if (animation != null) {
- animation.setAnimationListener(null);
+ animation.setStateChangedListener(null);
animation.cancel();
if (callback != null) {
callback.onFinishProgress();
@@ -96,29 +113,45 @@ final class PausableProgressBar extends FrameLayout {
}
public void startProgress() {
- maxProgressView.setVisibility(GONE);
-
- animation = new PausableScaleAnimation(0, 1, 1, 1, Animation.ABSOLUTE, 0, Animation.RELATIVE_TO_SELF, 0);
+ maxProgressView.setVisibility(HIDE);
+ animation = new AnimatorValue();
animation.setDuration(duration);
- animation.setInterpolator(new LinearInterpolator());
- animation.setAnimationListener(new Animation.AnimationListener() {
+ animation.setCurveType(AnimatorValue.CurveType.LINEAR);
+ animation.setStateChangedListener(new Animator.StateChangedListener() {
@Override
- public void onAnimationStart(Animation animation) {
- frontProgressView.setVisibility(View.VISIBLE);
+ public void onStart(Animator animator) {
+ frontProgressView.setVisibility(VISIBLE);
if (callback != null) callback.onStartProgress();
}
@Override
- public void onAnimationRepeat(Animation animation) {
+ public void onStop(Animator animator) {
+ }
+
+ @Override
+ public void onCancel(Animator animator) {
}
@Override
- public void onAnimationEnd(Animation animation) {
+ public void onEnd(Animator animator) {
if (callback != null) callback.onFinishProgress();
}
+
+ @Override
+ public void onPause(Animator animator) {
+ }
+
+ @Override
+ public void onResume(Animator animator) {
+ }
+ });
+ animation.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+ frontProgressView.setWidth((int) (progressWidth * v));
+ }
});
- animation.setFillAfter(true);
- frontProgressView.startAnimation(animation);
+ animation.start();
}
public void pauseProgress() {
@@ -135,49 +168,46 @@ final class PausableProgressBar extends FrameLayout {
void clear() {
if (animation != null) {
- animation.setAnimationListener(null);
+ animation.setStateChangedListener(null);
animation.cancel();
animation = null;
}
}
- private class PausableScaleAnimation extends ScaleAnimation {
-
- private long mElapsedAtPause = 0;
- private boolean mPaused = false;
-
- PausableScaleAnimation(float fromX, float toX, float fromY,
- float toY, int pivotXType, float pivotXValue, int pivotYType,
- float pivotYValue) {
- super(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType,
- pivotYValue);
- }
-
- @Override
- public boolean getTransformation(long currentTime, Transformation outTransformation, float scale) {
- if (mPaused && mElapsedAtPause == 0) {
- mElapsedAtPause = currentTime - getStartTime();
- }
- if (mPaused) {
- setStartTime(currentTime - mElapsedAtPause);
- }
- return super.getTransformation(currentTime, outTransformation, scale);
+ void reset() {
+ if (animation != null) {
+ animation.cancel();
}
+ }
- /***
- * pause animation
- */
- void pause() {
- if (mPaused) return;
- mElapsedAtPause = 0;
- mPaused = true;
- }
- /***
- * resume animation
- */
- void resume() {
- mPaused = false;
+ /**
+ * 通过颜色id 获取elemet对象
+ *
+ * @param res
+ * @return Element
+ */
+ public Element getColorDrawable(int res) {
+ int color = getColor(res);
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setRgbColor(RgbColor.fromArgbInt(color));
+ return shapeElement;
+ }
+
+ /**
+ * 通过颜色id
+ *
+ * @param res
+ * @return int
+ */
+ public int getColor(int res) {
+ int result = 0;
+ try {
+ result = mContext.getResourceManager().getElement(res).getColor();
+ } catch (Exception e) {
+ e.printStackTrace();
}
+ return result;
}
+
}
diff --git a/library/src/main/java/jp/shts/android/storiesprogressview/StoriesProgressView.java b/library/src/main/java/jp/shts/ability/storiesprogressview/StoriesProgressView.java
similarity index 74%
rename from library/src/main/java/jp/shts/android/storiesprogressview/StoriesProgressView.java
rename to library/src/main/java/jp/shts/ability/storiesprogressview/StoriesProgressView.java
index ec8c22e4c34b82c4576dfe7979007596f53188c6..3a4527371446262a7efd928e62964a3c18a8d7b2 100644
--- a/library/src/main/java/jp/shts/android/storiesprogressview/StoriesProgressView.java
+++ b/library/src/main/java/jp/shts/ability/storiesprogressview/StoriesProgressView.java
@@ -1,24 +1,18 @@
-package jp.shts.android.storiesprogressview;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
+package jp.shts.ability.storiesprogressview;
+
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.DirectionalLayout;
+import ohos.app.Context;
import java.util.ArrayList;
import java.util.List;
-public class StoriesProgressView extends LinearLayout {
-
+public class StoriesProgressView extends DirectionalLayout {
private static final String TAG = StoriesProgressView.class.getSimpleName();
- private final LayoutParams PROGRESS_BAR_LAYOUT_PARAM = new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
- private final LayoutParams SPACE_LAYOUT_PARAM = new LayoutParams(5, LayoutParams.WRAP_CONTENT);
+ private final LayoutConfig PROGRESS_BAR_LAYOUT_PARAM = new LayoutConfig(0, LayoutConfig.MATCH_PARENT,DirectionalLayout.HORIZONTAL, 1);
+ private final LayoutConfig SPACE_LAYOUT_PARAM = new LayoutConfig(5, LayoutConfig.MATCH_CONTENT);
private final List progressBars = new ArrayList<>();
@@ -45,53 +39,50 @@ public class StoriesProgressView extends LinearLayout {
this(context, null);
}
- public StoriesProgressView(Context context, @Nullable AttributeSet attrs) {
+ public StoriesProgressView(Context context, AttrSet attrs) {
super(context, attrs);
init(context, attrs);
}
- public StoriesProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- init(context, attrs);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public StoriesProgressView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
+ public StoriesProgressView(Context context, AttrSet attrs, String styleName) {
+ super(context, attrs, styleName);
init(context, attrs);
}
- private void init(Context context, @Nullable AttributeSet attrs) {
- setOrientation(LinearLayout.HORIZONTAL);
- TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.StoriesProgressView);
- storiesCount = typedArray.getInt(R.styleable.StoriesProgressView_progressCount, 0);
- typedArray.recycle();
+ private void init(Context context, AttrSet attrSet) {
+ setOrientation(DirectionalLayout.HORIZONTAL);
+ //取不到参数报错
+ try {
+ storiesCount = attrSet.getAttr("progressCount").get().getIntegerValue();
+ } catch (Exception e){
+ e.printStackTrace();
+ }
bindViews();
}
private void bindViews() {
progressBars.clear();
- removeAllViews();
+ removeAllComponents();
for (int i = 0; i < storiesCount; i++) {
final PausableProgressBar p = createProgressBar();
progressBars.add(p);
- addView(p);
+ addComponent(p);
if ((i + 1) < storiesCount) {
- addView(createSpace());
+ addComponent(createSpace());
}
}
}
private PausableProgressBar createProgressBar() {
PausableProgressBar p = new PausableProgressBar(getContext());
- p.setLayoutParams(PROGRESS_BAR_LAYOUT_PARAM);
+ p.setLayoutConfig(PROGRESS_BAR_LAYOUT_PARAM);
return p;
}
- private View createSpace() {
- View v = new View(getContext());
- v.setLayoutParams(SPACE_LAYOUT_PARAM);
+ private Component createSpace() {
+ Component v = new Component(getContext());
+ v.setLayoutConfig(SPACE_LAYOUT_PARAM);
return v;
}
@@ -155,7 +146,7 @@ public class StoriesProgressView extends LinearLayout {
*
* @param durations milli
*/
- public void setStoriesCountWithDurations(@NonNull long[] durations) {
+ public void setStoriesCountWithDurations(long[] durations) {
storiesCount = durations.length;
bindViews();
for (int i = 0; i < progressBars.size(); i++) {
@@ -202,6 +193,7 @@ public class StoriesProgressView extends LinearLayout {
* Start progress animation
*/
public void startStories() {
+ reset();
progressBars.get(0).startProgress();
}
@@ -212,11 +204,12 @@ public class StoriesProgressView extends LinearLayout {
for (int i = 0; i < from; i++) {
progressBars.get(i).setMaxWithoutCallback();
}
+ reset();
progressBars.get(from).startProgress();
}
/**
- * Need to call when Activity or Fragment destroy
+ * Need to call when Ability or Fraction destroy
*/
public void destroy() {
for (PausableProgressBar p : progressBars) {
@@ -224,6 +217,15 @@ public class StoriesProgressView extends LinearLayout {
}
}
+ /**
+ * Need to call when startStories
+ */
+ public void reset() {
+ for (PausableProgressBar p : progressBars) {
+ p.reset();
+ }
+ }
+
/**
* Pause story
*/
diff --git a/library/src/main/res/layout/pausable_progress.xml b/library/src/main/res/layout/pausable_progress.xml
deleted file mode 100644
index 0aef0cfbee6153048884ea497f367adfedfc401f..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/pausable_progress.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
deleted file mode 100644
index fca6bd03c3e52e57013dc4b76a7d7c7dce4c0a46..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml
deleted file mode 100644
index cdeacff5f72c3fe608dd6ec358f1be7eb9790f15..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- @color/white
- @color/gray_scale
- @color/white
-
- #8affffff
- #fff
-
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
deleted file mode 100644
index ebd79f2eea128d20cb9fafb179e5fc24e66da353..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 2dp
-
\ No newline at end of file
diff --git a/library/src/main/resources/base/element/color.json b/library/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..319d59090eead256a07f79c016c4c5274549a1e0
--- /dev/null
+++ b/library/src/main/resources/base/element/color.json
@@ -0,0 +1,16 @@
+{
+ "color": [
+ {
+ "name": "progress_secondary",
+ "value": "#8affffff"
+ },
+ {
+ "name": "progress_primary",
+ "value": "#ffffff"
+ },
+ {
+ "name": "progress_max_active",
+ "value": "#ffffff"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/library/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1e2b219ccdd1183e23968586e5e2e404b41c38c9
--- /dev/null
+++ b/library/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "library"
+ }
+ ]
+}
diff --git a/library/src/main/resources/base/layout/pausable_progress.xml b/library/src/main/resources/base/layout/pausable_progress.xml
new file mode 100644
index 0000000000000000000000000000000000000000..19046fc7cb46ba2f44281cae0a785a4a5470311e
--- /dev/null
+++ b/library/src/main/resources/base/layout/pausable_progress.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
diff --git a/library/src/test/java/jp/shts/ability/storiesprogressview/ExampleTest.java b/library/src/test/java/jp/shts/ability/storiesprogressview/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1a5ca2afc6839a6204fe1d935b6641814a6eb742
--- /dev/null
+++ b/library/src/test/java/jp/shts/ability/storiesprogressview/ExampleTest.java
@@ -0,0 +1,9 @@
+package jp.shts.ability.storiesprogressview;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/library/src/test/java/jp/shts/android/storiesprogressview/ExampleUnitTest.java b/library/src/test/java/jp/shts/android/storiesprogressview/ExampleUnitTest.java
deleted file mode 100644
index ab5cf0ffff973900008b10f7a828dcdae6811eac..0000000000000000000000000000000000000000
--- a/library/src/test/java/jp/shts/android/storiesprogressview/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package jp.shts.android.storiesprogressview;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file