Skip to content

Commit 4b47fe1

Browse files
committed
First upload
1 parent 080c204 commit 4b47fe1

File tree

45 files changed

+1024
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1024
-0
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ captures/
4949
.idea/modules.xml
5050
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
5151
.idea/navEditor.xml
52+
.idea/
5253

5354
# Keystore files
5455
# Uncomment the following lines if you do not want to check your keystore files in.
@@ -83,3 +84,6 @@ lint/generated/
8384
lint/outputs/
8485
lint/tmp/
8586
# lint/reports/
87+
88+
89+
.DS_Store

Diff for: AndroidBaseClasses/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: AndroidBaseClasses/build.gradle

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdkVersion 29
8+
buildToolsVersion "30.0.2"
9+
10+
defaultConfig {
11+
minSdkVersion 24
12+
targetSdkVersion 29
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
consumerProguardFiles "consumer-rules.pro"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
kotlinOptions {
31+
jvmTarget = '1.8'
32+
}
33+
}
34+
35+
dependencies {
36+
37+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
38+
implementation 'androidx.core:core-ktx:1.3.2'
39+
implementation 'androidx.appcompat:appcompat:1.2.0'
40+
implementation 'com.google.android.material:material:1.2.1'
41+
testImplementation 'junit:junit:4.+'
42+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
43+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
44+
implementation 'com.android.volley:volley:1.1.0'
45+
}

Diff for: AndroidBaseClasses/consumer-rules.pro

Whitespace-only changes.

Diff for: AndroidBaseClasses/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.github.song9063.androidbaseclasses
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.github.song9063.androidbaseclasses.test", appContext.packageName)
23+
}
24+
}

