Skip to content

Commit

Permalink
Merge pull request #8 from eszdman/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eszdman committed Jun 29, 2020
2 parents c4d46c1 + afec436 commit 84f5104
Show file tree
Hide file tree
Showing 90 changed files with 4,054 additions and 1,046 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
/app/google-services.json
/.idea/codeStyles/Project.xml
30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 53 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,66 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

android {
def versionPropsFile = file('version.properties')
def versionBuild
compileSdkVersion 29
buildToolsVersion "29.0.3"
ndkVersion "21.1.6352462"
lintOptions {
abortOnError false
}

if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionBuild = versionProps['VERSION_BUILD'].toInteger()
} else {
throw new FileNotFoundException("Could not read version.properties!")
}

ext.autoIncrementBuildNumber = {
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionBuild = versionProps['VERSION_BUILD'].toInteger() + 1
versionProps['VERSION_BUILD'] = versionBuild.toString()
versionProps.store(versionPropsFile.newWriter(), null)
} else {
throw new FileNotFoundException("Could not read version.properties!")
}
}

defaultConfig {
applicationId 'com.eszdman.photoncamera'
minSdkVersion 26
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
renderscriptTargetApi 24
renderscriptSupportModeEnabled false
versionCode versionCode
versionName '0.3'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "arm64-v8a"
}
}

gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(assembleDebug)) {
autoIncrementBuildNumber()
} else if (taskGraph.hasTask(assembleRelease)) {
autoIncrementBuildNumber()
}
}

buildTypes {
release {
minifyEnabled true
shrinkResources true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
jniDebuggable = true
}
debug {
minifyEnabled false
Expand All @@ -33,6 +70,12 @@ android {
renderscriptDebuggable = true
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -45,6 +88,8 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-perf:19.0.7'
implementation 'androidx.preference:preference:1.1.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand All @@ -53,4 +98,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.mohammadatif:Animatoo:master'
implementation 'org.jocl:jocl:2.0.2'
implementation 'com.github.ChickenHook:RestrictionBypass:2.2'
implementation 'com.google.firebase:firebase-analytics:17.4.3'
implementation 'com.google.firebase:firebase-crashlytics-ndk:17.0.1'
}
13 changes: 9 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:isGame="true"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher"
android:roundIcon="@drawable/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.SettingsActivity"></activity>
android:theme="@style/AppTheme"
>
<activity android:name=".ui.SettingsActivity" />
<activity android:name=".ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="firebase_performance_logcat_enabled"
android:value="true" />
</application>

</manifest>
44 changes: 44 additions & 0 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
native-photon_accel

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
native-lib.cpp )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
set_target_properties(native-photon_accel PROPERTIES OUTPUT_NAME "photon_accel")
target_link_libraries( # Specifies the target library.
native-photon_accel

# Links the target library to the log library
# included in the NDK.
${log-lib} )
16 changes: 16 additions & 0 deletions app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <jni.h>
#include <string>
#include <android/log.h>
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "photon_native", __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "photon_native", __VA_ARGS__)
extern "C"
JNIEXPORT void JNICALL
Java_com_eszdman_photoncamera_Wrapper_Test(JNIEnv *env, jclass clazz) {
LOGD("Yeah, working");
}
extern "C"
JNIEXPORT jobject JNICALL
Java_com_eszdman_photoncamera_Wrapper_ProcessOpenCL(JNIEnv *env, jclass clazz, jobject in) {
// TODO: implement ProcessOpenCL()

}
Binary file removed app/src/main/ic_launcher-playstore.png
Binary file not shown.
71 changes: 71 additions & 0 deletions app/src/main/java/com/eszdman/photoncamera/Control/Gravity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.eszdman.photoncamera.Control;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;

import com.eszdman.photoncamera.api.Interface;

import java.nio.IntBuffer;

public class Gravity {
private static String TAG = "Gravity";
private SensorManager mSensorManager;
private Sensor mGravitySensor;
public float[] mGravity;


public Gravity(){
mSensorManager = (SensorManager) Interface.i.mainActivity.getSystemService(Context.SENSOR_SERVICE);
mGravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);

}
public void run(){
mSensorManager.registerListener(mGravityTracker,mGravitySensor,SensorManager.SENSOR_DELAY_FASTEST);
}
public void stop(){
mSensorManager.unregisterListener(mGravityTracker,mGravitySensor);
}
private SensorEventListener mGravityTracker = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (mGravity == null) {
mGravity = sensorEvent.values.clone();
}

for (int i = 0; i < sensorEvent.values.length; i++) {
mGravity[i] = sensorEvent.values[i];
}
}

@Override
public void onAccuracyChanged(Sensor sensor, int i) { }
};
public int getRotation() {

if (mGravity == null) {
return 90;
}
for(float f:mGravity) Log.d(TAG,"gravity:"+f);
if (mGravity[2] > 9f) //pointing at the ground
return 90;

if (Math.abs(mGravity[0]) > Math.abs(mGravity[1])) {
if (mGravity[0] > 0f)
return 0;
else
return 180;
} else {
if (mGravity[1] > 1.5f)
return 90;
else
return 270;
}
}
public int getCameraRotation(){
return (Interface.i.camera.mSensorOrientation+Interface.i.gravity.getRotation()+270) % 360;
}
}
Loading

0 comments on commit 84f5104

Please sign in to comment.