diff --git a/remoteexample/.gitignore b/remoteexample/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/remoteexample/.gitignore @@ -0,0 +1 @@ +/build diff --git a/remoteexample/build.gradle b/remoteexample/build.gradle new file mode 100644 index 00000000..eb4009c2 --- /dev/null +++ b/remoteexample/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + + defaultConfig { + applicationId "com.etesync.remotecontroller" + minSdkVersion 14 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.3.0' + testCompile 'junit:junit:4.12' +} diff --git a/remoteexample/proguard-rules.pro b/remoteexample/proguard-rules.pro new file mode 100644 index 00000000..94fc9377 --- /dev/null +++ b/remoteexample/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/tal/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/remoteexample/src/androidTest/java/com/etesync/ExampleInstrumentedTest.java b/remoteexample/src/androidTest/java/com/etesync/ExampleInstrumentedTest.java new file mode 100644 index 00000000..c3fc2651 --- /dev/null +++ b/remoteexample/src/androidTest/java/com/etesync/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.etesync; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.etesync", appContext.getPackageName()); + } +} diff --git a/remoteexample/src/main/AndroidManifest.xml b/remoteexample/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6ecf5c0d --- /dev/null +++ b/remoteexample/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl b/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl new file mode 100644 index 00000000..19920d52 --- /dev/null +++ b/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl @@ -0,0 +1,10 @@ +// IEteSyncService.aidl +package com.etesync.syncadapter; + +// Declare any non-default types here with import statements + +interface IEteSyncService { + boolean hasPermission(String journalType); + + void requestPermission(String journalType); +} diff --git a/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java b/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java new file mode 100644 index 00000000..9f09e712 --- /dev/null +++ b/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java @@ -0,0 +1,62 @@ +package com.etesync.remotecontroller; + +import android.content.ComponentName; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.IBinder; +import android.os.RemoteException; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; + +import com.etesync.syncadapter.IEteSyncService; + +public class MainActivity extends AppCompatActivity { + + private static final String TAG = "MainActivity"; + private static final String JOURNAL_TYPE = "ToDo"; + + + private IEteSyncService mEteSyncService; + + private ServiceConnection mServiceConnection = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName componentName, IBinder iBinder) { + mEteSyncService = IEteSyncService.Stub.asInterface(iBinder); + + try { + boolean isAllowed = mEteSyncService.hasPermission(JOURNAL_TYPE); + if (!isAllowed) { + mEteSyncService.requestPermission(JOURNAL_TYPE); + } + + Log.i(TAG, JOURNAL_TYPE + " isAllowed:" + mEteSyncService.hasPermission(JOURNAL_TYPE) + + "\n other is allowed:" + mEteSyncService.hasPermission("other")); + } catch (RemoteException aE) { + aE.printStackTrace(); + } + } + + @Override + public void onServiceDisconnected(ComponentName componentName) { + mEteSyncService = null; + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Intent intent = new Intent("com.etesync.syncadapter.RemoteService"); + intent.setPackage("com.etesync.syncadapter"); + startService(intent); + bindService(intent, mServiceConnection, 0); + } + + @Override + public void onDestroy() { + super.onDestroy(); + unbindService(mServiceConnection); + } +} diff --git a/remoteexample/src/main/res/layout/activity_main.xml b/remoteexample/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..301b3e22 --- /dev/null +++ b/remoteexample/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/remoteexample/src/main/res/mipmap-hdpi/ic_launcher.png b/remoteexample/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..cde69bcc Binary files /dev/null and b/remoteexample/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/remoteexample/src/main/res/mipmap-mdpi/ic_launcher.png b/remoteexample/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..c133a0cb Binary files /dev/null and b/remoteexample/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/remoteexample/src/main/res/mipmap-xhdpi/ic_launcher.png b/remoteexample/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..bfa42f0e Binary files /dev/null and b/remoteexample/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/remoteexample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/remoteexample/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..324e72cd Binary files /dev/null and b/remoteexample/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/remoteexample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/remoteexample/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..aee44e13 Binary files /dev/null and b/remoteexample/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/remoteexample/src/main/res/values-w820dp/dimens.xml b/remoteexample/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 00000000..63fc8164 --- /dev/null +++ b/remoteexample/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/remoteexample/src/main/res/values/colors.xml b/remoteexample/src/main/res/values/colors.xml new file mode 100644 index 00000000..3ab3e9cb --- /dev/null +++ b/remoteexample/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/remoteexample/src/main/res/values/dimens.xml b/remoteexample/src/main/res/values/dimens.xml new file mode 100644 index 00000000..47c82246 --- /dev/null +++ b/remoteexample/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/remoteexample/src/main/res/values/strings.xml b/remoteexample/src/main/res/values/strings.xml new file mode 100644 index 00000000..331327e3 --- /dev/null +++ b/remoteexample/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Remote Controller + diff --git a/remoteexample/src/main/res/values/styles.xml b/remoteexample/src/main/res/values/styles.xml new file mode 100644 index 00000000..5885930d --- /dev/null +++ b/remoteexample/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/remoteexample/src/test/java/com/etesync/ExampleUnitTest.java b/remoteexample/src/test/java/com/etesync/ExampleUnitTest.java new file mode 100644 index 00000000..faa54efb --- /dev/null +++ b/remoteexample/src/test/java/com/etesync/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.etesync; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 0e8d35a9..69aebcd8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,7 +6,7 @@ * http://www.gnu.org/licenses/gpl.html */ -include ':app' +include ':app', ':remoteexample' include ':ical4android' include ':vcard4android' include ':cert4android'