Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Commit

Permalink
We’ve updated Cannonball from using Fabric to Firebase.
Browse files Browse the repository at this point in the history
This commit shows the transition to using Firebase Crashlytics, Google Analytics for Firebase, and Firebase Authentication. Poems are now stored using Firebase Realtime Database.
  • Loading branch information
jhuleatt authored and kmcnellis committed Jun 18, 2018
1 parent 72c0d70 commit fdd98ae
Show file tree
Hide file tree
Showing 54 changed files with 560 additions and 952 deletions.
13 changes: 5 additions & 8 deletions .google/packaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ status: PUBLISHED
# statusNote:

# See http://go/sample-categories
technologies: [Android, AppEngine, Google+]
categories: [Getting Started, UI]
languages: [Java, Python]
technologies: [Android, Firebase, Fabric, Crashlytics]
categories: [Getting Started]
languages: [Java]
solutions: [Mobile]

# May be omitted if unpublished
github: google/actionbar-basics
github: firebase/cannonball-android

# Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT
level: BEGINNER

# Dimensions: 512x512, PNG fomrat
icon: screenshots/icon.png
icon: cannonball-android/app/src/main/res/drawable-xxhdpi/ic_logo.png

# List of APIs that this sample should be listed under. Use authoritive,
# names that are unique for the product in question. Examples:
Expand All @@ -32,9 +32,6 @@ icon: screenshots/icon.png
# gae-python:<package>
# Web Services - ws:<name of API from Cloud Console>
apiRefs:
- android:com.android.ui.ActionBar
- ws:drive.files
- ws:urlshortener.url

# Default: apache2. May be omitted for most samples.
# Alternatives: apache2-android (for AOSP)
Expand Down
5 changes: 0 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

## License

By contributing your code, You agree to license your contribution under the terms of the Apache Public License 2.0
https://github.com/firebase/cannonball-android/blob/master/LICENSE

[github]: https://github.com/firebase/cannonball-android
[google-cla]: https://cla.developers.google.com
[stackoverflow]: http://stackoverflow.com/questions/tagged/firebase
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Cannonball is the fun way to create and share stories and poems on your phone. Start with a beautiful image from the gallery, then choose words about #adventure, #romance, #nature or #mystery to complete the story and share it with friends.

![Cannonball flow](docs/cannonball.gif)

## Introduction

