Skip to content

Commit 51b0041

Browse files
author
Muralidharan Ramasamy
committed
initial version
0 parents  commit 51b0041

Some content is hidden

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

46 files changed

+1738
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

app/.gitignore

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

app/build.gradle

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
id 'com.google.gms.google-services'
5+
}
6+
check.dependsOn 'assembleDebugAndroidTest'
7+
8+
android {
9+
compileSdk 33
10+
11+
defaultConfig {
12+
applicationId "com.sample.pnfpbandroid"
13+
minSdk 21
14+
targetSdk 33
15+
versionCode 3
16+
versionName "1.2"
17+
multiDexEnabled true
18+
19+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
packagingOptions {
29+
resources {
30+
excludes += ['LICENSE.txt']
31+
}
32+
}
33+
34+
35+
buildFeatures {
36+
viewBinding = true
37+
}
38+
//lint {
39+
// abortOnError false
40+
//}
41+
compileOptions {
42+
sourceCompatibility JavaVersion.VERSION_11
43+
targetCompatibility JavaVersion.VERSION_11
44+
}
45+
namespace 'com.sample.pnfpbandroid'
46+
}
47+
48+
dependencies {
49+
// implementation project(":internal:lintchecks")
50+
//implementation project(":internal:chooserx")
51+
implementation 'androidx.annotation:annotation:1.5.0'
52+
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
53+
implementation 'androidx.core:core-ktx:1.9.0'
54+
55+
// Required when asking for permission to post notifications (starting in Android 13)
56+
implementation 'androidx.activity:activity-ktx:1.6.1'
57+
implementation 'androidx.fragment:fragment-ktx:1.5.5'
58+
59+
implementation 'com.google.android.material:material:1.7.0'
60+
61+
// Import the Firebase BoM (see: https://firebase.google.com/docs/android/learn-more#bom)
62+
implementation platform('com.google.firebase:firebase-bom:31.1.0')
63+
64+
// Firebase Cloud Messaging (Java)
65+
implementation 'com.google.firebase:firebase-messaging'
66+
67+
// Firebase Cloud Messaging (Kotlin)
68+
implementation 'com.google.firebase:firebase-messaging-ktx'
69+
70+
// For an optimal experience using FCM, add the Firebase SDK
71+
// for Google Analytics. This is recommended, but not required.
72+
implementation 'com.google.firebase:firebase-analytics'
73+
74+
implementation 'androidx.security:security-crypto:1.1.0-alpha05'
75+
76+
implementation 'com.google.firebase:firebase-installations-ktx:17.1.0'
77+
78+
implementation 'androidx.work:work-runtime:2.7.1'
79+
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
80+
81+
// Testing dependencies
82+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
83+
androidTestImplementation 'androidx.test:runner:1.5.2'
84+
androidTestImplementation 'androidx.test:rules:1.5.0'
85+
androidTestImplementation 'androidx.annotation:annotation:1.5.0'
86+
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
87+
88+
}

app/google-services.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}

