Skip to content

Commit

Permalink
Update for Android Developer Studio 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ReyKoxha committed May 27, 2018
1 parent cbd3acc commit 722c909
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 75 deletions.
69 changes: 36 additions & 33 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,56 @@
// gradle wrapper Create Gradle Wrapper


buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.1, 0.99.99]'
classpath 'com.google.gms:google-services:3.2.0'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
maven { url 'https://maven.google.com' }
}

final VERSION_MAJOR = 3 // Max 2 digits
final VERSION_MINOR = 0 // Max 2 digits
final VERSION_PATCH = 0 // Max 2 digits
final VERSION_BUILD = 0 // Max 3 digits


apply plugin: 'com.android.application'


dependencies
{
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile "com.google.android.gms:play-services-base:10.2.0"
compile "com.google.android.gms:play-services-analytics:10.2.0"
compile "com.google.android.gms:play-services-ads:10.2.0"
compile "com.google.android.gms:play-services-gcm:10.2.0"
compile "com.google.android.gms:play-services-location:10.2.0"
compile 'com.onesignal:OneSignal:3.+@aar'
compile 'commons-io:commons-io:2.4'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-analytics:16.0.0"
implementation "com.google.android.gms:play-services-ads:15.0.1"
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation 'commons-io:commons-io:2.6'
}


android
{
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig
{
multiDexEnabled true
minSdkVersion 19
targetSdkVersion 25
targetSdkVersion 27
versionCode VERSION_MAJOR*10000000 + VERSION_MINOR*100000 + VERSION_PATCH*1000 + VERSION_BUILD
versionName "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"

Expand Down Expand Up @@ -80,25 +97,11 @@ android
}
}

applicationVariants.all
{
variant ->
if(variant.buildType.name.equals("release"))
{
variant.outputs.each
{
output ->
def outputFile = output.outputFile
def date = new Date()
if(outputFile!=null && outputFile.name.endsWith('.apk'))
{
def fileName = outputFile.name.replace(
"app",
"WebApp-" + defaultConfig.versionName + "-" + defaultConfig.versionCode)
output.outputFile = new File((String) outputFile.parent, (String) fileName)
}
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def newApkName = applicationId + "-" + variant.versionName + "(" + variant.versionCode + ")" + ".apk";
outputFileName = new File(variant.name, newApkName);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
Expand All @@ -27,7 +27,7 @@
import com.webview.nodebb.fragment.MainFragment;


public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private ListView mDrawerListView;
Expand Down
46 changes: 14 additions & 32 deletions app/src/main/java/com/webview/nodebb/utility/DownloadUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,20 @@ public class DownloadUtility
{
public static void downloadFile(Context context, String url, String fileName)
{
if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB_MR2)
{
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

// Download Directory
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);

// Media Scanner
request.allowScanningByMediaScanner();

// Download completed
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

// Start download
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
}
else
{
try
{
if(url!=null)
{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(intent);
}
}
catch(android.content.ActivityNotFoundException e)
{
// FAILURE
}
}
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

// Download Directory
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);

// Media Scanner
request.allowScanningByMediaScanner();

// Download completed
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

// Start download
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) {
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};
Expand All @@ -112,7 +112,7 @@ public static String getDataColumn(Context context, Uri uri, String selection, S
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}

Expand All @@ -121,7 +121,7 @@ public static boolean isExternalStorageDocument(Uri uri) {
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}

Expand All @@ -130,7 +130,7 @@ public static boolean isDownloadsDocument(Uri uri) {
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/webview/nodebb/utility/NetworkInf.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ public class NetworkInf {
// Checks if online
public static boolean isOnline(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected());
}

// WiFi or Data
public static int getType(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

if (networkInfo != null) {
Expand All @@ -28,6 +30,7 @@ public static int getType(Context context) {
// Returns human readable name
public static String getTypeName(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

if (networkInfo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
public class NetworkManager {
public static boolean isOnline(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected());
}


public static int getType(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

if (networkInfo != null) {
Expand All @@ -29,6 +31,7 @@ public static int getType(Context context) {

public static String getTypeName(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert connectivityManager != null;
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

if (networkInfo != null) {
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.1.2'
}
}

allprojects {
repositories {
jcenter()
google()
}
}

task wrapper(type: Wrapper) {
gradleVersion = '3.5'
gradleVersion = '4.7'
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

keystore.file=extras/keystore/WebApp.keystore
keystore.properties=extras/keystore/WebApp.properties
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_121
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_172
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://downloads.gradle.org/distributions/gradle-4.7-all.zip

0 comments on commit 722c909

Please sign in to comment.