Chinese P20 Pro Sending Unusual Packets? - Huawei P20 Pro Questions & Answers

Hey guys, I've recenty bought the chinese version of the P20 Pro (CLT-AL00), and I noticed that it's sending weird packets to random addresses seen in the screenshots. Anyone know what it's doing?

Yeah, my chinese p20 pro does that too. One interesting thing is that one of these requests is returning a wifi login success html page:
```
<!DOCTYPE html>
<meta charset="utf-8">
<title>WiFi登录</title>
<style>
body,header,div,p,i{margin:0;padding:0;list-style:none;}
body{background: #e0e3e7;font-family:"\5FAE\8F6F\96C5\9ED1";text-shadow: 0 1px 1px #fff;}
header{ height: 50px; background: #406394;}
.logo{
width: 160px;
height: 100%;
background: url(images/logo.png) no-repeat;
-webkit-background-size: auto 50px;
background-size: auto 50px;
display: block;
}
.icon-ok{
background: url(images/icon-ok.png) no-repeat;
-webkit-background-size: auto 34px;
background-size: auto 34px;
width: 34px;
height: 34px;
display: inline-block;
}
.tip-box{ border: 1px solid #d8d9da; border-radius: 10px; padding: 10px; margin: 120px 20px 0; font-size: 16px; line-height: 26px; text-align: center;}
</style>
<header></header>
<div class="tip-box">
<i class="icon-ok"></i>
<p>腾讯手机管家提醒您
<p>WiFi登录成功,可使用WiFi上网
</div>
```
Really want to know what it's doing too. Any insights would be greatly appreciated.

Related

Wikipedia HTML panel Help!

Hey,
I wanted to create an easy html panel for the X1 to search wikipedia.
The panel seems almost done, but one problem remains.
My javascript code creates a variabel 'Searchlink' where the complete url is in. So for example:
'http://en.wikipedia.org/wiki/Special:Search?search=subject'
Which of course tries to find an article named 'subject'.
The problem is how to launch my default browser showing me this url.
When is just tell to go to that url, the webpage will load in the panel itself. But since the panel is non scrollable, this sucks. So I want it to open the user's default webbrowser and show him the url created.
Any suggestions?
Code so far below:
HTML:
<SCRIPT TYPE="text/javascript">
<!--
function Makelink(LinkForm)
{
var t=""
for (i=0; i<2; i++)
{
if (document.LinkForm.Language[i].checked==true)
{
t =document.LinkForm.Language[i].value
}
}
var Srchtg = LinkForm.Search_link.value;
var Lng = t;
var Searchlink = 'http://' + Lng + '.wikipedia.org/wiki/Special:Search?search=' + Srchtg;
//Here it needs to launch defalut browser with 'Searchlink' as url...
}
// -->
</SCRIPT>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="MobileOptimized" content="400">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="cleartype" CONTENT="ON">
<title>Wiki Panel</title>
</head>
<body>
<div class="content">
<form name="LinkForm">
<img border="0" src="Wikilogo1.bmp" width="216" height="38">
<p>
<INPUT NAME="Search_link" SIZE=20>
<INPUT TYPE=BUTTON OnClick="Makelink(this.form);" VALUE=">">
</p>
<p>
<input type="radio" name="Language" value="nl" checked='checked' />Nederlands
<input type="radio" name="Language" value="en" />English 
</p>
<p>
<img border="0" src="Wikilogo2.bmp" width="218" height="217"></p>
</form>
</div>
</body>
</html>
Tazard4 said:
Hey,
I wanted to create an easy html panel for the X1 to search wikipedia.
The panel seems almost done, but one problem remains.
My javascript code creates a variabel 'Searchlink' where the complete url is in. So for example:
'http://en.wikipedia.org/wiki/Special:Search?search=subject'
Which of course tries to find an article named 'subject'.
The problem is how to launch my default browser showing me this url.
When is just tell to go to that url, the webpage will load in the panel itself. But since the panel is non scrollable, this sucks. So I want it to open the user's default webbrowser and show him the url created.
Any suggestions?
Code so far below:
HTML:
<SCRIPT TYPE="text/javascript">
<!--
function Makelink(LinkForm)
{
var t=""
for (i=0; i<2; i++)
{
if (document.LinkForm.Language[i].checked==true)
{
t =document.LinkForm.Language[i].value
}
}
var Srchtg = LinkForm.Search_link.value;
var Lng = t;
var Searchlink = 'http://' + Lng + '.wikipedia.org/wiki/Special:Search?search=' + Srchtg;
//Here it needs to launch defalut browser with 'Searchlink' as url...
}
// -->
</SCRIPT>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="MobileOptimized" content="400">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="cleartype" CONTENT="ON">
<title>Wiki Panel</title>
</head>
<body>
<div class="content">
<form name="LinkForm">
<img border="0" src="Wikilogo1.bmp" width="216" height="38">
<p>
<INPUT NAME="Search_link" SIZE=20>
<INPUT TYPE=BUTTON OnClick="Makelink(this.form);" VALUE=">">
</p>
<p>
<input type="radio" name="Language" value="nl" checked='checked' />Nederlands
<input type="radio" name="Language" value="en" />English 
</p>
<p>
<img border="0" src="Wikilogo2.bmp" width="218" height="217"></p>
</form>
</div>
</body>
</html>
Click to expand...
Click to collapse
i know nout about this but cant you just open the google panel files and edit them for wikipedia?
Tried to do this several times, but it didn't work.
I don't have the knowledge to code that kind of stuff.
i no nothing about it so cant help but would be interested in having it for my phone if you get it sorted