Diff for: AndroidBaseClasses/src/main/AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.github.song9063.androidbaseclasses">
4+
5+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.github.song9063.androidbaseclasses.activities
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import android.os.Bundle
6+
import androidx.appcompat.app.AppCompatActivity
7+
import com.github.song9063.androidbaseclasses.utils.BoltDataManager
8+
9+
open class BoltBaseActivity : AppCompatActivity(){
10+
var boltDataManager: BoltDataManager? = null
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
14+
15+
}
16+
17+
fun initDataManager(prefName: String){
18+
boltDataManager = BoltDataManager(this, prefName)
19+
}
20+
21+
fun openURL(strUrl: String) {
22+
val uri = Uri.parse(strUrl)
23+
val intent = Intent(Intent.ACTION_VIEW, uri)
24+
val b = Bundle()
25+
b.putBoolean("new_window", true)
26+
intent.putExtras(b)
27+
startActivity(intent)
28+
}
29+
30+
fun openGoogleMapBrowser(strLat: String, strLng: String, strZoomLevel: String){
31+
val strUrl = "https://www.google.com/maps/@${strLat},${strLng},${strZoomLevel}z"
32+
openURL(strUrl)
33+
}
34+
35+
fun openGoogleMapRouteBrowser(strStartLat: String, strStartLng: String,
36+
strEndLat: String, strEndLng: String){
37+
var strUrl = "https://www.google.com/maps/dir/?api=1&origin=${strStartLat},${strStartLng}"
38+
strUrl += "&destination=${strEndLat},${strEndLng}&travelmode=driving"
39+
openURL(strUrl)
40+
}
41+
42+
fun phoneCall(strPhoneNumber: String){
43+
openURL("tel:${strPhoneNumber}")
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.github.song9063.androidbaseclasses.http
2+
3+
import android.content.Context
4+
import com.android.volley.Request
5+
import com.android.volley.Response
6+
import com.android.volley.toolbox.JsonObjectRequest
7+
import org.json.JSONObject
8+
9+
class BoltHttp(context: Context) {
10+
private val mContext = context
11+
12+
// onResp(urlString, responseObject, Success, CustomTag)
13+
// onError(urlString, errorString, CustomTag)
14+
fun httpPost(strUrl: String, params: JSONObject,
15+
onResp: (String, JSONObject, Boolean, Int) -> (Boolean),
16+
onError: (String, String, Int) -> (Boolean),
17+
extHeaders: HashMap<String, String>,
18+
nCustomTag: Int = 0){
19+
20+
val jsonObjReq = object : JsonObjectRequest(
21+
Request.Method.POST, strUrl, params,
22+
Response.Listener<JSONObject> { resp ->
23+
onResp(strUrl, resp, resp != null, nCustomTag)
24+
},
25+
Response.ErrorListener { error ->
26+
onError(strUrl, error.toString(), nCustomTag)
27+
}
28+
){
29+
override fun getHeaders(): MutableMap<String, String> {
30+
return extHeaders
31+
/*val headers = HashMap<String, String>()
32+
headers.put("X-API-KEY",DLConst.HTTP_API_KEY)
33+
return headers*/
34+
}
35+
}
36+
BoltVolleyQueue.getInstance(mContext).addToRequestQueue(jsonObjReq)
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.github.song9063.androidbaseclasses.http
2+
3+
import android.content.Context
4+
import android.graphics.Bitmap
5+
import android.util.LruCache
6+
import com.android.volley.Request
7+
import com.android.volley.RequestQueue
8+
import com.android.volley.toolbox.ImageLoader
9+
import com.android.volley.toolbox.Volley
10+
11+
class BoltVolleyQueue constructor(context: Context) {
12+
companion object {
13+
@Volatile
14+
private var INSTANCE: BoltVolleyQueue? = null
15+
fun getInstance(context: Context) =
16+
INSTANCE ?: synchronized(this) {
17+
INSTANCE ?: BoltVolleyQueue(context).also {
18+
INSTANCE = it
19+
}
20+
}
21+
}
22+
23+
val imageLoader: ImageLoader by lazy {
24+
ImageLoader(requestQueue,
25+
object : ImageLoader.ImageCache {
26+
private val cache = LruCache<String, Bitmap>(20)
27+
override fun getBitmap(url: String): Bitmap {
28+
return cache.get(url)
29+
}
30+
override fun putBitmap(url: String, bitmap: Bitmap) {
31+
cache.put(url, bitmap)
32+
}
33+
})
34+
}
35+
val requestQueue: RequestQueue by lazy {
36+
// applicationContext is key, it keeps you from leaking the
37+
// Activity or BroadcastReceiver if someone passes one in.
38+
Volley.newRequestQueue(context.applicationContext)
39+
}
40+
fun <T> addToRequestQueue(req: Request<T>) {
41+
requestQueue.add(req)
42+
}
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.github.song9063.androidbaseclasses.utils
2+
3+
import android.content.Context
4+
import android.content.SharedPreferences
5+
import org.json.JSONObject
6+
7+
open class BoltDataManager(context: Context, prefName: String) {
8+
private val pref: SharedPreferences = context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
9+
10+
fun getString(key: String, defaultValue: String): String {
11+
return pref.getString(key, defaultValue).toString()
12+
}
13+
14+
fun setString(key: String, value: String){
15+
pref.edit().putString(key, value).apply()
16+
}
17+
18+
fun setJSON(key: String, obj: JSONObject){
19+
val strJson = obj.toString()
20+
setString(key, strJson)
21+
}
22+
23+
fun getJSON(key: String): JSONObject? {
24+
val strJson = getString(key,"")
25+
if(strJson.isNotEmpty()){
26+
return JSONObject(strJson)
27+
}
28+
return null
29+
}
30+
31+
fun setSignedUserJSON(obj: JSONObject?){
32+
if(obj != null)
33+
setJSON("SIGNED_USER_JSON", obj)
34+
else
35+
setString("SIGNED_USER_JSON","")
36+
}
37+
fun getSignedUserJSON(): JSONObject?{
38+
return getJSON("SIGNED_USER_JSON")
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.song9063.androidbaseclasses
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

Diff for: app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: app/build.gradle

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
id 'kotlin-android-extensions'
5+
}
6+
7+
android {
8+
compileSdkVersion 29
9+
buildToolsVersion "30.0.2"
10+
11+
defaultConfig {
12+
applicationId "com.github.song9063.androidbaseclassesdemo"
13+
minSdkVersion 24
14+
targetSdkVersion 29
15+
versionCode 1
16+
versionName "1.0"
17+
18+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled false
24+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
targetCompatibility JavaVersion.VERSION_1_8
30+
}
31+
kotlinOptions {
32+
jvmTarget = '1.8'
33+
}
34+
}
35+
36+
dependencies {
37+
38+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
39+
implementation 'androidx.core:core-ktx:1.3.2'
40+
implementation 'androidx.appcompat:appcompat:1.2.0'
41+
implementation 'com.google.android.material:material:1.2.1'
42+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
43+
implementation project(path: ':AndroidBaseClasses')
44+
testImplementation 'junit:junit:4.+'
45+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
46+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
47+
implementation 'com.android.volley:volley:1.1.0'
48+
}

Diff for: app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)