-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1a94d9f
Showing
63 changed files
with
3,667 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*.iml | ||
.gradle | ||
**.apk | ||
**/.idea | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
*logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
applicationId "com.neilyxin.blinder_android" | ||
minSdk 21 | ||
targetSdk 31 | ||
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_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
namespace 'com.neilyxin.blinder_android' | ||
} | ||
repositories { | ||
} | ||
dependencies { | ||
// implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly-SNAPSHOT' | ||
implementation 'org.pytorch:pytorch_android:1.12' | ||
implementation 'org.pytorch:pytorch_android_torchvision:1.12' | ||
implementation 'androidx.appcompat:appcompat:1.3.0' | ||
implementation 'com.google.android.material:material:1.4.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
26 changes: 26 additions & 0 deletions
26
...ndroid/app/src/androidTest/java/com/neilyxin/blinder_android/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.neilyxin.blinder_android; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.example.anonymization_android", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<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/Theme.Anonymization_Android"> | ||
<activity | ||
android:name="com.neilyxin.blinder_android.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
117 changes: 117 additions & 0 deletions
117
Blinder-Android/app/src/main/java/com/neilyxin/blinder_android/CircularArrayList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.neilyxin.blinder_android; | ||
|
||
import android.util.Log; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* Source: http://www.museful.net/2012/software-development/circulararraylist-for-java | ||
* | ||
* If you use this code, please consider notifying isak at du-preez dot com | ||
* with a brief description of your application. | ||
* <p> | ||
* This is free and unencumbered software released into the public domain. | ||
* Anyone is free to copy, modify, publish, use, compile, sell, or | ||
* distribute this software, either in source code form or as a compiled | ||
* binary, for any purpose, commercial or non-commercial, and by any | ||
* means. | ||
* <p> | ||
* -------- | ||
* Example: | ||
* if(buf.size()==buf.capacity()){ | ||
* buf.remove(0); | ||
* } | ||
* buf.add(e); | ||
* --------- | ||
*/ | ||
|
||
public class CircularArrayList<E> | ||
extends AbstractList<E> implements RandomAccess { | ||
|
||
private final int n; // buffer length | ||
private final List<E> buf; // a List implementing RandomAccess | ||
private int head = 0; | ||
private int tail = 0; | ||
|
||
public CircularArrayList(int capacity) { | ||
n = capacity + 1; | ||
buf = new ArrayList<E>(Collections.nCopies(n, (E) null)); | ||
} | ||
|
||
public int capacity() { | ||
return n - 1; | ||
} | ||
|
||
private int wrapIndex(int i) { | ||
int m = i % n; | ||
if (m < 0) { // java modulus can be negative | ||
m += n; | ||
} | ||
return m; | ||
} | ||
|
||
// This method is O(n) but will never be called if the | ||
// CircularArrayList is used in its typical/intended role. | ||
private void shiftBlock(int startIndex, int endIndex) { | ||
assert (endIndex > startIndex); | ||
for (int i = endIndex - 1; i >= startIndex; i--) { | ||
set(i + 1, get(i)); | ||
} | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return tail - head + (tail < head ? n : 0); | ||
} | ||
|
||
@Override | ||
public E get(int i) { | ||
if (i < 0 || i >= size()) { | ||
Log.e("CircularArrayList: ", "Index: " + i); | ||
throw new IndexOutOfBoundsException(); | ||
} | ||
return buf.get(wrapIndex(head + i)); | ||
} | ||
|
||
@Override | ||
public E set(int i, E e) { | ||
if (i < 0 || i >= size()) { | ||
throw new IndexOutOfBoundsException(); | ||
} | ||
return buf.set(wrapIndex(head + i), e); | ||
} | ||
|
||
@Override | ||
public void add(int i, E e) { | ||
int s = size(); | ||
if (s == n - 1) { | ||
throw new IllegalStateException( | ||
"CircularArrayList is filled to capacity. " | ||
+ "(You may want to remove from front" | ||
+ " before adding more to back.)"); | ||
} | ||
if (i < 0 || i > s) { | ||
throw new IndexOutOfBoundsException(); | ||
} | ||
tail = wrapIndex(tail + 1); | ||
if (i < s) { | ||
shiftBlock(i, s); | ||
} | ||
set(i, e); | ||
} | ||
|
||
@Override | ||
public E remove(int i) { | ||
int s = size(); | ||
if (i < 0 || i >= s) { | ||
throw new IndexOutOfBoundsException(); | ||
} | ||
E e = get(i); | ||
if (i > 0) { | ||
shiftBlock(0, i); | ||
} | ||
head = wrapIndex(head + 1); | ||
return e; | ||
} | ||
|
||
} |
Oops, something went wrong.