|
@ -0,0 +1,7 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: gradle
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
open-pull-requests-limit: 10
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- run: ./gradlew build --stacktrace
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: build
|
||||||
|
path: app/build/outputs/apk/debug/app-debug.apk
|
||||||
|
- if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
cd app/build/outputs/apk/release
|
||||||
|
echo $RELEASE_KEY | base64 -d > release-key.jks
|
||||||
|
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore release-key.jks -storepass $STOREPASS -keypass $KEYPASS app-release-unsigned.apk nextpush
|
||||||
|
jarsigner -verify app-release-unsigned.apk
|
||||||
|
sudo apt-get install zipalign -y
|
||||||
|
zipalign -v 4 app-release-unsigned.apk nextpush.apk
|
||||||
|
env:
|
||||||
|
RELEASE_KEY: ${{ secrets.RELEASE_KEY }}
|
||||||
|
KEYPASS: ${{ secrets.KEYPASS }}
|
||||||
|
STOREPASS: ${{ secrets.STOREPASS }}
|
||||||
|
- if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: app/build/outputs/apk/release/nextpush.apk
|
||||||
|
tag: ${{ github.ref }}
|
||||||
|
overwrite: true
|
|
@ -0,0 +1,15 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
|
@ -0,0 +1 @@
|
||||||
|
/build
|
|
@ -0,0 +1,68 @@
|
||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
id 'kotlin-android'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 30
|
||||||
|
buildToolsVersion "30.0.3"
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
force 'androidx.core:core-ktx:1.6.0'
|
||||||
|
force 'androidx.core:core:1.6.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "org.unifiedpush.distributor.nextpush"
|
||||||
|
minSdkVersion 24
|
||||||
|
targetSdkVersion 30
|
||||||
|
versionCode 1
|
||||||
|
versionName "0.0.1"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
resValue "string", "app_name", "NextPush"
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
debug {
|
||||||
|
resValue "string", "app_name", "NextPush-dbg"
|
||||||
|
applicationIdSuffix ".debug"
|
||||||
|
debuggable true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude("META-INF/*")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
implementation 'androidx.core:core-ktx:1.6.0'
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||||
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||||
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
||||||
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
||||||
|
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.1"))
|
||||||
|
implementation("com.squareup.okhttp3:okhttp")
|
||||||
|
implementation("com.squareup.okhttp3:logging-interceptor")
|
||||||
|
implementation("com.squareup.okhttp3:okhttp-sse")
|
||||||
|
implementation 'com.github.nextcloud:Android-SingleSignOn:0.6.0'
|
||||||
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
|
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||||
|
implementation "com.squareup.retrofit2:adapter-rxjava2:2.9.0"
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# 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
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.unifiedpush.distributor.nextpush" >
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.NextPush"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
|
<activity
|
||||||
|
android:name=".activities.SettingsActivity"
|
||||||
|
android:label="@string/action_settings"
|
||||||
|
android:parentActivityName=".activities.MainActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.MainActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.NextPush.NoActionBar" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".services.StartService"
|
||||||
|
android:enabled="true" />
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".receivers.StartReceiver"
|
||||||
|
android:enabled="true" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
<receiver
|
||||||
|
android:name=".receivers.RegisterBroadcastReceiver"
|
||||||
|
android:enabled="true" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="org.unifiedpush.android.distributor.REGISTER" />
|
||||||
|
<action android:name="org.unifiedpush.android.distributor.UNREGISTER" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,61 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.account
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import com.nextcloud.android.sso.AccountImporter
|
||||||
|
import com.nextcloud.android.sso.exceptions.AndroidGetAccountsPermissionNotGranted
|
||||||
|
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException
|
||||||
|
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotInstalledException
|
||||||
|
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException
|
||||||
|
import com.nextcloud.android.sso.helper.SingleAccountHelper
|
||||||
|
import com.nextcloud.android.sso.model.SingleSignOnAccount
|
||||||
|
import com.nextcloud.android.sso.ui.UiExceptionManager
|
||||||
|
|
||||||
|
private const val TAG = "AccountUtils"
|
||||||
|
|
||||||
|
const val PREF_NAME = "NextPush"
|
||||||
|
const val PREF_DEVICE_ID = "deviceId"
|
||||||
|
|
||||||
|
lateinit var ssoAccount: SingleSignOnAccount
|
||||||
|
|
||||||
|
fun isConnected(context: Context) : Boolean {
|
||||||
|
try {
|
||||||
|
ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(context)
|
||||||
|
} catch (e: NextcloudFilesAppAccountNotFoundException) {
|
||||||
|
UiExceptionManager.showDialogForException(context, e)
|
||||||
|
} catch (e: NoCurrentAccountSelectedException) {
|
||||||
|
Log.d(TAG,"Device is not connected")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun connect(activity: Activity) {
|
||||||
|
try {
|
||||||
|
AccountImporter.pickNewAccount(activity)
|
||||||
|
} catch (e: NextcloudFilesAppNotInstalledException) {
|
||||||
|
UiExceptionManager.showDialogForException(activity, e)
|
||||||
|
} catch (e: AndroidGetAccountsPermissionNotGranted) {
|
||||||
|
UiExceptionManager.showDialogForException(activity, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveDeviceId(context: Context, deviceId: String) {
|
||||||
|
context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||||
|
.edit()
|
||||||
|
.putString(PREF_DEVICE_ID, deviceId)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDeviceId(context: Context) : String? {
|
||||||
|
return context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||||
|
.getString(PREF_DEVICE_ID,null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeDeviceId(context: Context) {
|
||||||
|
context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||||
|
.edit()
|
||||||
|
.remove(PREF_DEVICE_ID)
|
||||||
|
.commit()
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.activities
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.*
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.nextcloud.android.sso.AccountImporter
|
||||||
|
import com.nextcloud.android.sso.ui.UiExceptionManager
|
||||||
|
import org.unifiedpush.distributor.nextpush.services.StartService
|
||||||
|
import com.nextcloud.android.sso.AccountImporter.IAccountAccessGranted
|
||||||
|
|
||||||
|
import com.nextcloud.android.sso.api.NextcloudAPI.ApiConnectedListener
|
||||||
|
|
||||||
|
import com.nextcloud.android.sso.helper.SingleAccountHelper
|
||||||
|
|
||||||
|
import com.nextcloud.android.sso.model.SingleSignOnAccount
|
||||||
|
import java.lang.Exception
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.nextcloud.android.sso.AccountImporter.clearAllAuthTokens
|
||||||
|
import com.nextcloud.android.sso.exceptions.*
|
||||||
|
import org.unifiedpush.distributor.nextpush.R
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.isConnected
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.connect
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.ssoAccount
|
||||||
|
import org.unifiedpush.distributor.nextpush.api.ApiUtils
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.sendUnregistered
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.MessagingDatabase
|
||||||
|
import java.lang.String.format
|
||||||
|
|
||||||
|
const val TAG = "NextPush-MainActivity"
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var listView : ListView
|
||||||
|
private var showLogout = false
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_main)
|
||||||
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||||||
|
if (isConnected(this)) {
|
||||||
|
showMain()
|
||||||
|
} else {
|
||||||
|
findViewById<Button>(R.id.button_connection).setOnClickListener {
|
||||||
|
connect(this)
|
||||||
|
}
|
||||||
|
showStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
try {
|
||||||
|
AccountImporter.onActivityResult(
|
||||||
|
requestCode,
|
||||||
|
resultCode,
|
||||||
|
data,
|
||||||
|
this,
|
||||||
|
object : IAccountAccessGranted {
|
||||||
|
var callback: ApiConnectedListener = object : ApiConnectedListener {
|
||||||
|
override fun onConnected() {}
|
||||||
|
|
||||||
|
override fun onError(ex: Exception) {
|
||||||
|
Log.e(TAG, "Cannot get account access", ex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun accountAccessGranted(account: SingleSignOnAccount) {
|
||||||
|
val context = applicationContext
|
||||||
|
|
||||||
|
// As this library supports multiple accounts we created some helper methods if you only want to use one.
|
||||||
|
// The following line stores the selected account as the "default" account which can be queried by using
|
||||||
|
// the SingleAccountHelper.getCurrentSingleSignOnAccount(context) method
|
||||||
|
SingleAccountHelper.setCurrentAccount(context, account.name)
|
||||||
|
|
||||||
|
// Get the "default" account
|
||||||
|
try {
|
||||||
|
ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(context)
|
||||||
|
} catch (e: NextcloudFilesAppAccountNotFoundException) {
|
||||||
|
UiExceptionManager.showDialogForException(context, e)
|
||||||
|
} catch (e: NoCurrentAccountSelectedException) {
|
||||||
|
UiExceptionManager.showDialogForException(context, e)
|
||||||
|
}
|
||||||
|
showMain()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: AccountImportCancelledException) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showMain() {
|
||||||
|
findViewById<ConstraintLayout>(R.id.sub_start).isVisible = false
|
||||||
|
findViewById<ConstraintLayout>(R.id.sub_main).isVisible = true
|
||||||
|
findViewById<TextView>(R.id.main_account_desc).text =
|
||||||
|
format(getString(R.string.main_account_desc), ssoAccount.name)
|
||||||
|
showLogout = true
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
startListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showStart() {
|
||||||
|
findViewById<ConstraintLayout>(R.id.sub_start).isVisible = true
|
||||||
|
findViewById<ConstraintLayout>(R.id.sub_main).isVisible = false
|
||||||
|
showLogout = false
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if(hasFocus) {
|
||||||
|
setListView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
|
menu.findItem(R.id.action_logout).isVisible = showLogout
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
return when (item.itemId) {
|
||||||
|
R.id.action_settings -> {
|
||||||
|
val intent = Intent(this, SettingsActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.action_restart -> {
|
||||||
|
restart()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.action_logout -> {
|
||||||
|
logout()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restart() {
|
||||||
|
Log.d(TAG, "Restarting the Listener")
|
||||||
|
val serviceIntent = Intent(this, StartService::class.java)
|
||||||
|
this.stopService(serviceIntent)
|
||||||
|
startListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun logout() {
|
||||||
|
val alert: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder(
|
||||||
|
this)
|
||||||
|
alert.setTitle(getString(R.string.logout_alert_title))
|
||||||
|
alert.setMessage(R.string.logout_alert_content)
|
||||||
|
alert.setPositiveButton(R.string.ok) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
clearAllAuthTokens(this)
|
||||||
|
AccountImporter.getSharedPreferences(this)
|
||||||
|
.edit()
|
||||||
|
.remove("PREF_CURRENT_ACCOUNT_STRING")
|
||||||
|
.apply()
|
||||||
|
ApiUtils().deleteDevice(this)
|
||||||
|
showStart()
|
||||||
|
finish();
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
alert.setNegativeButton(getString(R.string.discard)) { dialog, _ -> dialog.dismiss() }
|
||||||
|
alert.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startListener(){
|
||||||
|
Log.d(TAG, "Starting the Listener")
|
||||||
|
val serviceIntent = Intent(this, StartService::class.java)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
this.startForegroundService(serviceIntent)
|
||||||
|
}else{
|
||||||
|
this.startService(serviceIntent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setListView(){
|
||||||
|
listView = findViewById<ListView>(R.id.applications_list)
|
||||||
|
val db = MessagingDatabase(this)
|
||||||
|
val tokenList = db.listTokens().toMutableList()
|
||||||
|
val appList = emptyArray<String>().toMutableList()
|
||||||
|
tokenList.forEach {
|
||||||
|
appList.add(db.getPackageName(it))
|
||||||
|
}
|
||||||
|
db.close()
|
||||||
|
listView.adapter = ArrayAdapter(
|
||||||
|
this,
|
||||||
|
android.R.layout.simple_list_item_1,
|
||||||
|
appList
|
||||||
|
)
|
||||||
|
listView.setOnItemLongClickListener(
|
||||||
|
fun(parent: AdapterView<*>, v: View, position: Int, id: Long): Boolean {
|
||||||
|
val alert: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder(
|
||||||
|
this)
|
||||||
|
alert.setTitle("Unregistering")
|
||||||
|
alert.setMessage("Are you sure to unregister ${appList[position]} ?")
|
||||||
|
alert.setPositiveButton("YES") { dialog, _ ->
|
||||||
|
sendUnregistered(this, tokenList[position])
|
||||||
|
val db = MessagingDatabase(this)
|
||||||
|
db.unregisterApp(tokenList[position])
|
||||||
|
db.close()
|
||||||
|
tokenList.removeAt(position)
|
||||||
|
appList.removeAt(position)
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
alert.setNegativeButton("NO") { dialog, _ -> dialog.dismiss() }
|
||||||
|
alert.show()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.activities
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.EditText
|
||||||
|
import org.unifiedpush.distributor.nextpush.R
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.MessagingDatabase
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.getEndpoint
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.sendEndpoint
|
||||||
|
|
||||||
|
class SettingsActivity : AppCompatActivity() {
|
||||||
|
private var prefs: SharedPreferences? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
prefs = getSharedPreferences("Config", Context.MODE_PRIVATE)
|
||||||
|
setContentView(R.layout.activity_settings)
|
||||||
|
val address = prefs?.getString("address", "")
|
||||||
|
val proxy = prefs?.getString("proxy", "")
|
||||||
|
findViewById<EditText>(R.id.settings_address_value).setText(address)
|
||||||
|
findViewById<EditText>(R.id.settings_proxy_value).setText(proxy)
|
||||||
|
val btn = findViewById<View>(R.id.settings_save_button)
|
||||||
|
btn.setOnClickListener { v -> save(v) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun save(view: View){
|
||||||
|
val address = findViewById<EditText>(R.id.settings_address_value).text.toString()
|
||||||
|
val proxy = findViewById<EditText>(R.id.settings_proxy_value).text.toString()
|
||||||
|
Log.i("save",address)
|
||||||
|
val editor = prefs!!.edit()
|
||||||
|
editor.putString("address", address)
|
||||||
|
editor.putString("proxy", proxy)
|
||||||
|
editor.commit()
|
||||||
|
val db = MessagingDatabase(this)
|
||||||
|
val tokenList = db.listTokens()
|
||||||
|
db.close()
|
||||||
|
tokenList.forEach {
|
||||||
|
sendEndpoint(this, it, getEndpoint(this, it))
|
||||||
|
}
|
||||||
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.api
|
||||||
|
|
||||||
|
data class ApiResponse(
|
||||||
|
val success: Boolean = false,
|
||||||
|
val deviceId: String = "",
|
||||||
|
val token: String = "",
|
||||||
|
)
|
|
@ -0,0 +1,163 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.api
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import com.nextcloud.android.sso.api.NextcloudAPI
|
||||||
|
import io.reactivex.Observer
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.sse.EventSource
|
||||||
|
import okhttp3.sse.EventSources
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.getDeviceId
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.removeDeviceId
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.saveDeviceId
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.ssoAccount
|
||||||
|
import org.unifiedpush.distributor.nextpush.api.ProviderApi.Companion.mApiEndpoint
|
||||||
|
import org.unifiedpush.distributor.nextpush.services.SSEListener
|
||||||
|
import retrofit2.NextcloudRetrofitApiBuilder
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
private const val TAG = "ApiUtils"
|
||||||
|
|
||||||
|
class ApiUtils {
|
||||||
|
private lateinit var mApi: ProviderApi
|
||||||
|
private lateinit var nextcloudAPI: NextcloudAPI
|
||||||
|
private lateinit var factory: EventSource.Factory
|
||||||
|
|
||||||
|
fun destroy() {
|
||||||
|
if (this::nextcloudAPI.isInitialized)
|
||||||
|
nextcloudAPI.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cApi(context: Context, callback: ()->Unit) {
|
||||||
|
if (this::mApi.isInitialized and this::nextcloudAPI.isInitialized) {
|
||||||
|
callback()
|
||||||
|
} else {
|
||||||
|
val callback = object : NextcloudAPI.ApiConnectedListener {
|
||||||
|
override fun onConnected() {
|
||||||
|
Log.d(TAG, "Api connected.")
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
override fun onError(ex: Exception) {
|
||||||
|
Log.d(TAG, "Cannot connect to API: ex = [$ex]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nextcloudAPI = NextcloudAPI(context, ssoAccount, GsonBuilder().create(), callback)
|
||||||
|
mApi = NextcloudRetrofitApiBuilder(nextcloudAPI, mApiEndpoint)
|
||||||
|
.create(ProviderApi::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sync(context: Context) {
|
||||||
|
cApi(context) { cSync(context) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cSync(context: Context) {
|
||||||
|
var deviceId = getDeviceId(context)
|
||||||
|
// Register the device if it is not yet registered
|
||||||
|
if (deviceId.isNullOrEmpty()) {
|
||||||
|
Log.d(TAG, "No deviceId found.")
|
||||||
|
val parameters: MutableMap<String, String> = HashMap()
|
||||||
|
parameters["deviceName"] = Build.MODEL
|
||||||
|
mApi.createDevice(parameters)
|
||||||
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
?.observeOn(Schedulers.newThread())
|
||||||
|
?.subscribe(object : Observer<ApiResponse?> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
Log.d(TAG, "onSubscribe")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNext(response: ApiResponse) {
|
||||||
|
val deviceIdentifier: String = response.deviceId
|
||||||
|
Log.d(TAG, "Device Identifier: $deviceIdentifier")
|
||||||
|
saveDeviceId(context,deviceIdentifier)
|
||||||
|
deviceId = deviceIdentifier
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
// Sync once it is registered
|
||||||
|
cSync(deviceId!!)
|
||||||
|
Log.d(TAG, "mApi register: onComplete")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// Sync directly
|
||||||
|
Log.d(TAG, "Found deviceId: $deviceId")
|
||||||
|
cSync(deviceId!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun cSync(deviceId: String) {
|
||||||
|
val client = OkHttpClient.Builder()
|
||||||
|
.readTimeout(0, TimeUnit.SECONDS)
|
||||||
|
.retryOnConnectionFailure(false)
|
||||||
|
.build()
|
||||||
|
val url = "${ssoAccount.url}$mApiEndpoint/device/$deviceId"
|
||||||
|
|
||||||
|
val request = Request.Builder().url(url)
|
||||||
|
.get()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
factory = EventSources.createFactory(client)
|
||||||
|
factory.newEventSource(request, SSEListener())
|
||||||
|
Log.d(TAG, "doConnect done.")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteDevice(context: Context) {
|
||||||
|
cApi(context) { cDeleteDevice(context) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cDeleteDevice(context: Context) {
|
||||||
|
var deviceId = getDeviceId(context)
|
||||||
|
|
||||||
|
mApi.deleteDevice(deviceId)
|
||||||
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
?.observeOn(Schedulers.newThread())
|
||||||
|
?.subscribe(object : Observer<ApiResponse?> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
Log.d(TAG, "Subscribed to deleteDevice.")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNext(response: ApiResponse) {
|
||||||
|
if (response.success) {
|
||||||
|
Log.d(TAG, "Device successfully deleted.")
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "An error occurred while deleting the device registration.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
removeDeviceId(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createApp(context: Context) {
|
||||||
|
cApi(context) { cCreateApp(context) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cCreateApp(context: Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteApp(context: Context) {
|
||||||
|
cApi(context) { cDeleteApp(context) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cDeleteApp(context: Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.api
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import retrofit2.http.PUT
|
||||||
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.DELETE
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.Path
|
||||||
|
|
||||||
|
interface ProviderApi {
|
||||||
|
|
||||||
|
@PUT("/device/")
|
||||||
|
fun createDevice(
|
||||||
|
@Body subscribeMap: MutableMap<String, String>?
|
||||||
|
): Observable<ApiResponse>?
|
||||||
|
|
||||||
|
@GET("/device/{deviceId}")
|
||||||
|
fun syncDevice(@Path("deviceId") devideId: String?): Observable<SSEResponse?>?
|
||||||
|
|
||||||
|
@DELETE("/device/{deviceId}")
|
||||||
|
fun deleteDevice(@Path("deviceId") devideId: String?): Observable<ApiResponse>?
|
||||||
|
|
||||||
|
@PUT("/app/")
|
||||||
|
fun createApp(
|
||||||
|
@Body authorizeMap: MutableMap<String, String>?
|
||||||
|
): Observable<ApiResponse>?
|
||||||
|
|
||||||
|
@DELETE("/app/{token}")
|
||||||
|
fun deleteApp(@Path("token") token: String?): Observable<ApiResponse>?
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val mApiEndpoint = "/index.php/apps/uppush"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.api
|
||||||
|
|
||||||
|
data class SSEResponse (
|
||||||
|
val type: String = "",
|
||||||
|
val token: String = "",
|
||||||
|
val message: String = ""
|
||||||
|
)
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.distributor
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These functions are used to send messages to other apps
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun sendMessage(context: Context, token: String, message: String){
|
||||||
|
val application = getApp(context, token)
|
||||||
|
if (application.isNullOrBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val broadcastIntent = Intent()
|
||||||
|
broadcastIntent.`package` = application
|
||||||
|
broadcastIntent.action = ACTION_MESSAGE
|
||||||
|
broadcastIntent.putExtra(EXTRA_TOKEN, token)
|
||||||
|
broadcastIntent.putExtra(EXTRA_MESSAGE, message)
|
||||||
|
context.sendBroadcast(broadcastIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendEndpoint(context: Context, token: String, endpoint: String) {
|
||||||
|
val application = getApp(context, token)
|
||||||
|
if (application.isNullOrBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val broadcastIntent = Intent()
|
||||||
|
broadcastIntent.`package` = application
|
||||||
|
broadcastIntent.action = ACTION_NEW_ENDPOINT
|
||||||
|
broadcastIntent.putExtra(EXTRA_TOKEN, token)
|
||||||
|
broadcastIntent.putExtra(EXTRA_ENDPOINT, endpoint)
|
||||||
|
context.sendBroadcast(broadcastIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendUnregistered(context: Context, token: String) {
|
||||||
|
val application = getApp(context, token)
|
||||||
|
if (application.isNullOrBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val broadcastIntent = Intent()
|
||||||
|
broadcastIntent.`package` = application
|
||||||
|
broadcastIntent.action = ACTION_UNREGISTERED
|
||||||
|
broadcastIntent.putExtra(EXTRA_TOKEN, token)
|
||||||
|
context.sendBroadcast(broadcastIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getApp(context: Context, token: String): String?{
|
||||||
|
val db = MessagingDatabase(context)
|
||||||
|
val app = db.getPackageName(token)
|
||||||
|
db.close()
|
||||||
|
return if (app.isBlank()) {
|
||||||
|
Log.w("notifyClient", "No app found for $token")
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
app
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEndpoint(context: Context, appToken: String): String {
|
||||||
|
val settings = context.getSharedPreferences("Config", Context.MODE_PRIVATE)
|
||||||
|
val address = settings?.getString("address","")
|
||||||
|
return settings?.getString("proxy","") +
|
||||||
|
"/foo/$appToken/"
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.distributor
|
||||||
|
|
||||||
|
import android.content.ContentValues
|
||||||
|
import android.content.Context
|
||||||
|
import android.database.sqlite.SQLiteDatabase
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper
|
||||||
|
|
||||||
|
private const val DB_NAME = "apps_db"
|
||||||
|
private const val DB_VERSION = 1
|
||||||
|
|
||||||
|
class MessagingDatabase(context: Context):
|
||||||
|
SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||||
|
private val CREATE_TABLE_APPS = "CREATE TABLE apps (" +
|
||||||
|
"package_name TEXT," +
|
||||||
|
"token TEXT," +
|
||||||
|
"PRIMARY KEY (token));"
|
||||||
|
private val TABLE_APPS = "apps"
|
||||||
|
private val FIELD_PACKAGE_NAME = "package_name"
|
||||||
|
private val FIELD_TOKEN = "token"
|
||||||
|
|
||||||
|
override fun onCreate(db: SQLiteDatabase) {
|
||||||
|
db.execSQL(CREATE_TABLE_APPS)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
|
||||||
|
throw IllegalStateException("Upgrades not supported")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun registerApp(packageName: String, token: String) {
|
||||||
|
val db = writableDatabase
|
||||||
|
val values = ContentValues().apply {
|
||||||
|
put(FIELD_PACKAGE_NAME, packageName)
|
||||||
|
put(FIELD_TOKEN, token)
|
||||||
|
}
|
||||||
|
db.insert(TABLE_APPS, null, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unregisterApp(token: String) {
|
||||||
|
val db = writableDatabase
|
||||||
|
val selection = "$FIELD_TOKEN = ?"
|
||||||
|
val selectionArgs = arrayOf(token)
|
||||||
|
db.delete(TABLE_APPS, selection, selectionArgs)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isRegistered(packageName: String, token: String): Boolean {
|
||||||
|
val db = readableDatabase
|
||||||
|
val selection = "$FIELD_PACKAGE_NAME = ? AND $FIELD_TOKEN = ?"
|
||||||
|
val selectionArgs = arrayOf(packageName, token)
|
||||||
|
return db.query(
|
||||||
|
TABLE_APPS,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
).use { cursor ->
|
||||||
|
(cursor != null && cursor.count > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getPackageName(token: String): String {
|
||||||
|
val db = readableDatabase
|
||||||
|
val projection = arrayOf(FIELD_PACKAGE_NAME)
|
||||||
|
val selection = "$FIELD_TOKEN = ?"
|
||||||
|
val selectionArgs = arrayOf(token)
|
||||||
|
return db.query(
|
||||||
|
TABLE_APPS,
|
||||||
|
projection,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
).use { cursor ->
|
||||||
|
val column = cursor.getColumnIndex(FIELD_PACKAGE_NAME)
|
||||||
|
if (cursor.moveToFirst() && column >= 0) cursor.getString(column) else ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun listTokens(): List<String> {
|
||||||
|
val db = readableDatabase
|
||||||
|
val projection = arrayOf(FIELD_TOKEN)
|
||||||
|
return db.query(
|
||||||
|
TABLE_APPS,
|
||||||
|
projection,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
).use{ cursor ->
|
||||||
|
generateSequence { if (cursor.moveToNext()) cursor else null }
|
||||||
|
.mapNotNull{
|
||||||
|
val column = cursor.getColumnIndex(FIELD_TOKEN)
|
||||||
|
if (column >= 0) it.getString(column) else null }
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.distributor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants as defined on the specs
|
||||||
|
* https://github.com/UnifiedPush/UP-spec/blob/main/specifications.md
|
||||||
|
*/
|
||||||
|
|
||||||
|
const val ACTION_NEW_ENDPOINT = "org.unifiedpush.android.connector.NEW_ENDPOINT"
|
||||||
|
const val ACTION_REGISTRATION_FAILED = "org.unifiedpush.android.connector.REGISTRATION_FAILED"
|
||||||
|
const val ACTION_REGISTRATION_REFUSED = "org.unifiedpush.android.connector.REGISTRATION_REFUSED"
|
||||||
|
const val ACTION_UNREGISTERED = "org.unifiedpush.android.connector.UNREGISTERED"
|
||||||
|
const val ACTION_MESSAGE = "org.unifiedpush.android.connector.MESSAGE"
|
||||||
|
|
||||||
|
const val ACTION_REGISTER = "org.unifiedpush.android.distributor.REGISTER"
|
||||||
|
const val ACTION_UNREGISTER = "org.unifiedpush.android.distributor.UNREGISTER"
|
||||||
|
const val ACTION_MESSAGE_ACK = "org.unifiedpush.android.distributor.MESSAGE_ACK"
|
||||||
|
|
||||||
|
const val EXTRA_APPLICATION = "application"
|
||||||
|
const val EXTRA_TOKEN = "token"
|
||||||
|
const val EXTRA_ENDPOINT = "endpoint"
|
||||||
|
const val EXTRA_MESSAGE = "message"
|
||||||
|
const val EXTRA_MESSAGE_ID = "id"
|
|
@ -0,0 +1,65 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.receivers
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
|
import org.unifiedpush.distributor.nextpush.distributor.*
|
||||||
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THIS SERVICE IS USED BY OTHER APPS TO REGISTER
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RegisterBroadcastReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
|
private fun unregisterApp(db: MessagingDatabase, application: String, token: String) {
|
||||||
|
Log.i("RegisterService","Unregistering $application token: $token")
|
||||||
|
db.unregisterApp(token)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerApp(context: Context?, db: MessagingDatabase, application: String, token: String) {
|
||||||
|
if (application.isBlank()) {
|
||||||
|
Log.w("RegisterService","Trying to register an app without packageName")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Log.i("RegisterService","registering $application token: $token")
|
||||||
|
// The app is registered with the same token : we re-register it
|
||||||
|
// the client may need its endpoint again
|
||||||
|
if (db.isRegistered(application, token)) {
|
||||||
|
Log.i("RegisterService","$application already registered")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
db.registerApp(application, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
when (intent!!.action) {
|
||||||
|
ACTION_REGISTER ->{
|
||||||
|
Log.i("Register","REGISTER")
|
||||||
|
val token = intent.getStringExtra(EXTRA_TOKEN)?: ""
|
||||||
|
val application = intent.getStringExtra(EXTRA_APPLICATION)?: ""
|
||||||
|
thread(start = true) {
|
||||||
|
val db = MessagingDatabase(context!!)
|
||||||
|
registerApp(context, db, application, token)
|
||||||
|
db.close()
|
||||||
|
Log.i("RegisterService","Registration is finished")
|
||||||
|
}.join()
|
||||||
|
sendEndpoint(context!!, token, getEndpoint(context, token))
|
||||||
|
}
|
||||||
|
ACTION_UNREGISTER ->{
|
||||||
|
Log.i("Register","UNREGISTER")
|
||||||
|
val token = intent.getStringExtra(EXTRA_TOKEN)?: ""
|
||||||
|
val application = intent.getStringExtra(EXTRA_APPLICATION)?: ""
|
||||||
|
thread(start = true) {
|
||||||
|
val db = MessagingDatabase(context!!)
|
||||||
|
unregisterApp(db,application, token)
|
||||||
|
db.close()
|
||||||
|
Log.i("RegisterService","Unregistration is finished")
|
||||||
|
}
|
||||||
|
sendUnregistered(context!!, token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.receivers
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import org.unifiedpush.distributor.nextpush.services.StartService
|
||||||
|
|
||||||
|
class StartReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||||
|
Intent(context, StartService::class.java).also {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
context.startForegroundService(it)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
context.startService(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.services
|
||||||
|
|
||||||
|
import okhttp3.sse.EventSourceListener
|
||||||
|
import okhttp3.sse.EventSource
|
||||||
|
import android.util.Log
|
||||||
|
import okhttp3.Response
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
|
private const val TAG = "SSEListener"
|
||||||
|
|
||||||
|
class SSEListener : EventSourceListener() {
|
||||||
|
private var pingtime = 0.toLong()
|
||||||
|
private val networkConnected = false
|
||||||
|
|
||||||
|
override fun onOpen(eventSource: EventSource, response: Response) {
|
||||||
|
pingtime = System.currentTimeMillis()
|
||||||
|
try {
|
||||||
|
Log.d(TAG, "onOpen: " + response.code)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEvent(eventSource: EventSource, id: String?, eventType: String?, data: String) {
|
||||||
|
Log.d(TAG, "New SSE message event=$eventType message=$data")
|
||||||
|
pingtime = System.currentTimeMillis()
|
||||||
|
if (eventType == "warning") {
|
||||||
|
Log.d(TAG, "Warning event received.")
|
||||||
|
// Notification warning
|
||||||
|
}
|
||||||
|
if (eventType == "ping") {
|
||||||
|
Log.d(TAG, "SSE ping received.")
|
||||||
|
}
|
||||||
|
if (eventType != "notification") return
|
||||||
|
Log.d(TAG, "Notification event received.")
|
||||||
|
// handle notification
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClosed(eventSource: EventSource) {
|
||||||
|
Log.d(TAG, "onClosed: $eventSource")
|
||||||
|
if (!networkConnected) return
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(eventSource: EventSource, t: Throwable?, response: Response?) {
|
||||||
|
t?.let {
|
||||||
|
Log.d(TAG, "An error occurred: $t")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response?.let {
|
||||||
|
Log.d(TAG, "onFailure: ${it.code}")
|
||||||
|
if (!networkConnected) return
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
package org.unifiedpush.distributor.nextpush.services
|
||||||
|
|
||||||
|
import android.app.Notification
|
||||||
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.os.PowerManager
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException
|
||||||
|
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException
|
||||||
|
import com.nextcloud.android.sso.helper.SingleAccountHelper
|
||||||
|
import com.nextcloud.android.sso.ui.UiExceptionManager
|
||||||
|
|
||||||
|
import org.unifiedpush.distributor.nextpush.R
|
||||||
|
import org.unifiedpush.distributor.nextpush.api.ApiUtils
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.ssoAccount
|
||||||
|
|
||||||
|
private const val TAG = "StartService"
|
||||||
|
|
||||||
|
class StartService: Service(){
|
||||||
|
|
||||||
|
private var isServiceStarted = false
|
||||||
|
private var wakeLock: PowerManager.WakeLock? = null
|
||||||
|
private var api = ApiUtils()
|
||||||
|
|
||||||
|
override fun onBind(intent: Intent?): IBinder? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(){
|
||||||
|
super.onCreate()
|
||||||
|
Log.i(TAG,"Starting")
|
||||||
|
val notification = createNotification()
|
||||||
|
startForeground(51115, notification)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
|
startService()
|
||||||
|
// by returning this we make sure the service is restarted if the system kills the service
|
||||||
|
return START_STICKY
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
api.destroy()
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createNotification(): Notification {
|
||||||
|
val appName = getString(R.string.app_name)
|
||||||
|
val notificationChannelId = "$appName.Listener"
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
||||||
|
val channel = NotificationChannel(
|
||||||
|
notificationChannelId,
|
||||||
|
appName,
|
||||||
|
NotificationManager.IMPORTANCE_LOW
|
||||||
|
).let {
|
||||||
|
it.description = getString(R.string.listening_notif_description)
|
||||||
|
it
|
||||||
|
}
|
||||||
|
notificationManager.createNotificationChannel(channel)
|
||||||
|
}
|
||||||
|
|
||||||
|
val builder: Notification.Builder = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) Notification.Builder(
|
||||||
|
this,
|
||||||
|
notificationChannelId
|
||||||
|
) else Notification.Builder(this)
|
||||||
|
|
||||||
|
return builder
|
||||||
|
.setContentTitle(getString(R.string.app_name))
|
||||||
|
.setContentText(getString(R.string.listening_notif_description))
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher_notification)
|
||||||
|
.setTicker("Listening")
|
||||||
|
.setPriority(Notification.PRIORITY_LOW) // for under android 26 compatibility
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startService() {
|
||||||
|
if (isServiceStarted) return
|
||||||
|
isServiceStarted = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(this)
|
||||||
|
} catch (e: NextcloudFilesAppAccountNotFoundException) {
|
||||||
|
UiExceptionManager.showDialogForException(this, e)
|
||||||
|
} catch (e: NoCurrentAccountSelectedException) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need this lock so our service gets not affected by Doze Mode
|
||||||
|
wakeLock = (getSystemService(Context.POWER_SERVICE) as PowerManager).run {
|
||||||
|
newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "EndlessService::lock").apply {
|
||||||
|
acquire()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
api.sync(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<group android:scaleX="4.2519684"
|
||||||
|
android:scaleY="4.2519684"
|
||||||
|
android:translateX="27"
|
||||||
|
android:translateY="27">
|
||||||
|
<path
|
||||||
|
android:pathData="M6.35,0.7937A5.5563,5.5563 0,0 0,0.7937 6.35,5.5563 5.5563,0 0,0 6.35,11.9063 5.5563,5.5563 0,0 0,11.9063 6.35,5.5563 5.5563,0 0,0 6.35,0.7937ZM6.35,2.1167A4.2333,4.2333 0,0 1,10.5833 6.35,4.2333 4.2333,0 0,1 6.35,10.5833 4.2333,4.2333 0,0 1,2.1167 6.35,4.2333 4.2333,0 0,1 6.35,2.1167Z"
|
||||||
|
android:strokeWidth="0.291905"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M9.4115,7.816H3.2885L6.35,4.9012Z"
|
||||||
|
android:strokeWidth="0.0907924"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#ffffff"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<group android:scaleX="8"
|
||||||
|
android:scaleY="8"
|
||||||
|
android:translateX="8"
|
||||||
|
android:translateY="8">
|
||||||
|
<path
|
||||||
|
android:pathData="M6.35,0.7937A5.5563,5.5563 0,0 0,0.7937 6.35,5.5563 5.5563,0 0,0 6.35,11.9063 5.5563,5.5563 0,0 0,11.9063 6.35,5.5563 5.5563,0 0,0 6.35,0.7937ZM6.35,2.1167A4.2333,4.2333 0,0 1,10.5833 6.35,4.2333 4.2333,0 0,1 6.35,10.5833 4.2333,4.2333 0,0 1,2.1167 6.35,4.2333 4.2333,0 0,1 6.35,2.1167Z"
|
||||||
|
android:strokeWidth="0.291905"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M9.4115,7.816H3.2885L6.35,4.9012Z"
|
||||||
|
android:strokeWidth="0.0907924"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#ffffff"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="org.unifiedpush.distributor.nextpush.activities.MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/Theme.NextPush.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/Theme.NextPush.PopupOverlay" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/sub_main"
|
||||||
|
layout="@layout/content_main" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/sub_start"
|
||||||
|
layout="@layout/content_start" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="org.unifiedpush.distributor.nextpush.activities.SettingsActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_address_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/settings_address_label"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/settings_address_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/settings_address_hint"
|
||||||
|
android:inputType="textPersonName"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_address_help"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:text="@string/help"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/settings_address_value"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/settings_address_value" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_gateway_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/settings_gateway_label"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/settings_address_value" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/settings_proxy_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/settings_gateway_hint"
|
||||||
|
android:inputType="textPersonName"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/settings_save_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/settings_save_button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/settings_proxy_value" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/settings_address_information"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/settings_address_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/settings_gateway_information"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/settings_gateway_label" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_account_title"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/main_account_title"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_account_desc"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/main_account_desc"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/main_account_title" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_applications_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/main_applications_title"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/main_account_desc" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/applications_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/main_applications_title" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_connection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/connection_button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:text="@string/connection_description"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="org.unifiedpush.distributor.nextpush.activities.MainActivity">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_restart"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_restart"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_logout"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_logout"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,16 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.NextPush" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/nextcloud</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/black</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="nextcloud">#0F9AE6</color>
|
||||||
|
</resources>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#0F9AE6</color>
|
||||||
|
</resources>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<resources>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
|
<!-- Strings used on the main page -->
|
||||||
|
<string name="main_applications_title">Registered applications</string>
|
||||||
|
|
||||||
|
<!-- Strings used for configuration -->
|
||||||
|
<string name="settings_address_label">Your address</string>
|
||||||
|
<string name="settings_address_information">This is your static address on your custom network. It is necessary to know where to forward the notifications.</string>
|
||||||
|
<string name="settings_address_hint">[::1]</string>
|
||||||
|
<string name="settings_gateway_label">Your proxy</string>
|
||||||
|
<string name="settings_gateway_information">This is the proxy to forward requests inside your custom network, to reach your phone from the Internet.</string>
|
||||||
|
<string name="settings_gateway_hint">https://proxy.example.tld</string>
|
||||||
|
<string name="settings_save_button">Save</string>
|
||||||
|
<string name="help"></string>
|
||||||
|
<string name="listening_notif_description">Listening incoming notifications</string>
|
||||||
|
<string name="connection_button">Login</string>
|
||||||
|
<string name="connection_description">You are not connected to Nextcloud yet</string>
|
||||||
|
<string name="action_logout">Logout</string>
|
||||||
|
<string name="logout_alert_title">Logout</string>
|
||||||
|
<string name="logout_alert_content">Confirm to logout</string>
|
||||||
|
<string name="ok">Ok</string>
|
||||||
|
<string name="discard">Discard</string>
|
||||||
|
<string name="main_account_title">Account</string>
|
||||||
|
<string name="main_account_desc">You are connected as: %s</string>
|
||||||
|
<string name="action_restart">Restart Service</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.NextPush" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/nextcloud</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/white</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.NextPush.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.NextPush.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="Theme.NextPush.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
</resources>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<network-security-config>
|
||||||
|
<base-config>
|
||||||
|
<trust-anchors>
|
||||||
|
<!-- Trust preinstalled CAs -->
|
||||||
|
<certificates src="system" />
|
||||||
|
<!-- Additionally trust user added CAs -->
|
||||||
|
<certificates src="user" />
|
||||||
|
</trust-anchors>
|
||||||
|
</base-config>
|
||||||
|
</network-security-config>
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = "1.5.31"
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "com.android.tools.build:gradle:7.0.3"
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# 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.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -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
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
|
@ -0,0 +1,5 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# 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\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# 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
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
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" -a "$nonstop" = "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 or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# 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=`expr $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
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,89 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@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="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@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 execute
|
||||||
|
|
||||||
|
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 execute
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
: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 %*
|
||||||
|
|
||||||
|
: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
|
|
@ -0,0 +1,2 @@
|
||||||
|
include ':app'
|
||||||
|
rootProject.name = "NextPush"
|