Skip to content

Commit

Permalink
Merge master into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntudroid committed Mar 11, 2019
1 parent 2bc7e17 commit 42d10eb
Show file tree
Hide file tree
Showing 36 changed files with 1,115 additions and 333 deletions.
66 changes: 46 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[![Release](https://jitpack.io/v/stanwood/Dialog_Framework_android.svg?style=flat-square)](https://jitpack.io/#stanwood/Dialog_Framework_android)
[![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21)

# stanwood Rating Dialog (Android)

This library contains a simple to use "please rate my app" dialog, which is shown at x-th time of app starts.

![Demo](indicator.gif)
![Demo](images/dialog_screenshot.png)

## Import

Expand All @@ -26,11 +27,12 @@ Then add this to you app's `build.gradle`:
```groovy
dependencies {
implementation 'com.github.stanwood:Dialog_Framework_android:<insert latest version here>'
implementation 'com.github.stanwood.Core_Framework_android:framework-base:<insert latest version here>'
implementation 'com.github.stanwood.Core_Framework_android:framework-ui:<insert latest version here>'
}
```

For more info about how to add Stanwood analytics framework to the app please check the
https://github.com/stanwood/Analytics_Framework_android

## Usage

Initialise the dialog within Application and set after how many app starts would you want to show the dialog.
Expand All @@ -42,15 +44,14 @@ public class MyApp extends Application implements HasActivityInjector {

@Inject
RatingService ratingService;

@Override
public void onCreate() {
super.onCreate();
DaggerAppComponent.builder().application(this).build().inject(this);

ratingService.setLaunchTimes(2);
}

@Override
public DispatchingAndroidInjector<Activity> activityInjector() {
return dispatchingAndroidInjector;
Expand All @@ -59,36 +60,61 @@ public class MyApp extends Application implements HasActivityInjector {
```

Show the dialog within Activity

```java
public class MainActivity extends AppCompatActivity {

@Inject
RatingService ratingService;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidInjection.inject(this);

setContentView(R.layout.activity_main);
if (ratingService.shouldBeDisplayed()) {
RatingDialog.builder()
.setParagraph1("Hi,\nI'm the developer of this app.")
.setParagraph2("Developers like me live on good ratings in Google Play.")
.setParagraph3("If you like the app, please rate it.")
.setParagraph4("It takes only 1 minute.")
.setCancelText("Cancel")
.setOkText("Ok")
.setBannerUrl(<add url to image here>)
.setFaceUrl(<<add url to image here>)
.build()
.show(getSupportFragmentManager(), "dialog");
RatingDialog.builder()
.addParagraph(Html.fromHtml("Hi, <br/> I'm the <font color='red'>developer</font> of this app."))
.addParagraph("Developers like me live on good ratings in Google Play.")
.addParagraph("If you like the app,\nplease rate it.")
.addParagraph("It takes only 1 minute")
.setCancelText("Cancel")
.setOkText("Ok")
.setBannerUrl("https://media.istockphoto.com/photos/plitvice-lakes-picture-id500463760?s=2048x2048")
.setFaceUrl("https://lh5.googleusercontent.com/-_w2wo1s6SkI/AAAAAAAAAAI/AAAAAAAAhMU/s78iSxXwVZk/photo.jpg")
//.setAnalyticsTracker(add analytics instance here)
.preloadAndShow(this);
}
}
}
```

Min SDK Version = 21

Glide version = 4.8.x

For more information check out the sample app.

## Tips and Tricks

**Fixed in 0.6.1:** Firebase remote config does not support newlines by ifself. Here's a snippet which solves it:

```java
public String getString(@ConfigName String key) {
return mFirebaseRemoteConfig.getString(key);
}

public String getNewLinedString(@ConfigName String key) {
String s = getString(key);
if (s != null) {
return s.replaceAll("\\\\n", "\n");
} else {
return s;
}
}
```

## Roadmap

- add more possibilities about when to show the dialog
- add more possibilities about when to show the dialog
15 changes: 3 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "io.stanwood.framework.dialog"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -41,21 +41,12 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$rootProject.ext.supportLibVersion"
implementation project(':library')
implementation "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
annotationProcessor 'androidx.annotation:annotation:1.0.2'
annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.ext.glideVersion"
implementation "androidx.appcompat:appcompat:$rootProject.ext.supportLibVersion"

implementation "com.google.dagger:dagger:$rootProject.ext.dagger_version"
implementation "com.google.dagger:dagger-android:$rootProject.ext.dagger_version"
implementation "com.google.dagger:dagger-android-support:$rootProject.ext.dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.ext.dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.ext.dagger_version"

//stanwood framework
//implementation 'com.github.stanwood:Dialog_Framework_android:<put latest version here>'
implementation "com.github.stanwood.Core_Framework_android:base:$rootProject.ext.core_framework_version"
implementation "com.github.stanwood.Core_Framework_android:ui:$rootProject.ext.core_framework_version"
}
22 changes: 22 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2018 stanwood Gmbh
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.stanwood.framework.demo">

Expand Down
46 changes: 32 additions & 14 deletions app/src/main/java/io/stanwood/framework/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
/*
* Copyright (c) 2018 stanwood Gmbh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.stanwood.framework.demo;


import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.text.Html;

import javax.inject.Inject;

Expand All @@ -22,23 +45,18 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_main);
if (ratingService.shouldBeDisplayed()) {
RatingDialog dialog = RatingDialog.builder()
.setParagraph1("Hi,\nI'm the developer of this app.")
.setParagraph2("Developers like me live on good ratings in Google Play.")
.setParagraph3("If you like the app, please rate it.")
.setParagraph4("It takes only 1 minute.")
RatingDialog.builder()
.addParagraph(Html.fromHtml("<font color='blue'>Hi,</font>"))
.addParagraph("ich bin Hannes, der Entwicker von On Air")
.addParagraph("Kleine App-Entwicker wie wir leben von guten Bewertungen im App-Store.")
.addParagraph("Wenn Ihnen unsere App gefällt, dann bewerten Sie uns doch bitte.")
.addParagraph(Html.fromHtml("<font color='red'>Sternchen reichen - dauert nur 1 Minute</font>"))
.setCancelText("Cancel")
.setOkText("Ok")
.setBannerUrl("https://media.istockphoto.com/photos/plitvice-lakes-picture-id500463760?s=2048x2048")
.setBannerUrl("https://lh5.googleusercontent.com/-Lc9l-g5gkUM/AAAAAAAAAAI/AAAAAAAAAAg/NCA9hVKHbp4/photo.jpg")
.setFaceUrl("https://lh5.googleusercontent.com/-_w2wo1s6SkI/AAAAAAAAAAI/AAAAAAAAhMU/s78iSxXwVZk/photo.jpg")
.build();
//dialog.setAnalytics(add analytics instance here);
dialog.show(getSupportFragmentManager(), "dialog");
//.setAnalyticsTracker(add analytics instance here)
.preloadAndShow(this);
}
}

@Override
public void onResume() {
super.onResume();
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/io/stanwood/framework/demo/MyApp.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2018 stanwood Gmbh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.stanwood.framework.demo;

import android.app.Activity;
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/io/stanwood/framework/demo/di/AppComponent.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2018 stanwood Gmbh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.stanwood.framework.demo.di;

import android.app.Application;
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/io/stanwood/framework/demo/di/AppModule.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2018 stanwood Gmbh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.stanwood.framework.demo.di;

import android.app.Application;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2018 stanwood Gmbh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.stanwood.framework.demo.di;

import dagger.Module;
Expand Down

This file was deleted.

22 changes: 22 additions & 0 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
<!--
~ Copyright (c) 2018 stanwood Gmbh
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
Expand Down
Loading

0 comments on commit 42d10eb

Please sign in to comment.