add sublime text plugin support
This commit is contained in:
@@ -7,9 +7,12 @@ package com.stardust.scriptdroid.tool;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.util.IntentUtil;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
@@ -26,6 +29,11 @@ public class CrashHandler implements UncaughtExceptionHandler {
|
||||
}
|
||||
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
if (causedByBadWindowToken(ex)) {
|
||||
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
IntentUtil.goToAppDetailSettings(App.getApp());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Log.e(TAG, "Uncaught Exception", ex);
|
||||
if (crashTooManyTimes())
|
||||
@@ -38,6 +46,16 @@ public class CrashHandler implements UncaughtExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean causedByBadWindowToken(Throwable e) {
|
||||
while (e != null) {
|
||||
if (e instanceof WindowManager.BadTokenException) {
|
||||
return true;
|
||||
}
|
||||
e = e.getCause();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startErrorReportActivity(String msg, String detail) {
|
||||
Intent intent = new Intent(App.getApp(), this.mErrorReportClass);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.stardust.scriptdroid.tool;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.text.format.Formatter;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/11.
|
||||
*/
|
||||
|
||||
public class WifiTool {
|
||||
|
||||
public static String getWifiAddress(Context context) {
|
||||
WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
|
||||
int ip = wifiInfo.getIpAddress();
|
||||
return Formatter.formatIpAddress(ip);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user