Giter Site home page Giter Site logo

tytyty's Introduction

Webasyst-X-Android

webasyst-x-android-ru-v1-showcase-dev

Project structure

This project consists of three (main) gradle modules:

auth

Webasyst ID OAauth client (pure java). auth/kt contains some Kotlin extensions.

api

Contains Webasyst application's api clients

webasyst-x

Example Android application

Creating new Webasyst application from scratch

  1. Enable auth dependency. In your app's module build.gradle:
dependencies {
  // For Java projects:
  implementation project(':auth')
  // For Kotlin projects:
  implementation project(':auth:kt')
}
  1. In your app's AndroidManifest.xml, in application section, add authentication redirect activity. Note the comment on <data android:scheme= key
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <!-- Authentication redirect scheme. It should be unique across the device. It is recommended to use app's package name. -->
    <data android:scheme="webasyst-x"/>
  </intent-filter>
</activity>
  1. Configure Webasyst ID (WAID) client. This should be done once, preferably early in application's lifecycle. The recommended option is to extend Application class and do configuration in its onCreate() method. See WebasystAuthService.configure() for details.

  2. Implement Authentication Activity.

The easiest way to do it is to extend your Activity from WebasystAuthActivity and call its waSignIn() from your SignIn button onClick() callback.

If that's not an option (e.g. your Activity is an extension of some other activity) you can use WebasystAuthHelper directly. See WebasystAuthActivity code for details.

  1. You are good to go. Use WebasystAuthService's withFreshAccessToken() (or Kotlin extension) to perform api requests.

Note for translators

String resources are located in /webasyst-x/src/main/res/values[-lang[-rREGION]] where lang is two-letter ISO 639-1 language code and REGION is two letter ISO 3166-1-alpha-2 region code (note the lowercase r).

Android selects resources based on the system locale. If it fails to locate appropriate resources, it falls back to default (res/values/)

For details, follow the link https://developer.android.com/guide/topics/resources/localization

For details on string resource format, follow the link https://developer.android.com/guide/topics/resources/string-resource

Running the example app with Android Studio

  1. Clone this repository

  2. Create new file webasyst.properties in repository root:

webasyst.x.client_id="YOUR_WEBASYSTID_APP_CLIENT_ID_HERE"
webasyst.x.host="https://www.webasyst.com"

(obtain Webasyst ID app client id from Webasyst and save it into this configuration file)

  1. Install Android Studio as described in https://developer.android.com/studio/install

  2. In Android Studio choose file -> open and navigate to project directory.

  3. Detailed manual on running an app on the Android Emulator can be found here: https://developer.android.com/studio/run/emulator

tytyty's People

Contributors

m1r7 avatar m1r77 avatar vofka avatar wazawaigai avatar mirt-in-exile avatar muhammadolelah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.