text:
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0 - 2019-02-03]

Major release, entire plugin rewrite

### Added

- Support for multiple strategies (currently `BroadcastChannel` and `LocalStorage` are supported)

### Fixed

- Internet Explorer support when sharing big payloads

### Other

- Migrated to karma + mocha from ava
- E2E tests are run on real browsers to ensure browsers specifics is taken into account

## [0.0.7 - 2019-01-07]

- Proper build of 0.0.6, no major changes

## [0.0.6 - 2019-01-07]

### Fixed

- Issue introduced in 0.0.5 when plugin failed to work in Chrome due to concurrency issues (#13)

## [0.0.5 - 2018-11-11]

Thanks to [@jameswragg](https://github.com/jameswragg) and [@justin-schroeder](https://github.com/justin-schroeder) for this version

### Fixed

- IE11 is not triggering storage events if payload is bigger than 16kb

## [0.0.4 - 2018-06-22]

Credits to [@qkdreyer ](https://github.com/qkdreyer) for this version

### Fixed

- Bump vuex peer dependency

## [0.0.3 - 2017-02-20]

Credits to [@LeonardPauli](https://github.com/LeonardPauli) for this version

### Fixed

- Repeating the same mutation would previously only have shared the first commit

### Added

- Readme section "Contributing"
- Readme section "How it works"
- Readme predicate function usage example
- Passing `state` to predicate function allows for invoking other plugins in the predicate

## [0.0.2] - 2017-02-01

### Added

- Print error and fail early if localStorage.setItem throws an error

### Changed

- Print error instead of crashing when window is not available (SSR)

### Changed

- Properly report plugin name in error messages

## 0.0.1 - 2017-01-31

Initial release

[0.0.2]: https://github.com/xanf/vuex-shared-mutations/compare/v0.0.1...v0.0.2


text:
<!--
waggle_topic=/node_controller,Waggle Core Software
waggle_topic=/edge_processor,Waggle Core Software
-->

# Node Stack - Core Repo

This repo contains software and tools common to both the node controller and
edge processor, covering functionality such as:

* Managing deployment state.
* Controlling plugins.
* Heartbeating
* Media recovery.

Note that this software was originally targetting the ODROID C1+ and ODROID XU4,
so some components may require significant tweaks before running them on other devices.

## Setup

Dependencies and services are installed and configured by running:

```sh
git clone https://github.com/waggle-sensor/core /usr/lib/waggle/core
cd /usr/lib/waggle/core
./configure
```

repository: waggle-sensor/core

branch_name: refs/heads/master

extension: md

gha_language: Python

license_type: permissive

repo_name: waggle-sensor/core


text:
---
title: Automatic build versioning
description: How to set a new build number to push to app stores
weight: 2
aliases:
  - /building/build-versioning
  - /configuration/build-versioning
---

If you are going to publish your app to **App Store Connect** or **Google Play**, each uploaded artifact must have a new version satisfying each app store's requirements. You'll need to devise a build versioning strategy that satisfies the App Store and/or Google Play Store versioning requirements and works for your team's development processes. On this page, we will explain the App Store and Google Play build versioning requirements, how the Flutter framework generalizes build versioning, and various strategies to set your build versions using Codemagic. See the [build versioning codemagic blog article](https://blog.codemagic.io/build-versioning-with-codemagic/) for a detailed overview.

{{< youtube UezlgmCZLcU >}}

## Overview of Build Versioning Requirements

#### App Store Connect Requirements

The main values for iOS & macOS versioning are `CFBundleShortVersionString` (Release Version Number) and `CFBundleVersion` (Build Version Number). The best explanation of these two values, despite being outdated, is Apple's technical note on [Version Numbers and Build Numbers](https://developer.apple.com/library/archive/technotes/tn2420/_index.html).

[CFBundleShortVersionString](https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring), Release Version Number, is the external user facing release version of your app displayed in the App Store. It must follow the `{major}.{minor}.{patch}` version format of three period separated integers. This must be incremented every time you release a version to the App Store. It's advisable to commit this value to version control and update it for every new release of your app to the App Store.

[CFBundleVersion](https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion), Build Version Number, is the internal build version number of your application used for testing and development. It appears in `{major}.{minor}.{patch}` format of one to three period separated integers. If {minor}.{patch} are not provided, then they will default to zero. Build version number must be incremented with every release candidate submitted to TestFlight for a particular release version number. For iOS, build version number can be reused across different release version numbers while for macOS, build version number must be unique across all release version numbers. This value is best incremented and set by your CI/CD pipeline for every build you're submitting to TestFlight.

#### Google Play Requirements

You can find the Google Play build versioning requirements in the [Android documentation](https://developer.android.com/studio/publish/versioning#appversioning). The important values defined in the build.gradle file are `versionName` and `versionCode`.

`versionName` is a text based, external, version of your app that is displayed to users and visible in Google Play. There are no restrictions for `versionName`, so you should choose something that makes sense for you and your users, such as `{major}.{minor}.{patch}` versioning. It's advisable to commit this value to version control and update it for every new release of your app to the Play Store.

`versionCode` is an internal version of your app that must be an integer value between `1` and `2100000000`. This must be incremented for every build you upload to Google Play. This value is best incremented and set by your CI/CD pipeline for every build.

#### Flutter Build Versioning

Flutter generalizes iOS and Android build versioning with the [pubspec.yaml **version** property](https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/app/pubspec.yaml.tmpl#L9-L19). This is a value in the form `{major}.{minor}.{patch}+{build_number}` (e.g. `1.2.3+45`). In Flutter builds, the value for build name, `{major}.{minor}.{patch}`, sets  `CFBundleShortVersionString` for iOS and `versionName` for Android. While the optional build number, `{build_number}`, sets `CFBundleVersion` for iOS and `versionCode` for Android. With `flutter build` commands these values can be overridden with the command line arguments `--build-name` and `--build-number` or by setting the environment variables `FLUTTER_BUILD_NAME` and `FLUTTER_BUILD_NUMBER`.

In order to complete an automatic build versioning process for Flutter iOS apps, make sure the following keys along with their string values are set in `ios/Runner/info.plist`:

{{< highlight bash "style=paraiso-dark">}}
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
{{< /highlight >}}

It is advisable to set your build version (e.g. `1.2.3`) in the `pubspec.yaml` `version` property and commit this to version control, as this will only change on every app release. On the other hand, you should consider having your CI/CD pipeline increment and set build number automatically, as this should be updated for every build.

---

## Build versioning in Codemagic

### Environment variables

There are several approaches you can use for build versioning on Codemagic. One of the easiest ways to increment the application version on every build is by using the [environment variables](/variables/environment-variables) that Codemagic exports during the build. There are two environment variables that count the number of builds:

* `BUILD_NUMBER`. Holds the total count of builds (including the ongoing build) for a specific **workflow** in Codemagic. In other words, if you have triggered 10 builds for some workflow in Codemagic, the next time you build it, `BUILD_NUMBER` will be exported as `11`.

* `PROJECT_BUILD_NUMBER`. Holds the total count of builds (including the ongoing build) for a **project** (application) in Codemagic. In contrast with `BUILD_NUMBER`, `PROJECT_BUILD_NUMBER` will increase every time you build any of the workflows of the app.

{{< tabpane >}}
{{< tab header="Flutter" >}}
{{<markdown>}}
For Flutter, you can easily increment your build number and build name using the `PROJECT_BUILD_NUMBER` by passing the following to the build arguments:

{{< highlight bash "style=paraiso-dark">}}
--build-name=1.0.$PROJECT_BUILD_NUMBER --build-number=$PROJECT_BUILD_NUMBER
{{< /highlight >}}

Note that if the build version is manually incremented in `pubspec.yaml`, these arguments do not need to be passed to the build command.

If you've added an existing project to Codemagic and need to offset the build number by the current build number, i.e. 200, then you can pass the following argument to correctly increment your build number.

{{< highlight bash "style=paraiso-dark">}}
--build-number=$(($PROJECT_BUILD_NUMBER + 200))
{{< /highlight >}}
{{</markdown>}}
{{< /tab >}}

{{< tab header="Xcode" >}}
{{<markdown>}}
You can use the [Xcode command line agvtool](https://developer.apple.com/library/archive/qa/qa1827/_index.html) to set the next build version name for your build.

{{< highlight yaml "style=paraiso-dark">}}
  scripts:
    - name: Set the build version
      script: |
        #!/bin/sh
        set -e
        set -x
        cd $CM_BUILD_DIR
        agvtool new-version -all $(($BUILD_NUMBER + 1))
{{< /highlight >}}
{{</markdown>}}
{{< /tab >}}
{{< /tabpane >}}

## App Store or TestFlight latest build number

Using Codemagic [CLI tools](../knowledge-codemagic/codemagic-cli-tools) it is possible to get the latest build number from **App Store** or from **TestFlight** so you can automatically increment the build version in your workflow. For more details, check the [get-latest-app-store-build-number](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/get-latest-app-store-build-number.md#get-latest-app-store-build-number) or [get-latest-testflight-build-number](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/get-latest-testflight-build-number.md#get-latest-testflight-build-number) actions from [app-store-connect](https://github.com/codemagic-ci-cd/cli-tools/tree/master/docs/app-store-connect#app-store-connect) Codemagic CLI Tool.

In order to allow Codemagic to connect to your App Store Connect account, you need to provide API access to App Store Connect API. It is possible that some of these environment variables are already configured as part of the iOS code signing configuration.

#### Creating the App Store Connect API key

{{< include "/partials/app-store-connect-api-key.md">}}

#### Configuring the API access variables

Configure the following environment variables if they are missing from your Codemagic UI:

- `APP_STORE_CONNECT_KEY_IDENTIFIER`

  In **App Store Connect > Users and Access > Keys**, this is the **Key ID** of the key.

- `APP_STORE_CONNECT_ISSUER_ID`

  In **App Store Connect > Users and Access > Keys**, this is the **Issuer ID** displayed above the table of active keys.

- `APP_STORE_CONNECT_PRIVATE_KEY`

  This is the private API key downloaded from App Store Connect.

- `APP_APPLE_ID`

  Automatically generated ID assigned to your app, e.g. `1234567890`.
  It can be found under **General > App Information > Apple ID** under your application in App Store Connect.

Follow these steps to configure the above variables for your Codemagic app:

{{< tabpane >}}
{{< tab header="codemagic.yaml" >}}
{{<markdown>}}
1. Open your Codemagic app settings, and go to the **Environment variables** tab.
2. Enter the desired **_Variable name_**, e.g. `APP_STORE_CONNECT_KEY_IDENTIFIER`.
3. Enter the variable value as **_Variable value_**.
4. Enter the variable group name, e.g. **_app_store_credentials_**. Click the button to create the group.
5. Make sure the **Secure** option is selected.
6. Click the **Add** button to add the variable.
7. Repeat the steps to also add all of the above variables.

8. Add the variable group to your `codemagic.yaml` file
{{< highlight yaml "style=paraiso-dark">}}
  environment:
    groups:
      - app_store_credentials
{{< /highlight >}}
{{</markdown>}}
{{< /tab >}}

{{< tab header="Flutter workflow editor" >}}
{{<markdown>}}
Add the following environment variables to your Flutter project in **App settings > Environment variables** (See the details [here](/flutter-configuration/env-variables)):

- `APP_STORE_CONNECT_ISSUER_ID`
- `APP_STORE_CONNECT_KEY_IDENTIFIER`
- `APP_STORE_CONNECT_PRIVATE_KEY`
- `APP_APPLE_ID`
{{</markdown>}}
{{< /tab >}}
{{< /tabpane >}}

{{<notebox>}}
**Tip:** Alternatively, each property can be specified in the `scripts` section of the YAML file as a command argument to programs with dedicated flags. See the details [here](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/fetch-signing-files.md#--issuer-idissuer_id). In that case, the environment variables will be fallbacks for missing values in scripts.
{{</notebox>}}

#### Set the build number with `agvtool`

Once you have the App Store Connect API access configured, you can get the build number using the CLI tool and set your incremented project version.

Add the following script under your `scripts` field for `codemagic.yaml`, or as a custom [Pre-build script](/flutter-configuration/custom-scripts) in the Flutter workflow editor:

{{< highlight yaml "style=paraiso-dark">}}
  scripts:
    - name: Get the latest build number
      script: |
        LATEST_BUILD_NUMBER=$(app-store-connect get-latest-app-store-build-number $APP_APPLE_ID)
        cd ./ios # avgtool must run in the folder where xcodeproj file is located
        agvtool new-version -all $(($LATEST_BUILD_NUMBER + 1))
{{< /highlight >}}

{{<notebox>}}
**Tip:** Helpful optional arguments:

* `--app-store-version=APP_STORE_VERSION` to get the latest build number for a particular version of your application (`CFBundleShortVersionString`)
* `--platform=IOS | MAC_OS | TV_OS` to specify which platform to get the latest build number

Check the details for [get-latest-app-store-build-number](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/get-latest-app-store-build-number.md#optional-arguments-for-action-get-latest-app-store-build-number) or for [get-latest-testflight-build-number](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/get-latest-testflight-build-number.md#optional-arguments-for-action-get-latest-testflight-build-number).
{{</notebox>}}

Alternatively, if you use `YAML` configuration, you may just export the value to an environment variable and use it under your `CFBundleVersion` in `Info.plist`.

## Google Play latest build number

Use [`google-play get-latest-build-number`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/google-play/get-latest-build-number.md#get-latest-build-number) action from Codemagic CLI tools to get the latest build number from Google Play Console.

In order to do that, you need to provide Google Play API access credentials by providing `GCLOUD_SERVICE_ACCOUNT_CREDENTIALS` as arguments to the action, as defined below.

Additionally, you will need to provide the package name of the app in Google Play Console (Ex. `com.example.app`).

#### Creating Google service account credentials

You will need to set up a service account in Google Play Console and create a JSON key with credentials. See how to [set up a service account and create a key](https://docs.codemagic.io/yaml-publishing/google-play/#configure-google-play-api-access).

#### Configuring the API access environment variables

{{< tabpane >}}
{{< tab header="codemagic.yaml" >}}
{{<markdown>}}
1. Open your Codemagic app settings, and go to the **Environment variables** tab.
2. Enter the `GCLOUD_SERVICE_ACCOUNT_CREDENTIALS` as **_Variable name_**.
3. Copy and paste the credentials content as **_Variable value_**.
4. Enter the variable group name, e.g. **_google_play_credentials_**. Click the button to create the group.
5. Make sure the **Secure** option is selected.
6. Click the **Add** button to add the variable.

7. Add the variable group to your `codemagic.yaml` file
{{< highlight yaml "style=paraiso-dark">}}
  environment:
    groups:
      - google_play_credentials
{{< /highlight >}}
{{</markdown>}}
{{< /tab >}}

{{% tab header="Flutter workflow editor"%}}

Add the `GCLOUD_SERVICE_ACCOUNT_CREDENTIALS` environment variable to your Flutter project in **App settings > Environment variables** (See the details [here](../flutter-configuration/env-variables)).
{{% /tab %}}
{{< /tabpane >}}

{{<notebox>}}
**Tip:** Alternatively, credentials can be specified as a command argument with the dedicated flag, see the details [here](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/google-play/get-latest-build-number.md#--credentialsgcloud_service_account_credentials). In any case, it is advisable to save the service account credentials file to an environment variable so that it can be accessed during a build without committing it to version control. The environment variable will be a fallback for the missing value in the script.
{{</notebox>}}

#### Set the build number

Once you have the Google Play Developer API access set, you can get the build number using the CLI tool:

{{< highlight bash "style=paraiso-dark">}}
LATEST_BUILD_NUMBER=$(google-play get-latest-build-number --package-name 'com.example.app')
{{< /highlight >}}

{{<notebox>}}
**Note:** By default, the action will try to get the latest build number as the maximum build number across all tracks (`internal`, `alpha`, `beta`, `production`, and custom tracks, if available). If you want to limit the search, you can specify particular tracks with the optional argument `--tracks` described [here](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/google-play/get-latest-build-number.md#--tracksinternal--alpha--beta--production).
{{</notebox>}}

There are a number of ways how you can pass the obtained build number to an Android project (through environment variables, `gradlew` argument properties, file, or a call from `build.gradle`). Check the [android-versioning-example repository](https://github.com/codemagic-ci-cd/android-versioning-example/tree/master) for more details. Here is an example using `gradlew` arguments:

1. Edit your `build.gradle` file by adding the functions to read version name and code number from argument properties

{{< highlight Groovy "style=paraiso-dark">}}
// get version code from the specified property argument `-PversionCode` during the build call
def getMyVersionCode = { ->
    return project.hasProperty('versionCode') ? versionCode.toInteger() : -1
}
// get version name from the specified property argument `-PversionName` during the build call
def getMyVersionName = { ->
    return project.hasProperty('versionName') ? versionName : "1.0"
}

....
android {
    ....
    defaultConfig {
        ...
        versionCode getMyVersionCode()
        versionName getMyVersionName()
{{< /highlight >}}

2. Add a script to your `codemagic.yaml` file to set the build number and pass it to `gradlew` command

{{< highlight yaml "style=paraiso-dark">}}
scripts:
  - name: Build Android release
    script: |
      LATEST_GOOGLE_PLAY_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME")
      if [ -z $LATEST_GOOGLE_PLAY_BUILD_NUMBER ]
        then
          # fallback in case no build number was found from Google Play.
          # Alternatively, you can `exit 1` to fail the build
          # BUILD_NUMBER is a Codemagic built-in variable tracking the number of
          # times this workflow has been built
          UPDATED_BUILD_NUMBER=$BUILD_NUMBER
        else
          UPDATED_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_BUILD_NUMBER + 1))
      fi
      cd android # change folder if needed
      ./gradlew bundleRelease -PversionCode=$UPDATED_BUILD_NUMBER -PversionName=1.0.$UPDATED_BUILD_NUMBER
{{< /highlight >}}

#### Get the build number in the Flutter workflow editor

Provided you have exported your Google Play Console service account credentials as an environment variable `GCLOUD_SERVICE_ACCOUNT_CREDENTIALS`, you can call it immediately as a build argument to your Android build command to increment the build number:

{{< highlight bash "style=paraiso-dark">}}
--build-number=$(($(google-play get-latest-build-number --package-name 'com.example.app') + 1))
{{< /highlight >}}

Alternatively, you can add a custom [Pre-build script](/flutter-configuration/custom-scripts) and write the build number to a file, which will be read from your `android/app/build.gradle` during the build (See details [here](https://github.com/codemagic-ci-cd/android-versioning-example/tree/autoversioning_through_file)).

## Firebase App Distribution latest build version

Use [`firebase-app-distribution get-latest-build-version`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/firebase-app-distribution/get-latest-build-version.md#get-latest-build-version) action from Codemagic CLI tools to get the latest build version from Firebase App Distribution.

In order to do that, you need to provide Firebase access credentials by providing `FIREBASE_SERVICE_ACCOUNT_CREDENTIALS` as arguments to the action, as defined below.

Additionally, you will need to provide project ID (e.g. `228333310124`) and application ID (e.g. `1:228333310124:ios:5e439e0d0231a788ac8f09`).

#### Creating Firebase service account credentials

You will need to set up a [Firebase service account](https://docs.codemagic.io/yaml-publishing/firebase-app-distribution/).

#### Configuring the API access environment variables

{{< tabpane >}}
{{< tab header="codemagic.yaml" >}}
{{<markdown>}}
1. Open your Codemagic app settings, and go to the **Environment variables** tab.
2. Enter the `FIREBASE_SERVICE_ACCOUNT_CREDENTIALS` as **_Variable name_**.
3. Copy and paste the credentials content as **_Variable value_**.
4. Enter the variable group name, e.g. `firebase_credentials`. Click the button to create the group.
5. Make sure the **Secure** option is selected.
6. Click the **Add** button to add the variable.

7. Add the variable group to your `codemagic.yaml` file
{{< highlight yaml "style=paraiso-dark">}}
  environment:
    groups:
      - firebase_credentials
{{< /highlight >}}
{{</markdown>}}
{{< /tab >}}

{{% tab header="Flutter workflow editor"%}}

Add the `FIREBASE_SERVICE_ACCOUNT_CREDENTIALS` environment variable to your Flutter project in **App settings > Environment variables** (See the details [here](../flutter-configuration/env-variables)).
{{% /tab %}}
{{< /tabpane >}}

{{<notebox>}}
**Tip:** Alternatively, credentials can be specified as a command argument with the dedicated flag, see the details [here](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/firebase-app-distribution/get-latest-build-version.md#--credentials--cfirebase_service_account_credentials). In any case, it is advisable to save the service account credentials file to an environment variable so that it can be accessed during a build without committing it to version control. The environment variable will be a fallback for the missing value in the script.
{{</notebox>}}

#### Set the build version for iOS projects using `agvtool`

Add the following script under your `scripts` field for `codemagic.yaml`, or as a custom [Pre-build script](/flutter-configuration/custom-scripts) in the Flutter workflow editor:

{{< highlight yaml "style=paraiso-dark">}}
  scripts:
    - name: Get the latest build number
      script: |
        LATEST_BUILD_VERSION=$(firebase-app-distribution get-latest-build-version -p<PHONE_NUMBER>24 -a 1:228333310124:ios:5e439e0d0231a788ac8f09)
        cd ./ios # avgtool must run in the folder where xcodeproj file is located
        agvtool new-version -all $(($LATEST_BUILD_VERSION + 1))
{{< /highlight >}}

Alternatively, if you use `YAML` configuration, you may just export the value to an environment variable and use it under your `CFBundleVersion` in `Info.plist`.

#### Set the build version for Android projects

Once you have the Firebase access set, you can get the build version using the CLI tool:

{{< highlight bash "style=paraiso-dark">}}
LATEST_BUILD_VERSION=$(firebase-app-distribution get-latest-build-version -p<PHONE_NUMBER>24 -a 1:228333310124:ios:5e439e0d0231a788ac8f09)
{{< /highlight >}}

There are a number of ways how you can pass the obtained build version to an Android project (through environment variables, `gradlew` argument properties, file, or a call from `build.gradle`). Here is an example using `gradlew` arguments:

1. Edit your `build.gradle` file by adding the functions to read version name and code number from argument properties

{{< highlight Groovy "style=paraiso-dark">}}
// get version code from the specified property argument `-PversionCode` during the build call
def getMyVersionCode = { ->
    return project.hasProperty('versionCode') ? versionCode.toInteger() : -1
}
// get version name from the specified property argument `-PversionName` during the build call
def getMyVersionName = { ->
    return project.hasProperty('versionName') ? versionName : "1.0"
}

....
android {
    ....
    defaultConfig {
        ...
        versionCode getMyVersionCode()
        versionName getMyVersionName()
{{< /highlight >}}

2. Add a script to your `codemagic.yaml` file to set the build version and pass it to `gradlew` command

{{< highlight yaml "style=paraiso-dark">}}
scripts:
  - name: Build Android release
    script: |
      LATEST_FIREBASE_BUILD_VERSION=$(firebase-app-distribution get-latest-build-version -p "$PACKAGE_ID" -a "$APPLICATION_ID")
      if [ -z $LATEST_FIREBASE_BUILD_VERSION ]
        then
          # Fallback in case no build version was found at Firebase.
          # Alternatively, you can `exit 1` to fail the build.
          # BUILD_NUMBER is a Codemagic built-in variable tracking the number of
          # times this workflow has been built
          UPDATED_BUILD_VERSION=$BUILD_NUMBER
        else
          UPDATED_BUILD_VERSION=$(($LATEST_FIREBASE_BUILD_VERSION + 1))
      fi
      cd android # change folder if needed
      ./gradlew bundleRelease -PversionCode=$UPDATED_BUILD_VERSION -PversionName=1.0.$UPDATED_BUILD_VERSION
{{< /highlight >}}

#### Get the build version in the Flutter workflow editor

Provided you have exported your Firebase service account credentials as an environment variable `FIREBASE_SERVICE_ACCOUNT_CREDENTIALS`, you can call it immediately as a build argument to your Android build command to increment the build version:

{{< highlight bash "style=paraiso-dark">}}
--build-number=$(($(firebase-app-distribution get-latest-build-version -p<PHONE_NUMBER>24 -a 1:228333310124:ios:5e439e0d0231a788ac8f09) + 1))
{{< /highlight >}}

Alternatively, you can add a custom [Pre-build script](/flutter-configuration/custom-scripts) and write the build version to a file, which will be read from your `android/app/build.gradle` during the build (see details [here](https://github.com/codemagic-ci-cd/android-versioning-example/tree/autoversioning_through_file)).

license: MIT

repository: codemagic-ci-cd/codemagic-docs

gha_language: JavaScript

gha_license_id: MIT

repo_name: codemagic-ci-cd/codemagic-docs


text:
This is [episode 8][rce] of Radiantcasts.

You'll see how to use [Radiant Chronicle Extension][rc].

Login using "admin" as username and "radiant" as password

[rce]:http://radiantcms.org/blog/archives/2010/04/13/radiantcasts-episode-8-radiant-chronicle-extension
[rc]:http://github.com/jgarber/radiant-chronicle-extension

repository: cristi/radiantcasts-episodes

repo_name: cristi/radiantcasts-episodes


text:
RMarshal
========

[![Build Status](https://travis-ci.org/kyrylo/rmarshal.svg?branch=master)](https://travis-ci.org/kyrylo/rmarshal)
[![semver]](http://semver.org)

Introduction
------------

This Erlang library deserialises Ruby objects dumped by `Marshal.dump` into
Erlang terms. It's like Ruby's [`Marshal.load`][marshal-load], but for
Erlang. Currently, it doesn't support loading advanced objects like classes, but
the bare minimum is supported. The list of supported objects includes:

* Fixnum
* Hash
* Array
* Bignum
* Symbol
* Float
* String

Installation
------------

### Rebar3

```erlang
%% rebar.config
{deps, [
  {rmarshal, {git, "git://github.com/kyrylo/rmarshal.git", {tag, "v0.0.4"}}}
]}.
```

Examples
---

### Basic example

Dump some Ruby objects into a binary file:

```ruby
# data.rb
data = Marshal.dump(hello: 'world')
File.open('data.dat', 'w') do |f|
  f.write(data)
end
```

Read the dumped data with Erlang and load it with help of the RMarshal library:

```erlang
%% loader.erl
load_ruby_data() ->
    case file:read_file("data.dat") of
        {ok, BinaryData} -> rmarshal:load(BinaryData);
        Any -> Any
    end.

load_ruby_data()
%% Returns:
%% {ok, #{hello => "world"}}
```

API
---

### rmarshal:load/1

Accepts binary string formatted according to the official
[Marshal Format][marshal-format]. Returns a tuple with in the format `{ok,
rterm()}`.

```erlang
{ok, Decoded} = rmarshal:load(BinaryData).
```

Testing
---

Run the following command:

```shell
make test
```

Supported Erlang versions
-------------------------

* ≥17.0

Contact
-------

In case you have a problem, question or a bug report, feel free to:

* [file an issue][issues]
* [send me an<EMAIL_ADDRESS>* [tweet at me][twitter]

Licence
---

The project uses the zlib License. See the LICENCE.txt file for more
information.

[semver]: https://img.shields.io/:semver-0.0.4-brightgreen.svg?style=flat
[marshal-load]: http://ruby-doc.org/core-2.3.0/Marshal.html#method-c-load
[marshal-format]: https://github.com/ruby/ruby/blob/b01c28eeb3942bce1ddf9b9243ecf727d5421c6d/doc/marshal.rdoc
[issues]: https://github.com/kyrylo/rmarshal/issues
[twitter]: https://twitter.com/kyrylosilin

license: Zlib

repository: kyrylo/rmarshal

gha_language: Erlang

repo_name: kyrylo/rmarshal


text:
---
title: Quickly build digital look books from existing collateral
contexts: office365,microsoft365
copyright: Microsoft
translations: en
tools: Delve,Office 365,PowerPoint
areas: RETAIL ,  MARKETING
color: #777777
icon: https://jumpto365.com/resources/images/app/jumpto365-Icon-white.png
externalref: https://www.microsoft.com/en-us/microsoft-365/success/productivitylibrary/quickly-build-digital-look-books-from-existing-collateral
---
Provide your sales team with high-quality digital look books that draw on existing content from across the organization, without the expense of hiring a design agency.

## Create visually appealing presentations using professional templates

You can easily create professional-looking digital marketing materials that showcase your company’s products without the help of a design team. Start with a **PowerPoint** template or theme that uses visually appealing combinations of colors, images, and text elements. To ensure the consistent appearance of digital marketing materials, you can create a custom template or theme that incorporates your company’s colors, fonts, and imagery.

[View Training](https://support.office.com/article/Understand-the-difference-between-PowerPoint-templates-and-themes-E2408E10-E015-43B3-8B29-B99D128AE448)

[IFRAME](https://www.microsoft.com/en-us/videoplayer/embed/RE1UEZG)

## Discover and reuse existing content from across your organization

To populate your presentation, use the intelligent search features of **Delve** to find relevant marketing content, trend information, and sales data from across your organization. Add the documents, workbooks, and presentations you find to a Delve board so you can easily return to them.

[View Training](https://support.office.com/article/Group-and-share-documents-in-Office-Delve-da0c5804-01ef-4edd-8b87-e576b19bef3e)

[IFRAME](https://www.microsoft.com/en-us/videoplayer/embed/RE1TrEK)

## Easily incorporate visual content in eye-catching ways

When you add an image or chart to a slide or enter a list of sequential or action-oriented items, **PowerPoint** Designer automatically shows you design ideas for incorporating the content into your presentation with flair.

[View Training](https://support.office.com/article/About-PowerPoint-Designer-53c77d7b-dc40-45c2-b684-81415eac0617)

[IFRAME](https://www.microsoft.com/en-us/videoplayer/embed/RE1UEYT)

## Enhance slide content with icons

**PowerPoint** provides an extensive library of icons representing concepts related to people, apparel, communication, business, commerce, technology, and many other topics. The icons area includes scalable vector graphics (SVG files) so you can easily resize and recolor them to match the content of your look book presentation.

[View Training](https://support.office.com/article/Insert-SVG-icons-E2459F17-3996-4795-996E-B9A13486FA79)

![](http://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1NyLW?ver=c859)

## Proof and enhance presentation content

Feel confident that your content is free of spelling and grammatical errors before you distribute it. Use the **Office 365** Proofing and Insights tools to review the text of your presentation, suggest synonyms, and locate related information and images online.

[View Training](https://support.office.com/article/Get-insights-into-what-you-re-working-on-with-Smart-Lookup-debf2083-5ac0-4739-8667-ae2467bec044)

![](http://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1N0Pc?ver=412a)

url: https://raw.githubusercontent.com/Hexatown/docs/8baa1eb908c9182449d094b697dd50d197a8a0a1/microsoft/usecases/microsoft365/quickly build digital look books from existing collateral/index.md

repository: Hexatown/docs

gha_language: PowerShell

repo_name: Hexatown/docs


text:
# Library Management System

#Description
This Database programming project involves the creation of a web application implementing a Library Management System for Librarians.

#Working of the system
1)Search a Book - Allows the user to search any book using any combinations of Book id and/or Book Title and /or Book Author.
2)Checkout a Book – Allows a user to check-out the book based on its availability and book borrowers credibility provided with the card no of the borrower.
3)Checkin a Book - Allows a user to check-in the book. This feature first searches for all the book loans the borrower has taken which are not checked-in yet and then allows the user to check in the selected the book.
4)Register New Borrower - Allows the user to register a new borrower to the library loan system by specifying the SSN, name, address, and phone number.
5)Fine - This feature allows two types of fine computation.

## Software Requirements
Front-end : HTML,CSS,Javascript
Server-side Scripting language:PHP 7
Platform : Mac, Windows
Database : MySQL

## Installation
Install XAMPP
Load phpMyAdmin
Load MySQl
Execute library.sql file
Copy the folder library into "htdocs" folder of XAMPP
Load http://localhost/library/index.html
The Application works!

#Design Model
index.html is the Homepage where you can search, Register Borrowers, Update or Get Fine, Return Books
book-return.html - Return books
register.html -Create new  borrower to the library loan system by specifying the SSN, name, address, and phone number.
fine-mgmt.html-Get/Update fine by providing card number as the input.


text:
# Express JS starter (Backend Only)

> This is a simple starter template to build your backend quickly and efficiently. Clone it and start building your project quicker.

## Overview

**This is a backend starter using Express, Prisma and Typescript. Simply clone this project, and add further functionality and modules.**

### Techstack

- Typescript
- Express JS
- Mongodb for Express-Sessions
- SQLite (Can be switched quickly)
- Prisma ORM
- Passport JS (Local-Auth setup)
- Webpack

## Get Started

### Commands

#### Clone Repo

```bash
git clone "https://github.com/techboy-coder/express-backend-starter" && cd express-backend-starter && yarn
```

#### Additional Commands (in package.json)

*<u>Don’t forget to install modules first</u>*

- `dev`  -  Running a dev server (ts-node-dev)
- `build`  -  Export TypeScript to JavaScript + bundle JS into 1 file.
- `start`  -  Run build + `node "./production/bundle.js"` (Starts Server)
- `dev:migrate`  -  Make migrations from `schema.prisma` file.

## API usage
API uses Express-Sessions. This means it will generate a session cookie.
### Register User

```json
POST http://localhost:4000/v1/user/register
Json Body:
{
    "name": "Bob Smith",
    "email"<EMAIL_ADDRESS>    "password": "secret",
    "password_confirmation": "secret"
}
```

### Login User

```json
POST http://localhost:4000/v1/user/login
Json Body:
{
    "email"<EMAIL_ADDRESS>    "password": "secret"
}
```

### Get User Info

```json
GET http://localhost:4000/v1/user/
```

### Delete User

*User gets recognized thanks to session.*

```json
DELETE http://localhost:4000/v1/user/
```

### Example Protected Route

```json
GET http://localhost:4000/v1/user/protected
```

## File tree

```
📦express-backend-starter
 ┣ 📂.git
 ┣ 📂prisma
 ┃ ┣ 📜dev.db
 ┃ ┗ 📜schema.prisma
 ┣ 📂src
 ┃ ┣ 📂auth
 ┃ ┃ ┣ 📂config
 ┃ ┃ ┃ ┣ 📂strategy
 ┃ ┃ ┃ ┃ ┗ 📜local.ts
 ┃ ┃ ┃ ┗ 📜passport.ts
 ┃ ┃ ┣ 📂middleware
 ┃ ┃ ┃ ┗ 📜auth.ts
 ┃ ┃ ┣ 📜controller.ts
 ┃ ┃ ┣ 📜services.ts
 ┃ ┃ ┗ 📜validators.ts
 ┃ ┣ 📂modules
 ┃ ┃ ┣ 📂module 1 (Implement your own ones here)
 ┃ ┃ ┗ 📂module 2
 ┃ ┣ 📜index.ts
 ┃ ┣ 📜README.md
 ┃ ┣ 📜routes.ts
 ┃ ┣ 📜secrets.ts
 ┃ ┗ 📜session.ts
 ┣ 📜.env.example (Change to .env)
 ┣ 📜.gitignore
 ┣ 📜package.json
 ┣ 📜README.md
 ┣ 📜tsconfig.json
 ┣ 📜webpack.config.js
 ┗ 📜yarn.lock
```

---

Made with :heart: by [techboy-coder](https://github.com/techboy-coder/) - Express Backend Starter

repository: techboy-coder/express-backend-starter

repo_name: techboy-coder/express-backend-starter


text:
# Dockerized Mock for Nexus API

Building [Roboconf's Docker images](https://github.com/roboconf/roboconf-dockerfile) requires an internet connection to
retrieve the last artifacts from [Sonatype's OSS repository](https://oss.sonatype.org/). However,
there are times where we would like to use locally built Maven artifacts.

This project aims at mocking [Nexus' Core API](https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/index.html)
to download local Maven artifacts.
The server can be launched manually with NodeJS or embedded in a Docker image.

> For the moment, only the
> [redirect operation](https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_redirect.html)
> is implemented.
> The **LATEST** value is not supported when resolving artifacts.

## Build it

```
docker build -t roboconf/mock-for-nexus-api .
```

## Run it

```properties
# Add a volume to load the local Maven repository.
# The volume is read-only.
# Make the API available on the 9090 port.
# The container will run in background and be deleted automatically once stopped.
docker run -d --rm -p 9090:9090 -v /home/me/.m2:/home/maven:ro roboconf/mock-for-nexus-api
```

## Access the API

The API will be available by default at http://localhost:9090/redirect
Example of GET request (to run in your web browser).

```
http://localhost:9090/redirect?g=net.roboconf&r=releases&a=roboconf-karaf-dist-dm&v=0.9-SNAPSHOT&p=tar.gz
```

## Run the Server without Docker

Assuming you have NodeJS installed...

```properties
# Start the server
npm start
```

... or...

```properties
# To start the server while watching file edition
npm run dev
```

repository: roboconf/dockerized-mock-for-nexus-api

repo_name: roboconf/dockerized-mock-for-nexus-api


text:
---
title: A weekly series of Miami
tags:
  - Jan 1996
---

A weekly series of Miami history will be printed until 28 July.

Newspapers: **Miami Morning News or The Miami Herald**

Page: **1**, Section: **B**


text:
#  Build dockerHub development stacks

## Description

This project will produce a suite of Docker images for OpenSUSE and ClefOS (a CentOS clone for Z).

If you go to Dockerhub and look at  https://hub.docker.com/u/clefos you’ll see all the existing builds for Z. These are all based on a CentOS clone called ClefOS. The source for most of these (excluding the OpenShift and Source-to-Image images) may be found at https://github.com/nealef/docker.

What we want to do is:

* Keep these images current. In many cases the recipes were created on existing CentOS images and others were created by me. I would like a mechanism for keeping both the derived and original recipe kept current and the dockerhub repo updated more regularly.
* Where possible produce the equivalent suite based on OpenSUSE. It’s possible that some packages used for ClefOS images may not exist for OpenSUSE. Part of this project will be to document the deficiencies.
* In addition the are  many of the images for created based on the OpenShift Origin software collection. These recipes are found at:https://github.com/nealef/okcd-images.git. A mechanism to keep these up to date is desired. The okcd-images repo shows the type of model I’d like to apply to the other repo as well (if possible – it won’t always be possible). That is, we pull from the seminal repo, apply any s390x-specific fixes if required, and build from there. Many times the fix is to change the FROM image name to a ClefOS one.

In most instances all these images are updated on an ad-hoc basis. I would like something like this: create a PR on github that will trigger a build and ultimately a push of the image to dockerhub. This would entail creating a CI mechanism (like Jenkins) to properly automate and manage the process.

Some of the builds have test suites others don’t. If a test suite could be developed for all or most of these images then this would be a bonus.

## Additional Information

Open source projects known working on s390 listed at https://www.ibm.com/developerworks/community/forums/html/topic?id=5dee144a-7c64-4bfe-884f-751d6308dbdf

## Desirable Skills

Basic Linux devops

## Expected Outcome

DockerHub images for s390x

## Difficultly

*Medium*

## Mentors

* Neale Ferguson<EMAIL_ADDRESS>


text:
---
layout: post
title: AliExpress XSS vulnerability - take over any seller account
---

In this blog post I will discuss a XSS vulnerability I’ve found in AliExpress website.

I discovered this vulnerability while i bought items in the website, i wanted to contact with the seller so i sent him a message. As an application security expert i suspected that the messages system might be vulnerable to XSS so i started investigate it.

after a full investigation i found that it is possible to inject HTML \ tag into the message, and it will be rendered as HTML code in the recipients' browser.

By injection the following malicious script payload in a message content parameter, the seller will browse to the message center in AliExpress website, thus, the malicious script will be executed on his browser:

```javascript
Hello Seller :)\<b style="position:fixed;top:0;left:0;display:block;width:100%;height:100%" onmouseover="alert('Barak Tawily, AppSec Labs')"\>PoC</b>
```

Note: the system doesn't allow send HTML tags in the content of the message, but it allows \ tag only, thats why the payload to exploit the vulnerability is \ tag and not any other.

[![](https://4.bp.blogspot.com/-i_Q0N2SzR2k/VIhITDHTiMI/AAAAAAAAAhA/E9rS2Gfdkkw/s1600/Untitled.png)](http://4.bp.blogspot.com/-i_Q0N2SzR2k/VIhITDHTiMI/AAAAAAAAAhA/E9rS2Gfdkkw/s1600/Untitled.png)

The vulnerability allows the attacker to execute malicious code on the seller's browser, thereby putting in danger all of the AliExpress sellers.

The attack scenario:

1\. An attacker sends a message to a store via the "contact now" feature.

2\. The attacker sends a malicious script injected inside the message content.

3\. The seller browses to the AliExpress message center.

4\. The malicious script executed on the seller's browser, which can be lead to several attacks such as perform actions on behalf of a seller, phishing attacks, steal the victim's sessions identifier, etc.

5\. The attacker succeeds in executing malicious code in the seller's browser and will take it over on his store.

A Proof of Concept (PoC) video can be found at the following link:
[https://www.youtube.com/watch?v=78Y0CEQYN1Q](https://www.youtube.com/watch?v=78Y0CEQYN1Q)


text:
Ines's Blog.

## Setup dev env

GitHub Pages does NOT support the latest Ruby nor the latest Jekyll not every Jekyll gem. Here is a list of the gems and their versions, which are suppoerted on GitHub Pages: https://pages.github.com/versions/

- Install Ruby (last I checked GitHub Pages is using Ruby 2.7.1).
  Last time it was `sudo apt-get install ruby-full`, but check here: https://www.ruby-lang.org/en/documentation/installation/#apt
  Don't forget to run `source ~/.bashrc` to load the new $PATH values
- Install Bundler (a Ruby gem): `gem install bundler`
- Install all the gems in the `Gemfile`: `bundle install`
- Run the server `bundle exec jekyll serve --future`

Jekyll is a Ruby's gem. All the gem's you will use to run your site have to be listed in the `Gemfile`.

### Updating gems

Every so often run `bundle update --all` and then commit the new generated `Gemfile.lock`.

gha_language: SCSS


text:
# au-fa-check
A checkbox for the Aurelia Framework that uses FontAwesome for checkbox icons.
![overview](https://github.com/rdelhommer/au-fa-check/blob/master/docs/images/overview.png)

## Compatibility
At this time, this libary is only compatible with font icons in FontAwesome 4.x.x and Solid font icons in FontAwesome 5.x.x.  We hope to support SVG icons in the future

## Installation and Usage
This plugin uses FontAwesome font icons.  You'll need to ensure that the css classes are bundled with your app

### Install the plugin
```
npm install au-fa-check --save
```

### Configure the plugin
Add the following to your index file
```javascript
aurelia.use
  .plugin(PLATFORM.moduleName('au-fa-check'), { /* configuration object */})
```

### Use the plugin
Add a checkbox to any template
```html
<template>
  <au-fa-check>This is the label</au-fa-check>
</template>
```
## Configuration
### Bindings
#### checked: boolean
Exposes the checked state of the input

#### disabled: boolean
Controls whether the input is enabled or disabled

#### icon: string
Default value: fa-check

The icon to use in the checkbox.

The value of this property functions in a different way depending on the value provided to the iconType property (See below)

#### orientation: FaCheckOrientation
Default value: horizontal

When horizontal, the checkbox is placed to the left of the label

When vertical, the checkbox is placed above the label

#### checkedColor: string
Default value: black

The color of the checkbox when it is checked

#### size: FaCheckSize
Default value: standard

The size of the checkbox relative to the label

#### shape: FaCheckShape
Default value: square

The shape of the checkbox

#### iconType: FaCheckIconType
Default value: standard

When standard, the value of the icon property is placed inside the checkbox outline

```
<au-fa-check>Standard Checked</au-fa-check>
```
![standard](https://github.com/rdelhommer/au-fa-check/blob/master/docs/images/standard-check.png)

When outline, the value of the icon property is rendered as the checkbox when it is checked and its "*-o" version is rendered as the checkbox when it is unchecked
**NOTE** This option is only available when using FontAwesome 4.x.x

```
<au-fa-check icon-type="outline" icon="fa-heart" checked-color="red">Hello</au-fa-check>
```
![outline](https://github.com/rdelhommer/au-fa-check/blob/master/docs/images/outline-check.png)

### Global Configuration
When performing the initial configuration in your app's index file you may provide an optional configuration object.  The global configuration will specify default values that can generally be overriden in case-by-case scenarios with the component bindings.

#### Properties
##### faVersion: 4 | 5
Default value: 4

Specifies the FontAwesome version that you are using.

##### checkedColor: string
Default value: black

Specifies the default color of a checked checkbox

##### theme: FaCheckTheme
Default value: standard

Specifies the style theme you wish use.  Material theme is currently not supported but is coming soon!

##### size: FaCheckSize
Default value: standard

Specifies the default size of a checkbox relative to its label

##### shape: FaCheckShape
Default value: square

Specifies the shape of the checkbox outline when a checkbox's iconType === 'standard'

## TODO
* material styles - need to figure out a good way to do theming
* add support for fontawesome libraries like aurelia-fontawesome

repository: rdelhommer/au-fa-check

repo_name: rdelhommer/au-fa-check


text:
## 2.0.1

-   Add generics to ExpectedRequest.respond
-   Add more types

## 2.0.0

-   Convert to typescript

## 1.2.3

-   Convert away from `Promise.defer`.
-   Pass the whole request object to response handlers.

## 1.2.2

-   Add stop() method returning a promise that resolves when all
    flushes are complete.

## 1.2.1

-   Bump default timeout on `flushAllExpected` to 1000ms.

## 1.2.0

-   Allow specification of a timeout on `flushAllExpected`.

## 1.1.1

-   Give a sensible rejection from `flushAllExpected` when there are no
    expectations (previously it would throw an obscure exception).

## 1.1.0

-   Add `flushAllExpected`.
-   Wait for longer in `flush` when a `numToFlush` is specified.
-   Try to avoid throwing exceptions from `setTimeout` (and reject the returned
    promise instead).
-   Switch to bluebird instead of q.

## 1.0.0

-   Changes required for https://github.com/matrix-org/matrix-js-sdk/pull/479:
    js-sdk now does its own JSON encoding/parsing, so in order to keep the tests
    working we need to reverse that process.

## 0.1.3

-   Fix missing /lib in published package.

## 0.1.2

-   Transpile for ES5.

## 0.1.1

-   Import changes from riot-web.

## 0.1.0

-   Initial release, factored out from matrix-js-sdk.

repository: matrix-org/matrix-mock-request

gha_language: TypeScript

repo_name: matrix-org/matrix-mock-request


text:
## Overview

DialogFragment is a specialized Fragment used when you want to display an overlay modal window within an activity that floats on top of the rest of the content.

This is typically used for displaying an alert dialog, a confirm dialog, or prompting the user for information within an overlay without having to switch to another Activity.

DialogFragment is now the canonical way to display overlays; using Dialog directly is considered bad practice.

## Usage

The minimum that must be implemented when creating a DialogFragment is either the `onCreateView` method or the `onCreateDialog` method. Use `onCreateView` when the entire view of the dialog is going to be defined via custom XML. Use `onCreateDialog` when you just need to construct and configure a standard Dialog class (such as AlertDialog) to display.

**Note:** The entire guide below requires every fragment related class imported to use the `android.support.v4.app` namespace and **not** the `android.app` namespace. If any imported class (FragmentManager, DialogFragment, etc) uses the `android.app` namespace, compile-time errors will occur.

### Custom View

Let's start by providing the code for creating a completely custom dialog based on an XML view. First, an example fragment XML file in `res/layout/fragment_edit_name.xml`:

```xml
<!-- fragment_edit_name.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/edit_name"
	android:layout_width="wrap_content" android:layout_height="wrap_content"
	android:layout_gravity="center" android:orientation="vertical"  >

	<TextView
		android:id="@+id/lbl_your_name" android:text="Your name"
		android:layout_width="wrap_content" android:layout_height="wrap_content" />

	<EditText
		android:id="@+id/txt_your_name"
		android:layout_width="match_parent"  android:layout_height="wrap_content"
		android:inputType="text"
		android:imeOptions="actionDone" />
</LinearLayout>
```

and defining the fragment itself extending from the **support version of dialog fragment**:

```java
import android.support.v4.app.DialogFragment;
// ...

public class EditNameDialogFragment extends DialogFragment {

	private EditText mEditText;

	public EditNameDialogFragment() {
		// Empty constructor is required for DialogFragment
                // Make sure not to add arguments to the constructor
                // Use `newInstance` instead as shown below
	}

	public static EditNameDialogFragment newInstance(String title) {
		EditNameDialogFragment frag = new EditNameDialogFragment();
		Bundle args = new Bundle();
		args.putString("title", title);
		frag.setArguments(args);
		return frag;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_edit_name, container);
	}

	@Override
	public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		// Get field from view
		mEditText = (EditText) view.findViewById(R.id.txt_your_name);
		// Fetch arguments from bundle and set title
		String title = getArguments().getString("title", "Enter Name");
		getDialog().setTitle(title);
		// Show soft keyboard automatically and request focus to field
		mEditText.requestFocus();
		getDialog().getWindow().setSoftInputMode(
		    WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
	}
}
```
and showing the dialog in an Activity extending `AppCompatActivity`:

```java
// Note: `FragmentActivity` works here as well
public class DialogDemoActivity extends AppCompatActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      showEditDialog();
  }

  private void showEditDialog() {
      FragmentManager fm = getSupportFragmentManager();
      EditNameDialogFragment editNameDialogFragment = EditNameDialogFragment.newInstance("Some Title");
      editNameDialogFragment.show(fm, "fragment_edit_name");
  }
}
```

For this to work properly make sure that all the fragment related items (`FragmentDialog`) are from the `android.support.v4.app` namespace.

### Build Dialog

Second, let's take a look at how to build a dialog simply by customizing the available
Dialog objects that we can construct. For more details about the different types of dialogs, check out the "Things to Note" section below.

```java
class MyAlertDialogFragment extends DialogFragment {
    public MyAlertDialogFragment() {
          // Empty constructor required for DialogFragment
    }

    public static MyAlertDialogFragment newInstance(String title) {
        MyAlertDialogFragment frag = new MyAlertDialogFragment();
    	Bundle args = new Bundle();
    	args.putString("title", title);
    	frag.setArguments(args);
    	return frag;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        String title = getArguments().getString("title");
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
        alertDialogBuilder.setTitle(title);
        alertDialogBuilder.setMessage("Are you sure?");
        alertDialogBuilder.setPositiveButton("OK",  new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // on success
            }
        });
        alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        return alertDialogBuilder.create();
    }
}
```

and to display the alert dialog in an activity extending `AppCompatActivity`:

```java
public class DialogDemoActivity extends AppCompatActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      showAlertDialog();
  }

  private void showAlertDialog() {
      FragmentManager fm = getSupportFragmentManager();
      MyAlertDialogFragment alertDialog = MyAlertDialogFragment.newInstance("Some title");
      alertDialog.show(fm, "fragment_alert");
  }
}
```

### Passing Data to Activity

To pass data from a dialog to an Activity, use the same approach you would use for any fragment which is [creating a custom listener](http://guides.codepath.com/android/Creating-Custom-Listeners). In short, you will need to do the following:

1. Define an interface with methods that can be invoked to pass data result to the activity
2. Setup a [view event](http://guides.codepath.com/android/Basic-Event-Listeners) which invokes the custom listener passing data through the method
3. Implement the interface in the Activity defining behavior for when the event is triggered

This example below demonstrates how to pass a data result back to the activity when the "Done" button is pressed on the keyboard but this works similarly for other cases or for the `AlertDialog` (just use the listeners defined for each of the buttons):

```java
public class EditNameDialogFragment extends DialogFragment implements OnEditorActionListener {
    private EditText mEditText;

    // 1. Defines the listener interface with a method passing back data result.
    public interface EditNameDialogListener {
        void onFinishEditDialog(String inputText);
    }

    // ...
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        // ...
        // 2. Setup a callback when the "Done" button is pressed on keyboard
        mEditText.setOnEditorActionListener(this);
    }

    // Fires whenever the textfield has an action performed
    // In this case, when the "Done" button is pressed
    // REQUIRES a 'soft keyboard' (virtual keyboard)
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (EditorInfo.IME_ACTION_DONE == actionId) {
            // Return input text back to activity through the implemented listener
            EditNameDialogListener listener = (EditNameDialogListener) getActivity();
            listener.onFinishEditDialog(mEditText.getText().toString());
            // Close the dialog and return back to the parent activity
            dismiss();
            return true;
        }
        return false;
    }
}
```

and have the activity define the action to take when the dialog has the information:

```java
public class DialogDemoActivity extends AppCompatActivity implements EditNameDialogListener {
  // ...

  // 3. This method is invoked in the activity when the listener is triggered
  // Access the data result passed to the activity here
  @Override
  public void onFinishEditDialog(String inputText) {
  	Toast.makeText(this, "Hi, " + inputText, Toast.LENGTH_SHORT).show();
  }
}
```

**Note:** `setOnEditorActionListener` used above to dismiss requires the use of the soft keyboard in the emulator which [can be enabled through AVD](http://imgur.com/a/kf1s9) or by testing on a device. If you don't want to enable soft keyboard, you may want to dismiss on a button click or on a keypress instead.

### Passing Data to Parent Fragment

In certain situations, the a dialog fragment may be invoked **within the context of another fragment**. For example, a screen has tabs with a form contained in a fragment. The form has an input for selecting dates using a date picker in a dialog. In this case, we may want to pass the date back not to the activity but instead to the parent fragment. This data can be passed back directly to the parent fragment:

```java
import android.support.v4.app.DialogFragment;

public class EditNameDialogFragment extends DialogFragment {
    // Defines the listener interface
    public interface EditNameDialogListener {
        void onFinishEditDialog(String inputText);
    }

    // Call this method to send the data back to the parent fragment
    public void sendBackResult() {
      // Notice the use of `getTargetFragment` which will be set when the dialog is displayed
      EditNameDialogListener listener = (EditNameDialogListener) getTargetFragment();
      listener.onFinishEditDialog(mEditText.getText().toString());
      dismiss();
    }
}
```

And then the dialog must be displayed within a parent fragment passing the target via `setTargetFragment` with:

```java
import android.support.v4.app.Fragment;

public class MyParentFragment extends Fragment implements EditNameDialogListener {
    // Call this method to launch the edit dialog
    private void showEditDialog() {
        FragmentManager fm = getFragmentManager();
        EditNameDialogFragment editNameDialogFragment = EditNameDialog.newInstance("Some Title");
        // SETS the target fragment for use later when sending results
        editNameDialogFragment.setTargetFragment(MyParentFragment.this, 300);
        editNameDialogFragment.show(fm, "fragment_edit_name");
    }

    // This is called when the dialog is completed and the results have been passed
    @Override
    public void onFinishEditDialog(String inputText) {
        Toast.makeText(this, "Hi, " + inputText, Toast.LENGTH_SHORT).show();
    }
}
```

**Troubleshooting**

If you are having any issues, be sure to use the checklist below:

 * In parent fragment, before calling `dialogFragment.show()`, are you calling `setTargetFragment` and passing in the correct fragment as the target?
 * In the dialog fragment, before calling `dismiss()`, are you calling `listener.someCallbackMethod()` on a listener casted from the `getTargetFragment()` passed in above?
 * Have you correctly implemented the interface and callback method fired i.e `listener.someCallbackMethod()` inside of the parent fragment?
 * Try breakpointing each of those lines to make sure the target fragment is set property and the callback method is being executed.

With that, the two fragments are able to pass data back and forth.

## Styling Dialogs

### Styling Custom Dialog

Styling a DialogFragment with a custom layout works just the [[same as styling any views|Styles-and-Themes]]. Styling a dialog or `AlertDialog` requires changing several key properties in `styles.xml` such as the `dialogTheme` and `alertDialogTheme` as shown in this app [here](https://github.com/irccloud/android/blob/master/res/values/styles.xml) and shown below in `res/values/styles.xml`:

```xml
<!-- In res/values/colors.xml -->
<color name="dark_blue">#180065</color>
<color name="light_blue">#334ee9ff</color>
<color name="medium_green">#3d853e</color>
<color name="light_green">#3c2ae668</color>

<!-- In res/values/styles.xml -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Apply default style for dialogs -->
    <item name="android:dialogTheme">@style/AppDialogTheme</item>
    <!-- Apply default style for alert dialogs -->
    <item name="android:alertDialogTheme">@style/AppAlertTheme</item>
</style>

<!-- Define your custom dialog theme here extending from base -->
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <!-- Define color properties as desired -->
    <item name="colorPrimary">@color/dark_blue</item>
    <item name="colorPrimaryDark">#000</item>
    <item name="android:textColorHighlight">@color/light_blue</item>
    <item name="colorAccent">@color/dark_blue</item>
    <item name="colorControlNormal">@color/dark_blue</item>
    <!-- Define window properties as desired -->
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowFullscreen">false</item>
    <item name="android:windowBackground">@color/medium_green</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowCloseOnTouchOutside">true</item>
</style>

<!-- Define your custom alert theme here extending from base -->
<style name="AppAlertTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorPrimary">@color/dark_blue</item>
    <item name="colorAccent">@color/dark_blue</item>
    <item name="colorPrimaryDark">#000</item>
    <item name="colorControlNormal">@color/dark_blue</item>
    <item name="android:textColorHighlight">@color/light_blue</item>
</style>
```

#### Dialog Styling Workaround

**Note:** There is currently a bug in the support library that **causes styles not to show up properly**. Changing the `DialogFragment` in the `onCreateView` to use the activity's inflater seems to resolve the issue:

```java
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
        return getActivity().getLayoutInflater().inflate(R.layout.fragment_edit_name, container);
    }
```
All dialog widgets should now be properly themed. Check out this [stackoverflow post](http://stackoverflow.com/a/32791569) for details.

### Styling Titlebar of Dialog

The titlebar can be styled using the "android:windowTitleStyle" as follows:

```xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Apply default style for dialogs -->
    <item name="android:dialogTheme">@style/AppDialogTheme</item>
    <!-- Apply default style for alert dialogs -->
    <item name="android:alertDialogTheme">@style/AppAlertTheme</item>
</style>

<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
    <!-- ...other stuff here... -->
</style>

<style name="AppAlertTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
    <!-- ...other stuff here... -->
</style>

<style name="DialogWindowTitle" parent="Base.DialogWindowTitle.AppCompat">
    <item name="android:background">@color/light_green</item>
    <item name="android:gravity">center</item>
    <item name="android:textAppearance">@style/DialogWindowTitleText</item>
</style>

<style name="DialogWindowTitleText" parent="@android:style/TextAppearance.DialogWindowTitle">
    <item name="android:textSize">24sp</item>
</style>
```

### Removing the TitleBar from the Dialog

The TitleBar can be easily removed from your `DialogFragment` by overriding the `onCreateDialog` method:

```java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    // request a window without the title
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}
```

This will give you a dialog box without a title bar. Read more [in this StackOverflow post](http://stackoverflow.com/questions/15277460/how-to-create-a-dialogfragment-without-title)

### Transparent Dialogs

We can make the dialog (or the title of the dialog) translucent using the `android:windowBackground` property:

```xml
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <!-- ...other stuff here... -->
</style>
```

Note that this removes the [default background image](https://github.com/android/platform_frameworks_support/blob/master/v7/appcompat/res/drawable/abc_dialog_material_background_light.xml) from the dialog `@drawable/abc_dialog_material_background_light` and as a result the shadow and border is removed.

To complete the transparent effect, make sure to **set the alpha channel of the background colors** as [outlined here](http://stackoverflow.com/a/16890937) to make any background colors semi-transparent.

### Styling with Third-Party Libraries

Note that [[third party material libraries|Material-Design-Primer#dialog-styles]] such as [material-dialogs](https://github.com/afollestad/material-dialogs) can be used to simplify and improve dialog styling as well.

![Material Dialog](https://i.imgur.com/U4mr2BB.jpg)

In order to use the "material-dialogs" library, you will need to add in maven repository to your build.gradle file. Your gradle file should look [something like this](https://github.com/afollestad/impression/blob/master/app/build.gradle#L38-L47).

## Sizing Dialogs

### Runtime Dimensions

In certain situations, you may want to explicitly set the height and width of the `DialogFragment` at runtime during creation. This can be done easily with `getDialog().getWindow()` as follows. In the XML simply set the root layout to `wrap_content` with:

```xml
<!-- fragment_edit_name.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/edit_name"
    android:layout_width="wrap_content" android:layout_height="wrap_content" >
  <!-- ...subviews here... -->
</LinearLayout>
```

In the `DialogFragment` java source we can set the width and height `onResume` with:

```java
public void onResume() {
    int width = getResources().getDimensionPixelSize(R.dimen.popup_width);
    int height = getResources().getDimensionPixelSize(R.dimen.popup_height);
    getDialog().getWindow().setLayout(width, height);
    // Call super onResume after sizing
    super.onResume();
}
```

See [this stackoverflow post](http://stackoverflow.com/questions/12478520/how-to-set-dialogfragments-width-and-height) for more information. Using this approach we could set the dialog's width as a percentage of the screen within the `DialogFragment` with:

```java
public void onResume() {
    // Store access variables for window and blank point
    Window window = getDialog().getWindow();
    Point size = new Point();
    // Store dimensions of the screen in `size`
    Display display = window.getWindowManager().getDefaultDisplay();
    display.getSize(size);
    // Set the width of the dialog proportional to 75% of the screen width
    window.setLayout((int) (size.x * 0.75), WindowManager.LayoutParams.WRAP_CONTENT);
    window.setGravity(Gravity.CENTER);
    // Call super onResume after sizing
    super.onResume();
}
```

See [this stackoverflow post](http://stackoverflow.com/a/28596836/313399) for the source reference.

### Sizing Adjustments for Soft Keyboard

When displaying a dialog that is accepting text input, there can often be limited space on screen because the soft keyboard on screen eats up a lot of room. To account for this, you may want to modify the `android:windowSoftInputMode` property for the activity within the `AndroidManifest.xml` file:

```xml
<!-- Configures the UI to be resized to make room for the keyboard -->
<activity
    android:name="com.example.myactivity"
    android:windowSoftInputMode="adjustResize" />
```

See the full details in the [[working with the soft keyboard|Working-with-the-Soft-Keyboard#changing-ui-reaction]] guide. Alternatively, we could perform the resize directly at runtime within the `onCreateView` method of the fragment:

```java
public class EditNameDialog extends DialogFragment {
    // ...
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle bundle) {
        // Set to adjust screen height automatically, when soft keyboard appears on screen
        getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        return inflater.inflate(R.layout.fragment_edit_name, container);
    }
}
```

See [this stackoverflow post](http://stackoverflow.com/a/26434420) for additional details. Keep in mind that for either of these to work, the layout of the dialog must be configured to resize properly as the height changes.

### Full-Screen Dialog

In other cases, we want the dialog to fill the entire screen. First, in the XML layout for the dialog simply set the root layout to `match_parent` with:

```xml
<!-- fragment_edit_name.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/edit_name"
    android:layout_width="match_parent" android:layout_height="match_parent" >
  <!-- ...subviews here... -->
</LinearLayout>
```

Next, within the `onResume` method of the `DialogFragment` we need to set the rules on the `getDialog().getWindow()` object to `WindowManager.LayoutParams.MATCH_PARENT` with:

```java
@Override
public void onResume() {
    // Get existing layout params for the window
    ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
    // Assign window properties to fill the parent
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    getDialog().getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    // Call super onResume after sizing
    super.onResume();
}
```

With this code above, the dialog may still not appear to be entirely full-screen until we configure the background color and padding inside `res/values/styles.xml` with the following:

```xml
<style name="Dialog.FullScreen" parent="Theme.AppCompat.Dialog">
    <item name="android:padding">0dp</item>
    <item name="android:windowBackground">@android:color/white</item>
</style>
```

and then this style can be applied when creating the fragment with:

```java
EditNameDialogFragment editNameDialogFragment = new EditNameDialogFragment();
editNameDialogFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.Dialog_FullScreen);
editNameDialogFragment.show(getSupportFragmentManager(), "fragment_edit_name");
```

See [this stackoverflow post](http://stackoverflow.com/questions/27202382/android-dialog-fragment-width-keeps-on-matching-parent) for more details. Refer to [this post](http://stackoverflow.com/questions/7189948/full-screen-dialogfragment-in-android/31597906#31597906) for the customized dialog styles.

## Specialized Dialog Types

When using the `onCreateDialog` method there are many built-in Dialog types to take advantage of:

* [AlertDialog](http://developer.android.com/reference/android/app/AlertDialog.html) - Base dialog that can display a message, an icon and 1-3 buttons with customized text.
* [ProgressDialog](http://developer.android.com/reference/android/app/ProgressDialog.html) - Dialog showing a progress indicator and an optional text message
* [TimePickerDialog](http://developer.android.com/reference/android/app/TimePickerDialog.html) - Dialog that allows a user to select a time.
* [DatePickerDialog](http://developer.android.com/reference/android/app/DatePickerDialog.html) - Dialog that allows a user to select a date.
* BottomSheetDialog - Dialog that slides from the bottom.
* Other dialogs [not](http://developer.android.com/reference/android/text/method/CharacterPickerDialog.html) [worth](http://developer.android.com/reference/android/support/v7/app/MediaRouteChooserDialog.html) discussing here.

### Displaying a ProgressDialog

When running a long running background task, one easy way to notify users the app is loading is to display a [ProgressDialog](http://developer.android.com/intl/es/reference/android/app/ProgressDialog.html).

<img src="http://i.imgur.com/apLzWt6.png" width="250" />

A `ProgressDialog` can be created anytime with the following:

```java
ProgressDialog pd = new ProgressDialog(context);
pd.setTitle("Loading...");
pd.setMessage("Please wait.");
pd.setCancelable(false);
```

The dialog can be displayed with:

```java
pd.show();
```

and hidden anytime with:

```java
pd.dismiss();
```

`ProgressDialog` can be safely paired with an [[AsyncTask|Creating-and-Executing-Async-Tasks]]. Refer to this [ProgressDialog tutorial](http://www.quicktips.in/show-progressdialog-android/) for a code sample. The dialog progress animation can be customized by supplying your own animation drawable [using this tutorial](http://islandofatlas.net/2014/03/29/android-custom-progress-dialog.html).

Check out the CodePath [android-view-helpers](https://github.com/codepath/android-view-helpers) library for an easier way to create simple alert and progress modals.

### Displaying Date or Time Picker Dialogs

The native date and time pickers for Android are another example of specialized dialog fragments.  Please note that the date/time pickers that comes with the Android SDK differ depending on the Android device version.  See [this section](https://github.com/codepath/android_guides/wiki/Working-with-Input-Views#date-and-time-pickers) for more information.

<img src="http://imgur.com/8YqcxA7.png" width="300"/>
<img src="http://imgur.com/s358M0K.png" width="300"/>

If you wish for the containing activity to receive the date or time selected by the dialog, you should ensure that the Activity implements the respective interface. If we want the date picker to be shown from within another dialog fragment, refer to [[setting a target fragment|Using-DialogFragment#passing-data-to-parent-fragment]]. For instance, for a date picker fragment, you will want to ensure that the activity implements the `OnDateSetListener` interface:

```java

import java.util.Calendar;  // do not import java.icu.utils.Calendar

public class DatePickerFragment extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current time as the default values for the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

        // Activity needs to implement this interface
        DatePickerDialog.OnDateSetListener listener = (DatePickerDialog.OnDateSetListener) getActivity();

        // Create a new instance of TimePickerDialog and return it
        return new DatePickerDialog(getActivity(), listener, year, month, day);
    }
```

The Activity, which also is responsible for instantiating this dialog fragment, simply needs to implement the `onDateSet` method of this interface.

```java
public class MyActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {

  // attach to an onclick handler to show the date picker
  public void showDatePickerDialog(View v) {
     DatePickerFragment newFragment = new DatePickerFragment();
     newFragment.show(getSupportFragmentManager(), "datePicker");
  }

  // handle the date selected
  @Override
  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    // store the values selected into a Calendar instance
    final Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, monthOfYear);
    c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  }
```

A similar approach can be done with the time picker too:

```java
public class TimePickerFragment extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current time as the default values for the picker
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);

        // Activity has to implement this interface
        TimePickerDialog.OnTimeSetListener listener = (TimePickerDialog.OnTimeSetListener) getActivity();

        // Create a new instance of TimePickerDialog and return it
        return new TimePickerDialog(getActivity(), listener, hour, minute,
                DateFormat.is24HourFormat(getActivity()));
    }

    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        // Do something with the time chosen by the user
    }
}
```

### Modal Bottom Sheets

With the [[support design library|Design-Support-Library]], it also fairly easy to convert your dialog to use modal bottom sheets.  Instead of `DialogFragment`, you can extend from `BottomSheetDialogFragment`:

```java
public class MyBottomSheetDialogFragment extends BottomSheetDialogFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_bottom_sheet, container);
    }
}
```

When you show this fragment, you will notice that it appears from the bottom:

```java
MyBottomSheetDialogFragment myDialog = new MyBottomSheetDialogFragment();

FragmentManager fm = getSupportFragmentManager();
myDialog.show(fm, "test");
```

## Things To Note

* Notice that we are using the support library version of fragments for better compatibility in our code samples. The non-support version works identically.
* Dialogs are just classes that extend `DialogFragment` and define the view to display in the floating content area.
* `DialogFragment` classes must define an empty constructor as shown in the code samples, otherwise the Android system will raise an exception when it attempts to instantiate the fragment.
* After loading the initial view, the activity immediately shows the dialog using the show() method which allows the fragment manager to keep track of the state and gives us certain things for free such as the back button dismissing the fragment.
* In the code snippets above, notice the use of `requestFocus` and input modes to control the appearance of the soft keyboard when the dialog appears.
* We can dismiss a dialog one of two ways. Here we are calling `dismiss()` within the Dialog class itself. It could also be called from the Activity like the `show()` method. In API 13, `removeDialog(int id)` and `dismissDialog(int id)` were deprecated. `dismiss()` directly on the dialog is now the recommended approach [as outlined here](http://stackoverflow.com/a/36120864/313399).

## References

 * <http://android-developers.blogspot.com/2012/05/using-dialogfragments.html>
 * <http://codebaum.wordpress.com/2013/04/10/dialog-fragments/>
 * <http://developer.android.com/reference/android/app/DialogFragment.html>
 * <http://www.coderzheaven.com/2013/02/14/dialogfragments-android-simple-example/>
 * <http://stackoverflow.com/questions/12912181/simplest-yes-no-dialog-fragment>

repository: teocci/AndroidGuidenotes

repo_name: teocci/AndroidGuidenotes


text:
Version 0.3.0 (released 2022-08-11)
==========================================================

* Vignette mimics calling REDCap. (#9)
* Small modernizations. (#9)

Version 0.2.0 (released 2018-09-07)
==========================================================

* added `table_nih_enrollment()` and `table_nih_enrollment_pretty()`. #2
* added `nih-enrollment-html` vignette. #6
* started pkgdown site. #7
* the idea was created by [Peter Higgins](http://www.med.umich.edu/higginslab/) (@higgi13425) for [R/Medicine 2018](https://events.linuxfoundation.org/r-medicine/).

repository: OuhscBbmc/codified

branch_name: refs/heads/main

gha_language: R

gha_license_id: NOASSERTION

repo_name: OuhscBbmc/codified


text:
# latex-receipt
Latex-Receipt is a LaTeX Template for typical reciepts here in Germany.

Format: A6

## Requirements
Please use latexmk and download [code128.tex](https://www.ctan.org/tex-archive/macros/generic/code128) and place it in the same directory

## Usage
Just edit it and use it.

## Example
See receipt.pdf

## Contributing
Pull Requests are welcome.

## License
[MIT](https://github.com/psuet/latex-receipt/blob/master/LICENSE)

repository: psuet/latex-receipt

repo_name: psuet/latex-receipt


text:
# Title Case for Epicodus
## by Daniel Toader and James Nielson
### Date: March 09, 2015
#### Description
The Title Case program capitalizes the first letter of all words in a multiple-word title. For example, we expect it to change the color purple to The Color Purple.

#### Setup instructions
1. Clone this git repository
2. Set your localhost root folder to ~/TitleCase/web/
3. Ensure PHP server is running.
4. Start the web app by pointing your browser to the root (http://localhost:8000/)

#### Copyright © 2015, Daniel Toader and James Nielson

#### License: MIT

#### Technologies used
- HTML5
- CSS3
- Bootstrap
- PHP (tested to run on PHP ver 5.6.6)
- Silex ver 1.2.3
- Twig ver 1.18.0
- PHPUnit

repository: CountPacMan/TitleCase

repo_name: CountPacMan/TitleCase


text:
# Sample OData usage with ASP.NET Boilerplate

* This is a sample project to show usage of OData within an ABP based application. It uses Abp.Web.Api.OData nuget package (https://www.nuget.org/packages/Abp.Web.Api.OData)
* It also shows how to host a Web API in an empty web application.

## How to test

* Restore all nuget packages.
* Set __AbpODataDemo.WebHost__ as startup project
* Open Package Manager Console, set __AbpODataDemo.EntityFramework__ as default project and run __Update-Database__ command.
* Run the application.
* Perform a GET request to __http://localhost:61842/odata/Persons__ to get list of people.
* Perform a GET request to __http://localhost:61842/odata/$metadata#Persons__ to get person metadata.

## Documentation

See http://aspnetboilerplate.com/Pages/Documents/OData-Integration

repository: aspnetboilerplate/sample-odata

gha_language: C#

repo_name: aspnetboilerplate/sample-odata