FOSSASIA Summit 2024 takes place in Hanoi, Vietnam on April 8 – 10

We are excited to announce that our 15th annual summit will be hosted in the capital of Vietnam, Hanoi. We invite you to be a part of an extraordinary gathering that celebrates the spirit of collaboration, innovation, and open source.

  • Date: April 8-10, 2024
  • Location: Post and Telecommunications Institute of Technology, Hanoi, Vietnam

This year’s event is co-organized by FOSSASIA, VFOSSA, Vietnam Internet Association and PTIT. For event updates and registration, visit summit.fossasia.org 

Connecting Developers Across the Region

With over a decade of fostering collaboration and knowledge exchange, the FOSSASIA Summit has become a platform for developers, enthusiasts, and industry leaders. This year, we expect to welcome a diverse community of 3,000 attendees from across the globe, providing a unique opportunity to connect with like-minded individuals and explore the latest advancements in open source.

Call for Speakers: Share Your Insights!

Interested in becoming a speaker? Submit your proposals by January 31st with early submissions given priority.

Exhibition Booths: Showcase Your Projects!

Open source projects, organisations, and businesses are encouraged to sign up for exhibition booths. This is your chance to showcase your solutions, connect with the community, and explore collaborations. Reserve your space today at https://summit.fossasia.org/exhibition 

Complimentary Space For FOSS Communities and Foundations

As a commitment to fostering community growth, we are offering complimentary space for FOSS communities. If you represent a community that would benefit from this opportunity, please complete this form by February 17th. 

Sponsorship Opportunities

Elevate your brand and support the open source movement by becoming a sponsor of the FOSSASIA Summit 2024. Gain visibility among a diverse audience and showcase your commitment to the principles of open source. For sponsorship details, please contact office@fossasia.org.

Join us in Hanoi for an unforgettable experience at the FOSSASIA Summit 2024. Let’s celebrate 15 years of open source excellence, connect with the global community, and shape the future of open source together!

More About The FOSSASIA Summit 

The FOSSASIA Summit is an annual event for professionals, developers, companies and researchers. During the three day event participants get together to share projects and ideas, learn from each other, and network. The event is one of the longest running IT conferences in Asia.

At the FOSSASIA Summit 2024 we will focus on the rapid growth of AI and discuss its transformative impact considering both opportunities and ethical considerations. Large-scale cloud computing, scalability, seamless integration, open-source operating systems, the revolutionary domain of Web3 technologies are also among the featured topics. We look at opportunities for businesses by using open-source and explore the potential of new technologies to streamline processes across industries. With a commitment to sustainability, the summit will continue to showcase the pivotal role of open hardware in fostering local production capabilities, contributing to a more inclusive and interconnected technological future.

Continue ReadingFOSSASIA Summit 2024 takes place in Hanoi, Vietnam on April 8 – 10

FOSSASIA Summit 2023 Schedule – Participate Onsite or Online

The schedule is out and the FOSSASIA Summit will finally take place again in-person! Please join us for the event at the Lifelong Learning Institute Singapore from April 13-15, 2023.

During the three day event professionals, developers, companies, researchers and tech communities get together to share projects and ideas, learn from each other, and network. Over 150 International speakers will join us and show what is possible with technology today. Catering is provided throughout the event.

For community members we have a promotion with the link here.

For online participants virtual tickets are free and you can win a Tshirt in the lucky draw if you ask a question via Twitter/Mastodon to a speaker.*

The opening is at 9:00 AM on Thursday April 13 with a keynote on the Open Source tech community in 2023. The exhibition with more than 40 exhibitors opens at 8.30 AM daily featuring job opportunities in tech and latest trends in the industry.

Sessions are also going to be streamed to YouTube and services in China.

Find out more about the highlights at the event, sponsors and exhibition partners below. Please also join our Telegram chat here. We can’t wait to meet you again at the summit!

 

Tracks and Topics

A big topic currently everywhere is AI and ChatGPT. In the artificial intelligence track we will talk about how to build, deploy and run large AI systems using in-house data and Open Source and discuss how the technology can benefit humanity in a rapidly changing world.

Areas that are also receiving more and more attention recently are roboticshardware, firmware, and microchips. How can open source robotics and open hardware help to solve the challenges in public health, renewable energy, food production and climate change?

Other dedicated tracks cover everything from cloud, DevOps and databases to Blockchainweb & mobileInnerSource and open source standards where we exchange about standardization and approaches that ensure interoperability, security and the economical use of our resources and energy.

In tracks about kernel, platform, operating systems and security experts get together to discuss the latest solutions in the industry.
Highlights

Workshops: Join us for three intensive workshop tracks on Friday and Saturday on “Cloud and DevOps”, “Databases and Optimization” and “Artificial Intelligence” with experts from around the world.

FOSSASIA Academy with BuildingBloCS: Join us for introductory levelled technology workshops conducted by students from Singapore. Topics include Introduction to Graph Neural Networks, AI in Astronomy and Physics, Processing data with Python, Steganographic malware embedding in AI models, and the Forward-Forward Algorithm. Sign up to reserve.

12 Conference Tracks: Join talks by industry experts and sponsors from OpenEuler, OnlyOffice, PagerDuty, Oracle, Google, YDB, ExpressVPN, Instaclustr by NetApp, Varnish Software, Temporal, NARlabs, Grafana Labs, AngelHack, Mercari, UI-licious, and participants from GovTech, OPNTEC, Microsoft, Datadog, Shopify, AWS, MariaDB, Percona, Intrinsic, Viettel, GitLab, Thoughtworks, Nextcloud, Gojek, Grab, Wavestone, Pythian, IEEE, SODA Foundation, Hyperledger Foundation, Apache Foundation, LionsForge, and open source projects like VLC, LibreOffice, Kaiyuanshe 开源社, Debian, AlmaLinux, KDE, openKylin, SCoRE Lab, Keploy and communities like HackerspaceSG, GOSH, Calyx Institute, COSCUP, Korean FOSS Community, WomenWhoCode, SegmentFault, The IO Foundation, Hack Club, SalvageGarden Assistive Makerspace, CivicTechLab as well as hardware experts from the Raspberry Pi Foundation, Precursor, and many more. Find the complete schedule here.

Exhibition Booths: Showcases and career opportunities with industry-leading companies and Institutes of Higher Learning like NUS, Nanyang Polytechnic, Republic Polytechnic, ITE West, plus career consultant sessions of SkillsFutureSG. Check out the exhibition overview.

Don’t miss out on our Social Events

FOSSASIA Party with Buffet, Live Music, Dance & Cultural Program on Fri. 14 April: Celebrate the FOSSASIA get together party! Social event ticket

FOSSASIA Meet & Greet on Wed. 12 April: Join the speakers and attendees, meet the local tech scene, explore Singapore in a culture and exploration Wednesday afternoon, and enjoy the taste of Asia at a local dinner: Sign up

Chinatown Snacks, Smith Street Taps and Brewerkz with speakers on Thu. 13 April: Network with speakers and participants of the FOSSASIA OpenTechSummit at a Chinatown and Clarke Quay snacks and beer evening: Sign up

Dim Sums and Midnight Hacks: Didn’t get enough? Join us for the FOSSASIA after-event at Hackerspace.sg on Saturday evening 15 April: Sign up

Community Walk in the nature on Sunday afternoon 16 April: Join us for a Sunday afternoon walk at MacRitchie park with FOSSASIA Summit speakers and participants: Sign up

Online Participation

Sessions are going to be streamed to YouTube and services in China. Virtual Ticket holders can also join a number of interactive sessions live on eventyay. Please get a free virtual event ticket.

* Please post a screenshot of the session video on your tweet on Twitter or Mastodon during the event and tag it @fossasia to be eligible for the Tshirt lucky draw during the event.

Continue ReadingFOSSASIA Summit 2023 Schedule – Participate Onsite or Online

FOSSASIA Summit 2023 in Singapore and Online

We are happy to announce that the FOSSASIA Summit will return as an in-person event to Singapore from April 13 to 15, 2023. For online participants we also offer a remote participation option.

To reserve your slot, please click here for an early bird ticket.

Interested in becoming a speaker? Please propose a talk, panel or workshop before February 8.

Want to share about your Open Source project or showcase your company as a sponsor or exhibitor? Please fill out the form here.

The FOSSASIA Summit is an annual event for professionals, developers, companies, researchers and tech communities from around the world. During the three day event participants get together in Singapore to share projects and ideas, learn from each other, and network. The event is one of the longest running IT conferences in Asia.

