Skip to content

Commit 8cfddc1

Browse files
committed
support conceal v2.0
1 parent 2262829 commit 8cfddc1

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<b>Project :</b> Secure Android SharedPreferences Using Conceal Crypto by Facebook<br>
33
<b>Description </b>
44
<br>
5-
Conceal provides a set of Java APIs to perform cryptography on Android. It was designed to be able to encrypt large files on disk in a fast and memory efficient manner. Implementation on SharedPreferences of Android would be great data Encryption and Decryption.
5+
Conceal provides a set of Java APIs to perform cryptography on Android. It was designed to be able to encrypt large files on disk in a fast and memory efficient manner. Implementation on SharedPreferences of Android would be great data Encryption and Decryption. Currently supported Facebook Conceal V2.0
66

77
## Installation
88

99
Gradle
1010
```gradle
1111
dependencies {
12-
compile 'com.github.afiqiqmal:ConcealSharedPreference-Android:1.2.1'
12+
compile 'com.github.afiqiqmal:ConcealSharedPreference-Android:1.3.0'
1313
}
1414
```
1515

@@ -18,7 +18,7 @@ Maven
1818
<dependency>
1919
<groupId>com.github.afiqiqmal</groupId>
2020
<artifactId>ConcealSharedPreference-Android</artifactId>
21-
<version>1.2.0</version>
21+
<version>1.3.0</version>
2222
</dependency>
2323
```
2424

@@ -28,6 +28,14 @@ Maven
2828

2929
## Usage
3030

31+
#### First of All
32+
33+
it needed to first init in Application class in `oncreate` method or on Base Activity Class. or everything is not working =D
34+
```java
35+
ConcealPrefRepository.applicationInit(this, false);
36+
```
37+
38+
3139
Permission need to use in your project. Please Allow it first, or it will affect .putImage and .putFile method
3240
```xml
3341
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

app/src/main/java/com/zeroone/concealexample/MainActivity.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,7 @@ protected void onCreate(Bundle savedInstanceState) {
3030
super.onCreate(savedInstanceState);
3131
setContentView(R.layout.activity_main);
3232

33-
File getFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/.files/here.pdf");
34-
//
35-
// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
36-
// || ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
37-
//
38-
// Log.d("TAG","bye2");
39-
// return;
40-
// }
41-
33+
ConcealPrefRepository.applicationInit(getApplication(), false);
4234

4335
new ConcealPrefRepository.Editor()
4436
.putString(NAME_KEY, "Hafiq Iqmal")

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ android {
2222

2323
dependencies {
2424
compile fileTree(dir: 'libs', include: ['*.jar'])
25-
compile 'com.facebook.conceal:conceal:1.1.3@aar'
25+
compile 'com.facebook.conceal:conceal:2.0.1@aar'
2626
compile 'com.android.support:support-annotations:26.1.0'
2727
}

library/src/main/java/com/zeroone/conceal/ConcealPrefRepository.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.Manifest;
44
import android.annotation.SuppressLint;
5+
import android.app.Application;
56
import android.content.Context;
67
import android.content.SharedPreferences;
78
import android.graphics.Bitmap;
@@ -14,6 +15,7 @@
1415
import android.support.annotation.StringRes;
1516

1617
import com.facebook.crypto.CryptoConfig;
18+
import com.facebook.soloader.SoLoader;
1719
import com.zeroone.conceal.model.CryptoFile;
1820

1921
import java.io.File;
@@ -82,6 +84,19 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
8284
}
8385
}
8486

87+
88+
/***
89+
* Since Conceal facebook v2.0.+ (2017-06-27) you will need to initialize the native library loader.
90+
* This step is needed because the library loader uses the context.
91+
* The highly suggested way to do it is in the application class onCreate method like this:
92+
* @param application
93+
* @param type
94+
*/
95+
96+
public static void applicationInit(Application application, boolean type){
97+
SoLoader.init(application, type);
98+
}
99+
85100
/**********************
86101
* DESTROY FILES
87102
**********************/

0 commit comments

Comments
 (0)