Measuring Real Angle

Hi;
I have been looking for some information about how to translate the G-Sensor x/y/z vectors to an actual angle.
Can anyone provide any leads please.
Thanks
Maybe this will help you solve your problem
http://scottandmichelle.net/scott/cestuff/sensortest.zip
This is the source code in c++ for the tilt sensor
typedef struct _SENSORDATA
{
SHORT TiltX; // From -1000 to 1000 (about), 0 is flat
SHORT TiltY; // From -1000 to 1000 (about), 0 is flat
SHORT Orientation; // From -1000 to 1000 (about)
// 0 = Straight up, -1000 = Flat, 1000 = Upside down
WORD Unknown1; // Always zero
DWORD AngleY; // From 0 to 359
DWORD AngleX; // From 0 to 359
DWORD Unknown2; // Bit field?
} SENSORDATA, *PSENSORDATA;
It did help
Hi Soderstrom;
Thanks for your reply.
After downlaoding this, I wrote 2 properties for class IGSensor (AngleX, AngleY) and modified HTCGSensor.GetGVector() to allow for the data to be captured using the same classes and structures and it gave me exactly what I needed.
I.
I'm glad my advice could help you !!!

Need help with code

Hello, on my forums I added something and I positioned it with CSS. It overlaps everything. How do I make it so stuff will automatically make room?
Code:
<override_macro name="show_administrator_notice">
<div style="background-color: #F0F0F0; height: 30px; left: 0; position: relative; top: 80px; width: 100%; text-align: center">
<t>Community Guidelines</t>
<p><b>
Excuse our look!
</b></p>
</div>
</override_macro>

Autotools Webscreen - switch image based on variable

So I am trying to make an AutoTools webscreen. and am just running into the limitations of my knowledge. I can see all the pieces, I just can't make 'em fit together. I want to make a simple webscreen, that show one image. When tasker changes a variable, I want the the AutoTools webscreen to grab a different image, based on the variable change. That is to say, %image = i, img src = "files/image1" %img = 2 img src ="files/image2"....
Any help or advice you all could offer would be much appriciated.
nijohnson said:
So I am trying to make an AutoTools webscreen. and am just running into the limitations of my knowledge. I can see all the pieces, I just can't make 'em fit together. I want to make a simple webscreen, that show one image. When tasker changes a variable, I want the the AutoTools webscreen to grab a different image, based on the variable change. That is to say, %image = i, img src = "files/image1" %img = 2 img src ="files/image2"....
Any help or advice you all could offer would be much appriciated.
Click to expand...
Click to collapse
I think this page, getting started with autotools web screen variables might help.
Does the variable happen to change at a time when the Web Screen is open? Or can the variable change happen outside the Web Screen? What determines how and when the variable changes?
Thanks! I've seen that.
The variable will change outside the webscreen. The web screen image displayed is the end result of another tasker procsss
nijohnson said:
Thanks! I've seen that.
The variable will change outside the webscreen. The web screen image displayed is the end result of another tasker procsss
Click to expand...
Click to collapse
Ok so then this will be easy, because you can just use Javascript to determine what the variable is and react accordingly:
add a <meta> tag into the head section of your Web Screen HTML using this as a guide. Make sure it is for a Javascript variable (type="variablejs") and not an HTML variable. Call it "image"
create a <script> tag and enter the following Javscript code:
HTML:
<script type="text/javascript">
var imageSource = null;
switch (image) {
case 'one image':
imageSource = "files/image1";
break;
case 'second image':
imageSource = "files/image2";
break;
case 'other image':
imageSource = "files/image3";
break;
};
<img src=imageSource>
</script>
Hope that helps! Out of curiosity, what is your Web Screen for?
Thanks! I'll try it tomorrow. I'm working on a Heads Up Display (HUD) profile. I'll share if I get it going.
Well, I am just convinced that suck at web stuff and java.
The script above should work. But I can't figure out how to put it into an html file/package to make it work. Here's what is just not working. I am sure this is just because I am making rookie mistakes.
Code:
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height,initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="autotoolswebscreen" type="variablejs" id="image" label="Image" description="Image to display " defaultValue="1, 2, 3" />
</head>
<body>
<script type="text/javascript">
var imageSource = null;
switch (image) {
case 1:
imageSource = "files/flipped1.jpg";
break;
case 2:
imageSource = "files/iflipped2.jpg";
break;
case 3:
imageSource = "files/flipped3.jpg";
break;
};
<img src=imageSource>
</script>
</body>
</html>
I'd like to put in something that checks to see if Tasker has set the variable, and an update function too. I know they are availible in autotools but I'll be damned if I can figure it out.
nijohnson said:
Well, I am just convinced that suck at web stuff and java.
The script above should work. But I can't figure out how to put it into an html file/package to make it work. Here's what is just not working. I am sure this is just because I am making rookie mistakes.
Code:
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height,initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="autotoolswebscreen" type="variablejs" id="image" label="Image" description="Image to display " defaultValue="1, 2, 3" />
</head>
<body>
<script type="text/javascript">
var imageSource = null;
switch (image) {
case 1:
imageSource = "files/flipped1.jpg";
break;
case 2:
imageSource = "files/iflipped2.jpg";
break;
case 3:
imageSource = "files/flipped3.jpg";
break;
};
<img src=imageSource>
</script>
</body>
</html>
Click to expand...
Click to collapse
Ok so first your "imageSource" variable does not have the correct syntax. It should be something like this:
Code:
////storage//emulated/0/[FOLDER]//[SUB-FOLDER]//flipped1.jpg"
Change the "[FOLDER]//[SUB-FOLDER]" part to match where ever the images are kept within the device.
Also for the case 2, check the spelling:
Code:
imageSource = "files/iflipped2.jpg";[\code] should be: [code]imageSource = "files/flipped2.jpg";
there is an extra "i".
nijohnson said:
I'd like to put in something that checks to see if Tasker has set the variable,
Click to expand...
Click to collapse
For what purpose? To set a default number in case Tasker hasn't set that value? If that is the case, there are 2 ways to go about this and both can be done simultaneously to make certain the variable is set.
Change your meta variable to match this:
Code:
<meta name="autotoolswebscreen" type="variablejs" id="image" label="Image" description="Image to display " hint="1, 2, 3" defaultValue="1" />
the "hint" attribute is just as it sounds; same goes for the "defaultValue" attribute. By using a default value of "1", it will be pre-filled in the option when configuring in Tasker.
Adding the "AutoTools.setDefault" function within your HTML, like so:
Code:
<script type="text/javascript">
AutoTools.setDefault("image", "1");
</script>
This will also do as it sounds. Place this code just below the <body> tag.
How are you displaying your images? If the above code you showed me is all of it, you are missing the HTML elements responsible for showing the image within the scene!
nijohnson said:
and an update function too. I know they are availible in autotools but I'll be damned if I can figure it out.
Click to expand...
Click to collapse
here is the github that explains all of the functions and give examples. https://github.com/joaomgcd/AutoToolsWebScreens
If you still need help, reply back. Good luck!
Thanks so much!
nijohnson said:
Thanks so much!
Click to expand...
Click to collapse
No problem! Glad I could help out. If you want to see some more AutoTools Web Screen examples and explanations check out my website post with instructions and demo videos!
http://www.rorycodes.com/material-design-autotools-web-screen/

