Skip to content

Commit 9afdd35

Browse files
Merge pull request #2 from YashDaga17/main
Pull request for ported HMOS Code
2 parents d39a71b + 7f1aead commit 9afdd35

61 files changed

Lines changed: 1666 additions & 1280 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,17 @@
1-
*~
2-
# built application files
3-
*.apk
4-
*.ap_
5-
6-
# files for the dex VM
7-
*.dex
8-
9-
# Java class files
10-
*.class
11-
12-
# generated files
13-
bin/
14-
gen/
15-
build/
16-
html/
17-
# Local configuration file (sdk path, etc)
18-
local.properties
19-
20-
.gradle
21-
22-
# Eclipse project files
23-
.classpath
24-
.project
25-
26-
# Android Studio
27-
.idea/
28-
.gradle
29-
/*/local.properties
30-
/*/out
31-
/*/*/build
32-
/*/*/production
331
*.iml
34-
*.iws
35-
*.ipr
36-
*~
37-
*.swp
38-
39-
# Mac temporary
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
4010
.DS_Store
41-
42-
node_modules/
43-
44-
deploygate.properties
45-
46-
# Crashlytics
47-
com_crashlytics_export_strings.xml
48-
crashlytics.properties
49-
crashlytics-build.properties
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
/entry/.preview
15+
.cxx
16+
/.idea
17+
upload.gradle

LICENSE.md renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Apache License
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright (C) 2014 Drivemode, Inc. All rights reserved.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 87 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,141 @@
11
# TypefaceHelper
22

