Skip to content

Commit

Permalink
* android x migration
Browse files Browse the repository at this point in the history
* version updates
* color fix
  • Loading branch information
MFlisar committed Mar 1, 2019
1 parent 246c2db commit 138ae8c
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 77 deletions.
24 changes: 15 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27

dataBinding {
enabled = true
}
compileSdkVersion setup.compileSdk
dataBinding.enabled = setup.enableDataBinding

defaultConfig {
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
applicationId "com.michaelflisar.gdprdialog.demo"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand All @@ -29,8 +26,17 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'

// ------------------------
// AndroidX
// ------------------------

implementation "androidx.appcompat:appcompat:${androidx.appcompat}"
implementation "com.google.android.material:material:${androidx.material}"

// ------------------------
// Library
// ------------------------

implementation project(':library')
// implementation 'com.github.MFlisar:GDPRDialog:-SNAPSHOT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand All @@ -11,7 +11,6 @@
import com.michaelflisar.gdprdialog.GDPRConsent;
import com.michaelflisar.gdprdialog.GDPRConsentState;
import com.michaelflisar.gdprdialog.GDPRDefinitions;
import com.michaelflisar.gdprdialog.GDPRLocation;
import com.michaelflisar.gdprdialog.GDPRSetup;
import com.michaelflisar.gdprdialog.demo.app.App;
import com.michaelflisar.gdprdialog.demo.gdpr.DemoGDPRActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.michaelflisar.gdprdialog.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.michaelflisar.gdprdialog.demo;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.view.PagerAdapter;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
import com.google.android.material.snackbar.Snackbar;
import androidx.viewpager.widget.PagerAdapter;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
android:orientation="vertical"
tools:context=".DemoActivity">

<android.support.design.widget.TabLayout
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
Expand Down Expand Up @@ -267,7 +267,7 @@

</ScrollView>

</android.support.v4.view.ViewPager>
</androidx.viewpager.widget.ViewPager>

<Button
android:id="@+id/btTest"
Expand Down
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

apply from: './versions.gradle'

buildscript {


apply from: './versions.gradle'

repositories {
jcenter()
maven { url "https://maven.google.com" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:' + versions.gradlePlugin
classpath 'com.github.dcendents:android-maven-gradle-plugin:' + versions.mavenVersion
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 16 08:32:36 CEST 2018
#Fri Mar 01 09:53:14 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
34 changes: 13 additions & 21 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.MFlisar'

android {
if (project.hasProperty('setup.compileSdk')) {
compileSdkVersion setup.compileSdk
buildToolsVersion setup.buildTools
defaultConfig {
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
}
} else {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
}

compileSdkVersion setup.compileSdk
defaultConfig {
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -32,11 +24,11 @@ android {
}

dependencies {
if (project.hasProperty('versions.supportLib')) {
implementation "com.android.support:appcompat-v7:$rootProject.versions.supportLib"
implementation "com.android.support:design:$rootProject.versions.supportLib"
} else {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}

// ------------------------
// AndroidX
// ------------------------

implementation "androidx.appcompat:appcompat:${androidx.appcompat}"
implementation "com.google.android.material:material:${androidx.material}"
}
4 changes: 2 additions & 2 deletions library/src/main/java/com/michaelflisar/gdprdialog/GDPR.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.appcompat.app.AppCompatActivity;

import com.michaelflisar.gdprdialog.helper.PreperationAsyncTask;
import com.michaelflisar.gdprdialog.helper.GDPRPreperationData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatDialog;
import android.support.v7.app.AppCompatDialogFragment;
import androidx.annotation.NonNull;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatDialog;
import androidx.appcompat.app.AppCompatDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void onBackPressed() {
};
dlg.setOnShowListener(dialog -> {
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = d.findViewById(android.support.design.R.id.design_bottom_sheet);
FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior behaviour = BottomSheetBehavior.from(bottomSheet);
// fully expand sheet and disable collapse state
behaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.support.annotation.ColorInt;

import androidx.annotation.ColorInt;
import android.telephony.TelephonyManager;
import android.util.TypedValue;

import com.michaelflisar.gdprdialog.GDPR;
import com.michaelflisar.gdprdialog.GDPRNetwork;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.Toolbar;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.widget.Toolbar;

import android.text.Html;
import android.text.Layout;
import android.text.SpannableString;
Expand All @@ -19,7 +17,6 @@
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
Expand Down Expand Up @@ -152,7 +149,7 @@ public void init(Activity activity, View view, IOnFinishView onFinishViewListene
final CheckBox cbAge = view.findViewById(R.id.cbAge);

initGeneralTexts(activity, tvQuestion, tvText1, tvText2, tvText3, cbAge);
initButtons(activity, btAgree, btDisagree, btNoConsentAtAll, tvText1.getTextColors().getDefaultColor());
initButtons(activity, btAgree, btDisagree, btNoConsentAtAll);

// info page
final TextView tvServiceInfo1 = view.findViewById(R.id.tvServiceInfo1);
Expand Down Expand Up @@ -231,7 +228,7 @@ public void init(Activity activity, View view, IOnFinishView onFinishViewListene
});
}

private void initButtons(Activity activity, Button btAgree, Button btDisagree, Button btNoConsentAtAll, int textColor) {
private void initButtons(Activity activity, Button btAgree, Button btDisagree, Button btNoConsentAtAll) {

if (mSetup.hasPaidVersion()) {
if (!mSetup.allowNonPersonalisedForPaidVersion()) {
Expand All @@ -256,7 +253,7 @@ private void initButtons(Activity activity, Button btAgree, Button btDisagree, B
SpannableString spannableText = new SpannableString(textButton + textInfo);
spannableText.setSpan(new StyleSpan(Typeface.BOLD), 0, textButton.length(), 0);
spannableText.setSpan(new RelativeSizeSpan(0.8f), textButton.length(), spannableText.length(), 0);
spannableText.setSpan(new ForegroundColorSpan(textColor), textButton.length(), spannableText.length(), 0);
spannableText.setSpan(new ForegroundColorSpan(btDisagree.getTextColors().getDefaultColor()), textButton.length(), spannableText.length(), 0);
btDisagree.setAllCaps(false);
btDisagree.setTypeface(Typeface.DEFAULT);
btDisagree.setText(spannableText);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.michaelflisar.gdprdialog.helper;

import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import com.michaelflisar.gdprdialog.GDPR;
import com.michaelflisar.gdprdialog.GDPRConsent;
Expand All @@ -11,7 +11,6 @@
import com.michaelflisar.gdprdialog.GDPRSetup;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

public class PreperationAsyncTask<T extends AppCompatActivity & GDPR.IGDPRCallback> extends AsyncTask<Object, Void, GDPRPreperationData> {

Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/layout/gdpr_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
19 changes: 19 additions & 0 deletions versions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ext {

setup = [
compileSdk : 28,
enableDataBinding: true,
minSdk : 21,
targetSdk : 28
]

androidx = [
appcompat : "1.0.2",
material : "1.0.0"
]

versions = [
gradlePlugin: "3.3.1",
mavenVersion: "2.1"
]
}

0 comments on commit 138ae8c

Please sign in to comment.