Remove old project
This commit is contained in:
12
.babelrc
12
.babelrc
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
"babel-preset-react-native-stage-0/decorator-support"
|
||||
],
|
||||
"env": {
|
||||
"development": {
|
||||
"plugins": [
|
||||
"transform-react-jsx-source"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
24
.gitignore
vendored
24
.gitignore
vendored
@@ -1,24 +0,0 @@
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# expo
|
||||
.expo/
|
||||
.idea/
|
||||
build
|
||||
# dependencies
|
||||
/node_modules
|
||||
.gradle
|
||||
# misc
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
*.iml
|
||||
|
||||
|
||||
local.properties
|
||||
android/app/src/main/assets
|
||||
58
.travis.yml
58
.travis.yml
@@ -1,58 +0,0 @@
|
||||
language: android
|
||||
sudo: required
|
||||
jdk: oraclejdk8
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
before_cache:
|
||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.gradle/caches/"
|
||||
- "$HOME/.gradle/wrapper/"
|
||||
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-27.0.3
|
||||
- android-27
|
||||
- extra-google-m2repository
|
||||
- extra-android-m2repository
|
||||
licenses:
|
||||
- android-sdk-preview-license-.+
|
||||
- android-sdk-license-.+
|
||||
- google-gdk-license-.+
|
||||
|
||||
before_install:
|
||||
- yes | sdkmanager "platforms;android-27"
|
||||
- nvm install 8
|
||||
- node --version
|
||||
- openssl aes-256-cbc -K $encrypted_f6e0f94759d3_key -iv $encrypted_f6e0f94759d3_iv
|
||||
-in gotify-release-key.jks.enc -out gotify-release-key.jks -d
|
||||
- chmod +x android/gradlew
|
||||
- "android/gradlew dependencies || true"
|
||||
- npm install
|
||||
|
||||
script:
|
||||
- "(cd android &&./gradlew clean build -PdisablePreDex --stacktrace)"
|
||||
|
||||
before_deploy:
|
||||
- cp $TRAVIS_BUILD_DIR/gotify-release-key.jks $HOME
|
||||
- cd android/app/build/outputs/apk
|
||||
- jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $HOME/gotify-release-key.jks
|
||||
-storepass $STOREPASS -keypass $KEYPASS app-release-unsigned.apk gotify-release-key
|
||||
- jarsigner -verify app-release-unsigned.apk
|
||||
- "${ANDROID_HOME}/build-tools/27.0.3/zipalign -v 4 app-release-unsigned.apk Gotify.apk"
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
file: Gotify.apk
|
||||
api_key: $GH_TOKEN
|
||||
skip_cleanup: true
|
||||
on:
|
||||
repo: gotify/android
|
||||
tags: true
|
||||
jdk: oraclejdk8
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
16
App.js
16
App.js
@@ -1,16 +0,0 @@
|
||||
import AuthLoading from './src/AuthLoading'
|
||||
import Login from './src/Login'
|
||||
import { createSwitchNavigator } from 'react-navigation';
|
||||
import MainNavigation from "./src/MainNavigation";
|
||||
|
||||
export default createSwitchNavigator({
|
||||
MainNavigation: {
|
||||
screen: MainNavigation,
|
||||
},
|
||||
Login: {
|
||||
screen: Login,
|
||||
},
|
||||
AuthLoading: {
|
||||
screen: AuthLoading
|
||||
},
|
||||
}, {initialRouteName: 'AuthLoading'});
|
||||
@@ -1,8 +0,0 @@
|
||||
# Gotify Android [![Build Status][badge-travis]][travis]
|
||||
|
||||
## Setup Dev Environment
|
||||
Follow the instructions on [React-Native Getting Started][react-getstarted] for "Building Projects with Native Code".
|
||||
|
||||
[react-getstarted]: https://facebook.github.io/react-native/docs/getting-started.html
|
||||
[badge-travis]: https://travis-ci.org/gotify/android.svg?branch=master
|
||||
[travis]: https://travis-ci.org/gotify/android
|
||||
@@ -1,65 +0,0 @@
|
||||
# To learn about Buck see [Docs](https://buckbuild.com/).
|
||||
# To run your application with Buck:
|
||||
# - install Buck
|
||||
# - `npm start` - to start the packager
|
||||
# - `cd android`
|
||||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
||||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
||||
# - `buck install -r android/app` - compile, install and run application
|
||||
#
|
||||
|
||||
lib_deps = []
|
||||
|
||||
for jarfile in glob(['libs/*.jar']):
|
||||
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
|
||||
lib_deps.append(':' + name)
|
||||
prebuilt_jar(
|
||||
name = name,
|
||||
binary_jar = jarfile,
|
||||
)
|
||||
|
||||
for aarfile in glob(['libs/*.aar']):
|
||||
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
|
||||
lib_deps.append(':' + name)
|
||||
android_prebuilt_aar(
|
||||
name = name,
|
||||
aar = aarfile,
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "all-libs",
|
||||
exported_deps = lib_deps,
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "app-code",
|
||||
srcs = glob([
|
||||
"src/main/java/**/*.java",
|
||||
]),
|
||||
deps = [
|
||||
":all-libs",
|
||||
":build_config",
|
||||
":res",
|
||||
],
|
||||
)
|
||||
|
||||
android_build_config(
|
||||
name = "build_config",
|
||||
package = "com.github.gotify",
|
||||
)
|
||||
|
||||
android_resource(
|
||||
name = "res",
|
||||
package = "com.github.gotify",
|
||||
res = "src/main/res",
|
||||
)
|
||||
|
||||
android_binary(
|
||||
name = "app",
|
||||
keystore = "//android/keystores:debug",
|
||||
manifest = "src/main/AndroidManifest.xml",
|
||||
package_type = "debug",
|
||||
deps = [
|
||||
":app-code",
|
||||
],
|
||||
)
|
||||
@@ -1,164 +0,0 @@
|
||||
apply plugin: "com.android.application"
|
||||
|
||||
import com.android.build.OutputFile
|
||||
|
||||
/**
|
||||
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
|
||||
* and bundleReleaseJsAndAssets).
|
||||
* These basically call `react-native bundle` with the correct arguments during the Android build
|
||||
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
|
||||
* bundle directly from the development server. Below you can see all the possible configurations
|
||||
* and their defaults. If you decide to add a configuration block, make sure to add it before the
|
||||
* `apply from: "../../node_modules/react-native/react.gradle"` line.
|
||||
*
|
||||
* project.ext.react = [
|
||||
* // the name of the generated asset file containing your JS bundle
|
||||
* bundleAssetName: "index.android.bundle",
|
||||
*
|
||||
* // the entry file for bundle generation
|
||||
* entryFile: "index.android.js",
|
||||
*
|
||||
* // whether to bundle JS and assets in debug mode
|
||||
* bundleInDebug: false,
|
||||
*
|
||||
* // whether to bundle JS and assets in release mode
|
||||
* bundleInRelease: true,
|
||||
*
|
||||
* // whether to bundle JS and assets in another build variant (if configured).
|
||||
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
|
||||
* // The configuration property can be in the following formats
|
||||
* // 'bundleIn${productFlavor}${buildType}'
|
||||
* // 'bundleIn${buildType}'
|
||||
* // bundleInFreeDebug: true,
|
||||
* // bundleInPaidRelease: true,
|
||||
* // bundleInBeta: true,
|
||||
*
|
||||
* // whether to disable dev mode in custom build variants (by default only disabled in release)
|
||||
* // for example: to disable dev mode in the staging build type (if configured)
|
||||
* devDisabledInStaging: true,
|
||||
* // The configuration property can be in the following formats
|
||||
* // 'devDisabledIn${productFlavor}${buildType}'
|
||||
* // 'devDisabledIn${buildType}'
|
||||
*
|
||||
* // the root of your project, i.e. where "package.json" lives
|
||||
* root: "../../",
|
||||
*
|
||||
* // where to put the JS bundle asset in debug mode
|
||||
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
|
||||
*
|
||||
* // where to put the JS bundle asset in release mode
|
||||
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in debug mode
|
||||
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in release mode
|
||||
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
|
||||
*
|
||||
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
|
||||
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
|
||||
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
|
||||
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
|
||||
* // for example, you might want to remove it from here.
|
||||
* inputExcludes: ["android/**", "ios/**"],
|
||||
*
|
||||
* // override which node gets called and with what additional arguments
|
||||
* nodeExecutableAndArgs: ["node"],
|
||||
*
|
||||
* // supply additional arguments to the packager
|
||||
* extraPackagerArgs: []
|
||||
* ]
|
||||
*/
|
||||
|
||||
project.ext.react = [
|
||||
entryFile: "index.js",
|
||||
bundleInDebug: false,
|
||||
bundleInRelease: true,
|
||||
root: "../../"
|
||||
]
|
||||
|
||||
apply from: "../../node_modules/react-native/react.gradle"
|
||||
|
||||
project.ext.vectoricons = [
|
||||
iconFontNames: [ 'Ionicons.ttf' ] // Name of the font files you want to copy
|
||||
]
|
||||
|
||||
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
|
||||
/**
|
||||
* Set this to true to create two separate APKs instead of one:
|
||||
* - An APK that only works on ARM devices
|
||||
* - An APK that only works on x86 devices
|
||||
* The advantage is the size of the APK is reduced by about 4MB.
|
||||
* Upload all the APKs to the Play Store and people will download
|
||||
* the correct one based on the CPU architecture of their device.
|
||||
*/
|
||||
def enableSeparateBuildPerCPUArchitecture = false
|
||||
|
||||
/**
|
||||
* Run Proguard to shrink the Java bytecode in release builds.
|
||||
*/
|
||||
def enableProguardInReleaseBuilds = false
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.github.gotify"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 27
|
||||
versionCode 2
|
||||
versionName "1.0.1"
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
}
|
||||
splits {
|
||||
abi {
|
||||
reset()
|
||||
enable enableSeparateBuildPerCPUArchitecture
|
||||
universalApk false // If true, also generate a universal APK
|
||||
include "armeabi-v7a", "x86"
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled enableProguardInReleaseBuilds
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
// applicationVariants are e.g. debug, release
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
// For each separate APK per architecture, set a unique version code as described here:
|
||||
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
|
||||
def versionCodes = ["armeabi-v7a":1, "x86":2]
|
||||
def abi = output.getFilter(OutputFile.ABI)
|
||||
if (abi != null) { // null for the universal-debug, universal-release variants
|
||||
output.versionCodeOverride =
|
||||
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':react-native-shared-preferences')
|
||||
compile project(':react-native-device-info')
|
||||
compile project(':react-native-vector-icons')
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:27.1.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.9.1'
|
||||
compile 'com.google.code.gson:gson:2.8.4'
|
||||
compile 'com.facebook.react:react-native:0.55.3'
|
||||
// From node_modules
|
||||
}
|
||||
|
||||
// Run this once to be able to run the application with BUCK
|
||||
// puts all compile dependencies into folder libs for BUCK to use
|
||||
task copyDownloadableDepsToLibs(type: Copy) {
|
||||
from configurations.compile
|
||||
into 'libs'
|
||||
}
|
||||
70
android/app/proguard-rules.pro
vendored
70
android/app/proguard-rules.pro
vendored
@@ -1,70 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /usr/local/Cellar/android-sdk/24.3.3/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 *;
|
||||
#}
|
||||
|
||||
# Disabling obfuscation is useful if you collect stack traces from production crashes
|
||||
# (unless you are using a system that supports de-obfuscate the stack traces).
|
||||
-dontobfuscate
|
||||
|
||||
# React Native
|
||||
|
||||
# Keep our interfaces so they can be used by other ProGuard rules.
|
||||
# See http://sourceforge.net/p/proguard/bugs/466/
|
||||
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
|
||||
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
|
||||
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
|
||||
|
||||
# Do not strip any method/class that is annotated with @DoNotStrip
|
||||
-keep @com.facebook.proguard.annotations.DoNotStrip class *
|
||||
-keep @com.facebook.common.internal.DoNotStrip class *
|
||||
-keepclassmembers class * {
|
||||
@com.facebook.proguard.annotations.DoNotStrip *;
|
||||
@com.facebook.common.internal.DoNotStrip *;
|
||||
}
|
||||
|
||||
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
|
||||
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
|
||||
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
|
||||
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
|
||||
|
||||
-dontwarn com.facebook.react.**
|
||||
|
||||
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
|
||||
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
|
||||
-dontwarn android.text.StaticLayout
|
||||
|
||||
# okhttp
|
||||
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-dontwarn okhttp3.**
|
||||
|
||||
# okio
|
||||
|
||||
-keep class sun.misc.Unsafe { *; }
|
||||
-dontwarn java.nio.file.*
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
||||
-dontwarn okio.**
|
||||
@@ -1,31 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.github.gotify">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
|
||||
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE"/>
|
||||
|
||||
<application
|
||||
android:name=".MainApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="false"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
|
||||
|
||||
<service android:name=".PushService"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GotifyPackage implements ReactPackage {
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Arrays.<NativeModule>asList(new LogManager(reactContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Log {
|
||||
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ENGLISH);
|
||||
private static final List<String> LOG = Collections.synchronizedList(new ArrayList<String>());
|
||||
private static final String TAG = "gotify";
|
||||
|
||||
public static void i(String message) {
|
||||
i(message, null);
|
||||
}
|
||||
|
||||
public static List<String> get() {
|
||||
return LOG;
|
||||
}
|
||||
|
||||
public static void i(String message, Throwable throwable) {
|
||||
log("INFO", message, throwable);
|
||||
android.util.Log.i(TAG, message, throwable);
|
||||
}
|
||||
|
||||
public static void e(String message) {
|
||||
e(message, null);
|
||||
}
|
||||
|
||||
public static void e(String message, Throwable throwable) {
|
||||
log("ERROR", message, throwable);
|
||||
android.util.Log.e("gotify", message, throwable);
|
||||
}
|
||||
|
||||
private static void log(String type, String message, Throwable exception) {
|
||||
if (exception == null) {
|
||||
LOG.add(String.format("%s: %s - %s", type, FORMAT.format(new Date()), message));
|
||||
} else {
|
||||
LOG.add(String.format("%s: %s - %s%s%s", type, FORMAT.format(new Date()), message, "\n", android.util.Log.getStackTraceString(exception)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
|
||||
public class LogManager extends ReactContextBaseJavaModule {
|
||||
LogManager(final ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LogManager";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void clear(Callback callback) {
|
||||
Log.get().clear();
|
||||
callback.invoke();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void getLog(Callback callback) {
|
||||
StringBuilder log = new StringBuilder();
|
||||
for (String line : Log.get()) {
|
||||
log.append(line).append("\n");
|
||||
}
|
||||
callback.invoke(log.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.facebook.react.ReactActivity;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
startService(new Intent(this, PushService.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the main component registered from JavaScript.
|
||||
* This is used to schedule rendering of the component.
|
||||
*/
|
||||
@Override
|
||||
protected String getMainComponentName() {
|
||||
return "gotify";
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
|
||||
import in.sriraman.sharedpreferences.RNSharedPreferencesReactPackage;
|
||||
import com.learnium.RNDeviceInfo.RNDeviceInfo;
|
||||
import com.oblador.vectoricons.VectorIconsPackage;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||
@Override
|
||||
public boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new RNSharedPreferencesReactPackage(),
|
||||
new RNDeviceInfo(),
|
||||
new GotifyPackage(),
|
||||
new VectorIconsPackage()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getJSMainModuleName() {
|
||||
return "index";
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ReactNativeHost getReactNativeHost() {
|
||||
return mReactNativeHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SoLoader.init(this, /* native exopackage */ false);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* Creates a Notification channel for android oreo.
|
||||
*/
|
||||
public class OreoNotificationSupport {
|
||||
public static final String CHANNEL_ID = "gotify";
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
public static void createChannel(NotificationManager notificationManager) {
|
||||
try {
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Gotify", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
} catch (Exception e) {
|
||||
Log.e("Could not create channel", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
package com.github.gotify;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.github.gotify.model.Message;
|
||||
import com.github.gotify.model.PagedMessages;
|
||||
import com.github.gotify.model.Paging;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
|
||||
public class PushService extends Service {
|
||||
private static final String TOKEN = "@global:token";
|
||||
private static final String URL = "@global:url";
|
||||
private static final List<String> UPDATE_ON_KEYS = Arrays.asList(TOKEN, URL);
|
||||
private static final int NO_MESSAGE = -1;
|
||||
|
||||
private final Object socketLock = new Object();
|
||||
private final OkHttpClient client = new OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).pingInterval(1, TimeUnit.MINUTES).connectTimeout(10, TimeUnit.SECONDS).build();
|
||||
private final AtomicLong lastError = new AtomicLong(0);
|
||||
private final AtomicInteger lastReceivedMessage = new AtomicInteger(NO_MESSAGE);
|
||||
private Handler handler = null;
|
||||
private WebSocket socket = null;
|
||||
private Gson gson = null;
|
||||
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (!UPDATE_ON_KEYS.contains(key)) {
|
||||
return;
|
||||
}
|
||||
synchronized (socketLock) {
|
||||
if (socket != null) {
|
||||
Log.i("Closing WebSocket (preference change)");
|
||||
socket.close(1000, "client logout");
|
||||
socket = null;
|
||||
}
|
||||
}
|
||||
new Thread(pushService).start();
|
||||
}
|
||||
};
|
||||
|
||||
private final Runnable pushService = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
start(true);
|
||||
} catch (Exception e) {
|
||||
Log.e("Could not start service", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final Runnable pushServiceAfterError = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
start(false);
|
||||
}
|
||||
};
|
||||
|
||||
private final Runnable pushServiceAfterErrorInNewThread = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new Thread(pushServiceAfterError).start();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
return START_REDELIVER_INTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i("Creating WebSocket-Service");
|
||||
|
||||
gson = new Gson();
|
||||
handler = new Handler();
|
||||
new Thread(pushService).start();
|
||||
appPreferences().registerOnSharedPreferenceChangeListener(listener);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
OreoNotificationSupport.createChannel((NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE));
|
||||
}
|
||||
}
|
||||
|
||||
private void foregroundNotification(String message) {
|
||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this, "GOTIFY_CHANNEL")
|
||||
.setSmallIcon(R.mipmap.ic_launcher)
|
||||
.setContentTitle("Gotify")
|
||||
.setChannelId(OreoNotificationSupport.CHANNEL_ID)
|
||||
.setOngoing(true)
|
||||
.setPriority(Notification.PRIORITY_MIN)
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
|
||||
.setContentText(message)
|
||||
.setContentIntent(pendingIntent).build();
|
||||
|
||||
startForeground(1337, notification);
|
||||
}
|
||||
|
||||
private void ensureAllMessagesArePublished(boolean firstStart, String url, String token) {
|
||||
PagedMessages message = getMessages(url, token, 1, null);
|
||||
List<Message> messages = message.getMessages();
|
||||
|
||||
if (firstStart) {
|
||||
if (messages.isEmpty()) {
|
||||
lastReceivedMessage.set(NO_MESSAGE);
|
||||
Log.i("Last available message id: no stored messages on server");
|
||||
} else {
|
||||
lastReceivedMessage.set(messages.get(0).getId());
|
||||
Log.i("Last available message id: " + lastReceivedMessage.get());
|
||||
}
|
||||
} else {
|
||||
if (!messages.isEmpty() && message.getMessages().get(0).getId() > lastReceivedMessage.get()) {
|
||||
Log.i("Missed messages while being disconnected from the WebSocket, publishing them now.");
|
||||
if (lastReceivedMessage.get() == NO_MESSAGE) {
|
||||
notifyTill(url, token, 0);
|
||||
} else {
|
||||
notifyTill(url, token, lastReceivedMessage.get());
|
||||
}
|
||||
} else {
|
||||
Log.i("Missed no messages while being disconnected from the WebSocket.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyTill(String url, String token, int till) {
|
||||
Integer since = null;
|
||||
while (true) {
|
||||
PagedMessages messages = getMessages(url, token, 10, since);
|
||||
for (Message message : messages.getMessages()) {
|
||||
if (message.getId() > till) {
|
||||
notify(message);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
since = messages.getPaging().getSince();
|
||||
if (since <= 0) {
|
||||
// no messages left
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PagedMessages getMessages(String url, String token, int limit, @Nullable Integer since) {
|
||||
HttpUrl.Builder builder = HttpUrl.parse(url).newBuilder()
|
||||
.addPathSegment("message")
|
||||
.addQueryParameter("token", token)
|
||||
.addQueryParameter("limit", String.valueOf(limit));
|
||||
if (since != null) {
|
||||
builder.addQueryParameter("since", String.valueOf(since));
|
||||
}
|
||||
HttpUrl httpUrl = builder.build();
|
||||
final Request request = new Request.Builder().url(httpUrl).get().build();
|
||||
try {
|
||||
Response execute = client.newCall(request).execute();
|
||||
if (execute.isSuccessful()) {
|
||||
return gson.fromJson(execute.body().string(), PagedMessages.class);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e("Could not request messages", e);
|
||||
}
|
||||
PagedMessages pagedMessages = new PagedMessages();
|
||||
pagedMessages.setMessages(new ArrayList<Message>());
|
||||
Paging paging = new Paging();
|
||||
paging.setSince(0);
|
||||
pagedMessages.setPaging(paging);
|
||||
return pagedMessages;
|
||||
}
|
||||
|
||||
private void start(boolean firstStart) {
|
||||
String url = appPreferences().getString(URL, null);
|
||||
String token = appPreferences().getString(TOKEN, null);
|
||||
|
||||
if (url == null || token == null) {
|
||||
Log.i("url or token not configured; login required");
|
||||
foregroundNotification("login required");
|
||||
return;
|
||||
}
|
||||
|
||||
ensureAllMessagesArePublished(firstStart, url, token);
|
||||
|
||||
HttpUrl httpUrl = HttpUrl.parse(url).newBuilder().addPathSegment("stream").addQueryParameter("token", token).build();
|
||||
|
||||
final Request request = new Request.Builder().url(httpUrl).get().build();
|
||||
|
||||
foregroundNotification("Initializing WebSocket");
|
||||
Log.i("Initializing WebSocket");
|
||||
|
||||
final WebSocket newSocket = client.newWebSocket(request, new WebSocketListener() {
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket webSocket, Response response) {
|
||||
Log.i("Initialized WebSocket");
|
||||
foregroundNotification("Listening to " + request.url().host());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
Message message = gson.fromJson(text, Message.class);
|
||||
PushService.this.notify(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
Log.e("WebSocket closed " + reason);
|
||||
foregroundNotification("WebSocket closed, re-login required");
|
||||
showNotification(-4, "WebSocket closed", "The WebSocket connection closed, this normally means the token(login) was invalidated. A re-login is required");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, @Nullable Response response) {
|
||||
foregroundNotification("Error: " + t.getMessage());
|
||||
Log.e("WebSocket failure", t);
|
||||
if (response != null && response.code() >= 400 && response.code() <= 499) {
|
||||
showNotification(-2, "WebSocket Bad-Request", "Could not connect: " + response.message());
|
||||
appPreferences().edit().remove(TOKEN).apply();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean recentErrored = recentErrored();
|
||||
lastError.set(System.currentTimeMillis());
|
||||
|
||||
if (recentErrored) {
|
||||
Log.i("Waiting one minute to reconnect to the WebSocket (because WebSocket failed recently)");
|
||||
foregroundNotification("WebSocket connected failed, trying to reconnect in one minute.");
|
||||
handler.postDelayed(pushServiceAfterErrorInNewThread, TimeUnit.MINUTES.toMillis(1));
|
||||
} else {
|
||||
Log.i("Trying to reconnect to WebSocket");
|
||||
start(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
synchronized (socketLock) {
|
||||
socket = newSocket;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recentErrored() {
|
||||
return System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(1) < lastError.get();
|
||||
}
|
||||
|
||||
private void showNotification(int id, String title, String message) {
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
NotificationCompat.Builder b = new NotificationCompat.Builder(this, "GOTIFY_CHANNEL");
|
||||
|
||||
b.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(android.R.mipmap.sym_def_app_icon)
|
||||
.setTicker("Gotify - " + title)
|
||||
.setContentTitle(title)
|
||||
.setContentText(message)
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
|
||||
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
|
||||
.setChannelId(OreoNotificationSupport.CHANNEL_ID)
|
||||
.setContentIntent(contentIntent);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(id, b.build());
|
||||
}
|
||||
|
||||
private SharedPreferences appPreferences() {
|
||||
// https://github.com/sriraman/react-native-shared-preferences/issues/12 for why wit_player_shared_preferences
|
||||
return this.getSharedPreferences("wit_player_shared_preferences", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
private void notify(Message message) {
|
||||
if (lastReceivedMessage.get() < message.getId()) {
|
||||
lastReceivedMessage.set(message.getId());
|
||||
}
|
||||
|
||||
showNotification(message.getId(), message.getTitle(), message.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.i("Destroying WebSocket-Service");
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.github.gotify.model;
|
||||
|
||||
public class Message {
|
||||
private Integer id;
|
||||
private String title;
|
||||
private String message;
|
||||
private int priority;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.github.gotify.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PagedMessages {
|
||||
private Paging paging;
|
||||
private List<Message> messages;
|
||||
|
||||
public List<Message> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(List<Message> messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public Paging getPaging() {
|
||||
return paging;
|
||||
}
|
||||
|
||||
public void setPaging(Paging paging) {
|
||||
this.paging = paging;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.github.gotify.model;
|
||||
|
||||
public class Paging {
|
||||
private int since;
|
||||
|
||||
public int getSince() {
|
||||
return since;
|
||||
}
|
||||
|
||||
public void setSince(int since) {
|
||||
this.since = since;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
@@ -1,3 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">Gotify</string>
|
||||
</resources>
|
||||
@@ -1,8 +0,0 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,49 +0,0 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url 'https://maven.google.com' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url 'https://maven.google.com' }
|
||||
jcenter()
|
||||
maven {
|
||||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
||||
url "$rootDir/../node_modules/react-native/android"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ext {
|
||||
compileSdkVersion = 27
|
||||
buildToolsVersion = '27.0.3'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
afterEvaluate {
|
||||
android {
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# 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.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
android.useDeprecatedNdk=true
|
||||
android.enableAapt2=false
|
||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
164
android/gradlew
vendored
164
android/gradlew
vendored
@@ -1,164 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
android/gradlew.bat
vendored
90
android/gradlew.bat
vendored
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,8 +0,0 @@
|
||||
keystore(
|
||||
name = "debug",
|
||||
properties = "debug.keystore.properties",
|
||||
store = "debug.keystore",
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
key.store=debug.keystore
|
||||
key.alias=androiddebugkey
|
||||
key.store.password=android
|
||||
key.alias.password=android
|
||||
@@ -1,9 +0,0 @@
|
||||
rootProject.name = 'gotify'
|
||||
include ':react-native-shared-preferences'
|
||||
project(':react-native-shared-preferences').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-shared-preferences/android')
|
||||
include ':react-native-device-info'
|
||||
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
|
||||
include ':react-native-vector-icons'
|
||||
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
|
||||
|
||||
include ':app'
|
||||
Binary file not shown.
6
index.js
6
index.js
@@ -1,6 +0,0 @@
|
||||
import { AppRegistry, YellowBox } from 'react-native';
|
||||
import App from './App';
|
||||
|
||||
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
|
||||
|
||||
AppRegistry.registerComponent('gotify', () => App);
|
||||
6734
package-lock.json
generated
6734
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "gotify",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"babel-preset-react-native-stage-0": "^1.0.1",
|
||||
"react-test-renderer": "16.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-native start",
|
||||
"android": "react-native run-android",
|
||||
"ios": "react-native run-ios",
|
||||
"test": "jest",
|
||||
"dev": "adb shell input keyevent 82",
|
||||
"bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"react": "16.3.1",
|
||||
"react-native": "~0.55.2",
|
||||
"react-native-device-info": "^0.21.5",
|
||||
"react-native-push-notification": "^3.0.2",
|
||||
"react-native-shared-preferences": "^1.0.0",
|
||||
"react-native-vector-icons": "^4.6.0",
|
||||
"react-navigation": "^2.0.1"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import React from 'react';
|
||||
import {ActivityIndicator, StatusBar, View} from 'react-native';
|
||||
import SharedPreferences from 'react-native-shared-preferences';
|
||||
|
||||
export default class AuthLoadingScreen extends React.Component {
|
||||
componentDidMount() {
|
||||
SharedPreferences.getItem('@global:token', (token) => {
|
||||
this.props.navigation.navigate(token ? 'MainNavigation' : 'Login');
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<ActivityIndicator/>
|
||||
<StatusBar barStyle="default"/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
57
src/Home.js
57
src/Home.js
@@ -1,57 +0,0 @@
|
||||
import React from 'react';
|
||||
import {Alert, Button, Image, ScrollView, Text} from "react-native";
|
||||
import SharedPreferences from 'react-native-shared-preferences';
|
||||
import Icon from 'react-native-vector-icons/Ionicons'
|
||||
|
||||
export default class Messages extends React.Component {
|
||||
static navigationOptions = ({navigation}) => {
|
||||
return {
|
||||
headerTitle: (
|
||||
<React.Fragment>
|
||||
<Image source={require('../logo.png')} style={{width: 55, height: 55}}/>
|
||||
<Text style={{fontSize: 25, marginLeft: 10}}>Gotify</Text>
|
||||
</React.Fragment>
|
||||
),
|
||||
headerRight: (
|
||||
<Icon.Button
|
||||
name="md-exit"
|
||||
onPress={() => {
|
||||
Alert.alert(
|
||||
'Logout Confirmation',
|
||||
'Do you really want to log out?',
|
||||
[
|
||||
{
|
||||
text: 'Cancel', onPress: () => {
|
||||
}, style: 'cancel'
|
||||
},
|
||||
{
|
||||
text: 'OK', onPress: () => {
|
||||
SharedPreferences.removeItem("@global:token");
|
||||
navigation.navigate('AuthLoading');
|
||||
}
|
||||
},
|
||||
],
|
||||
{cancelable: false}
|
||||
)
|
||||
}}
|
||||
color="#000"
|
||||
size={30}
|
||||
backgroundColor="#fff"/>
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ScrollView contentContainerStyle={{
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
}}>
|
||||
<Text style={{fontSize: 27, textAlign: 'center', marginBottom: 20}}>See notifications for status</Text>
|
||||
<Button onPress={() => this.props.navigation.navigate('Logs')} title="View Logs"/>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
}
|
||||
166
src/Login.js
166
src/Login.js
@@ -1,166 +0,0 @@
|
||||
import React from 'react';
|
||||
import {Button, Text, TextInput, ToastAndroid, View} from 'react-native';
|
||||
import SharedPreferences from 'react-native-shared-preferences';
|
||||
import Icon from 'react-native-vector-icons/Ionicons'
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import * as axios from "axios";
|
||||
|
||||
const urlRegex = new RegExp("^(http|https)://", "i");
|
||||
const defaultClientName = DeviceInfo.getManufacturer() + ' ' + DeviceInfo.getDeviceId();
|
||||
export default class Login extends React.Component {
|
||||
state = {
|
||||
tryConnect: null,
|
||||
url: null,
|
||||
error: null,
|
||||
version: null,
|
||||
name: '',
|
||||
pass: '',
|
||||
loggedIn: null,
|
||||
client: defaultClientName
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
SharedPreferences.getItem("@global:url", (url) => {
|
||||
if (url) {
|
||||
this.setState({...this.state, url: url}, this.checkUrl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleChange = (name, merge) => {
|
||||
return (val) => {
|
||||
const old = {...this.state, ...(merge || {})};
|
||||
old[name] = val;
|
||||
this.setState(old);
|
||||
}
|
||||
};
|
||||
|
||||
reachedButNot = () => {
|
||||
this.setState({...this.state, tryConnect: false, error: 'server exists, but it is not a valid gotify instance'})
|
||||
};
|
||||
|
||||
notReachable = () => {
|
||||
this.setState({...this.state, tryConnect: false, error: 'could not reach ' + this.state.url})
|
||||
};
|
||||
|
||||
createClient = () => {
|
||||
const {client, url, pass, name} = this.state;
|
||||
axios.post(url + 'client', {name: client}, {auth: {username: name, password: pass}}).then((resp) => {
|
||||
SharedPreferences.setItem('@global:token', resp.data.token);
|
||||
ToastAndroid.show("Created client " + client + " for user " + name, ToastAndroid.SHORT);
|
||||
this.props.navigation.navigate('AuthLoading')
|
||||
}).catch(() => {
|
||||
ToastAndroid.show("Could not create client", ToastAndroid.SHORT);
|
||||
})
|
||||
};
|
||||
|
||||
version(url, errorCallback, reachedButNoApi) {
|
||||
axios.get(url + 'version').then((resp) => {
|
||||
if (resp && resp.status === 200) {
|
||||
const {data} = resp;
|
||||
if (data
|
||||
&& typeof data === 'object'
|
||||
&& 'version' in data
|
||||
&& 'buildDate' in data
|
||||
&& 'commit' in data
|
||||
) {
|
||||
SharedPreferences.setItem('@global:url', url);
|
||||
this.setState({...this.state, url: url, tryConnect: true, error: null, version: data});
|
||||
return;
|
||||
}
|
||||
}
|
||||
(reachedButNoApi ? reachedButNoApi : errorCallback)();
|
||||
}).catch(errorCallback);
|
||||
}
|
||||
|
||||
checkUrl = () => {
|
||||
let {url} = this.state;
|
||||
if (!url.endsWith('/')) {
|
||||
url += '/';
|
||||
}
|
||||
|
||||
if (urlRegex.test(url)) {
|
||||
if (url.match(/^http:\/\//i)) {
|
||||
this.version(url.replace(/^http:\/\//i, "https://"), () => {
|
||||
this.version(url, this.notReachable, this.reachedButNot)
|
||||
});
|
||||
} else {
|
||||
this.version(url, this.notReachable, this.reachedButNot)
|
||||
}
|
||||
} else {
|
||||
this.setState({...this.state, error: 'url must either start with http:// or https://'})
|
||||
}
|
||||
};
|
||||
|
||||
checkUser = () => {
|
||||
const {url, pass, name} = this.state;
|
||||
axios.get(url + 'current/user', {auth: {username: name, password: pass}}).then((resp) => {
|
||||
this.setState({...this.state, loggedIn: true})
|
||||
}).catch((resp) => {
|
||||
this.setState({...this.state, loggedIn: false})
|
||||
})
|
||||
};
|
||||
|
||||
render() {
|
||||
const {tryConnect, error, version, url, client, loggedIn} = this.state;
|
||||
|
||||
return (
|
||||
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
|
||||
<View style={{width: "80%"}}>
|
||||
<Text style={{fontSize: 20, textAlign: 'center'}}>Gotify</Text>
|
||||
<View style={{alignItems: 'center', flexDirection: 'row'}}>
|
||||
<TextInput
|
||||
value={url}
|
||||
placeholder="URL f.ex https://push.domain.tld"
|
||||
style={{alignSelf: 'stretch', flex: 1}}
|
||||
keyboardType="url"
|
||||
onChangeText={this.handleChange('url', {tryConnect: false, version: null})}/>
|
||||
<Icon.Button name="md-send" style={{alignSelf: 'flex-end'}} iconStyle={{marginRight: 0}}
|
||||
onPress={this.checkUrl}/>
|
||||
</View>
|
||||
{error && <Text style={{textAlign: 'center', color: 'red'}}>{error}</Text>}
|
||||
{version && <Text style={{textAlign: 'center', color: 'green'}}>Gotify v{version.version}</Text>}
|
||||
{tryConnect === true && (
|
||||
<React.Fragment>
|
||||
<TextInput placeholder="Username"
|
||||
onChangeText={this.handleChange('name', {loggedIn: null})}
|
||||
style={{width: '100%'}}/>
|
||||
<View style={{alignItems: 'center', flexDirection: 'row'}}>
|
||||
|
||||
<TextInput placeholder="Password"
|
||||
secureTextEntry={true}
|
||||
onChangeText={this.handleChange('pass', {loggedIn: null})}
|
||||
style={{alignSelf: 'stretch', flex: 1}}
|
||||
/>
|
||||
<Icon.Button name="md-send" style={{alignSelf: 'flex-end'}} iconStyle={{marginRight: 0}}
|
||||
onPress={this.checkUser}/>
|
||||
</View>
|
||||
{loggedIn === true && (
|
||||
<React.Fragment>
|
||||
|
||||
<Text style={{textAlign: 'center', color: 'green'}}>
|
||||
valid user
|
||||
</Text>
|
||||
|
||||
<TextInput placeholder="Client Name"
|
||||
value={client}
|
||||
onChangeText={this.handleChange('client')}
|
||||
style={{width: '100%'}}/>
|
||||
<Button title="Create Client" onPress={this.createClient}/>
|
||||
|
||||
</React.Fragment>
|
||||
)}
|
||||
{loggedIn === false && (
|
||||
<Text style={{textAlign: 'center', color: 'red'}}>
|
||||
wrong name / pass
|
||||
</Text>
|
||||
)}
|
||||
|
||||
</React.Fragment>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
51
src/Logs.js
51
src/Logs.js
@@ -1,51 +0,0 @@
|
||||
import React from "react";
|
||||
import {ScrollView, Text, ToastAndroid} from "react-native";
|
||||
import LogManager from "./native/LogManager";
|
||||
import Icon from 'react-native-vector-icons/Ionicons'
|
||||
|
||||
export default class Logs extends React.Component {
|
||||
static navigationOptions = {
|
||||
headerTitle: <Text style={{fontSize: 25, marginLeft: 10}}>Logs</Text>,
|
||||
headerRight: (
|
||||
<Icon.Button
|
||||
name="md-trash"
|
||||
onPress={() => {
|
||||
ToastAndroid.show('Clearing logs...', ToastAndroid.SHORT);
|
||||
LogManager.clear(() => ToastAndroid.show('Cleared logs.', ToastAndroid.SHORT));
|
||||
}}
|
||||
color="#000"
|
||||
size={30}
|
||||
backgroundColor="#fff"/>
|
||||
),
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.id = 0;
|
||||
this.state = {logs: ''}
|
||||
}
|
||||
|
||||
refresh = () => {
|
||||
LogManager.getLog((data) => {
|
||||
this.setState({logs: data})
|
||||
});
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.refresh();
|
||||
this.id = window.setInterval(this.refresh, 1000);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.id);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {logs} = this.state;
|
||||
return (
|
||||
<ScrollView contentContainerStyle={{padding: 5}}>
|
||||
<Text style={{fontFamily: 'monospace', fontSize: 10}}>{logs}</Text>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import Home from './Home'
|
||||
import {createStackNavigator} from 'react-navigation';
|
||||
import Logs from "./Logs";
|
||||
|
||||
export default createStackNavigator({
|
||||
Home: {
|
||||
screen: Home,
|
||||
},
|
||||
Logs: {
|
||||
screen: Logs
|
||||
}
|
||||
}, {initialRouteName: 'Home'});
|
||||
@@ -1,3 +0,0 @@
|
||||
import {NativeModules} from 'react-native';
|
||||
|
||||
export default NativeModules.LogManager;
|
||||
Reference in New Issue
Block a user