Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 54b424b

Browse files
obs1diumobs1dium
authored andcommitted
automatically restart the app after auto power off etc.
1 parent 1fa853c commit 54b424b

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 10
5-
buildToolsVersion "20.0.0"
5+
buildToolsVersion '25.0.2'
66

77
defaultConfig {
88
applicationId "com.obsidium.bettermanual"
99
minSdkVersion 10
1010
targetSdkVersion 10
11-
versionCode 6
12-
versionName "1.4.1"
11+
versionCode 7
12+
versionName "1.5"
1313
}
1414
buildTypes {
1515
release {

app/src/main/java/com/github/ma1co/pmcademo/app/BaseActivity.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
public class BaseActivity extends Activity {
1313
public static final String NOTIFICATION_DISPLAY_CHANGED = "NOTIFICATION_DISPLAY_CHANGED";
1414

15+
public static final String KEY_ACCESSORY_APO = "KEY_ACCESSORY_APO";
16+
public static final String KEY_DEDICATED_APO = "KEY_DEDICATED_APO";
17+
public static final String KEY_LENS_APO = "KEY_LENS_APO";
18+
public static final String KEY_MEDIA_INOUT_APO = "KEY_MEDIA_INOUT_APO";
19+
public static final String KEY_PLAY_APO = "KEY_PLAY_APO";
20+
public static final String KEY_PLAY_PON = "KEY_PLAY_PON";
21+
public static final String KEY_POWER_APO = "KEY_POWER_APO";
22+
public static final String KEY_POWER_SLIDE_PON = "KEY_POWER_SLIDE_PON";
23+
public static final String KEY_RELEASE_APO = "KEY_RELEASE_APO";
24+
1525
private DisplayManager displayManager;
1626

1727
@Override
@@ -211,7 +221,11 @@ protected void notifyAppInfo() {
211221
intent.putExtra("class_name", getComponentName().getClassName());
212222
//intent.putExtra("pkey", new String[] {});// either this or these two:
213223
//intent.putExtra("pullingback_key", new String[] {});
214-
//intent.putExtra("resume_key", new String[] {});
224+
// Exit app when plugging camera into USB
225+
intent.putExtra("pullingback_key", new String[] { "KEY_USB_CONNECT" });
226+
// Automatically resume app after power off etc.
227+
intent.putExtra("resume_key", new String[] { KEY_POWER_SLIDE_PON, KEY_RELEASE_APO, KEY_PLAY_APO,
228+
KEY_MEDIA_INOUT_APO, KEY_LENS_APO, KEY_ACCESSORY_APO, KEY_DEDICATED_APO, KEY_POWER_APO, KEY_PLAY_PON });
215229
sendBroadcast(intent);
216230
}
217231

app/src/main/java/com/obsidium/bettermanual/ManualActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,20 @@ protected boolean onShutterKeyDown()
19121912
return true;
19131913
}
19141914

1915+
@Override
1916+
protected boolean onDeleteKeyUp()
1917+
{
1918+
// Exiting, make sure the app isn't restarted
1919+
Intent intent = new Intent("com.android.server.DAConnectionManagerService.AppInfoReceive");
1920+
intent.putExtra("package_name", getComponentName().getPackageName());
1921+
intent.putExtra("class_name", getComponentName().getClassName());
1922+
intent.putExtra("pullingback_key", new String[] {});
1923+
intent.putExtra("resume_key", new String[] {});
1924+
sendBroadcast(intent);
1925+
onBackPressed();
1926+
return true;
1927+
}
1928+
19151929
@Override
19161930
public boolean onKeyDown(int keyCode, KeyEvent event)
19171931
{

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
jcenter()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.1.2'
6+
classpath 'com.android.tools.build:gradle:2.3.0'
77
}
88
}
99

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Dec 28 10:00:20 PST 2015
1+
#Sat Mar 04 13:20:02 CET 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 commit comments

Comments
 (0)