At the 2023 summit we focus on sustainable technologies, resilience and solutions for a rapidly changing world. Public health, renewable energy, food production and climate change will remain major challenges in the coming decades. Solutions require new approaches and technologies. How can FOSS/Open Source software and Open Hardware approaches help? What solutions exist, what are engineers working on? What are emerging technologies? And, what standards do we need to ensure interoperability, security and the economical use of our resources and energy?

The topics of the tracks at the event range from artificial intelligence, to robotics, cloud & DevOps, databases, hardware and firmware, blockchain, to Open Source standards as well as web and mobile technologies.

So, let’s meet up at the FOSSASIA Summit and shape the unknown!

Continue ReadingFOSSASIA Summit 2023 in Singapore and Online
Read more about the article FOSSASIA Summit 2022 Cloud Skills Challenge
Cloud Skills Challenge

FOSSASIA Summit 2022 Cloud Skills Challenge

The FOSSASIA Summit 2022 Cloud Skills Challenge offers participants a free E-Learning opportunity to build up cloud skills, opening the doors to a professional IT journey. Join the Cloud Skills Challenge today to build up your cloud skills, get your certificate and stand a chance to win exciting prizes. 
Until March 31, you can sign-up for a series of Free E-Learning Modules on: 
  • Introduction to Cloud Computing 
  • Introduction to Machine Learning
  • Best AI service for your needs 
  • Objects Detection with the Custom Vision service
  • Database and Data storage services 
  • Concept of Data Analysis 
  • IoT service for your applications 
  • And many more 

Learning Rewards 

  • Complete at least 5 modules to get a digital certificate 
  • Complete 10 modules to receive a digital swag
  • Complete all 51 modules to stand a chance to win top prizes: 
    • 1st Prize: Surface Go 2 
    • 2nd Prize: Surface Headphone 2
    • 3rd Prize: JBL Charge 4 

Winners 

  • Winners will be announced during the FOSSASIA Summit 2022, April 7-9 by jury members.

Sign Up Now at https://summit.fossasia.org/cloud   

Continue ReadingFOSSASIA Summit 2022 Cloud Skills Challenge

FOSSASIA Summit 2022 Call for Speakers and Sign-Up

The FOSSASIA Summit 2022 will take place online from April 7-9.

While all of us are still learning to cope with the pandemic, it is very important that we get together, exchange ideas, collaborate on projects and together develop solutions that tackle our global issues.

2021 was a very challenging year for us as we lost our friend and core maintainer Areeb Jamal. Many of FOSSASIA members in the region were struggling to fight against Covid. Despite all the difficulties, we managed to continue our work in the area of open hardware with Pocket Science Lab, improving our collaborative event platform Eventyay and once again supporting more students to become open source contributors and developers via our CodeHeat program.

We would like to thank our contributors and 2022 sponsors Indeed and Linux Professional Institute for their support. If you would like to support FOSSASIA projects and our work, please consider making a donation here.

FOSSASIA Summit 2022 Call for Speakers

The current situation around the world shows us that open global collaboration is the way to solve the problems of our time. Now we would like you to share your hands-on examples at the FOSSASIA Summit Online of topics such as:

  • Open source tools advancing the software delivery process
  • Implement continuous delivery and observability in DevOps
  • Open source hardware and local production addressing global supply chain issues
  • Customize Linux and firmware software for lightweight hardware, robots and special use cases
  • Solve everyday problems with AI
  • Ensure digital sovereignty and independent data governance
  • Get security and privacy right
  • Open source solutions tackling global health issues and climate change
  • Open source and beyond: Citizen science and biohacking
  • Establishing a friendly, welcoming and collaborative project culture

Please find the complete list of tracks on the event site and submit your proposal. We are looking forward to your inspiring sessions.

Important Dates

Notification of acceptance: On an ongoing basis
Early submissions receive priority
Submission deadline: 22 January 2022
Event dates: 7 – 9 April 2022

Continue ReadingFOSSASIA Summit 2022 Call for Speakers and Sign-Up

FOSSASIA Virtual Summit 2021 Schedule and Highlights

We are very happy to share with you the schedule of the FOSSASIA Virtual Summit 2021!

  • 190+ speakers from 42 countries and 6 continents are joining us.
  • We are covering a diverse range of topics at the event such as Quantum computing, machine learning, open robotics, CAD and hardware development, search, databases, Covid-19 and open health, Blockchain, digital privacy, microservices, cloud, Kubernetes, kernel development, licensing and many more.
  • More than 180 sessions, talks, panels and workshops are taking place online. 
  • Plus, trainers conduct 28 hours of hands-on onsite sessions at the Lifelong Learning Institute in Singapore.

