Dying
This commit is contained in:
77
app/src/main/java/com/stardust/scriptdroid/external/floating_window/ConsoleFloaty.java
vendored
Normal file
77
app/src/main/java/com/stardust/scriptdroid/external/floating_window/ConsoleFloaty.java
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
16
app/src/main/java/com/stardust/scriptdroid/external/floating_window/FloatingConsole.java
vendored
Normal file
16
app/src/main/java/com/stardust/scriptdroid/external/floating_window/FloatingConsole.java
vendored
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user