Skip to content

Commit

Permalink
Merge pull request #62 from om26er/master
Browse files Browse the repository at this point in the history
Use the new super fast ezflashlight
  • Loading branch information
surc-bot committed Mar 31, 2015
2 parents c92e65b + 9f78234 commit 3b65050
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ezflashlight-0.8.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ezflashlight-0.8" level="project" />
</component>
</module>

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ repositories {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.byteshaft.ezflashlight:ezflashlight:0.8@aar'
compile 'com.byteshaft.ezflashlight:ezflashlight:0.8.5@aar'
}
Binary file not shown.
20 changes: 6 additions & 14 deletions app/src/main/java/com/byteshaft/neon/FlashlightService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
String starter = intent.getStringExtra("STARTER");
Log.i(AppGlobals.LOG_TAG, String.format("Service started from %s", starter));
AUTOSTART = intent.getBooleanExtra("AUTOSTART", true);
mFlashlight.setOnCameraStateChangedListener(this);
mFlashlight.initializeCamera();
mFlashlight.setCameraStateChangedListener(this);
mFlashlight.setupCameraPreview();
return START_NOT_STICKY;
}

Expand Down Expand Up @@ -97,6 +97,7 @@ public IBinder onBind(Intent intent) {

synchronized void lightenTorch() {
Log.i(AppGlobals.LOG_TAG, "Turning on");
mRemoteUi.setUiButtonsOn(true);
/* Make is foreground service by showing a Notification,
this ensures the service does not get killed on low resources.
Unless the situation is really really bad.
Expand All @@ -108,12 +109,14 @@ synchronized void lightenTorch() {

synchronized void stopTorch() {
Log.i(AppGlobals.LOG_TAG, "Turning off");
mRemoteUi.setUiButtonsOn(false);
stopForeground(true);
mFlashlight.turnOff();
AppGlobals.setIsWidgetTapped(false);
}

@Override
public void onCameraOpened() {
public void onCameraInitialized() {

}

Expand All @@ -139,15 +142,4 @@ public void onCameraBusy() {
}
stopSelf();
}

@Override
public void onFlashlightTurnedOn() {
mRemoteUi.setUiButtonsOn(true);
}

@Override
public void onFlashlightTurnedOff() {
mRemoteUi.setUiButtonsOn(false);
AppGlobals.setIsWidgetTapped(false);
}
}
17 changes: 3 additions & 14 deletions app/src/main/java/com/byteshaft/neon/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,15 @@ public void onClick(View view) {
switch (view.getId()) {
case R.id.switcher:
if (!FlashlightGlobals.isFlashlightOn()) {
mRemoteUi.setUiButtonsOn(true);
if (!FlashlightService.isRunning()) {
mRemoteUi.setUiButtonsOn(true);
mHelpers.startFlashlightServiceWithFlashlightOn(true);
} else {
new Thread(new Runnable() {
@Override
public void run() {
FlashlightService.getInstance().lightenTorch();
}
}).start();
FlashlightService.getInstance().lightenTorch();
}
AppGlobals.setIsWidgetTapped(false);
} else {
mRemoteUi.setUiButtonsOn(false);
new Thread(new Runnable() {
@Override
public void run() {
FlashlightService.getInstance().stopTorch();
}
}).start();
FlashlightService.getInstance().stopTorch();
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/byteshaft/neon/WidgetReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ public void onReceive(final Context context, Intent intent) {
serviceIntent.putExtra("STARTER", STARTER);
context.startService(serviceIntent);
} else if (FlashlightGlobals.isFlashlightOn()) {
remoteUi.setUiButtonsOn(false);
FlashlightService.getInstance().stopTorch();
sTimer.schedule(serviceTimerTask, SERVICE_SHUTDOWN_DELAY);
} else {
cancelServiceStopTimer();
remoteUi.setUiButtonsOn(true);
FlashlightService.getInstance().lightenTorch();
}
}
Expand Down

0 comments on commit 3b65050

Please sign in to comment.