Get your free ticket here!

The summit will spread out over the week of March 13-21 and will run on our open source virtual event platform eventyay.

In the virtual exhibition you can meet our sponsors and partners like Microsoft, Oracle, MySQL, OpenTAP Keysight, Linux Professional Institute, Elasticsearch, OpnTec, Cloud Native Computing Foundation, FreeBSD, UI-licious, Lifelong Learning Institute Singapore and the UNESCO.

And you can get together with developers and contributors from Free and Open Source projects, makerspaces, developer clubs and university IT groups. At summit hubs across Asia we are connecting to participants online and locally.

FOSSASIA Summit Highlights

  • 5 keynotes from Hong Phuc Dang (Founder, FOSSASIA) and Mario Behling (Co-Founder FOSSASIA, CEO OpnTec), Frank Karlitschek (CEO, Nextcloud), Greg Kroah-Hartman (Linux Kernel Maintainer), Brian Behlendorf (Executive Director, Hyperledger) and Bunnie Huang (CEO, Precursor)
  • 150+ sessions covering tech areas of Quantum computing, PyTorch, Scikit-learn, pocket science, open robotics, FreeCAD, hardware development, search, databases, Debian packaging, Covid-19, Hyperledger, Open Source event solutions, digital privacy, microservices, cloud, Kubernetes, and Linux Kernel development.
  • 30+ hands-on workshops focusing on getting started with Python, creating MySQL shell utilities and custom plugins, setting up PostgreSQL databases, creating test automation, machine learning, and science measurements.
  • Panel discussions about Open Source licensing vs. available source licenses, firmware development, digital sovereignty, Blockchain and diversity in tech.
  • Virtual exhibition with video rooms and exhibitor tours where participants can connect with companies and active tech communities from across Asia.

FOSSASIA Summit Exhibition and Hubs

Apart from company partners you can meet communities, students and developers from Asia and around the world in our virtual exhibition. Groups include OpenFIESTA Tsinghua University, Shenzhen DIY Community, Open Source Hong Kong, OpenStack Indonesia, Mozilla Philippines, Ubuntu Korea, FOSS Myanmar, KDE, BuildingBloCS Singapore, SUTD, Python Software Foundation, LibreOffice, KiwiTCMS, Nextcloud Sourcefabric, LambdaChip, and more.

Hubs bring attendees together locally or online. Participating hubs include the International Organisation of Software Developers, Open Source Club at Saintgits Engineering College Kerala, Biohacking Space Peshawar Pakistan, Society for Data Science at BIT Mesra India, Mar Athanasius College of Engineering India, Developer Student Community in BHILAI Institute of Technology Durg and Team Aveon Racing of BIT Mesra India.

FOSSASIA Summit Daily Focus Topics

Each day has different focus topics and tracks.

Sat, 13 Mar: Robotics, Open Hardware, Pocket Science Lab, Python/Web development, Digital Sovereignty

Sun, 14 Mar: Open Hardware, open science, lightning talks, Python/Web development

Mon, 15 Mar: Blockchain, hardware, design, learn how to solder

Tue, 16 Mar: DevOps, cloud, containers, Kernel & Platform, Quantum computers, Kubernetes

Wed, 17 Mar: Databases, MySQL, PostgreSQL, Monitoring

Thu, 18 Mar: Security, Privacy,  Digital Sovereignty, IoT, cloud, Blockchain, Open Source voice assistants

Fri, 19 Mar: Artificial Intelligence, PyTorch, Visdom, search, scikit, NLP

Sat, 20 Mar: DevOps, Python bot programming, Container Regisitries, OSS Licenses vs. available source, FOSS Community in Asia, OpenStreetMap, Python/Web development

Sun, 21 Mar: Lightning talks, Open Health, Covid-19 apps around the world, Fdroid, platform, smart devices

Continue ReadingFOSSASIA Virtual Summit 2021 Schedule and Highlights

FOSSASIA Summit 2021 Call for Speakers and Projects

The FOSSASIA Summit 2021 will take place ONLINE this year. The event will spread out over the week of March 13 – 21 and will run on our own open source virtual event platform ‘eventyay’. 

Speakers interested to submit a talk, panel or workshop please propose your session before 4th February (soft deadline). We want to learn from you how to solve the challenges of our time with Open Technologies! 

At the event we are connecting local hubs, makerspaces, clubs and university IT groups across Asia. Please fill in this form to become a community hub partner and get listed on the event site.


Topics

The current situation around the world shows us that open global collaboration is the way to solve our problems. Now we would like you to share your hands-on examples at the event of topics such as how to:

  • Take on the fight against COVID-19 with open health technologies
  • Solve everyday problems with AI
  • Tackle climate change with an open source approach
  • Create open hardware solutions for science and Biohacking
  • Run DevOps in a distributed team in home office
  • Implement continuous delivery and sovereign cloud stacks with diverse tools
  • Establish a friendly, welcoming and collaborative project culture
  • Ensure digital sovereignty and independent data governance
  • Get privacy and security right
  • Customize Linux for lightweight hardware and special use cases
  • And what are best practices for open access education

.. and many more topics about Databases, Web and Mobile Technologies, Robotics, Blockchain, Design and Compliance. Please find the complete list of tracks on the event site and submit your proposal.

Important Dates

  • CfS soft deadline: 4 February 2021 (submissions receive priority)
  • Late submission cut off date: 11 February 2021
  • Event dates: 13 – 21 March 2021
  • Notification of acceptance: On an ongoing basis

Sessions and Slots

Talks

Talk slots are 15 minutes, 25 minutes or 40 minutes long these include time for questions and answers. We recommend to reserve at least a third of the time for questions. Shorter sessions are preferred to avoid online fatigue of the audience.

Panels

Panels are sessions with at least two panelists who discuss a topic and provide insights. Available slots are 55 minutes.

Workshops

Workshop options are 90 minutes, 2 hours or 3 hours. We are looking for interactive workshops where participants can actively engage in.

Lightning talks

You have some interesting ideas but do not want to submit a full talk? We suggest you go for a lightning talk which is a 5 minutes slot to present your idea or project.

Virtual exhibition

We offer virtual exhibition rooms for companies, projects, online installations, team gatherings and other fun activities. We are curious to know what you would like to show. Please add details in the submission form.

To Know

  • This year summit will take place online.
  • Speakers will conduct their sessions live to provide an interactive environment
  • Speakers can deliver sessions in English or a language of their choice.
  • Q&As and interaction among participants are highly encouraged.
  • Submissions for hands-on workshops and panel discussions are preferable as they provide more interactive opportunities.

Publication

Audio and video recordings of the lectures will be published in various formats under the Creative Commons Attribution 4.0 International (CC BY 4.0) license. This license allows commercial use by media institutions as part of their reporting. If you do not wish for material from your lecture to be published or streamed, please let us know in your submission.

Links

FOSSASIA Summit: summit.fossasia.org

FOSSASIA Videos: Youtube FOSSASIA

FOSSASIA on Twitter: twitter.com/fossasia

Continue ReadingFOSSASIA Summit 2021 Call for Speakers and Projects

FOSSASIA Summit 2020 Takes Places as Online and Offline Event

Due to the Corona crisis it is clear that events like the FOSSASIA Summit cannot be run in the usual way with large crowds. Therefore this year the FOSSASIA Summit will only be possible as a smaller gathering with social distancing in Singapore and online interactions from Thursday, March 19 – Saturday, March 21. 

Even with travel restrictions in place a number of speakers are in Singapore and expressed their wish sharing their knowledge and the FOSSASIA team is working hard to facilitate this in a safe space offline and online. Due to ongoing changes we will conduct the event with both unscheduled and scheduled sessions. The program will be updated continuously here.

The Lifelong Learning Institute, our host and co-organizer, adjusted the venue to ensure the safety and health of all. To participate on-premise you need to pass a screening test and follow directions for hygiene measures. The sign up is here

Singapore has an outstanding record seen internationally as a gold standard when it comes to cleanliness, hygiene and health. Additional measures in the LLI include providing entrance screening tests, social distancing, using open spaces, reducing the use of mics and mic disinfection, avoiding close group photos. Please find a list of measures here.

The events of our time show more than ever that we need to collaborate to solve the world’s problems such as climate change, global health issues, poverty and economic challenges. The FOSS/Open Source community has proven that we are able to overcome differences and work together across countries and cultures. It is important that we stay connected and continue our work be it offline or online. To connect virtually during the FOSSASIA Summit you can join us on these channels:

