kkaun/tiny_ar_browser


Simple AR Browser Android library which represents single camera activity with customizable AR and UI overlays.

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.kkaun:tiny_ar_browser:1.4.1'
	}
	dependencies {
		implementation("com.github.kkaun:tiny_ar_browser:1.4.1")
	}
	<dependency>
	    <groupId>com.github.kkaun</groupId>
	    <artifactId>tiny_ar_browser</artifactId>
	    <version>1.4.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.kkaun" % "tiny_ar_browser" % "1.4.1"
        
        

                            
    :dependencies [[com.github.kkaun/tiny_ar_browser "1.4.1"]]
        
        

Readme


Tiny AR Browser

Simple AR Browser Android library written in Kotlin which represents single Camera activity with AR and fully customizable UI overlays.

If you're working with some geolocation data and looking for additional/optional functionality to provide the projection environment for your app's content, you may check this one.

Using it

Current version can be imported via JitPack:

Root build.gradle:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Local build.gradle:

dependencies {
        implementation 'com.github.kkaun:tiny_ar_browser:1.3'
}

After the import all you have to do to make it work is:

  • extending ARActivity class with your own standalone activity: be aware of the fact that basic activity has no parent xml layouts; you can attach custom xml layouts or views to UI implementation though, but in most cases you could add custom elements programmatically if needed;
  • transforming your data into collection of ARMarkers or extending your app's data class from ARMarker;
  • providing static CacheDataSource field to your activity for caching markers and use cacheDataSource.setData(data: CopyOnWriteArrayList<ARMarker>) when your ARMarker collection is ready for use;
  • accessing ARDataRepository "singleton" (Kotlin object) and calling ARDataRepository.populateARData(markers: Collection<Marker>?) to populate data for the projection view (ARMarker extends Marker, so there's no need to transform it here).

Generally projection-ready markers are hashed by their names(titles), so each marker should have its unique name for proper working. Feel free to make pull requests with own implementations of this and other concepts.

Features

Basically UI overlay has few additional features, such as:

  • AR markers themselves: you can set bitmap icon and hide/edit text of each marker, set on click listeners etc;
  • Radius change bar AKA Zoom bar: changes radius of cached/requested data display;
  • Radar: displays cached geo points on improvised radar overlay;
  • Menu: manages visibility of UI elements if they're not disabled and closes activity if back press is not working standard way.

To change UI elements appearance call one or more methods listed below inside overriden onCreate() or business methods:

| Method signature | Description | Default args / Boundaries | |-------------------------------------------------------------------|---|---| | setMenuEnabled(enabled: Boolean) | Enable/disable menu button | true | | setZoomProgress(progress: Int) | Set Zoom bar progress (in km) | 1-5 | | setMaxZoom(max: Int) | Set Zoom bar's max value (in km) | 2-100 | | setCollisionDetectionEnabled(enabled: Boolean) | Enable/disable markers collision detection. Caution: at current stage disabling it may lead to unpredictable results with massive data set | true | | setMenuSwitchRadarTitle(title: String) | Set menu Radar item title | Any String from your resources | | setMenuSwitchZoomBarTitle(title: String) | Set menu Zoom bar item title | Any String from your resources | | setMenuExitActivityTitle(title: String) | Set menu Exit item title | Any String from your resources | | useRadar(use: Boolean) | Use Radar at all? | true | | useZoombar(use: Boolean) | Use Zoom bar at all? | true | | showRadar(show: Boolean) | Show Radar? | true | | showZoombar(show: Boolean) | Show Zoom bar? | true | | setRadarBodyRadius(radius: Int) | Change Radar body radius | 50-200 | | setRadarBodyColor(alpha: Int, red: Int, green: Int, blue: Int) | Change Radar body color | 0-255 for each (ARGB) | | setRadarTextColor(red: Int, green: Int, blue: Int) | Change Radar text color | 0-255 for each (RGB) | | setRadarLineColor(red: Int, green: Int, blue: Int) | Change Radar lines(borders) color | 0-255 for each (RGB) | | ARMarker.setFontColor(red: Int, green: Int, blue: Int) | Change individual ARMarker font color | 0-255 for each (RGB) | | ARMarker.setBodyColor(red: Int, green: Int, blue: Int) | Change individual ARMarker body(background) color | 0-255 for each (ARGB) | | ARMarker.setFrameColor(red: Int, green: Int, blue: Int) | Change individual ARMarker borders color | 0-255 for each (RGB) |

Demo

After forking/downloading project you can quickly check how it works by running it on device/emulator. Sample activities are located in samples directory.