3-
[![Gitter](http://img.shields.io/badge/Gitter-Join%20Chat-brightgreen.svg?style=flat)](https://gitter.im/Drivemode/TypefaceHelper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TypefaceHelper-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1246)
5-
[![License](http://img.shields.io/badge/License-Apache%202-brightgreen.svg?style=flat)](https://github.com/Drivemode/TypefaceHelper/blob/master/LICENSE)
6-
[![Circle CI](https://circleci.com/gh/Drivemode/TypefaceHelper/tree/master.svg?style=shield)](https://circleci.com/gh/Drivemode/TypefaceHelper/tree/master)
3+
[![Build](https://github.com/applibgroup/TypefaceHelper/actions/workflows/main.yml/badge.svg)](https://github.com/applibgroup/TypefaceHelper/actions/workflows/main.yml)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=applibgroup_TypefaceHelper&metric=alert_status)](https://sonarcloud.io/dashboard?id=applibgroup_TypefaceHelper)
75

8-
Helper object for injecting typeface into various text views of android.
6+
Helper object for injecting typeface into various text components of HarmonyOS.
97

108
## Overview
119

12-
We can use various custom typefaces asset for any text views(like TextView, Button, RadioButton, EditText, etc.),
10+
We can use various custom typefaces asset for any text components (like Text, Button, RadioButton, etc.),
1311
but there's no way to set the typeface as a styled theme to apply the typeface for overall screens in the app.
1412

1513
This library helps to do it in easy way :)
1614

17-
And there's also a serious bug that creating typeface from asset resource will cause memory leak ([See this link](https://code.google.com/p/android/issues/detail?id=9904) for more details),
15+
And there's also a serious bug that creating typeface from asset resource will cause memory leak,
1816
this library will take care about this problem as well.
1917

20-
## How to use
18+
## Source
19+
This library has been inspired by https://github.com/Drivemode/TypefaceHelper
2120

22-
First, put your typeface into `asset` directory.
21+
## How to use
2322

24-
In your application class, take care about the helper object lifecycle.
23+
In your MyApplication class, take care about the helper object lifecycle.
2524

2625
```java
27-
public class MyApp extends Application {
28-
@Override
29-
public void onCreate() {
30-
super.onCreate();
31-
32-
TypefaceHelper.initialize(this);
33-
}
34-
35-
@Override
36-
public void onTerminate() {
37-
TypefaceHelper.destroy();
38-
super.onTerminate();
39-
}
26+
public abstract class MyApplication extends AbilityPackage {
27+
@Override
28+
public void onInitialize() {
29+
super.onInitialize();
30+
TypefaceHelper.initialize(this);
31+
}
32+
33+
@Override
34+
public void onEnd() {
35+
super.onEnd();
36+
TypefaceHelper.destroy();
37+
}
4038
}
4139
```
4240

43-
And in your activity, if you would like to set your typeface to a text view,
41+
And in your MainAbilitySlice, if you would like to set your typeface to a text ,
4442

4543
```java
46-
public class MyActivity extends Activity {
47-
@Override
48-
public void onCreate(Bundle savedInstanceState) {
49-
super.onCreate(savedInstanceState);
50-
setContentView(R.layout.activity_main);
51-
52-
TextView hello = (TextView) findViewById(R.id.hello_world);
53-
TypefaceHelper.getInstance().setTypeface(hello, "font/font_file.ttf");
54-
}
44+
45+
public class MainAbilitySlice extends AbilitySlice {
46+
47+
@Override
48+
public void onStart(Intent intent) {
49+
super.onStart(intent);
50+
super.setUIContent(ResourceTable.Layout_ability_main);
51+
52+
Text hello = (Text) findComponentById(ResourceTable.Id_hello_world);
53+
TypefaceHelper.getInstance().setTypeface(hello, "font_file.ttf");
54+
}
5555
}
56+
5657
```
5758

58-
You can also set your typeface for all text views that belong to a specific view group just like this.
59+
You can also set your typeface for all text that belong to a specific ComoponentConatainer just like this.
5960

6061
```java
61-
public class MyActivity extends Activity {
62-
@Override
63-
public void onCreate(Bundle savedInstanceState) {
64-
super.onCreate(savedInstanceState);
65-
setContentView(R.layout.activity_main);
66-
67-
LinearLayout container = (LinearLayout) findViewById(R.id.text_container);
68-
TypefaceHelper.getInstance().setTypeface(container, "font/font_file.ttf");
69-
}
62+
public class MainAbilitySlice extends AbilitySlice {
63+
@Override
64+
public void onStart(Intent intent) {
65+
super.onStart(intent);
66+
super.setUIContent(ResourceTable.Layout_ability_main);
67+
68+
DirectionalLayout container = (DirectionalLayout) findComponentById(ResourceTable.Id_container);
69+
TypefaceHelper.getInstance().setTypeface(container, "font_file.ttf");
70+
}
7071
}
7172
```
7273

73-
If you want to apply the typeface for all text views under the activity layout,
74+
If you want to apply the typeface for all text under the AbilitySlice,
7475

7576
```java
76-
public class MyActivity extends Activity {
77-
@Override
78-
public void onCreate(Bundle savedInstanceState) {
79-
super.onCreate(savedInstanceState);
80-
setContentView(TypefaceHelper.getInstance().setTypeface(this, R.layout.activity_main, "font/font_file.ttf"));
81-
}
77+
public class MainAbilitySlice extends AbilitySlice {
78+
@Override
79+
public void onStart(Intent intent) {
80+
super.onStart(intent);
81+
super.setUIContent(ResourceTable.Layout_ability_main);
82+
83+
TypefaceHelper.getInstance().setTypeface(this, "font_file.ttf");
84+
}
8285
}
86+
8387
```
8488

8589
Nice and easy!
8690

8791
You can apply the typeface to your whole window like this.
8892

8993
```java
90-
public class MyActivity extends Activity {
91-
@Override
92-
public void onCreate(Bundle savedInstanceState) {
93-
super.onCreate(savedInstanceState);
94-
setContentView(R.layout.layout_activity_main);
95-
TypefaceHelper.getInstance().setTypeface(this, "font/font_file.ttf");
96-
}
94+
95+
public class MainAbilitySlice extends AbilitySlice {
96+
@Override
97+
public void onStart(Intent intent) {
98+
super.onStart(intent);
99+
super.setUIContent(ResourceTable.Layout_ability_main);
100+
101+
TypefaceHelper.getInstance().setTypeface(this, "font_file.ttf");
102+
}
97103
}
104+
98105
```
99106

100107
And... you can also pass the font name as a string resource id:
101108

102109
```java
103-
public class MyActivity extends Activity {
104-
@Override
105-
public void onCreate(Bundle savedInstanceState) {
106-
super.onCreate(savedInstanceState);
107-
setContentView(R.layout.layout_activity_main);
108-
TypefaceHelper.getInstance().setTypeface(this, R.string.font_primary);
109-
}
110+
111+
public class MainAbilitySlice extends AbilitySlice {
112+
@Override
113+
public void onStart(Intent intent) {
114+
super.onStart(intent);
115+
super.setUIContent(ResourceTable.Layout_ability_main);
116+
117+
TypefaceHelper.getInstance().setTypeface(this, Resourcetable.String_font_primary);
118+
}
110119
}
111120
```
112121

113-
## Download
114122

115-
Gradle:
116123

124+
125+
126+
## Integration
127+
128+
1. For using TypefaceHelper module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
129+
```java
130+
implementation project(path: ':TypefaceHelper')
131+
```
132+
2. For using TypefaceHelper module in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
133+
```java
134+
implementation fileTree(dir: 'libs', include: ['*.har'])
117135
```
118-
compile 'com.drivemode:TypefaceHelper:1.2.0@aar'
136+
3. For using TypefaceHelper module from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
137+
```java
138+
implementation 'dev.applibgroup:TypefaceHelper:1.0.0'
119139
```
120140

121141
## License

TypefaceHelper/build.gradle

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
apply plugin: 'com.android.library'
2-
3-
android {
4-
compileSdkVersion 28
5-
1+
apply plugin: 'com.huawei.ohos.library'
2+
//For instructions on signature configuration, see https://developer.harmonyos.com/en/docs/documentation/doc-guides/ide_debug_device-0000001053822404#EN-US_TOPIC_0000001154985555__section1112183053510
3+
ohos {
4+
compileSdkVersion 5
65
defaultConfig {
7-
minSdkVersion 15
8-
targetSdkVersion 28
6+
compatibleSdkVersion 5
7+
}
8+
buildTypes {
9+
release {
10+
proguardOpt {
11+
proguardEnabled false
12+
rulesFiles 'proguard-rules.pro'
13+
}
14+
}
915
}
16+
1017
}
1118

1219
dependencies {
13-
implementation 'com.android.support:support-v4:28.0.0-rc01'
14-
implementation 'com.android.support:support-annotations:28.0.0-rc01'
20+
implementation fileTree(dir: 'libs', include: ['*.jar'])
21+
testImplementation 'junit:junit:4.13'
1522
}
16-
17-
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
18-
19-
afterEvaluate {
20-
androidJavadocs.failOnError = false
21-
androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
22-
}

TypefaceHelper/consumer-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add har specific ProGuard rules for consumer here.

TypefaceHelper/gradle.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.

TypefaceHelper/proguard-rules.pro

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
# Add project specific ProGuard rules here.
2-
# By default, the flags in this file are appended to flags specified
3-
# in /usr/local/Cellar/android-sdk/22.6.2/tools/proguard/proguard-android.txt
4-
# You can edit the include path and order by changing the proguardFiles
5-
# directive in build.gradle.
6-
#
7-
# For more details, see
8-
# http://developer.android.com/guide/developing/tools/proguard.html
9-
10-
# Add any project specific keep options here:
11-
12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:
15-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-
# public *;
17-
#}
1+
# config module specific ProGuard rules here.

TypefaceHelper/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"app": {
3+
"bundleName": "com.example.typefacemaster",
4+
"vendor": "drivemode",
5+
"version": {
6+
"code": 1000000,
7+
"name": "1.0.0"
8+
}
9+
},
10+
"deviceConfig": {
11+
},
12+
"module": {
13+
"package": "com.drivemode.harmony.typeface",
14+
"deviceType": [
15+
"phone",
16+
"tablet"
17+
],
18+
"distro": {
19+
"deliveryWithInstall": true,
20+
"moduleName": "TypefaceHelper",
21+
"moduleType": "har"
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)