We will share more details about sessions in the upcoming days. Furthermore, we are planning additional online events at a later time this year. Let’s continue and build a better world through learning and sharing where-ever and however we can!

We would like to thank everyone who supported us throughout these challenges around the event – our speakers, friends, supporters, and partners like Google, Facebook, Arm, and Elastic.

We hope to stay connected. All the best and stay healthy!

FOSSASIA Presentations
FOSSASIA Videographers
Continue ReadingFOSSASIA Summit 2020 Takes Places as Online and Offline Event

Implement JWT Refresh token in Open Event Attendee App

In open event attendee android app earlier only access token is used, which causes HTTP 401 many time due to expiry of the token. It needs to re sign-in for the user. Now we have implemented refresh token authorization with the open event server using retrofit and OkHttp. Retrofit is one of the most popular HTTP client for Android. When calling API, we may require authentication using a token. Usually, the token is expired after a certain amount of time and needs to be refreshed using the refresh token. The client would need to send an additional HTTP request in order to get the new token. Imagine you have a collection of many different APIs, each of them requires token authentication. If you have to handle refresh token by modifying your code one by one, it will take a lot of time and of course, it’s not a good solution. In this blog, I’m going to show you how to handle refresh token on each API calls automatically if the token expires.

  • How refresh token works?
  • Add authenticator to OkHttp
  • Network call and handle response
  • Conclusion
  • Resources 

Let’s analyze every step in detail.

How Refresh Token Works?

Whether tokens are opaque or not is usually defined by the implementation. Common implementations allow for direct authorization checks against an access token. That is, when an access token is passed to a server managing a resource, the server can read the information contained in the token and decide itself whether the user is authorized or not (no checks against an authorization server are needed). This is one of the reasons tokens must be signed (using JWS, for instance). On the other hand, refresh tokens usually require a check against the authorization server. 

Add Authenticator to OkHTTP

OkHttp will automatically ask the Authenticator for credentials when a response is 401 Not Authorised retrying last failed request with them.

class TokenAuthenticator: Authenticator {

    override fun authenticate(route: Route?, response: Response): Request? {

        // Refresh your access_token using a synchronous api request
        val newAccessToken = service.refreshToken();

        // Add new header to rejected request and retry it
        return response.request().newBuilder()
            .header(AUTHORIZATION, newAccessToken)
            .build()
    }
}

Add the authenticatior to OkHttp:

val builder = OkHttpClient().newBuilder()
            .authenticator(TokenAuthenticator())

Network Call and Handle Response

API call with retrofit:

@POST("/auth/token/refresh")
    fun refreshToken(): Single<RefreshResponse>

Refresh Response:

@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
data class RefreshResponse(
    val refreshToken: String
)

In a Nutshell

Refresh tokens improve security and allow for reduced latency and better access patterns to authorization servers. Implementations can be simple using tools such as JWT + JWS. If you are interested in learning more about tokens (and cookies), check our article here.

Resources

  1. Android – Retrofit 2 Refresh Access Token with OkHttpClient and Authenticator: https://www.woolha.com/tutorials/android-retrofit-2-refresh-access-token-with-okhttpclient-and-authenticator
  2. Refresh Tokens: When to Use Them and How They Interact with JWTs: https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/

Tags

Eventyay, open-event, FOSSASIA, GSoC, Android, Kotlin, Refresh tokens

Continue ReadingImplement JWT Refresh token in Open Event Attendee App

Enable Server Configuration with Okhttp and Retrofit in Open Event Attendee Application

The open event attendee is an android app which allows users to discover events happening around the world using the Open Event Platform. It consumes the APIs of the open event server to get a list of available events and can get detailed information about them.

We are using default API for eventyay app. Server configuration is something when we replace backend API with a new one and perform the same applications with the different server. As it is a fully open-source project on F-droid, so we have enabled the server configuration field for the F-droid build variant. 

  • Retrofit and okhttp for network calls
  • Create a feasible UI and set the link to preferences
  • Create interceptor for changing API URL
  • Add interceptor in okhttp client builder
  • Conclusion
  • Resources 

Let’s analyze every step in detail.

Retrofit and Okhttp for Network Call

Using Retrofit for your Android app’s networking can make your life so much easier. However, Retrofit’s design requires a single Retrofit instance for each API with a different base URL. Consequently, if your app is talking to two or more APIs (under different URLs), you’ll need to deal with at least two Retrofit instances.

