-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ScriptsLogTextView,add Init.sh(execute at startup)
- Loading branch information
1 parent
59588ee
commit 00adc9e
Showing
21 changed files
with
541 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
git status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
git status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/pangbai/weblog/activity/BottomTabControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.pangbai.weblog.activity; | ||
|
||
import android.view.View; | ||
import android.widget.LinearLayout; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.viewpager.widget.ViewPager; | ||
|
||
import com.google.android.material.bottomsheet.BottomSheetBehavior; | ||
import com.google.android.material.tabs.TabLayout; | ||
import com.pangbai.weblog.R; | ||
import com.pangbai.weblog.databinding.ActivityMainBinding; | ||
import com.pangbai.weblog.databinding.LayoutTerminalBinding; | ||
import com.pangbai.weblog.view.MainViewPagerAdapter; | ||
|
||
public class BottomTabControl extends BottomSheetBehavior.BottomSheetCallback implements TabLayout.OnTabSelectedListener { | ||
TabLayout tabLayout; | ||
ActivityMainBinding binding; | ||
LayoutTerminalBinding cmdBinding; | ||
BottomSheetBehavior behavior; | ||
|
||
public BottomTabControl(ActivityMainBinding binding, LayoutTerminalBinding cmdBinding, MainViewPagerAdapter fragmentAdapter){ | ||
this.binding=binding; | ||
this.tabLayout=binding.tabLayout; | ||
this.cmdBinding=cmdBinding; | ||
binding.viewpager.setAdapter(fragmentAdapter); | ||
|
||
} | ||
public void setup(){ | ||
//Repair pager content reconstruction | ||
binding.viewpager.setOffscreenPageLimit(2); | ||
|
||
// tabLayout跟viewpager关联 | ||
tabLayout.setupWithViewPager(binding.viewpager); | ||
|
||
behavior = BottomSheetBehavior.from(binding.bottomSheet); | ||
behavior.setHalfExpandedRatio(0.3F); | ||
behavior.addBottomSheetCallback(this); | ||
tabLayout.addOnTabSelectedListener(this); | ||
} | ||
@Override | ||
public void onStateChanged(@NonNull View bottomSheet, int newState) { | ||
if (newState == BottomSheetBehavior.STATE_COLLAPSED) { | ||
binding.bottomBar.setVisibility(View.VISIBLE); | ||
} else { | ||
binding.bottomBar.setVisibility(View.GONE); | ||
} | ||
// focus on cmdview; | ||
if (newState == BottomSheetBehavior.STATE_EXPANDED) { | ||
if (tabLayout.getSelectedTabPosition() == 0) { | ||
cmdBinding.terminal.requestFocus(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onSlide(@NonNull View bottomSheet, float slideOffset) { | ||
} | ||
|
||
@Override | ||
public void onTabSelected(TabLayout.Tab tab) { | ||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED); | ||
// focus on cmdview; | ||
if (tab.getPosition() == 1) { | ||
cmdBinding.terminal.requestFocus(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onTabUnselected(TabLayout.Tab tab) { | ||
} | ||
|
||
@Override | ||
public void onTabReselected(TabLayout.Tab tab) { | ||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
app/src/main/java/com/pangbai/weblog/activity/ExecuteStateControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.pangbai.weblog.activity; | ||
|
||
import static com.pangbai.weblog.tool.util.runOnUiThread; | ||
|
||
import android.content.Context; | ||
import android.renderscript.ScriptGroup; | ||
import android.widget.ProgressBar; | ||
import android.widget.TextView; | ||
|
||
import com.google.android.material.snackbar.Snackbar; | ||
import com.pangbai.weblog.R; | ||
import com.pangbai.weblog.databinding.ActivityMainBinding; | ||
import com.pangbai.weblog.execute.cmdExer; | ||
import com.pangbai.weblog.project.Project; | ||
import com.pangbai.weblog.tool.DialogUtils; | ||
import com.pangbai.weblog.tool.ThreadUtil; | ||
import com.pangbai.weblog.tool.util; | ||
import com.pangbai.weblog.view.ScriptsLogTextView; | ||
|
||
import java.util.List; | ||
|
||
public class ExecuteStateControl { | ||
public enum executeStatus { | ||
SUCCESSFUL , | ||
FAILED, | ||
EXECUTING | ||
|
||
} | ||
|
||
ActivityMainBinding binding; | ||
ScriptsLogTextView logTextView; | ||
List<String> scripts; | ||
Project project; | ||
|
||
public ExecuteStateControl(ActivityMainBinding binding, ScriptsLogTextView logTextView, Project project) { | ||
this.binding = binding; | ||
this.logTextView = logTextView; | ||
this.project=project; | ||
} | ||
|
||
|
||
void runScripts(List<String> scripts){ | ||
binding.progressbar.setIndeterminate(true); | ||
binding.executionStatus.setText(executeStatus.EXECUTING+scripts.toString()); | ||
//Snackbar.make(binding.getRoot(), "Excuting", Snackbar.LENGTH_SHORT).show(); | ||
logTextView.appendScriptText(scripts); | ||
ThreadUtil.thread(() -> { | ||
boolean cmd = cmdExer.executeScripts(scripts, project.getScriptPath(), true) == 0; | ||
runOnUiThread(() -> { | ||
|
||
binding.progressbar.setIndeterminate(false); | ||
|
||
logTextView.appendLogText(cmdExer.result); | ||
if (cmd) { | ||
binding.executionStatus.setText(executeStatus.SUCCESSFUL+scripts.toString()); | ||
// Snackbar.make(binding.getRoot(), "Success", Snackbar.LENGTH_SHORT).show(); | ||
} else { | ||
Context context=binding.getRoot().getContext(); | ||
binding.executionStatus.setText(executeStatus.FAILED+scripts.toString()); | ||
DialogUtils.showConfirmationDialog(context, context.getString(R.string.scripts_execution_failed), cmdExer.result,context.getString(android.R.string.copy),context.getString(R.string.cancle), () -> { | ||
util.copyToClipboard(context, cmdExer.result);}, null); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.