Flutter | Huawei Auth Service (Authorization With Email)

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Hello everyone,
In this article, I will give you some information about the Auth Service offered by Huawei AppGallery Connect to developers and how to use it in cross-platform applications that you will develop with Flutter.
What is Auth Service ?
Many mobile applications require membership systems and authentication methods. Setting up this system from scratch in mobile applications can be difficult and time consuming. Huawei AGC Auth Service enables you to quickly and securely integrate this authentication process into your mobile application. Moreover, Auth Service offers many authentication methods. It can be used in Android Native, IOS Native and cross-platform (Flutter, React-Native, Cordova) projects.
Highly secure, fast and easy to use, Auth Service supports all the following account methods and authentication methods.
Mobile Number (Android, IOS, Web)
Email Address (Android, IOS, Web)
HUAWEI ID (Android)
HUAWEI Game Center account (Android)
WeChat account (Android, IOS, Web)
QQ account (Android, IOS, Web)
Weibo account (Android, IOS)
Apple ID (IOS)
Google account* (Android, IOS)
Google Play Games account* (Android)
Facebook account* (Android, IOS)
Twitter account* (Android, IOS)
Anonymous account (Android, IOS, Web)
Self-owned account (Android, IOS)
Development Steps
Integration
After creating your application on the AGC Console and completing all of the necessary steps, the agconnect-services file should be added to the project first.
The agconnect-services.json configuration file should be added under the android/app directory in the Flutter project.
For IOS, the agconnect-services.plist configuration file should be added under ios/Runner directory in the Flutter project.
Next, the following dependencies for HMS usage need to be added to the build.gradle file under the android directory.
Java:
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.huawei.agconnect:agcp:1.4.2.301'
}
}
allprojects {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}
Then add the following line of code to the build.gradle file under the android/app directory.
Code:
apply plugin: 'com.huawei.agconnect'
Finally, the Auth Service SDK should be added to the pubspec.yaml file. To do this, open the pubspec.yaml file and add the required dependency as follows.
Code:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
agconnect_auth: ^1.1.0
agconnect_core: ^1.1.0
And, by clicking “pub get”, the dependencies are added to Android Studio. After all these steps are completed, your app is ready to code.
2. Register with Email
Create a new Dart file named AuthManager that contains all the operations we will do with Auth Service. In this class, the necessary methods for all operations such as sending verification code, registration, login will be written and all operations will be done in this class without any code confusion in the interface class.
When registering with the user’s email address, a verification code must be sent to the entered email address. In this way, it will be determined whether the users are a real person and security measures will be taken. For this, create a method called sendRegisterVerificationCode that takes the email address entered by the user as a parameter and sends a verification code to this email address. By creating a VerifyCodeSettings object within the method, it is specified for what purpose the verification code will be used by making the VerifyCodeAction value “registerLogin”. Finally, with EmailAuthProvider.requestVerifyCode, the verification code is sent to the mail address. Yo can find all of the method on the below.
Java:
void sendRegisterVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.registerLogin, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print("sendRegisterVerificationCode : " + result.validityPeriod);
});
}
After the user receives the verification code, the user is registered with the e-mail address, password, and verification code. Each user must set a special password, and this password must be at least 8 characters long and different from the e-mail address. In addition, lowercase letters, uppercase letters, numbers, spaces or special characters must meet at least two of the requirements. In order to the registration process, a method named registerWithEmail should be created and mail address, verification code and password should be given as parameters. Then create an EmailUser object and set these values. Finally, a new user is created with the AGCAuth.instance.createEmailUser (user) line. You can find registerWithEmail method on the below.
Java:
void registerWithEmail(String email, String verifyCode, String password, BuildContext context) async{
EmailUser user = EmailUser(email, verifyCode, password: password);
AGCAuth.instance.createEmailUser(user)
.then((signInResult) {
print("registerWithEmail : " + signInResult.user.email);
.catchError((error) {
print("Register Error " + error.toString());
_showMyDialog(context, error.toString());
});
}
3. Signin with Email
In order for users to log in to your mobile app after they have registered, a verification code should be sent. To send the verification code while logging in, a method should be created as in the registration, and a verification code should be sent to the e-mail address with this method.
After the verification code is sent, the user can login to the app with their e-mail address, password and verification code. You can test whether the operation is successful by adding .then and .catchError to the login method. You can find all the codes for the sign-in method below.
Java:
void sendSigninVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.registerLogin, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print("sendSigninVerificationCode : " + result.validityPeriod);
});
}
void loginWithEmail(String email, String verifyCode, String password) async{
AGCAuthCredential credential = EmailAuthProvider.credentialWithVerifyCode(email, verifyCode, password: password);
AGCAuth.instance.signIn(credential)
.then((signInResult){
AGCUser user = signInResult.user;
print("loginWithEmail : " + user.displayName);
})
.catchError((error){
print("Login Error " + error.toString());
});
}
4. Reset Password
If the user forgets or wants to change his password, the password reset method provided by Auth Service should be used. Otherwise, the user cannot change his password, and cannot log into his account.
As in every auth method, a verification code is still required when resetting the password. This verification code should be sent to the user’s mail address, similar to the register and sign. Unlike the register and signin operations, the VerifyCodeSettings parameter must be VerifyCodeAction.resetPassword. After sending the verification code to the user’s e-mail address, password reset can be done as follows.
Java:
void sendResetPasswordVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.resetPassword, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print(result.validityPeriod);
});
}
void resetPassword(String email, String newPassword, String verifyCode) async{
AGCAuth.instance.resetPasswordWithEmail(email, newPassword, verifyCode)
.then((value) {
print("Password Reseted");
})
.catchError((error) {
print("Password Reset Error " + error);
});
}
5. Logout
To end the user’s current session, an instance must be created from the AGCAuth object and the signOut() method must be called. You can find this code block on the below.
Java:
void signOut() async{
AGCAuth.instance.signOut().then((value) {
print("SignInSuccess");
}).catchError((error) => print("SignOut Error : " + error));
}
6. User Information
Auth Service provides a lot of data to show the user information of a logged in user. In order to obtain this data, an instance can be created from the AGCAuth object and all the information belonging to the user can be listed with the currentUser method.
Java:
void getCurrentUser() async {
AGCAuth.instance.currentUser.then((value) {
print('current user = ${value?.uid} , ${value?.email} , ${value?.displayName} , ${value?.phone} , ${value?.photoUrl} ');
});
}
The AuthManager class must contain these operations. Thanks to the above methods, you can log in and register with your Email address in your app. You can create an object from the AuthManager class and call the method you need wherever you need it. Now that the AuthManager class is complete, a registration page can be designed and the necessary methods can be called.
7. Create Register Page
I will share an example to give you an idea about design. I designed an animation so that the elements in the page design come with animation at 5 second intervals. In addition, I prepared a design that makes circles around the icon you add periodically to highlight your application’s logo.
I used the avatar_glow library for this. Avatar Glow library allows us to make a simple and stylish design. To add this library, you can add “avatar_glow: ^ 1.1.0” line to pubspec.yaml file and integrate it into your project with “pub get”.
After the library is added, we create a Dart file named DelayedAnimation to run the animations. In this class, we define all the features of animation. You can find all the codes of the class below.
Java:
import 'dart:async';
import 'package:flutter/material.dart';
class DelayedAnimation extends StatefulWidget {
final Widget child;
final int delay;
DelayedAnimation({@required this.child, this.delay});
@override
_DelayedAnimationState createState() => _DelayedAnimationState();
}
class _DelayedAnimationState extends State<DelayedAnimation>
with TickerProviderStateMixin {
AnimationController _controller;
Animation<Offset> _animOffset;
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 800));
final curve =
CurvedAnimation(curve: Curves.decelerate, parent: _controller);
_animOffset =
Tween<Offset>(begin: const Offset(0.0, 0.35), end: Offset.zero)
.animate(curve);
if (widget.delay == null) {
_controller.forward();
} else {
Timer(Duration(milliseconds: widget.delay), () {
_controller.forward();
});
}
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return FadeTransition(
child: SlideTransition(
position: _animOffset,
child: widget.child,
),
opacity: _controller,
);
}
}
Then we can create a Dart file called RegisterPage and continue coding.
In this class, we first set a fixed delay time. I set it to 500 ms. Then I increased it by 500ms for each element and made it load one after the other.
Then TextEditingController objects should be created to get values such as email, password, verify code written into TextFormField.
Finally, when clicked the send verification code button, I set a visibility value as bool to change the name of the button and the visibility of the field where a new verification code will be entered.
Java:
final int delayedAmount = 500;
AnimationController _controller;
bool _visible = false;
String buttonText = "Send Verify Code";
TextEditingController emailController = new TextEditingController();
TextEditingController passwordController = new TextEditingController();
TextEditingController verifyCodeController = new TextEditingController();
Now, AnimationController values must be set in initState method.
Java:
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: Duration(
milliseconds: 200,
),
lowerBound: 0.0,
upperBound: 0.1,
)..addListener(() {
setState(() {});
});
super.initState();
}
Then a method should be created for the verification code send button and the save button, and these methods should be called in the Widget build method where necessary. In both methods, first of all, the visibility values and texts should be changed and the related methods should be called by creating an object from the AuthManager class.
Java:
void _toggleVerifyCode() {
setState(() {
_visible = true;
buttonText = "Send Again";
final AuthManager authManager = new AuthManager();
authManager.sendRegisterVerificationCode(emailController.text);
});
}
void _toggleRegister() {
setState(() {
_visible = true;
buttonText = "Send Again";
final AuthManager authManager = new AuthManager();
authManager.registerWithEmail(emailController.text, verifyCodeController.text, passwordController.text, this.context);
});
}
Finally, in the Widget build method, the design of each element should be prepared separately and returned at the end. If all the codes are written under return, the code will look too complex and debugging or modification will be difficult. As seen on the below, I prepared an Avatar Glow object at the top. Then, create two TextFormFields for the user to enter their mail address and password. Under these two TextFormFields, there is a button for sending the verification code. When this button is clicked, a verification code is sent to the mail address, and a new button design is created for entering this verification code and a new TextFormField and register operations. Yo can find screenshots and all of the codes on the below.
Java:
@override
Widget build(BuildContext context) {
final color = Color(0xFFF4EADE);
_scale = 1 - _controller.value;
final logo = AvatarGlow(
endRadius: 90,
duration: Duration(seconds: 2),
glowColor: Color(0xFF2F496E),
repeat: true,
repeatPauseDuration: Duration(seconds: 2),
startDelay: Duration(seconds: 1),
child: Material(
elevation: 8.0,
shape: CircleBorder(),
child: CircleAvatar(
backgroundColor: Color(0xFFF4EADE),
backgroundImage: AssetImage('assets/huawei_logo.png'),
radius: 50.0,
)
),
);
final title = DelayedAnimation(
child: Text(
"Register",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 35.0,
color: Color(0xFF2F496E)),
),
delay: delayedAmount + 500,
);
final email = DelayedAnimation(
delay: delayedAmount + 500,
child: TextFormField(
controller: emailController,
keyboardType: TextInputType.emailAddress,
autofocus: false,
decoration: InputDecoration(
hintText: '* Email',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final password = DelayedAnimation(
delay: delayedAmount + 1000,
child: TextFormField(
controller: passwordController,
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: '* Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final sendVerifyCodeButton = RaisedButton(
color: Color(0xFF2F496E),
highlightColor: Color(0xFF2F496E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0),
),
onPressed: _toggleVerifyCode,
child: Text(
buttonText,
style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.normal,
color: color,
),
),
);
final verifyCode = DelayedAnimation(
delay: 500,
child: TextFormField(
controller: verifyCodeController,
keyboardType: TextInputType.emailAddress,
autofocus: false,
decoration: InputDecoration(
hintText: '* Verify Code',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final registerButton = RaisedButton(
color: Color(0xFF2F496E),
highlightColor: Color(0xFF2F496E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0),
),
onPressed: _toggleRegister,
child: Text(
'Register',
style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.normal,
color: color,
),
),
);
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Color(0xFFF4EADE),
body: Center(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
new Container(
margin: const EdgeInsets.all(20.0),
child: new Container()
),
title,
logo,
SizedBox(
height: 50,
width: 300,
child: email,
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: password,
),
SizedBox(height: 15.0),
SizedBox(
height: 40,
width: 300,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: sendVerifyCodeButton
),
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: _visible,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: verifyCode
),
)
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: _visible,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: registerButton
),
)
),
SizedBox(height: 50.0,),
],
),
),
),
),
);
}
8. Create Login Page
We coded the all of requirements for login in the AuthManager class as above. Using the same design on the Register page and changing the button’s onPressed method, the Login page can be created easily. Since all codes are the same, I will not share the codes for this class again. As I mentioned, this is just a design example, you can change your login and registration pages to your application needs.
More details perhaps?
hello team #XDA, i have entered Google pixel 5 contest of yours
Nice
good
It s everything on one place for learning about manufactured,about java and the programs and is realy helpful,thank you for your sharing knowledge with us,and i am in the contest for the pixel 5 sure it will be awesome will learning to have better phone on focusing knowledge in programs,thanks for all
Helpful
Kill For It
XDARoni said:
Hello everyone,
In this article, I will give you some information about the Auth Service offered by Huawei AppGallery Connect to developers and how to use it in cross-platform applications that you will develop with Flutter.
What is Auth Service ?
Many mobile applications require membership systems and authentication methods. Setting up this system from scratch in mobile applications can be difficult and time consuming. Huawei AGC Auth Service enables you to quickly and securely integrate this authentication process into your mobile application. Moreover, Auth Service offers many authentication methods. It can be used in Android Native, IOS Native and cross-platform (Flutter, React-Native, Cordova) projects.
Highly secure, fast and easy to use, Auth Service supports all the following account methods and authentication methods.
Mobile Number (Android, IOS, Web)
Email Address (Android, IOS, Web)
HUAWEI ID (Android)
HUAWEI Game Center account (Android)
WeChat account (Android, IOS, Web)
QQ account (Android, IOS, Web)
Weibo account (Android, IOS)
Apple ID (IOS)
Google account* (Android, IOS)
Google Play Games account* (Android)
Facebook account* (Android, IOS)
Twitter account* (Android, IOS)
Anonymous account (Android, IOS, Web)
Self-owned account (Android, IOS)
Development Steps
Integration
After creating your application on the AGC Console and completing all of the necessary steps, the agconnect-services file should be added to the project first.
The agconnect-services.json configuration file should be added under the android/app directory in the Flutter project.
For IOS, the agconnect-services.plist configuration file should be added under ios/Runner directory in the Flutter project.
Next, the following dependencies for HMS usage need to be added to the build.gradle file under the android directory.
Java:
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.huawei.agconnect:agcp:1.4.2.301'
}
}
allprojects {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}
Then add the following line of code to the build.gradle file under the android/app directory.
Code:
apply plugin: 'com.huawei.agconnect'
Finally, the Auth Service SDK should be added to the pubspec.yaml file. To do this, open the pubspec.yaml file and add the required dependency as follows.
Code:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
agconnect_auth: ^1.1.0
agconnect_core: ^1.1.0
And, by clicking “pub get”, the dependencies are added to Android Studio. After all these steps are completed, your app is ready to code.
2. Register with Email
Create a new Dart file named AuthManager that contains all the operations we will do with Auth Service. In this class, the necessary methods for all operations such as sending verification code, registration, login will be written and all operations will be done in this class without any code confusion in the interface class.
When registering with the user’s email address, a verification code must be sent to the entered email address. In this way, it will be determined whether the users are a real person and security measures will be taken. For this, create a method called sendRegisterVerificationCode that takes the email address entered by the user as a parameter and sends a verification code to this email address. By creating a VerifyCodeSettings object within the method, it is specified for what purpose the verification code will be used by making the VerifyCodeAction value “registerLogin”. Finally, with EmailAuthProvider.requestVerifyCode, the verification code is sent to the mail address. Yo can find all of the method on the below.
Java:
void sendRegisterVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.registerLogin, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print("sendRegisterVerificationCode : " + result.validityPeriod);
});
}
After the user receives the verification code, the user is registered with the e-mail address, password, and verification code. Each user must set a special password, and this password must be at least 8 characters long and different from the e-mail address. In addition, lowercase letters, uppercase letters, numbers, spaces or special characters must meet at least two of the requirements. In order to the registration process, a method named registerWithEmail should be created and mail address, verification code and password should be given as parameters. Then create an EmailUser object and set these values. Finally, a new user is created with the AGCAuth.instance.createEmailUser (user) line. You can find registerWithEmail method on the below.
Java:
void registerWithEmail(String email, String verifyCode, String password, BuildContext context) async{
EmailUser user = EmailUser(email, verifyCode, password: password);
AGCAuth.instance.createEmailUser(user)
.then((signInResult) {
print("registerWithEmail : " + signInResult.user.email);
.catchError((error) {
print("Register Error " + error.toString());
_showMyDialog(context, error.toString());
});
}
3. Signin with Email
In order for users to log in to your mobile app after they have registered, a verification code should be sent. To send the verification code while logging in, a method should be created as in the registration, and a verification code should be sent to the e-mail address with this method.
After the verification code is sent, the user can login to the app with their e-mail address, password and verification code. You can test whether the operation is successful by adding .then and .catchError to the login method. You can find all the codes for the sign-in method below.
Java:
void sendSigninVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.registerLogin, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print("sendSigninVerificationCode : " + result.validityPeriod);
});
}
void loginWithEmail(String email, String verifyCode, String password) async{
AGCAuthCredential credential = EmailAuthProvider.credentialWithVerifyCode(email, verifyCode, password: password);
AGCAuth.instance.signIn(credential)
.then((signInResult){
AGCUser user = signInResult.user;
print("loginWithEmail : " + user.displayName);
})
.catchError((error){
print("Login Error " + error.toString());
});
}
4. Reset Password
If the user forgets or wants to change his password, the password reset method provided by Auth Service should be used. Otherwise, the user cannot change his password, and cannot log into his account.
As in every auth method, a verification code is still required when resetting the password. This verification code should be sent to the user’s mail address, similar to the register and sign. Unlike the register and signin operations, the VerifyCodeSettings parameter must be VerifyCodeAction.resetPassword. After sending the verification code to the user’s e-mail address, password reset can be done as follows.
Java:
void sendResetPasswordVerificationCode(String email) async{
VerifyCodeSettings settings = VerifyCodeSettings(VerifyCodeAction.resetPassword, sendInterval: 30);
EmailAuthProvider.requestVerifyCode(email, settings)
.then((result){
print(result.validityPeriod);
});
}
void resetPassword(String email, String newPassword, String verifyCode) async{
AGCAuth.instance.resetPasswordWithEmail(email, newPassword, verifyCode)
.then((value) {
print("Password Reseted");
})
.catchError((error) {
print("Password Reset Error " + error);
});
}
5. Logout
To end the user’s current session, an instance must be created from the AGCAuth object and the signOut() method must be called. You can find this code block on the below.
Java:
void signOut() async{
AGCAuth.instance.signOut().then((value) {
print("SignInSuccess");
}).catchError((error) => print("SignOut Error : " + error));
}
6. User Information
Auth Service provides a lot of data to show the user information of a logged in user. In order to obtain this data, an instance can be created from the AGCAuth object and all the information belonging to the user can be listed with the currentUser method.
Java:
void getCurrentUser() async {
AGCAuth.instance.currentUser.then((value) {
print('current user = ${value?.uid} , ${value?.email} , ${value?.displayName} , ${value?.phone} , ${value?.photoUrl} ');
});
}
The AuthManager class must contain these operations. Thanks to the above methods, you can log in and register with your Email address in your app. You can create an object from the AuthManager class and call the method you need wherever you need it. Now that the AuthManager class is complete, a registration page can be designed and the necessary methods can be called.
7. Create Register Page
I will share an example to give you an idea about design. I designed an animation so that the elements in the page design come with animation at 5 second intervals. In addition, I prepared a design that makes circles around the icon you add periodically to highlight your application’s logo.
I used the avatar_glow library for this. Avatar Glow library allows us to make a simple and stylish design. To add this library, you can add “avatar_glow: ^ 1.1.0” line to pubspec.yaml file and integrate it into your project with “pub get”.
After the library is added, we create a Dart file named DelayedAnimation to run the animations. In this class, we define all the features of animation. You can find all the codes of the class below.
Java:
import 'dart:async';
import 'package:flutter/material.dart';
class DelayedAnimation extends StatefulWidget {
final Widget child;
final int delay;
DelayedAnimation({@required this.child, this.delay});
@override
_DelayedAnimationState createState() => _DelayedAnimationState();
}
class _DelayedAnimationState extends State<DelayedAnimation>
with TickerProviderStateMixin {
AnimationController _controller;
Animation<Offset> _animOffset;
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 800));
final curve =
CurvedAnimation(curve: Curves.decelerate, parent: _controller);
_animOffset =
Tween<Offset>(begin: const Offset(0.0, 0.35), end: Offset.zero)
.animate(curve);
if (widget.delay == null) {
_controller.forward();
} else {
Timer(Duration(milliseconds: widget.delay), () {
_controller.forward();
});
}
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return FadeTransition(
child: SlideTransition(
position: _animOffset,
child: widget.child,
),
opacity: _controller,
);
}
}
Then we can create a Dart file called RegisterPage and continue coding.
In this class, we first set a fixed delay time. I set it to 500 ms. Then I increased it by 500ms for each element and made it load one after the other.
Then TextEditingController objects should be created to get values such as email, password, verify code written into TextFormField.
Finally, when clicked the send verification code button, I set a visibility value as bool to change the name of the button and the visibility of the field where a new verification code will be entered.
Java:
final int delayedAmount = 500;
AnimationController _controller;
bool _visible = false;
String buttonText = "Send Verify Code";
TextEditingController emailController = new TextEditingController();
TextEditingController passwordController = new TextEditingController();
TextEditingController verifyCodeController = new TextEditingController();
Now, AnimationController values must be set in initState method.
Java:
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: Duration(
milliseconds: 200,
),
lowerBound: 0.0,
upperBound: 0.1,
)..addListener(() {
setState(() {});
});
super.initState();
}
Then a method should be created for the verification code send button and the save button, and these methods should be called in the Widget build method where necessary. In both methods, first of all, the visibility values and texts should be changed and the related methods should be called by creating an object from the AuthManager class.
Java:
void _toggleVerifyCode() {
setState(() {
_visible = true;
buttonText = "Send Again";
final AuthManager authManager = new AuthManager();
authManager.sendRegisterVerificationCode(emailController.text);
});
}
void _toggleRegister() {
setState(() {
_visible = true;
buttonText = "Send Again";
final AuthManager authManager = new AuthManager();
authManager.registerWithEmail(emailController.text, verifyCodeController.text, passwordController.text, this.context);
});
}
Finally, in the Widget build method, the design of each element should be prepared separately and returned at the end. If all the codes are written under return, the code will look too complex and debugging or modification will be difficult. As seen on the below, I prepared an Avatar Glow object at the top. Then, create two TextFormFields for the user to enter their mail address and password. Under these two TextFormFields, there is a button for sending the verification code. When this button is clicked, a verification code is sent to the mail address, and a new button design is created for entering this verification code and a new TextFormField and register operations. Yo can find screenshots and all of the codes on the below.
Java:
@override
Widget build(BuildContext context) {
final color = Color(0xFFF4EADE);
_scale = 1 - _controller.value;
final logo = AvatarGlow(
endRadius: 90,
duration: Duration(seconds: 2),
glowColor: Color(0xFF2F496E),
repeat: true,
repeatPauseDuration: Duration(seconds: 2),
startDelay: Duration(seconds: 1),
child: Material(
elevation: 8.0,
shape: CircleBorder(),
child: CircleAvatar(
backgroundColor: Color(0xFFF4EADE),
backgroundImage: AssetImage('assets/huawei_logo.png'),
radius: 50.0,
)
),
);
final title = DelayedAnimation(
child: Text(
"Register",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 35.0,
color: Color(0xFF2F496E)),
),
delay: delayedAmount + 500,
);
final email = DelayedAnimation(
delay: delayedAmount + 500,
child: TextFormField(
controller: emailController,
keyboardType: TextInputType.emailAddress,
autofocus: false,
decoration: InputDecoration(
hintText: '* Email',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final password = DelayedAnimation(
delay: delayedAmount + 1000,
child: TextFormField(
controller: passwordController,
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: '* Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final sendVerifyCodeButton = RaisedButton(
color: Color(0xFF2F496E),
highlightColor: Color(0xFF2F496E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0),
),
onPressed: _toggleVerifyCode,
child: Text(
buttonText,
style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.normal,
color: color,
),
),
);
final verifyCode = DelayedAnimation(
delay: 500,
child: TextFormField(
controller: verifyCodeController,
keyboardType: TextInputType.emailAddress,
autofocus: false,
decoration: InputDecoration(
hintText: '* Verify Code',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100.0),
borderSide: BorderSide(
color: Color(0xFF2F496E),
),
),
),
),
);
final registerButton = RaisedButton(
color: Color(0xFF2F496E),
highlightColor: Color(0xFF2F496E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0),
),
onPressed: _toggleRegister,
child: Text(
'Register',
style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.normal,
color: color,
),
),
);
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Color(0xFFF4EADE),
body: Center(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
new Container(
margin: const EdgeInsets.all(20.0),
child: new Container()
),
title,
logo,
SizedBox(
height: 50,
width: 300,
child: email,
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: password,
),
SizedBox(height: 15.0),
SizedBox(
height: 40,
width: 300,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: sendVerifyCodeButton
),
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: _visible,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: verifyCode
),
)
),
SizedBox(height: 15.0),
SizedBox(
height: 50,
width: 300,
child: Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: _visible,
child: DelayedAnimation(
delay: delayedAmount + 1500,
child: registerButton
),
)
),
SizedBox(height: 50.0,),
],
),
),
),
),
);
}
8. Create Login Page
We coded the all of requirements for login in the AuthManager class as above. Using the same design on the Register page and changing the button’s onPressed method, the Login page can be created easily. Since all codes are the same, I will not share the codes for this class again. As I mentioned, this is just a design example, you can change your login and registration pages to your application needs.
Click to expand...
Click to collapse
I like flutter ui ux
Useful and easy.

Categories

Resources