Retrofit is a type-safe REST client for Android, Java, and Kotlin developed by Square. The library provides a powerful framework for authenticating and interacting with APIs and sending network requests with OkHttp.

OkHttp communicating with the server- 

Design UI and set the link to preferences with MVVM

Create a simple dialog with a checkbox with default URL and a EditText:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <CheckBox
        android:id="@+id/urlCheckBox"
        android:layout_margin="@dimen/layout_margin_large"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.google.android.material.textfield.TextInputLayout           style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
        android:id="@+id/urlTextInputLayout"
        android:layout_margin="@dimen/layout_margin_large"
        android:hint="@string/other_url"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/urlEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

Handle visibility if the dialog and display for only F-droid build:

preferenceScreen.findPreference<PreferenceCategory>(getString(R.string.key_server_configuration))?.isVisible = BuildConfig.FLAVOR == FDROID_BUILD_FLAVOR

Set current API to preference screen:

preferenceScreen.findPreference<Preference>(getString(R.string.key_api_url))?.title =
            settingsViewModel.getApiUrl()

Get API from View model: 

fun getApiUrl(): String {
        return preference.getString(API_URL) ?: BuildConfig.DEFAULT_BASE_URL
    }

Setup alert dialog:

if (preference?.key == getString(R.string.key_api_url)) {
            showChangeApiDialog()
        }
private fun showChangeApiDialog() {
        val layout = layoutInflater.inflate(R.layout.dialog_api_configuration, null)
        layout.urlCheckBox.text = BuildConfig.DEFAULT_BASE_URL

        val dialog = AlertDialog.Builder(requireContext())
            .setView(layout)
            .setPositiveButton(getString(R.string.change)) { _, _ ->
                val url = if (layout.urlCheckBox.isChecked) BuildConfig.DEFAULT_BASE_URL
                                else layout.urlEditText.text.toString()
                if (url === settingsViewModel.getApiUrl()) return@setPositiveButton
                settingsViewModel.changeApiUrl(url)
                view?.snackbar("API URL changed to $url")
                findNavController().popBackStack(R.id.eventsFragment, false)
            }
            .setNegativeButton(getString(R.string.cancel)) { dialog, _ -> dialog.cancel() }
            .setCancelable(false)
            .show()
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false

        layout.urlCheckBox.setOnCheckedChangeListener { _, isChecked ->
            layout.urlTextInputLayout.isVisible = !isChecked
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = isChecked
        }

Set URL to preferences in the view model and end current session:

fun changeApiUrl(url: String) {
        preference.putString(API_URL, url)
        logout()
    }

Create Interceptor to Handle New API URL

Here default API URL is set to the retrofit already: 

Retrofit.Builder()
            .client(get())
            .baseUrl(baseUrl)
            .build()

As we discussed earlier OkHttp handles every network call for the application. So here we track the URL host from the okhttp interceptor. If the URL host is equaled to the default API URL host, then we can say that it is an API call and then we can replace same with the host getting from preferences if it is not null and set the interceptor to okhttp client builder.

Create host selection interceptor class to return interceptor with the API URL:

class HostSelectionInterceptor(private val preference: Preference) : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        var original = chain.request()
        val httpUrl = preference.getString(API_URL)?.toHttpUrlOrNull()
        if (original.url.host == BuildConfig.DEFAULT_BASE_URL.toHttpUrlOrNull()?.host && httpUrl != null) {
            val newUrl =
                original.url.newBuilder()
                    .scheme(httpUrl.scheme)
                    .host(httpUrl.host)
                    .port(httpUrl.port)
                    .build()
            original = original.newBuilder()
                .url(newUrl)
                .build()
        }
        return chain.proceed(original)
    }
}

Set the interceptor to okhttp client builder:

val builder = OkHttpClient().newBuilder()
            .addInterceptor(HostSelectionInterceptor(get()))

GIF

In a Nutshell

Server configuration provides better user experience for open-source platform and developer, as they can mention their own server and test it.

Resources

OkHttp client with retrofit: https://futurestud.io/tutorials/retrofit-2-share-okhttp-client-and-converters-between-retrofit-instances

Tags

Eventyay, open-event, OkHttp, Retrofit, FOSSASIA, GSoC, Android, Kotlin

Continue ReadingEnable Server Configuration with Okhttp and Retrofit in Open Event Attendee Application