app/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<dependency>
2+
<groupId>org.apache.httpcomponents</groupId>
3+
<artifactId>httpclient</artifactId>
4+
<version>4.5.10</version>
5+
</dependency>

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.sample.pnfpbandroid;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.sample.pnfpbandroid", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
9+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:dataExtractionRules="@xml/data_extraction_rules"
14+
android:fullBackupContent="@xml/backup_rules"
15+
android:icon="@mipmap/ic_launcher"
16+
android:label="@string/app_name"
17+
android:roundIcon="@mipmap/ic_launcher_round"
18+
android:supportsRtl="true"
19+
android:theme="@style/Theme.PnfpbAndroid"
20+
tools:targetApi="31">
21+
<!-- [START fcm_default_icon] -->
22+
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
23+
See README(https://goo.gl/l4GJaQ) for more. -->
24+
<meta-data
25+
android:name="com.google.firebase.messaging.default_notification_icon"
26+
android:resource="@mipmap/ic_launcher_round" />
27+
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
28+
notification message. See README(https://goo.gl/6BKBk7) for more. -->
29+
<!--meta-data
30+
android:name="com.google.firebase.messaging.default_notification_color"
31+
android:resource="@color/colorAccent" / -->
32+
<!-- [END fcm_default_icon] -->
33+
<!-- [START fcm_default_channel] -->
34+
<meta-data
35+
android:name="com.google.firebase.messaging.default_notification_channel_id"
36+
android:value="@string/default_notification_channel_id" />
37+
<!-- [END fcm_default_channel] -->
38+
<!-- [START fcm_disable_auto_init] -->
39+
<meta-data
40+
android:name="firebase_messaging_auto_init_enabled"
41+
android:value="false" />
42+
<meta-data
43+
android:name="firebase_analytics_collection_enabled"
44+
android:value="false" />
45+
<!-- [END fcm_disable_auto_init] -->
46+
<activity
47+
android:name="com.sample.pnfpbandroid.MainActivity"
48+
android:exported="true">
49+
<intent-filter>
50+
<action android:name="android.intent.action.MAIN" />
51+
52+
<category android:name="android.intent.category.LAUNCHER" />
53+
</intent-filter>
54+
</activity>
55+
<!-- [START firebase_service] -->
56+
<service
57+
android:name="com.sample.pnfpbandroid.MyFirebaseMessagingService"
58+
android:exported="false">
59+
<intent-filter>
60+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
61+
</intent-filter>
62+
</service>
63+
<!-- [END firebase_service] -->
64+
</application>
65+
66+
</manifest>
Loading

app/src/main/assets/img/gone.png

81.3 KB
Loading

app/src/main/assets/lost.html

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Connection Failed</title>
8+
<style>
9+
body {
10+
display: inline-block;
11+
background: #FFFFFF url('img/aquarium-android-app-icon.png') center/cover no-repeat;
12+
background-size: 300px;
13+
height: 10vh;
14+
margin: .3em;
15+
color: white;
16+
}
17+
18+
h1 {
19+
margin: .8em 3rem;
20+
font: 4em Roboto;
21+
}
22+
p {
23+
display: inline-block;
24+
margin: .2em 3rem;
25+
font: 2em Roboto;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<h2 style="text-align:center;padding:5px;color:#000000;">The network failed</h2>
31+
<h2 style="text-align:center;padding:5px;color:#000000;margin-top:20em;">Check your network connection and swipe to refresh </h2>
32+
33+
</body>
34+
</html>
721 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.sample.pnfpbandroid;
2+
3+
import android.content.Context;
4+
import android.content.SharedPreferences;
5+
import android.os.Build;
6+
import android.security.keystore.KeyGenParameterSpec;
7+
import android.security.keystore.KeyProperties;
8+
9+
import androidx.annotation.RequiresApi;
10+
import androidx.security.crypto.MasterKey;
11+
12+
import java.io.IOException;
13+
import java.security.GeneralSecurityException;
14+
15+
public class EncryptedDataHolder {
16+
17+
private static final String KEY_API_KEY = "api_key";
18+
private static final String KEY_STORE_ALIAS = "ANEncryptedSharedPreferences";
19+
20+
private SharedPreferences pref;
21+
private SharedPreferences.Editor editor;
22+
23+
24+
@RequiresApi(api = Build.VERSION_CODES.M)
25+
private KeyGenParameterSpec createKeyGenParameterSpec() {
26+
return new KeyGenParameterSpec.Builder(
27+
KEY_STORE_ALIAS,
28+
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT
29+
).setBlockModes(KeyProperties.BLOCK_MODE_GCM)
30+
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
31+
.setKeySize(256)
32+
.build();
33+
}
34+
35+
@RequiresApi(api = Build.VERSION_CODES.M)
36+
private MasterKey getMasterKey(Context context, KeyGenParameterSpec keyGenParameterSpec) throws GeneralSecurityException, IOException {
37+
return new MasterKey.Builder(context, KEY_STORE_ALIAS)
38+
.setKeyGenParameterSpec(keyGenParameterSpec)
39+
.build();
40+
}
41+
42+
@RequiresApi(api = Build.VERSION_CODES.M)
43+
public EncryptedDataHolder(Context context) {
44+
try {
45+
pref = androidx.security.crypto.EncryptedSharedPreferences.create(
46+
context,
47+
KEY_STORE_ALIAS,
48+
getMasterKey(context, createKeyGenParameterSpec()),
49+
androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
50+
androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
51+
);
52+
editor = pref.edit();
53+
editor.apply();
54+
} catch (GeneralSecurityException | IOException e) {
55+
e.printStackTrace();
56+
}
57+
58+
}
59+
60+
public String getApiKey() {
61+
return pref.getString(KEY_API_KEY, "");
62+
}
63+
64+
public void setApiKey(String apiKey) {
65+
editor.putString(KEY_API_KEY, apiKey);
66+
editor.apply();
67+
editor.commit();
68+
}
69+
70+
}

0 commit comments

Comments
 (0)