├── .gitignore ├── .travis.yml ├── CONDUCT.md ├── INSTRUCTIONS.md ├── LICENSE ├── README.md ├── build.gradle ├── demoapp ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── server │ ├── Gemfile │ ├── Gemfile.lock │ ├── config.ru │ ├── lib │ │ ├── turbolinks_demo.rb │ │ └── turbolinks_demo │ │ │ ├── app.rb │ │ │ └── views │ │ │ ├── error.erb │ │ │ ├── index.erb │ │ │ ├── layout.erb │ │ │ ├── one.erb │ │ │ ├── slow.erb │ │ │ └── two.erb │ └── tmp │ │ └── restart.txt └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── basecamp │ │ └── turbolinks │ │ └── demo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── basecamp │ │ │ └── turbolinks │ │ │ └── demo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── basecamp │ └── turbolinks │ └── demo │ └── ExampleUnitTest.java ├── docs ├── allclasses-frame.html ├── allclasses-noframe.html ├── com │ └── basecamp │ │ └── turbolinks │ │ ├── TurbolinksAdapter.html │ │ ├── TurbolinksHelper.html │ │ ├── TurbolinksLog.html │ │ ├── TurbolinksScrollUpCallback.html │ │ ├── TurbolinksSession.html │ │ ├── TurbolinksSwipeRefreshLayout.html │ │ ├── TurbolinksTestActivity.html │ │ ├── TurbolinksView.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html ├── constant-values.html ├── deprecated-list.html ├── help-doc.html ├── index-files │ ├── index-1.html │ ├── index-10.html │ ├── index-11.html │ ├── index-12.html │ ├── index-13.html │ ├── index-14.html │ ├── index-15.html │ ├── index-16.html │ ├── index-17.html │ ├── index-2.html │ ├── index-3.html │ ├── index-4.html │ ├── index-5.html │ ├── index-6.html │ ├── index-7.html │ ├── index-8.html │ └── index-9.html ├── index.html ├── overview-tree.html ├── package-list ├── script.js └── stylesheet.css ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── turbolinks ├── .gitignore ├── build.gradle ├── proguard-consumer-rules.pro ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── basecamp │ └── turbolinks │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── assets │ └── js │ │ └── turbolinks_bridge.js ├── java │ └── com │ │ └── basecamp │ │ └── turbolinks │ │ ├── TurbolinksAdapter.java │ │ ├── TurbolinksHelper.java │ │ ├── TurbolinksLog.java │ │ ├── TurbolinksScrollUpCallback.java │ │ ├── TurbolinksSession.java │ │ ├── TurbolinksSwipeRefreshLayout.java │ │ ├── TurbolinksTestActivity.java │ │ └── TurbolinksView.java └── res │ ├── layout │ └── turbolinks_progress.xml │ └── values │ └── strings.xml └── test └── java └── com └── basecamp └── turbolinks ├── BaseTest.java ├── TestBuildConfig.java ├── TurbolinksHelperTest.java ├── TurbolinksSessionTest.java └── TurbolinksViewTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | .DS_Store 4 | /build 5 | 6 | .idea/* 7 | *.iml 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - tools 6 | - tools # See https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943 7 | - platform-tools 8 | - build-tools-25.0.2 9 | - android-24 10 | - android-25 11 | - sys-img-armeabi-v7a-android-24 12 | - extra-android-support 13 | - extra-android-m2repository 14 | before_script: 15 | # Create and start emulator 16 | - echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a 17 | - emulator -avd test -no-skin -no-window & 18 | - android-wait-for-emulator 19 | - adb shell input keyevent 82 & 20 | before_cache: 21 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 22 | cache: 23 | directories: 24 | - $HOME/.gradle/caches/ 25 | - $HOME/.gradle/wrapper/ 26 | branches: 27 | except: 28 | - gh-pages 29 | script: 30 | ./gradlew clean testRelease -p turbolinks 31 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. 6 | 7 | Examples of unacceptable behavior by participants include: 8 | 9 | * The use of sexualized language or imagery 10 | * Personal attacks 11 | * Trolling or insulting/derogatory comments 12 | * Public or private harassment 13 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 14 | * Other unethical or unprofessional conduct. 15 | 16 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. 17 | 18 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one of the project maintainers, [Dan Kim](mailto:dan@basecamp.com) or [Jay Ohms](mailto:jay@basecamp.com). 21 | 22 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Basecamp, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | Turbolinks Android 1.x is deprecated. We will not be maintaining this adapter any further. We'd encourage you to read the [detailed explanation for why we deprecated this library](https://github.com/turbolinks/turbolinks-android/wiki/Turbolinks-Android-Adapter-1.x-Deprecation). The previous instructions are [still available](INSTRUCTIONS.md). 3 | 4 | # New Version 5 | The new Turbo Android framework is available at https://github.com/hotwired/turbo-android and is now a part of [Hotwire](https://hotwire.dev). 6 | 7 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /demoapp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demoapp/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion '28.0.3' 6 | 7 | defaultConfig { 8 | applicationId "com.basecamp.turbolinks.demo" 9 | minSdkVersion 19 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | debug { 20 | debuggable true 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(include: ['*.jar'], dir: 'libs') 28 | testImplementation 'junit:junit:4.12' 29 | implementation 'androidx.appcompat:appcompat:1.0.2' 30 | implementation 'com.google.android.material:material:1.1.0-alpha01' 31 | implementation project(':turbolinks') 32 | } 33 | -------------------------------------------------------------------------------- /demoapp/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/dankim/android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demoapp/server/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'sinatra' 4 | gem 'turbolinks-source' 5 | -------------------------------------------------------------------------------- /demoapp/server/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | rack (1.6.4) 5 | rack-protection (1.5.3) 6 | rack 7 | sinatra (1.4.7) 8 | rack (~> 1.5) 9 | rack-protection (~> 1.4) 10 | tilt (>= 1.3, < 3) 11 | tilt (2.0.2) 12 | turbolinks-source (5.0.0.beta1.1) 13 | 14 | PLATFORMS 15 | ruby 16 | 17 | DEPENDENCIES 18 | sinatra 19 | turbolinks-source 20 | 21 | BUNDLED WITH 22 | 1.10.6 23 | -------------------------------------------------------------------------------- /demoapp/server/config.ru: -------------------------------------------------------------------------------- 1 | $:.unshift File.dirname(__FILE__)+'/lib' 2 | 3 | require 'rubygems' 4 | require 'turbolinks_demo' 5 | 6 | run TurbolinksDemo::App 7 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo.rb: -------------------------------------------------------------------------------- 1 | require_relative 'turbolinks_demo/app' 2 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/app.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | require 'turbolinks/source' 3 | 4 | module TurbolinksDemo 5 | class App < Sinatra::Base 6 | get '/' do 7 | @title = 'Demo' 8 | erb :index, layout: :layout 9 | end 10 | 11 | get '/one' do 12 | @title = 'Page One' 13 | erb :one, layout: :layout 14 | end 15 | 16 | get '/two' do 17 | @title = 'Page Two' 18 | erb :two, layout: :layout 19 | end 20 | 21 | get '/slow' do 22 | sleep 2 23 | @title = 'Slow' 24 | erb :slow, layout: :layout 25 | end 26 | 27 | get '/error' do 28 | @title = 'Error' 29 | erb :error, layout: :layout 30 | end 31 | 32 | get '/turbolinks.js' do 33 | send_file(Turbolinks::Source.asset_path + '/turbolinks.js') 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/error.erb: -------------------------------------------------------------------------------- 1 |

Error

2 | 3 | You've hit an error. 4 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/index.erb: -------------------------------------------------------------------------------- 1 |

Hello from Turbolinks! This demo app will help you get acquainted with the framework.

2 | 3 | 9 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/layout.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <%= @title %> 7 | 8 | 12 | 13 | 14 | <%= yield %> 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/one.erb: -------------------------------------------------------------------------------- 1 |

Page One

2 | 3 | Go to page two. 4 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/slow.erb: -------------------------------------------------------------------------------- 1 |

Slow

2 | -------------------------------------------------------------------------------- /demoapp/server/lib/turbolinks_demo/views/two.erb: -------------------------------------------------------------------------------- 1 |

Page Two

2 | 3 | Go to page one. 4 | -------------------------------------------------------------------------------- /demoapp/server/tmp/restart.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/server/tmp/restart.txt -------------------------------------------------------------------------------- /demoapp/src/androidTest/java/com/basecamp/turbolinks/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.basecamp.turbolinks.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /demoapp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /demoapp/src/main/java/com/basecamp/turbolinks/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.basecamp.turbolinks.demo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | import com.basecamp.turbolinks.TurbolinksAdapter; 7 | import com.basecamp.turbolinks.TurbolinksSession; 8 | import com.basecamp.turbolinks.TurbolinksView; 9 | 10 | import androidx.appcompat.app.AppCompatActivity; 11 | 12 | public class MainActivity extends AppCompatActivity implements TurbolinksAdapter { 13 | // Change the BASE_URL to an address that your VM or device can hit. 14 | private static final String BASE_URL = "http://10.0.1.100:9292"; 15 | private static final String INTENT_URL = "intentUrl"; 16 | 17 | private String location; 18 | private TurbolinksView turbolinksView; 19 | 20 | // ----------------------------------------------------------------------- 21 | // Activity overrides 22 | // ----------------------------------------------------------------------- 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_main); 28 | 29 | // Find the custom TurbolinksView object in your layout 30 | turbolinksView = (TurbolinksView) findViewById(R.id.turbolinks_view); 31 | 32 | // For this demo app, we force debug logging on. You will only want to do 33 | // this for debug builds of your app (it is off by default) 34 | TurbolinksSession.getDefault(this).setDebugLoggingEnabled(true); 35 | 36 | // For this example we set a default location, unless one is passed in through an intent 37 | location = getIntent().getStringExtra(INTENT_URL) != null ? getIntent().getStringExtra(INTENT_URL) : BASE_URL; 38 | 39 | // Execute the visit 40 | TurbolinksSession.getDefault(this) 41 | .activity(this) 42 | .adapter(this) 43 | .view(turbolinksView) 44 | .visit(location); 45 | } 46 | 47 | @Override 48 | protected void onRestart() { 49 | super.onRestart(); 50 | 51 | // Since the webView is shared between activities, we need to tell Turbolinks 52 | // to load the location from the previous activity upon restarting 53 | TurbolinksSession.getDefault(this) 54 | .activity(this) 55 | .adapter(this) 56 | .restoreWithCachedSnapshot(true) 57 | .view(turbolinksView) 58 | .visit(location); 59 | } 60 | 61 | // ----------------------------------------------------------------------- 62 | // TurbolinksAdapter interface 63 | // ----------------------------------------------------------------------- 64 | 65 | @Override 66 | public void onPageFinished() { 67 | 68 | } 69 | 70 | @Override 71 | public void onReceivedError(int errorCode) { 72 | handleError(errorCode); 73 | } 74 | 75 | @Override 76 | public void pageInvalidated() { 77 | 78 | } 79 | 80 | @Override 81 | public void requestFailedWithStatusCode(int statusCode) { 82 | handleError(statusCode); 83 | } 84 | 85 | @Override 86 | public void visitCompleted() { 87 | 88 | } 89 | 90 | // The starting point for any href clicked inside a Turbolinks enabled site. In a simple case 91 | // you can just open another activity, or in more complex cases, this would be a good spot for 92 | // routing logic to take you to the right place within your app. 93 | @Override 94 | public void visitProposedToLocationWithAction(String location, String action) { 95 | Intent intent = new Intent(this, MainActivity.class); 96 | intent.putExtra(INTENT_URL, location); 97 | 98 | this.startActivity(intent); 99 | } 100 | 101 | // ----------------------------------------------------------------------- 102 | // Private 103 | // ----------------------------------------------------------------------- 104 | 105 | // Simply forwards to an error page, but you could alternatively show your own native screen 106 | // or do whatever other kind of error handling you want. 107 | private void handleError(int code) { 108 | if (code == 404) { 109 | TurbolinksSession.getDefault(this) 110 | .activity(this) 111 | .adapter(this) 112 | .restoreWithCachedSnapshot(false) 113 | .view(turbolinksView) 114 | .visit(BASE_URL + "/error"); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /demoapp/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turbolinks/turbolinks-android/fa8f38f1e3e413754837435d468b16a0417a75b1/demoapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #3F51B5 6 | 7 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Turbolinks Android Demo 3 | 4 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |