Skip to content

Commit

Permalink
Merge pull request #314 from guardianproject/dev-cameraviewplus
Browse files Browse the repository at this point in the history
Dev cameraviewplus
  • Loading branch information
n8fr8 authored Jul 17, 2018
2 parents 3a8b2e6 + c22ecae commit 9ff8b02
Show file tree
Hide file tree
Showing 21 changed files with 1,417 additions and 765 deletions.
21 changes: 16 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ android {

defaultConfig {
applicationId "org.havenapp.main"
versionCode 113
versionCode 116
versionName getVersionName()
archivesBaseName = "Haven-$versionName"
minSdkVersion 16
Expand All @@ -80,8 +80,15 @@ android {
}
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi 16
renderscriptSupportModeEnabled true

ndk {
abiFilters "armeabi", "armeabi-v7a", "x86"
}
}


buildTypes {
release {
minifyEnabled false
Expand All @@ -100,20 +107,20 @@ android {
}

dependencies {
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.github.guardianproject:signal-cli-android:-SNAPSHOT'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.guardianproject:signal-cli-android:v0.6.0-android-beta-1'
implementation 'com.github.satyan:sugar:1.5'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'net.the4thdimension:audio-wife:1.0.3'
implementation 'com.github.apl-devs:appintro:v4.2.3'
implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
implementation 'com.nanohttpd:nanohttpd-webserver:2.2.0'
implementation 'me.angrybyte.picker:picker:1.3.1'
implementation 'com.github.stfalcon:frescoimageviewer:0.5.0'
implementation 'com.facebook.fresco:fresco:1.8.1'
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'com.github.derlio.waveform:library:1.0.1'
implementation 'org.firezenk:audiowaves:1.1@aar'
implementation 'com.maxproj.simplewaveform:app:1.0.0'
Expand All @@ -123,5 +130,9 @@ dependencies {
implementation('com.mikepenz:aboutlibraries:6.0.2@aar') {
transitive = true
}
implementation 'com.asksira.android:cameraviewplus:0.9.4'
implementation 'com.github.halilozercan:BetterVideoPlayer:1.1.0'
implementation 'io.github.silvaren:easyrs:0.5.3'
implementation 'org.jcodec:jcodec:0.2.3'
implementation 'org.jcodec:jcodec-android:0.2.3'
}
21 changes: 19 additions & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@
android:screenOrientation="portrait" />
<activity
android:name=".MonitorActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop" />
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges=
"screenSize|smallestScreenSize|screenLayout|orientation"
/>
<activity
android:name=".ui.VideoPlayerActivity"
android:configChanges="orientation|keyboardHidden|screenLayout|screenSize"
Expand Down Expand Up @@ -103,6 +108,7 @@
android:configChanges="orientation|screenSize|keyboardHidden" />
<activity
android:name=".ui.CameraConfigureActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|keyboardHidden" />

<receiver android:name=".sensors.PowerConnectionReceiver">
Expand All @@ -111,6 +117,17 @@
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="org.havenapp.main.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>

</application>

</manifest>
25 changes: 18 additions & 7 deletions src/main/java/org/havenapp/main/HavenApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import android.util.Log;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig;
import com.orm.SugarContext;

import java.io.IOException;
Expand All @@ -44,26 +46,35 @@ public class HavenApp extends MultiDexApplication {
public void onCreate() {
super.onCreate();

SugarContext.init(this);

mPrefs = new PreferenceManager(this);

Fresco.initialize(this);
SugarContext.init(this);
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
.setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
.setResizeAndRotateEnabledForNetwork(true)
.setDownsampleEnabled(true)
.build();

Fresco.initialize(this,config);

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

if (mPrefs.getRemoteAccessActive())
startServer();

}


public void startServer ()
{
if (mOnionServer == null || (!mOnionServer.isAlive()))
{
try {
mOnionServer = new WebServer(this, mPrefs.getRemoteAccessCredential());
} catch (IOException ioe) {
Log.e("OnioNServer", "unable to start onion server", ioe);
if ( mPrefs.getRemoteAccessCredential() != null) {
try {
mOnionServer = new WebServer(this, mPrefs.getRemoteAccessCredential());
} catch (IOException ioe) {
Log.e("OnioNServer", "unable to start onion server", ioe);
}
}
}
}
Expand Down
44 changes: 15 additions & 29 deletions src/main/java/org/havenapp/main/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,19 @@ public void onItemClick(View view, int position) {
private void deleteEvent (final Event event, final int position)
{

final Runnable runnableDelete = new Runnable ()
{
public void run ()
{
event.delete();
}
};

handler.postDelayed(runnableDelete,3000);
final Runnable runnableDelete = () -> event.delete();

handler.postDelayed(runnableDelete,5000);
events.remove(position);
adapter.notifyItemRemoved(position);

event.delete();

Snackbar.make(recyclerView, getString(R.string.event_deleted), Snackbar.LENGTH_SHORT)
.setAction(getString(R.string.undo), new View.OnClickListener() {
@Override
public void onClick(View v) {
handler.removeCallbacks(runnableDelete);
event.save();
events.add(position, event);
adapter.notifyItemInserted(position);
}
.setAction(getString(R.string.undo), v -> {
handler.removeCallbacks(runnableDelete);
event.save();
events.add(position, event);
adapter.notifyItemInserted(position);
recyclerView.scrollToPosition(position);
})
.show();
}
Expand Down Expand Up @@ -343,16 +332,13 @@ public void run ()
handler.postDelayed(runnableDelete, 3000);

Snackbar.make(recyclerView, getString(R.string.events_deleted), Snackbar.LENGTH_SHORT)
.setAction(getString(R.string.undo), new View.OnClickListener() {
@Override
public void onClick(View v) {
handler.removeCallbacks(runnableDelete);

for (Event event : removedEvents) {
event.save();
events.add(event);
adapter.notifyItemInserted(events.size() - 1);
}
.setAction(getString(R.string.undo), v -> {
handler.removeCallbacks(runnableDelete);

for (Event event : removedEvents) {
event.save();
events.add(event);
adapter.notifyItemInserted(events.size() - 1);
}
})
.show();
Expand Down
53 changes: 44 additions & 9 deletions src/main/java/org/havenapp/main/MonitorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Environment;
Expand Down Expand Up @@ -186,10 +188,13 @@ private void updateTimerValue(int val) {

private void doCancel() {

boolean wasTimer = false;

if (cTimer != null) {
cTimer.cancel();
cTimer = null;
mOnTimerTicking = false;
wasTimer = true;
}

if (mIsMonitoring) {
Expand All @@ -205,10 +210,25 @@ private void doCancel() {

int timeM = preferences.getTimerDelay() * 1000;
txtTimer.setText(getTimerText(timeM));

if (!wasTimer)
finish();
}

}

@Override
public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) {
if (isInPictureInPictureMode) {
// Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.
findViewById(R.id.buttonBar).setVisibility(View.GONE);
} else {
// Restore the full-screen UI.
findViewById(R.id.buttonBar).setVisibility(View.VISIBLE);

}
}

private void showSettings() {

Intent i = new Intent(this, SettingsActivity.class);
Expand All @@ -233,7 +253,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
else if (requestCode == REQUEST_CAMERA)
{
mFragmentCamera.resetCamera();
mFragmentCamera.initCamera();
}
}

Expand Down Expand Up @@ -288,21 +308,36 @@ private void initMonitor() {

}

/**
* Closes the monitor activity and unset session properties
*/
private void close() {

finish();

@Override
public void onUserLeaveHint () {
if (mIsMonitoring) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
enterPictureInPictureMode();
}
}
}

/**
* When user closes the activity
*/
@Override
public void onBackPressed() {
close();

if (mIsMonitoring) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
enterPictureInPictureMode();
}
else
{
finish();
}
}
else
{
finish();
}


}

private void showTimeDelayDialog() {
Expand Down
Loading

0 comments on commit 9ff8b02

Please sign in to comment.