Add: commonjs support, Fix: editor auto line break
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.stardust.scriptdroid.tool;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.view.Gravity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
@@ -13,7 +15,27 @@ import java.util.List;
|
||||
*/
|
||||
public interface BackPressedHandler {
|
||||
|
||||
boolean onBackPressed();
|
||||
boolean onBackPressed(Activity activity);
|
||||
|
||||
class Observer implements BackPressedHandler {
|
||||
|
||||
private List<BackPressedHandler> mBackPressedHandlers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(Activity activity) {
|
||||
for (BackPressedHandler handler : mBackPressedHandlers) {
|
||||
if (handler.onBackPressed(activity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerHandler(BackPressedHandler handler) {
|
||||
mBackPressedHandlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DoublePressExit implements BackPressedHandler {
|
||||
|
||||
@@ -31,7 +53,7 @@ public interface BackPressedHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
public boolean onBackPressed(Activity activity) {
|
||||
if (System.currentTimeMillis() - mLastPressedMillis < mDoublePressInterval) {
|
||||
mActivity.finish();
|
||||
} else {
|
||||
@@ -42,22 +64,23 @@ public interface BackPressedHandler {
|
||||
}
|
||||
}
|
||||
|
||||
class Observer implements BackPressedHandler {
|
||||
class DrawerAutoClose implements BackPressedHandler {
|
||||
|
||||
private List<BackPressedHandler> mBackPressedHandlers = new ArrayList<>();
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private int mGravity;
|
||||
|
||||
public DrawerAutoClose(DrawerLayout drawerLayout, int gravity){
|
||||
mDrawerLayout = drawerLayout;
|
||||
mGravity = gravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
for (BackPressedHandler handler : mBackPressedHandlers) {
|
||||
if (handler.onBackPressed()) {
|
||||
return true;
|
||||
}
|
||||
public boolean onBackPressed(Activity activity) {
|
||||
if (mDrawerLayout.isDrawerOpen(mGravity)) {
|
||||
mDrawerLayout.closeDrawer(mGravity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerHandler(BackPressedHandler handler) {
|
||||
mBackPressedHandlers.add(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class IntentTool {
|
||||
public static boolean goToQQ(Context context, String qq) {
|
||||
try {
|
||||
String url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq;
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
@@ -33,7 +33,7 @@ public class IntentTool {
|
||||
* @return 返回true表示呼起手Q成功,返回false表示呼起失败
|
||||
******************/
|
||||
public static boolean joinQQGroup(Context context, String key) {
|
||||
Intent intent = new Intent();
|
||||
Intent intent = new Intent().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
|
||||
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
try {
|
||||
@@ -48,7 +48,7 @@ public class IntentTool {
|
||||
public static void goToMail(Context context, String sendTo, @Nullable String title, @Nullable String content) {
|
||||
Uri uri = Uri.parse("mailto:" + sendTo);
|
||||
String[] email = {sendTo};
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO, uri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_CC, email);
|
||||
if (title != null)
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, title);
|
||||
@@ -62,7 +62,7 @@ public class IntentTool {
|
||||
}
|
||||
|
||||
public static void goToLink(Context context, String link) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user