Skip to content

Commit

Permalink
automatically restart the app after auto power off etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
obs1dium authored and obs1dium committed Mar 4, 2017
1 parent 1fa853c commit 54b424b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 10
buildToolsVersion "20.0.0"
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "com.obsidium.bettermanual"
minSdkVersion 10
targetSdkVersion 10
versionCode 6
versionName "1.4.1"
versionCode 7
versionName "1.5"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
public class BaseActivity extends Activity {
public static final String NOTIFICATION_DISPLAY_CHANGED = "NOTIFICATION_DISPLAY_CHANGED";

public static final String KEY_ACCESSORY_APO = "KEY_ACCESSORY_APO";
public static final String KEY_DEDICATED_APO = "KEY_DEDICATED_APO";
public static final String KEY_LENS_APO = "KEY_LENS_APO";
public static final String KEY_MEDIA_INOUT_APO = "KEY_MEDIA_INOUT_APO";
public static final String KEY_PLAY_APO = "KEY_PLAY_APO";
public static final String KEY_PLAY_PON = "KEY_PLAY_PON";
public static final String KEY_POWER_APO = "KEY_POWER_APO";
public static final String KEY_POWER_SLIDE_PON = "KEY_POWER_SLIDE_PON";
public static final String KEY_RELEASE_APO = "KEY_RELEASE_APO";

private DisplayManager displayManager;

@Override
Expand Down Expand Up @@ -211,7 +221,11 @@ protected void notifyAppInfo() {
intent.putExtra("class_name", getComponentName().getClassName());
//intent.putExtra("pkey", new String[] {});// either this or these two:
//intent.putExtra("pullingback_key", new String[] {});
//intent.putExtra("resume_key", new String[] {});
// Exit app when plugging camera into USB
intent.putExtra("pullingback_key", new String[] { "KEY_USB_CONNECT" });
// Automatically resume app after power off etc.
intent.putExtra("resume_key", new String[] { KEY_POWER_SLIDE_PON, KEY_RELEASE_APO, KEY_PLAY_APO,
KEY_MEDIA_INOUT_APO, KEY_LENS_APO, KEY_ACCESSORY_APO, KEY_DEDICATED_APO, KEY_POWER_APO, KEY_PLAY_PON });
sendBroadcast(intent);
}

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/obsidium/bettermanual/ManualActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,20 @@ protected boolean onShutterKeyDown()
return true;
}

@Override
protected boolean onDeleteKeyUp()
{
// Exiting, make sure the app isn't restarted
Intent intent = new Intent("com.android.server.DAConnectionManagerService.AppInfoReceive");
intent.putExtra("package_name", getComponentName().getPackageName());
intent.putExtra("class_name", getComponentName().getClassName());
intent.putExtra("pullingback_key", new String[] {});
intent.putExtra("resume_key", new String[] {});
sendBroadcast(intent);
onBackPressed();
return true;
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.3.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Sat Mar 04 13:20:02 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 comments on commit 54b424b

Please sign in to comment.