diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..5948ee5 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "com.android.kisokmode" + minSdkVersion 21 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -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 diff --git a/app/src/androidTest/java/com/android/kioskmode/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/android/kioskmode/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..b7ad3b9 --- /dev/null +++ b/app/src/androidTest/java/com/android/kioskmode/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.android.kioskmode + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.android.kisokmode", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e2fb143 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/android/kioskmode/AdminReceiver.kt b/app/src/main/java/com/android/kioskmode/AdminReceiver.kt new file mode 100644 index 0000000..94271f6 --- /dev/null +++ b/app/src/main/java/com/android/kioskmode/AdminReceiver.kt @@ -0,0 +1,19 @@ +package com.android.kioskmode + +import android.app.admin.DeviceAdminReceiver +import android.content.ComponentName +import android.content.Context +import android.util.Log + +class AdminReceiver :DeviceAdminReceiver(){ + + companion object{ + fun getComponentName(context:Context):ComponentName{ + Log.d("Component Name",ComponentName(context.applicationContext, + AdminReceiver::class.java).toString()) + return ComponentName(context.applicationContext, + AdminReceiver::class.java) + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/android/kioskmode/MainActivity.kt b/app/src/main/java/com/android/kioskmode/MainActivity.kt new file mode 100644 index 0000000..d738f7f --- /dev/null +++ b/app/src/main/java/com/android/kioskmode/MainActivity.kt @@ -0,0 +1,89 @@ +package com.android.kioskmode + + +import android.app.admin.DevicePolicyManager +import android.content.Context +import android.os.Bundle +import android.view.View +import android.widget.Button +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity + + +class MainActivity : AppCompatActivity() { + + lateinit var mButton: Button + + private var mDecorView: View? = null + private lateinit var mDpm: DevicePolicyManager + private var mIsKioskEnabled = false + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + mButton= findViewById