Skip to content

Commit

Permalink
[Added] Readme pt and en
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Tortato Furtado committed Feb 13, 2019
1 parent f0a5851 commit d485ae0
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 17 deletions.
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# Linking para Android
# Deep Linking for Android

Aplicativo Android criado para simular o envio/recebimento de dados fazendo uso do Deep Linking.
Android app created to simulate the sending/receiving of data using the Deep Linking.

## Requisitos
## Requirements

- [Android Studio](https://developer.android.com/studio)
- [Java 8](https://www.oracle.com/technetwork/pt/java/javase/downloads/index.html)

## Configuração do ambiente
## Steps to Run

1. Instale o JDK 8.
1. Install JDK 8.

2. Instale o Android Studio e configure um emulador.
2. Install Android Studio e configure an emulador.

3. No Android Studio, abra e rode o projeto.
3. Open the Android Studio and build.

## Integração com o Clock-In
## Clock-In Integration

### Enviando dados para realizar o login com e-mail/senha:
### Sending data to login with email/password:

```java
public final class MyActivity extends AppCompatActivity {

// Ação quando usuário pressiona um botão
public void sendDataToClockIn() {
final Uri.Builder builder = new Uri.Builder()
.scheme("clockin")
Expand Down Expand Up @@ -54,7 +53,7 @@ public final class MyActivity extends AppCompatActivity {
}
```

### Recebendo dados da(s) última(s) batida(s):
### Receiving data from the latest clock-in(s):

```xml
<manifest>
Expand Down Expand Up @@ -91,7 +90,7 @@ public final class MyActivity extends AppCompatActivity {
}

final String data = mManager.receivedData(intent);
intent.setData(null); // limpar intent após opter os dados
intent.setData(null); // reset the data after handled

if (data == null) {
return;
Expand All @@ -100,7 +99,7 @@ public final class MyActivity extends AppCompatActivity {
final List<ClockInObject> clockIns = serializeData(data);

// ...
// manipular a lista serializada
// handle the serialized list
// ...
}

Expand Down Expand Up @@ -129,16 +128,22 @@ public final class ClockInObject {
}
```

*Para obter mais detalhes sobre a implementação basta rodar o projeto.*
*For more implementation details on just build and analise the example.*

*Informações sobre a comunicação com o Clock-In podem ser obtidas na [Wiki](https://github.com/totvslabs/clockin-deep-linking-android/wiki).*
*Information about deep linking protocol can be found on [Wiki](https://github.com/totvslabs/clockin-deep-linking-android/wiki).*

## Change-log

Um breve resumo de cada versão pode ser encontrado nas [releases](https://github.com/totvslabs/clockin-deep-linking-android/releases) do projeto.
A brief summary of each release can be found on the [releases](https://github.com/totvslabs/clockin-deep-linking-android/releases) do projeto.

## Licença de uso
## License

```
© TOTVS Labs
```

- - -

<p align="center">
<a href="https://github.com/totvslabs/clockin-deep-linking-android/blob/master/README_pt.md">Português</a>
</p>
150 changes: 150 additions & 0 deletions README_pt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Deep Linking para Android

Aplicativo Android criado para simular o envio/recebimento de dados fazendo uso do Deep Linking.

## Requisitos

- [Android Studio](https://developer.android.com/studio)
- [Java 8](https://www.oracle.com/technetwork/pt/java/javase/downloads/index.html)

## Configuração do ambiente

1. Instale o JDK 8.

2. Instale o Android Studio e configure um emulador.

3. No Android Studio, abra e rode o projeto.

## Integração com o Clock-In

### Enviando dados para realizar o login com e-mail/senha:

```java
public final class MyActivity extends AppCompatActivity {

// Ação quando usuário pressiona um botão
public void sendDataToClockIn() {
final Uri.Builder builder = new Uri.Builder()
.scheme("clockin")
.authority("login")
.appendPath("oauth2")
.appendQueryParameter("tenant", "mycompany")
.appendQueryParameter("email", "[email protected]")
.appendQueryParameter("password", "MyP455w0rd")
.appendQueryParameter("appScheme", "myappscheme")
.appendQueryParameter("appName", "My App Name")
.appendQueryParameter("appIdentifier", "com.mycompany.app");

final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

if (!isIntentSave(intent)) {
return;
}

startActivity(intent);
}

private boolean isIntentSave(final Intent intent) {
final PackageManager packageManager = mContext.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
return activities.size() > 0;
}

}
```

### Recebendo dados da(s) última(s) batida(s):

```xml
<manifest>
<application>
<activity android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myappscheme" android:host="clockin" />
</intent-filter>
</activity>
</application>
</manifest>
```

```java
public final class MyActivity extends AppCompatActivity {

@Override
protected void onResume() {
super.onResume();
receiveDataFromClockIn();
}

private void receiveDataFromClockIn() {
final Intent intent = getIntent();
if (intent == null) {
return;
}

final String data = mManager.receivedData(intent);
intent.setData(null); // limpar intent após opter os dados

if (data == null) {
return;
}

final List<ClockInObject> clockIns = serializeData(data);

// ...
// manipular a lista serializada
// ...
}

private List<ClockInObject> serializeData(@NonNull final String data) {
final Type type = new TypeToken<List<ClockInObject>>(){}.getType();
return new Gson().fromJson(data, type);
}

}

public final class ClockInObject {

@SerializedName("clockinCoordinates")
private String clockinCoordinates;

@SerializedName("deviceCode")
private String deviceCode;

@SerializedName("employeePersonId")
private String employeePersonId;

// ...
// getters e setters
// ...

}
```

*Para obter mais detalhes sobre a implementação basta rodar o projeto.*

*Informações sobre a comunicação com o Clock-In podem ser obtidas na [Wiki](https://github.com/totvslabs/clockin-deep-linking-android/wiki).*

## Change-log

Um breve resumo de cada versão pode ser encontrado nas [releases](https://github.com/totvslabs/clockin-deep-linking-android/releases) do projeto.

## Licença de uso

```
© TOTVS Labs
```

- - -

<p align="center">
<a href="https://github.com/totvslabs/clockin-deep-linking-android/blob/master/README.md">English</a>
</p>

0 comments on commit d485ae0

Please sign in to comment.