This commit is contained in:
hyb1996
2017-04-26 13:48:59 +08:00
parent 38fa3b3988
commit 6829c0659e
92 changed files with 3439 additions and 679 deletions

View File

@@ -0,0 +1,77 @@
package com.stardust.scriptdroid.external.floating_window;
import android.content.Context;
import android.content.ContextWrapper;
import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
import android.view.View;
import com.stardust.enhancedfloaty.ResizableFloaty;
import com.stardust.enhancedfloaty.ResizableFloatyService;
import com.stardust.scriptdroid.R;
/**
* Created by Stardust on 2017/4/20.
*/
public class ConsoleFloaty extends ResizableFloaty {
private ContextWrapper mContextWrapper;
private View mResizer, mMoveCursor;
@Override
public View inflateCollapsedView(ResizableFloatyService service) {
ensureContextWrapper(service);
return View.inflate(mContextWrapper, R.layout.floating_window_collapse, null);
}
private void ensureContextWrapper(Context context) {
if (mContextWrapper == null) {
mContextWrapper = new ContextThemeWrapper(context, R.style.AppTheme);
}
}
@Override
public View inflateExpandedView(ResizableFloatyService service) {
ensureContextWrapper(service);
View view = View.inflate(mContextWrapper, R.layout.floating_console_expand, null);
setListeners(view, service);
return view;
}
private void setListeners(final View view, final ResizableFloatyService service) {
view.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
service.stopSelf();
service.stopForeground(true);
}
});
view.findViewById(R.id.move_or_resize).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mMoveCursor.getVisibility() == View.VISIBLE){
mMoveCursor.setVisibility(View.GONE);
mResizer.setVisibility(View.GONE);
}else {
mMoveCursor.setVisibility(View.VISIBLE);
mResizer.setVisibility(View.VISIBLE);
}
}
});
}
@Nullable
@Override
public View getResizerView(View expandedView) {
mResizer = expandedView.findViewById(R.id.resizer);
return mResizer;
}
@Nullable
@Override
public View getMoveCursorView(View expandedView) {
mMoveCursor = expandedView.findViewById(R.id.move_cursor);
return mMoveCursor;
}
}

View File

@@ -0,0 +1,16 @@
package com.stardust.scriptdroid.external.floating_window;
import android.content.Context;
import com.stardust.enhancedfloaty.ResizableFloatyService;
/**
* Created by Stardust on 2017/4/18.
*/
public class FloatingConsole {
public static void startFloatingService(Context context) {
ResizableFloatyService.startService(context, new ConsoleFloaty());
}
}

View File

@@ -186,7 +186,7 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
@Override
public void onStop() {
MainActivity.onActionRecordStopped(mContext, mRecorder.getCode());
MainActivity.onRecordStop(mContext, mRecorder.getCode());
mRecorder = null;
}

View File

@@ -96,6 +96,7 @@ public class ScriptListNavigatorContent implements NavigatorContent {
int position = mFloatingScriptFileListView.getChildViewHolder((View) v.getParent()).getAdapterPosition();
ScriptFile file = mFloatingScriptFileListView.getAdapter().getScriptFileAt(position);
EditActivity.editFile(v.getContext(), file);
HoverMenuService.postEvent(new MessageEvent(HoverMenuService.MESSAGE_COLLAPSE_MENU));
}
});

View File

@@ -62,14 +62,15 @@ public class FloatingLayoutHierarchyView extends LayoutHierarchyView {
.customView(mNodeInfoView, false)
.theme(Theme.LIGHT)
.build();
mNodeInfoDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
if (mNodeInfoDialog.getWindow() != null)
mNodeInfoDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
EventBus.getDefault().post(new MessageEvent(HoverMenuService.MESSAGE_SHOW_AND_EXPAND_MENU));
HoverMenuService.postEvent(new MessageEvent(HoverMenuService.MESSAGE_SHOW_AND_EXPAND_MENU));
setVisibility(GONE);
return true;
}