Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Added the library
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-chernysh committed Mar 7, 2018
1 parent 1a8db2e commit c8fd4c7
Show file tree
Hide file tree
Showing 17 changed files with 1,219 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.mobile-dev-pro'

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
}
33 changes: 33 additions & 0 deletions library/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/cdv/Dev/Tools/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

#these classes should be available as public
-keep class com.mobiledevpro.remotelogcat.RemoteLog {
public <methods>;
}
-keep class com.mobiledevpro.remotelogcat.UserInfoModel {
public <methods>;
}
17 changes: 17 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.mobiledevpro.remotelogcat"
>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mobiledevpro.remotelogcat;

/**
* Mdel for app info
* <p>
* Created by Dmitriy V. Chernysh on 25.09.17.
* [email protected]
* <p>
* https://fb.me/mobiledevpro/
* <p>
* #MobileDevPro
*/

class AppInfoModel {
private String name;
private String version;
private int build;

/**
* Constructor for getting entry from DB
*/
AppInfoModel(String name, String version, int build) {
this.name = name;
this.version = version;
this.build = build;
}

String getName() {
return name;
}

String getVersion() {
return version;
}

int getBuild() {
return build;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.mobiledevpro.remotelogcat;

import android.os.AsyncTask;

/**
* Helper for accessing features in {@link AsyncTask}
* introduced after API level 4 in a backwards compatible fashion.
*
* This class has been removed from support library version 26+
* <p>
* Created by Dmitriy V. Chernysh on 07.03.18.
* <p>
* https://fb.com/mobiledevpro/
* https://github.com/dmitriy-chernysh
* #MobileDevPro
*/

class AsyncTaskCompat {
/**
* Executes the task with the specified parameters, allowing multiple tasks to run in parallel
* on a pool of threads managed by {@link AsyncTask}.
*
* @param task The {@link AsyncTask} to execute.
* @param params The parameters of the task.
* @return the instance of AsyncTask.
*/
static <Params, Progress, Result> AsyncTask<Params, Progress, Result> executeParallel(
AsyncTask<Params, Progress, Result> task, Params... params) {
if (task == null) {
throw new IllegalArgumentException("task can not be null");
}

// From API 11 onwards, we need to manually select the THREAD_POOL_EXECUTOR
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);

return task;
}
}
48 changes: 48 additions & 0 deletions library/src/main/java/com/mobiledevpro/remotelogcat/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.mobiledevpro.remotelogcat;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
* Class for storing constant values
* <p>
* Created by Dmitriy V. Chernysh on 23.09.17.
* [email protected]
* <p>
* https://fb.me/mobiledevpro/
* <p>
* #MobileDevPro
*/

class Constants {
static final int LOG_LEVEL_DEBUG = 1;
static final int LOG_LEVEL_ERROR = 2;
static final String LOG_TAG = "remote-logcat";

private static final String LOG_LEVEL_DEBUG_TXT = "debug";
private static final String LOG_LEVEL_ERROR_TXT = "error";

static String getLogLevelTxt(int logLevel) {
switch (logLevel) {
case LOG_LEVEL_DEBUG:
return LOG_LEVEL_DEBUG_TXT;
case LOG_LEVEL_ERROR:
return LOG_LEVEL_ERROR_TXT;
default:
return String.valueOf(logLevel);
}
}

/**
* Method for checking network connection
*
* @param context - application context
* @return true - device online
*/
static boolean isDeviceOnline(Context context) {
ConnectivityManager connMngr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = connMngr.getActiveNetworkInfo();
return (netInfo != null && netInfo.isConnected());
}
}
Loading

0 comments on commit c8fd4c7

Please sign in to comment.