-
Notifications
You must be signed in to change notification settings - Fork 0
Develop Bulletin sdk #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
2dee02e
86315b1
545c213
9f110ea
55f80aa
600e58d
0b1a1b3
c85c739
379ea77
8feffe8
ef4765d
9904590
dbdee01
2b0820e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| plugins { | ||
| id 'com.android.application' | ||
| id 'org.jetbrains.kotlin.android' | ||
| id 'kotlin-kapt' | ||
| } | ||
|
|
||
| android { | ||
| compileSdk 33 | ||
|
|
||
| defaultConfig { | ||
| applicationId "com.bulletin" | ||
| minSdk 21 | ||
| targetSdk 33 | ||
| versionCode 1 | ||
| versionName "1.0" | ||
|
|
||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| minifyEnabled false | ||
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
| } | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility JavaVersion.VERSION_11 | ||
| targetCompatibility JavaVersion.VERSION_11 | ||
| } | ||
| kotlinOptions { | ||
| jvmTarget = 11 | ||
| } | ||
| buildFeatures { | ||
| viewBinding true | ||
| } | ||
| } | ||
|
|
||
|
|
||
| ext { | ||
| appCompat='1.4.1' | ||
| materialDesign='1.6.0' | ||
| vectorDrawable='1.1.0' | ||
| multiDex='2.0.1' | ||
| jUnit='4.13.2' | ||
| runner='1.4.0' | ||
| playCore='1.10.3' | ||
| retrofit='2.9.0' | ||
| espressoCore='3.4.0' | ||
| } | ||
| dependencies { | ||
| implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
| implementation "androidx.appcompat:appcompat:$appCompat" | ||
| implementation "com.google.android.material:material:$materialDesign" | ||
| implementation "androidx.vectordrawable:vectordrawable:$vectorDrawable" | ||
| implementation "androidx.multidex:multidex:$multiDex" | ||
| implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) | ||
| implementation 'androidx.databinding:viewbinding:7.4.0' | ||
| testImplementation "junit:junit:$jUnit" | ||
| androidTestImplementation "androidx.test:runner:$runner" | ||
| implementation "com.google.android.play:core:$playCore" | ||
| androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCore" | ||
|
|
||
| implementation "com.squareup.retrofit2:converter-gson:$retrofit" | ||
|
|
||
| implementation 'com.github.bumptech.glide:glide:4.13.2' | ||
| kapt 'com.github.bumptech.glide:compiler:4.13.2' | ||
|
|
||
| } | ||
| 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 com.example.bulletin | ||
|
|
||
| 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.example.bulletin", appContext.packageName) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| package="com.example.bulletin"> | ||
|
|
||
| <uses-permission android:name="android.permission.INTERNET"/> | ||
|
|
||
| <application | ||
| android:name="com.bulletin.BulletinApp" | ||
| android:allowBackup="true" | ||
| android:dataExtractionRules="@xml/data_extraction_rules" | ||
| android:fullBackupContent="@xml/backup_rules" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| tools:targetApi="31"> | ||
| <activity | ||
| android:name=".DefaultActivity" | ||
| android:exported="true" | ||
| > | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
|
|
||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
|
|
||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.bulletin | ||
|
|
||
| import android.app.Application | ||
| import android.content.Context | ||
| import android.content.pm.PackageManager | ||
| import android.util.Log | ||
| import com.bulletin.utilities.GsonHelper | ||
| import com.google.gson.Gson | ||
|
|
||
| class BulletinApp : Application() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Application class is not required for this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have same thinking but we need to discuss. |
||
| private var gsonInstance: Gson? = null | ||
|
|
||
| companion object { | ||
| lateinit var shared: BulletinApp | ||
| private set | ||
|
|
||
| val applicationContext: Context | ||
| get() { | ||
| return shared.applicationContext | ||
| } | ||
| } | ||
|
|
||
| //Initializer | ||
| init { | ||
| shared = this | ||
| gsonInstance = GsonHelper.gsonInstance | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package com.bulletin | ||
|
|
||
| import com.bulletin.extension.lastSeenVersion | ||
| import com.bulletin.models.BulletinInfo | ||
| import com.bulletin.models.BulletinItem | ||
| import com.bulletin.models.Version | ||
| import com.bulletin.utilities.AppStorageHelper | ||
| import com.bulletin.utilities.VersionUtil | ||
| import java.util.* | ||
|
|
||
|
|
||
| class BulletinDataStore { | ||
|
|
||
| var data: MutableList<BulletinInfo> = mutableListOf() | ||
| private set | ||
|
|
||
| fun registerVersionInfo11(version: Version, items: MutableList<HashMap<String, Any>>) { | ||
|
|
||
| val bulletinItems = ArrayList<BulletinItem>() | ||
| for (itemAttributes in items) { | ||
| val bulletinItem = BulletinItem.createBulletinItem(itemAttributes) ?: return continue | ||
| bulletinItems.add(bulletinItem) | ||
| } | ||
|
|
||
| registerVersionInfo(version, bulletinItems) | ||
| } | ||
|
|
||
| fun registerVersionInfo(version: Version, items: MutableList<BulletinItem>?) { | ||
|
|
||
| if (items == null || items.isEmpty()) { | ||
| return | ||
| } | ||
|
|
||
| // Create Bulletin Info Object | ||
| val bulletinInfo = BulletinInfo.init(version, items) | ||
|
|
||
| data.add(bulletinInfo) | ||
| Collections.sort(data, BulletinInfo.descendingSort) | ||
| } | ||
|
|
||
|
|
||
| fun getData( | ||
| fromNewVersion: Version?, | ||
| toOldVersion: Version?, | ||
| limit: Int? = null | ||
| ): ArrayList<BulletinInfo> { | ||
| // val finalMap: MutableList<BulletinInfo> = mutableListOf() | ||
| val bulletinInfo = arrayListOf<BulletinInfo>() | ||
|
|
||
| if (fromNewVersion == null && toOldVersion == null && limit == null) { | ||
|
|
||
| bulletinInfo.addAll(data) | ||
| return bulletinInfo | ||
| } else if (fromNewVersion == null && toOldVersion == null && limit != null) { | ||
| bulletinInfo.addAll(data.take(limit)) | ||
| return bulletinInfo | ||
| } | ||
|
|
||
| val sortedList = data.sortedWith(compareBy({ | ||
| it.version.version | ||
| })) | ||
|
|
||
| for (indice in sortedList.indices) { | ||
|
|
||
| if (indice == 0) AppStorageHelper.shared.lastSeenVersion = | ||
| Version.init(sortedList[indice].version.version) | ||
| if (VersionUtil.versionCompare( | ||
| fromNewVersion?.version, | ||
| sortedList[indice].version.version | ||
| ) >= 0 | ||
| ) { | ||
| bulletinInfo.add(sortedList[indice]) | ||
| } else if (VersionUtil.versionCompare( | ||
| toOldVersion?.version, | ||
| sortedList[indice].version.version | ||
| ) < 0 | ||
| ) { | ||
| bulletinInfo.add(sortedList[indice]) | ||
| } | ||
|
|
||
| if (limit != null && bulletinInfo.size >= limit) break | ||
|
|
||
| } | ||
| return bulletinInfo | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be an application. This needs to be configured as a library.
Refer to
https://github.com/Codigami/CFAlertDialog/blob/master/cfalertdialog/build.gradle