Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
saadshams committed Mar 9, 2020
0 parents commit 8ec79de
Show file tree
Hide file tree
Showing 64 changed files with 2,237 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
88 changes: 88 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

.DS_Store
.idea/
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* PureMVC Kotlin Android Demo - Employee Admin - Copyright © 2020 Saad Shams
* PureMVC - Copyright © 2020 Futurescale, Inc.
* All rights reserved.

* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## [PureMVC](http://puremvc.github.com/) [Kotlin](https://github.com/PureMVC/puremvc-kotlin-multicore-framework/wiki) Android Demo: Employee Admin

This demo illustrates techniques for performing routine maintenance operations in a PureMVC-based [Android](https://en.wikipedia.org/wiki/Android_(operating_system)) application.

## Screenshot
![PureMVC Kotlin Android Demo: Employee Admin](http://puremvc.org/pages/images/screenshots/PureMVC-Shot-Kotlin-Android-EmployeeAdmin.png)

## Status
Production - [Version 1.0](https://github.com/PureMVC/puremvc-kotlin-demo-android-employeeadmin/blob/master/VERSION)

## Platforms / Technologies
* [Android](https://en.wikipedia.org/wiki/Android_(operating_system))
* [Kotlin](https://en.wikipedia.org/wiki/Kotlin_(programming_language))

## License
* PureMVC Kotlin Demo - Employee Admin Android App - Copyright © 2020 [Saad Shams](https://www.linkedin.com/in/muizz/)
* PureMVC - Copyright © 2020 [Futurescale, Inc.](http://futurescale.com)
* All rights reserved.

* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 10 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PureMVC Kotlin Android Demo - Employee Admin
--------------------------------------------------------------------------
Release Date: 03/08/20
Platform: Kotlin, Android
Version: 1
Major: 0
Minor: 0
Author: Saad Shams <[email protected]>
--------------------------------------------------------------------------
1.0.0 - First public release.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
57 changes: 57 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
applicationId "org.puremvc.kotlin.demos.android.employeeadmin"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
vectorDrawables {
useSupportLibrary true
}

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

}

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'
implementation 'com.github.PureMVC:puremvc-kotlin-multicore-framework:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.puremvc.kotlin.demos.android.employeeadmin

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("org.puremvc.kotlin.demos.android.employeeadmin", appContext.packageName)
}
}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.puremvc.kotlin.demos.android.employeeadmin">

<application
android:name="org.puremvc.kotlin.demos.android.employeeadmin.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/AppTheme">
<activity android:name=".view.components.UserListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".view.components.UserFormActivity" />
<activity android:name=".view.components.UserRoleActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Application.kt
// PureMVC Android Demo - EmployeeAdmin
//
// Copyright(c) 2020 Saad Shams <[email protected]>
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//

package org.puremvc.kotlin.demos.android.employeeadmin

import android.app.Application
import androidx.appcompat.app.AppCompatActivity

class Application: Application() {

companion object {
const val ACTIVITY_USER_FORM = 1

const val ACTIVITY_USER_ROLE = 2

const val BUNDLE_USER = "BUNDLE_USER"

const val BUNDLE_USER_ROLE = "BUNDLE_USER_ROLE"
}

private val facade = ApplicationFacade.getInstance("EmployeeAdmin") as ApplicationFacade

override fun onCreate() {
super.onCreate()
facade.startup(this)
}

fun registerActivity(activity: AppCompatActivity) {
facade.registerActivity(activity)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// ApplicationFacade.kt
// PureMVC Android Demo - EmployeeAdmin
//
// Copyright(c) 2020 Saad Shams <[email protected]>
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//

package org.puremvc.kotlin.demos.android.employeeadmin

import androidx.appcompat.app.AppCompatActivity
import org.puremvc.kotlin.demos.android.employeeadmin.controller.RegisterCommand
import org.puremvc.kotlin.demos.android.employeeadmin.controller.StartupCommand
import org.puremvc.kotlin.multicore.interfaces.IFacade
import org.puremvc.kotlin.multicore.patterns.facade.Facade

class ApplicationFacade(key: String) : Facade(key) {

companion object {

const val STARTUP: String = "startup"

const val REGISTER: String = "register"

fun getInstance(key: String): IFacade {
return Facade.getInstance(key) { k -> ApplicationFacade(k) }
}
}

override fun initializeController() {
super.initializeController()
registerCommand(STARTUP) { StartupCommand() }
registerCommand(REGISTER) { RegisterCommand() }
}

fun registerActivity(activity: AppCompatActivity) {
sendNotification(REGISTER, activity)
}

fun startup(application: Application) {
sendNotification(STARTUP, application)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// DeleteUserCommand.kt
// PureMVC Android Demo - EmployeeAdmin
//
// Copyright(c) 2020 Saad Shams <[email protected]>
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//

package org.puremvc.kotlin.demos.android.employeeadmin.controller

import org.puremvc.kotlin.demos.android.employeeadmin.model.RoleProxy
import org.puremvc.kotlin.demos.android.employeeadmin.model.UserProxy
import org.puremvc.kotlin.demos.android.employeeadmin.model.valueObject.UserVO
import org.puremvc.kotlin.multicore.interfaces.INotification
import org.puremvc.kotlin.multicore.patterns.command.SimpleCommand

class DeleteUserCommand: SimpleCommand() {

override fun execute(notification: INotification) {
val userVO = notification.body as UserVO
val userProxy = facade.retrieveProxy(UserProxy.NAME) as UserProxy
val roleProxy = facade.retrieveProxy(RoleProxy.NAME) as RoleProxy
userProxy.deleteItem(userVO)
roleProxy.deleteItem(userVO.username)
}

}
Loading

0 comments on commit 8ec79de

Please sign in to comment.