Skip to content

Commit 0ebfcff

Browse files
committed
Md5Util initial implementation.
1 parent 5842576 commit 0ebfcff

File tree

9 files changed

+773
-11
lines changed

9 files changed

+773
-11
lines changed

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import gwt.material.design.addins.client.MaterialAddins;
2424
import gwt.material.design.addins.client.avatar.js.AvatarOptions;
2525
import gwt.material.design.addins.client.avatar.js.JsAvatar;
26+
import gwt.material.design.addins.client.md5.Md5ClientBundle;
27+
import gwt.material.design.addins.client.md5.Md5DebugClientBundle;
2628
import gwt.material.design.client.MaterialDesignBase;
2729
import gwt.material.design.client.base.AbstractValueWidget;
2830
import gwt.material.design.client.base.JsLoader;
@@ -59,10 +61,10 @@ public class MaterialAvatar extends AbstractValueWidget<String> implements JsLoa
5961
static {
6062
if (MaterialAddins.isDebug()) {
6163
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.jdenticonDebugJs());
62-
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.md5DebugJs());
64+
MaterialDesignBase.injectDebugJs(Md5DebugClientBundle.INSTANCE.md5DebugJs());
6365
} else {
6466
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.jdenticonJs());
65-
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.md5Js());
67+
MaterialDesignBase.injectJs(Md5ClientBundle.INSTANCE.md5Js());
6668
}
6769
}
6870

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,4 @@ public interface MaterialAvatarClientBundle extends ClientBundle {
3434

3535
@Source("resources/js/jdenticon-2.2.0.min.js")
3636
TextResource jdenticonJs();
37-
38-
@Source("resources/js/md5.min.js")
39-
TextResource md5Js();
40-
4137
}

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,7 +34,4 @@ public interface MaterialAvatarDebugClientBundle extends ClientBundle {
3434

3535
@Source("resources/js/jdenticon-2.2.0.js")
3636
TextResource jdenticonDebugJs();
37-
38-
@Source("resources/js/md5.js")
39-
TextResource md5DebugJs();
4037
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package gwt.material.design.addins.client.md5;
2+
3+
import jsinterop.annotations.JsMethod;
4+
import jsinterop.annotations.JsPackage;
5+
import jsinterop.annotations.JsType;
6+
7+
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "md5")
8+
public class Md5 {
9+
10+
public Md5(String message) {
11+
}
12+
13+
public Md5() {
14+
}
15+
16+
@JsMethod(namespace = "md5")
17+
public static native String hex(String message);
18+
19+
@JsMethod(namespace = "md5")
20+
public static native byte[] array(String message);
21+
22+
@JsMethod(namespace = "md5")
23+
public static native byte[] digest(String message);
24+
25+
@JsMethod(namespace = "md5")
26+
public static native Object arrayBuffer(String message);
27+
28+
@JsMethod(namespace = "md5")
29+
public static native Object buffer(String message);
30+
31+
@JsMethod(namespace = "md5")
32+
public static native String base64(String message);
33+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.addins.client.md5;
21+
22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.resources.client.ClientBundle;
24+
import com.google.gwt.resources.client.TextResource;
25+
26+
/**
27+
* Client Bundle for Avatar component
28+
*
29+
* @author kevzlou7979
30+
*/
31+
public interface Md5ClientBundle extends ClientBundle {
32+
33+
Md5ClientBundle INSTANCE = GWT.create(Md5ClientBundle.class);
34+
35+
@Source("resources/js/md5.min.js")
36+
TextResource md5Js();
37+
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.addins.client.md5;
21+
22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.resources.client.ClientBundle;
24+
import com.google.gwt.resources.client.TextResource;
25+
26+
/**
27+
* Client Bundle for Avatar component
28+
*
29+
* @author kevzlou7979
30+
*/
31+
public interface Md5DebugClientBundle extends ClientBundle {
32+
33+
Md5DebugClientBundle INSTANCE = GWT.create(Md5DebugClientBundle.class);
34+
35+
@Source("resources/js/md5.js")
36+
TextResource md5DebugJs();
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package gwt.material.design.addins.client.md5;
2+
3+
import gwt.material.design.addins.client.MaterialAddins;
4+
import gwt.material.design.client.MaterialDesignBase;
5+
6+
public class Md5Util {
7+
static {
8+
if (MaterialAddins.isDebug()) {
9+
MaterialDesignBase.injectDebugJs(Md5DebugClientBundle.INSTANCE.md5DebugJs());
10+
} else {
11+
MaterialDesignBase.injectJs(Md5ClientBundle.INSTANCE.md5Js());
12+
}
13+
}
14+
15+
public Md5Util() {
16+
17+
}
18+
19+
public String hex(String message) {
20+
return Md5.hex(message);
21+
}
22+
23+
public byte[] array(String message) {
24+
return Md5.array(message);
25+
}
26+
27+
public byte[] digest(String message) {
28+
return Md5.digest(message);
29+
}
30+
31+
public Object arrayBuffer(String message) {
32+
return Md5.arrayBuffer(message);
33+
}
34+
35+
public Object buffer(String message) {
36+
return Md5.buffer(message);
37+
}
38+
39+
public String base64(String message) {
40+
return Md5.base64(message);
41+
}
42+
}

0 commit comments

Comments
 (0)