This repository contains the source code for Cannonball, an Android application written in Java built with [Firebase](https://firebase.google.com/).
Expand All @@ -14,7 +12,7 @@ Cannonball uses many of the features available in Firebase, including Realtime D

## Screenshots

TODO
![Cannonball flow](screenshot.png)

## Support

Expand All @@ -25,7 +23,15 @@ submitting a pull request through GitHub.

### Prerequisites

TODO
This project uses Gradle 4.4

To get started and run the app, you need to follow these simple steps:

1. Clone this repo via command line (`git clone https://github.com/Firebase/cannonball-android/`) or [Android Studio](https://stackoverflow.com/a/16597664/4816918)
1. Run "Sync Project with Gradle Files" via [command line](https://developer.android.com/studio/build/building-cmdline) or [Android Studio](https://stackoverflow.com/a/29565362/4816918)
1. If you don't already have a Firebase account, sign up for Firebase at [firebase.google.com](https://firebase.google.com/)
1. Follow the instructions to [add Firebase to your Android app](https://firebase.google.com/docs/android/setup#add_firebase_to_your_app)
1. Enable [Phone Sign-In](https://firebase.google.com/docs/auth/android/phone-auth) and [Anonymous Sign-In](https://firebase.google.com/docs/auth/android/anonymous-auth)

## Compatibility

Expand All @@ -48,10 +54,4 @@ Cannonball for Android is compatible with Android SDK version 17+.

## License

Copyright 2018 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
See [LICENSE](LICENSE)
45 changes: 13 additions & 32 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


Properties props = new Properties()
try {
props.load(file('crashlytics.properties').newDataInputStream())
} catch (Exception ex) {
throw new GradleException("Missing crashlytics.properties, check the crashlytics.properties.sample file.");
}

android {
compileSdkVersion 26
defaultConfig {
Expand All @@ -32,8 +13,6 @@ android {
}
buildTypes {
debug {
buildConfigField "String", "CONSUMER_KEY", "\"${props.getProperty("twitterConsumerKey")}\""
buildConfigField "String", "CONSUMER_SECRET", "\"${props.getProperty("twitterConsumerSecret")}\""
applicationIdSuffix ".dev"
debuggable true
}
Expand All @@ -51,14 +30,16 @@ repositories {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.twitter.sdk.android:twitter:1.8.0@aar') {
transitive = true
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:1.6.1@aar') {
transitive = true;
}
}
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'

implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'

implementation 'com.firebaseui:firebase-ui-auth:4.0.1'
implementation 'com.firebaseui:firebase-ui-database:4.0.1'
}

apply plugin: 'com.google.gms.google-services'
7 changes: 0 additions & 7 deletions app/crashlytics.properties.sample

This file was deleted.

19 changes: 10 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.google.cannonball.activity.ThemeChooserActivity" />
</activity>
<provider
android:name=".db.PoemProvider"
android:authorities="com.google.cannonball.provider"
android:exported="false" >
</provider>

<service
android:name=".AppService"
android:exported="false" >
</service>
<activity
android:name="com.google.cannonball.activity.AboutActivity"
android:label="@string/title_activity_about"
Expand All @@ -78,6 +69,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.google.cannonball.activity.ThemeChooserActivity" />
</activity>

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.google.cannonball.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
</application>

</manifest>
67 changes: 5 additions & 62 deletions app/src/main/java/com/google/cannonball/App.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright (C) 2017 Google Inc and other contributors.
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,19 +17,9 @@
package com.google.cannonball;

import android.app.Application;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Environment;
import android.preference.PreferenceManager;

import com.crashlytics.android.Crashlytics;
import com.digits.sdk.android.Digits;
import com.twitter.sdk.android.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;

import java.io.File;

import io.fabric.sdk.android.Fabric;
import com.google.firebase.FirebaseApp;

/**
* This class represents the Application and extends Application it is used to initiate the
Expand All @@ -49,55 +39,22 @@ public class App extends Application {
public final static String CRASHLYTICS_KEY_WORDBANK_COUNT = "word_bank_count_loaded";
public final static String CRASHLYTICS_KEY_POEM_TEXT = "saving_poem_text";
public final static String CRASHLYTICS_KEY_POEM_IMAGE = "saving_poem_image";
public final static String CRASHLYTICS_KEY_CRASHES = "are_crashes_enabled";
public final static String POEM_PIC_DIR = "cannonball";

private static App singleton;
private TwitterAuthConfig authConfig;
private Typeface avenirFont;

public static App getInstance() {
return singleton;
}

/* Checks if external storage is available for read and write */
public static boolean isExternalStorageWritable() {
final String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}

/* Checks if external storage is available to at least read */
public static boolean isExternalStorageReadable() {
final String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
return true;
}
return false;
}

public static File getPoemFile(String fileName) {
// Get the directory for the user's public pictures directory.
final File picsDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
final File poemPicsDir = new File(picsDir, POEM_PIC_DIR);
poemPicsDir.mkdirs();
return new File(poemPicsDir, fileName);
}

@Override
public void onCreate() {
super.onCreate();
singleton = this;
extractAvenir();
authConfig
= new TwitterAuthConfig(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
Fabric.with(this, new Crashlytics(), new Digits(), new Twitter(authConfig));

Crashlytics.setBool(CRASHLYTICS_KEY_CRASHES, areCrashesEnabled());
FirebaseApp.initializeApp(this);
}

private void extractAvenir() {
Expand All @@ -110,18 +67,4 @@ public Typeface getTypeface() {
}
return avenirFont;
}

public boolean areCrashesEnabled() {
SharedPreferences preferences;
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
return preferences.getBoolean("are_crashes_enabled", false);
}

public void setCrashesStatus(boolean status) {
SharedPreferences preferences;
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
final SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("are_crashes_enabled", status);
editor.apply();
}
}

0 comments on commit fdd98ae

Please sign in to comment.