Commit 95cef713 by Kim Jinsung

1.ホームアプリとしての使用するように仕様変更

2.ログ出力判断処理変更
3.アプリ自動起動(BroadcastReceiver)処理変更
parent 1040d40c
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"> android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT"/>
<!-- The following two intent-filters are the key to set homescreen --> <!-- The following two intent-filters are the key to set homescreen -->
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
...@@ -33,10 +35,10 @@ ...@@ -33,10 +35,10 @@
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/> android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
<receiver android:name=".receiver.OnBootReceiver"> <receiver android:enabled="true" android:name=".receiver.OnBootReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</receiver> </receiver>
</application> </application>
......
...@@ -27,12 +27,10 @@ public class ToiletApplication extends Application { ...@@ -27,12 +27,10 @@ public class ToiletApplication extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
// Logger logger = new Logger(); Logger logger = new Logger();
// File downloadFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); File downloadFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
// String logPath = downloadFilePath.getPath() + "/" + APP_LOG_PATH; String logPath = downloadFilePath.getPath() + "/" + APP_LOG_PATH;
// logger.setLogPathFormat(logPath); logger.setLogPathFormat(logPath);
// FileUtil.createParentDirectory(logPath);
Logger.i(TAG, "onCreate"); Logger.i(TAG, "onCreate");
} }
...@@ -56,6 +54,9 @@ public class ToiletApplication extends Application { ...@@ -56,6 +54,9 @@ public class ToiletApplication extends Application {
} }
} }
public Timer getUpdateToiletInfoTimer() {
return updateToiletInfoTimer;
}
public boolean isForeground(Context context) { public boolean isForeground(Context context) {
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
assert am != null; assert am != null;
......
...@@ -17,6 +17,7 @@ public class Logger extends AbstractLogger { ...@@ -17,6 +17,7 @@ public class Logger extends AbstractLogger {
private static String logPathFormat; private static String logPathFormat;
private String currentDay; private String currentDay;
private int retentionPeriod = 1; private int retentionPeriod = 1;
private static boolean isLog = false;
public Logger() { public Logger() {
} }
...@@ -27,6 +28,7 @@ public class Logger extends AbstractLogger { ...@@ -27,6 +28,7 @@ public class Logger extends AbstractLogger {
public void setLogPathFormat(String logPathFormat) { public void setLogPathFormat(String logPathFormat) {
this.logPathFormat = logPathFormat; this.logPathFormat = logPathFormat;
if (isLog) FileUtil.createParentDirectory(logPathFormat);
} }
public static void setLogger(AbstractLogger abstractLogger) { public static void setLogger(AbstractLogger abstractLogger) {
...@@ -68,6 +70,7 @@ public class Logger extends AbstractLogger { ...@@ -68,6 +70,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void d(String tag, String log) { public static void d(String tag, String log) {
Log.d(tag,log);
if (isDebugEnabled()) { if (isDebugEnabled()) {
logger.debug(tag, log); logger.debug(tag, log);
} }
...@@ -84,6 +87,7 @@ public class Logger extends AbstractLogger { ...@@ -84,6 +87,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void d(String tag, String log, Throwable t) { public static void d(String tag, String log, Throwable t) {
Log.d(tag,log, t);
if (isDebugEnabled()) { if (isDebugEnabled()) {
logger.debug(tag, log, t); logger.debug(tag, log, t);
} }
...@@ -94,6 +98,7 @@ public class Logger extends AbstractLogger { ...@@ -94,6 +98,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void i(String tag, String log) { public static void i(String tag, String log) {
Log.i(tag,log);
if (isInfoEnabled()) { if (isInfoEnabled()) {
logger.info(tag, log); logger.info(tag, log);
} }
...@@ -110,6 +115,7 @@ public class Logger extends AbstractLogger { ...@@ -110,6 +115,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void i(String tag, String log, Throwable t) { public static void i(String tag, String log, Throwable t) {
Log.i(tag,log, t);
if (isInfoEnabled()) { if (isInfoEnabled()) {
logger.info(tag, log, t); logger.info(tag, log, t);
} }
...@@ -120,6 +126,7 @@ public class Logger extends AbstractLogger { ...@@ -120,6 +126,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void w(String tag, String log) { public static void w(String tag, String log) {
Log.w(tag,log);
if (isWarnEnabled()) { if (isWarnEnabled()) {
logger.warn(tag, log); logger.warn(tag, log);
} }
...@@ -136,6 +143,7 @@ public class Logger extends AbstractLogger { ...@@ -136,6 +143,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void w(String tag, String log, Throwable t) { public static void w(String tag, String log, Throwable t) {
Log.w(tag,log);
if (isWarnEnabled()) { if (isWarnEnabled()) {
logger.warn(tag, log, t); logger.warn(tag, log, t);
} }
...@@ -146,6 +154,7 @@ public class Logger extends AbstractLogger { ...@@ -146,6 +154,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void e(String tag, String log) { public static void e(String tag, String log) {
Log.e(tag,log);
if (isErrorEnabled()) { if (isErrorEnabled()) {
logger.error(tag, log); logger.error(tag, log);
} }
...@@ -162,6 +171,7 @@ public class Logger extends AbstractLogger { ...@@ -162,6 +171,7 @@ public class Logger extends AbstractLogger {
// } // }
public static void e(String tag, String log, Throwable t) { public static void e(String tag, String log, Throwable t) {
Log.e(tag,log, t);
if (isErrorEnabled()) { if (isErrorEnabled()) {
logger.error(tag, log, t); logger.error(tag, log, t);
} }
...@@ -224,85 +234,75 @@ public class Logger extends AbstractLogger { ...@@ -224,85 +234,75 @@ public class Logger extends AbstractLogger {
@Override @Override
protected void verbose(String tag, String log) { protected void verbose(String tag, String log) {
log("VERBOSE", tag, log); log("VERBOSE", tag, log);
Log.w(tag,log);
} }
@Override @Override
protected void verbose(String tag, String log, Throwable t) { protected void verbose(String tag, String log, Throwable t) {
log("VERBOSE", tag, log, t); log("VERBOSE", tag, log, t);
Log.w(tag,log,t);
} }
@Override @Override
protected void debug(String tag, String log) { protected void debug(String tag, String log) {
log("DEBUG", tag, log); log("DEBUG", tag, log);
Log.d(tag,log);
} }
@Override @Override
protected void debug(String tag, String log, Throwable t) { protected void debug(String tag, String log, Throwable t) {
log("DEBUG", tag, log, t); log("DEBUG", tag, log, t);
Log.d(tag,log,t);
} }
@Override @Override
protected void info(String tag, String log) { protected void info(String tag, String log) {
log("INFO", tag, log); log("INFO", tag, log);
Log.i(tag, log);
} }
@Override @Override
protected void info(String tag, String log, Throwable t) { protected void info(String tag, String log, Throwable t) {
log("INFO", tag, log, t); log("INFO", tag, log, t);
Log.i(tag, log, t);
} }
@Override @Override
protected void warn(String tag, String log) { protected void warn(String tag, String log) {
log("WARN", tag, log); log("WARN", tag, log);
Log.w(tag, log);
} }
@Override @Override
protected void warn(String tag, String log, Throwable t) { protected void warn(String tag, String log, Throwable t) {
log("WARN", tag, log, t); log("WARN", tag, log, t);
Log.w(tag,log, t);
} }
@Override @Override
protected void error(String tag, String log) { protected void error(String tag, String log) {
log("ERROR", tag, log); log("ERROR", tag, log);
Log.e(tag,log);
} }
@Override @Override
protected void error(String tag, String log, Throwable t) { protected void error(String tag, String log, Throwable t) {
log("ERROR", tag, log, t); log("ERROR", tag, log, t);
Log.e(tag,log,t);
} }
private static boolean isLoggable(int level) { private static boolean isLoggable(int level) {
return false; return isLog;
} }
public static boolean isVerboseEnabled() { public static boolean isVerboseEnabled() {
return false; return isLog;
} }
public static boolean isDebugEnabled() { public static boolean isDebugEnabled() {
return false; return isLog;
} }
public static boolean isInfoEnabled() { public static boolean isInfoEnabled() {
return false; return isLog;
} }
public static boolean isWarnEnabled() { public static boolean isWarnEnabled() {
return false; return isLog;
} }
public static boolean isErrorEnabled() { public static boolean isErrorEnabled() {
return false; return isLog;
} }
} }
...@@ -3,9 +3,10 @@ package jp.odakyu.toiletsignage.receiver; ...@@ -3,9 +3,10 @@ package jp.odakyu.toiletsignage.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import jp.odakyu.toiletsignage.activity.MainActivity; import jp.odakyu.toiletsignage.activity.MainActivity;
import jp.odakyu.toiletsignage.log.Logger; import jp.odakyu.toiletsignage.application.ToiletApplication;
/** /**
* 端末の電源がONしたときに自動的にアプリを起動させるレシーバー * 端末の電源がONしたときに自動的にアプリを起動させるレシーバー
...@@ -16,9 +17,15 @@ public class OnBootReceiver extends BroadcastReceiver { ...@@ -16,9 +17,15 @@ public class OnBootReceiver extends BroadcastReceiver {
public static final String TAG = "OnBootReceiver"; public static final String TAG = "OnBootReceiver";
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Logger.i(TAG, "Power ON"); Log.i(TAG, "Power ON");
ToiletApplication application = (ToiletApplication)context.getApplicationContext();
Log.i(TAG, "application = " + application + "application.getUpdateToiletInfoTimer() = " + application.getUpdateToiletInfoTimer());
if (application == null || application.getUpdateToiletInfoTimer() == null) {
Intent i = new Intent(context, MainActivity.class); Intent i = new Intent(context, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i); context.startActivity(i);
} else {
Log.i(TAG, "Starting Application");
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment