删除无效代码

This commit is contained in:
TonyJiangWJ 2022-01-15 21:45:30 +08:00
parent d384bbf766
commit ad1bbecc7e
6 changed files with 19 additions and 383 deletions

View File

@ -104,7 +104,6 @@
android:name=".external.tasker.TaskerScriptEditActivity_"
android:configChanges="orientation|screenSize" android:exported="false"
/>
<activity android:name="org.autojs.autojs.ui.edit.ViewSampleActivity" android:exported="false"/>
<activity
android:name=".ui.user.LoginActivity_" android:exported="false"
android:windowSoftInputMode="adjustResize"/>

View File

@ -1,188 +0,0 @@
package org.autojs.autojs.ui.edit;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import android.util.SparseArray;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.stardust.app.OnActivityResultDelegate;
import com.stardust.autojs.engine.JavaScriptEngine;
import com.stardust.autojs.execution.ScriptExecution;
import org.autojs.autojs.R;
import org.autojs.autojs.autojs.AutoJs;
import org.autojs.autojs.model.sample.SampleFile;
import org.autojs.autojs.ui.BaseActivity;
import org.autojs.autojs.ui.common.ScriptOperations;
import com.stardust.theme.ThemeColorManager;
import com.stardust.util.SparseArrayEntries;
import org.autojs.autojs.ui.widget.ToolbarMenuItem;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import static org.autojs.autojs.model.script.Scripts.ACTION_ON_EXECUTION_FINISHED;
import static org.autojs.autojs.model.script.Scripts.EXTRA_EXCEPTION_MESSAGE;
/**
* Created by Stardust on 2017/4/29.
*/
public class ViewSampleActivity extends AppCompatActivity implements OnActivityResultDelegate.DelegateHost {
public static void view(Context context, SampleFile sample) {
context.startActivity(new Intent(context, ViewSampleActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("sample_path", sample.getPath()));
}
private View mView;
private SampleFile mSample;
private ScriptExecution mScriptExecution;
private SparseArray<ToolbarMenuItem> mMenuMap;
private OnActivityResultDelegate.Mediator mMediator = new OnActivityResultDelegate.Mediator();
private BroadcastReceiver mOnRunFinishedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_ON_EXECUTION_FINISHED)) {
mScriptExecution = null;
String msg = intent.getStringExtra(EXTRA_EXCEPTION_MESSAGE);
if (msg != null) {
Snackbar.make(mView, getString(R.string.text_error) + ": " + msg, Snackbar.LENGTH_LONG).show();
}
}
}
};
public void onCreate(Bundle b) {
super.onCreate(b);
mView = View.inflate(this, R.layout.activity_view_sample, null);
setContentView(mView);
handleIntent(getIntent());
setUpUI();
registerReceiver(mOnRunFinishedReceiver, new IntentFilter(ACTION_ON_EXECUTION_FINISHED));
}
private void handleIntent(Intent intent) {
mSample = new SampleFile(intent.getStringExtra("sample_path"), getAssets());
}
private void setUpUI() {
ThemeColorManager.addActivityStatusBar(this);
setUpToolbar();
initMenuItem();
ButterKnife.bind(this);
}
private void setUpToolbar() {
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mSample.getSimplifiedName());
}
@OnClick(R.id.run)
void run() {
Snackbar.make(mView, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
//mScriptExecution = Scripts.runWithBroadcastSender(new StringScriptSource(mSample.name, mEditorDelegate.getText()));
}
@OnClick(R.id.edit)
void edit() {
new ScriptOperations(this, mView)
.importSample(mSample)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(path -> {
EditActivity.editFile(ViewSampleActivity.this, path, false);
finish();
});
}
private void initMenuItem() {
mMenuMap = new SparseArrayEntries<ToolbarMenuItem>()
.entry(R.id.run, (ToolbarMenuItem) findViewById(R.id.run))
.sparseArray();
}
public void setMenuStatus(int menuResId, int status) {
ToolbarMenuItem menuItem = mMenuMap.get(menuResId);
if (menuItem == null)
return;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_view_sample, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_console:
showConsole();
return true;
case R.id.action_log:
showLog();
return true;
case R.id.action_help:
return true;
case R.id.action_import:
new ScriptOperations(this, mView)
.importSample(mSample)
.subscribe();
return true;
}
return super.onOptionsItemSelected(item);
}
private void showLog() {
AutoJs.getInstance().getScriptEngineService().getGlobalConsole().show();
}
private void showConsole() {
if (mScriptExecution != null) {
((JavaScriptEngine) mScriptExecution.getEngine()).getRuntime().console.show();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mOnRunFinishedReceiver);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
try {
super.onRestoreInstanceState(savedInstanceState);
} catch (RuntimeException e) {
// FIXME: 2017/3/20
e.printStackTrace();
}
}
@Override
public OnActivityResultDelegate.Mediator getOnActivityResultDelegateMediator() {
return mMediator;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mMediator.onActivityResult(requestCode, resultCode, data);
}
}

View File

@ -96,13 +96,13 @@ public class DrawerFragment extends androidx.fragment.app.Fragment {
@ViewById(R.id.header)
View mHeaderView;
@ViewById(R.id.username)
// @ViewById(R.id.username)
TextView mUserName;
@ViewById(R.id.avatar)
// @ViewById(R.id.avatar)
AvatarView mAvatar;
@ViewById(R.id.shadow)
View mShadow;
@ViewById(R.id.default_cover)
// @ViewById(R.id.default_cover)
View mDefaultCover;
@ViewById(R.id.drawer_menu)
RecyclerView mDrawerMenu;
@ -189,31 +189,6 @@ public class DrawerFragment extends androidx.fragment.app.Fragment {
mDrawerMenu.setLayoutManager(new LinearLayoutManager(getContext()));
}
@SuppressLint("CheckResult")
@Click(R.id.avatar)
void loginOrShowUserInfo() {
UserService.getInstance()
.me()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(user -> {
if (getActivity() == null)
return;
WebActivity_.intent(this)
.extra(WebActivity.EXTRA_URL, NodeBB.url("user/" + user.getUserslug()))
.extra(Intent.EXTRA_TITLE, user.getUsername())
.start();
},
error -> {
if (getActivity() == null)
return;
LoginActivity_.intent(getActivity()).start();
}
);
}
void enableOrDisableAccessibilityService(DrawerMenuItemViewHolder holder) {
boolean isAccessibilityServiceEnabled = isAccessibilityServiceEnabled();
boolean checked = holder.getSwitchCompat().isChecked();
@ -398,51 +373,6 @@ public class DrawerFragment extends androidx.fragment.app.Fragment {
public void onResume() {
super.onResume();
syncSwitchState();
// syncUserInfo();
}
private void syncUserInfo() {
NodeBB.getInstance().getRetrofit()
.create(UserApi.class)
.me()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::setUpUserInfo, error -> {
error.printStackTrace();
setUpUserInfo(null);
});
}
private void setUpUserInfo(@Nullable User user) {
if (mUserName == null || mAvatar == null)
return;
if (user == null) {
mUserName.setText(R.string.not_login);
mAvatar.setIcon(R.drawable.profile_avatar_placeholder);
} else {
mUserName.setText(user.getUsername());
mAvatar.setUser(user);
}
setCoverImage(user);
}
private void setCoverImage(User user) {
if (mDefaultCover == null || mShadow == null || mHeaderView == null)
return;
if (user == null || TextUtils.isEmpty(user.getCoverUrl()) || user.getCoverUrl().equals("/assets/images/cover-default.png")) {
mDefaultCover.setVisibility(View.VISIBLE);
mShadow.setVisibility(View.GONE);
mHeaderView.setBackgroundColor(ThemeColorManagerCompat.getColorPrimary());
} else {
mDefaultCover.setVisibility(View.GONE);
mShadow.setVisibility(View.VISIBLE);
Glide.with(this)
.load(NodeBB.BASE_URL + user.getCoverUrl())
.apply(new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.NONE)
)
.into(new BackgroundTarget(mHeaderView));
}
}
private void syncSwitchState() {
@ -493,14 +423,6 @@ public class DrawerFragment extends androidx.fragment.app.Fragment {
mDrawerMenu.scrollToPosition(0);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLoginStateChange(UserService.LoginStateChange change) {
syncUserInfo();
if (mCommunityDrawerMenu.isShown()) {
mCommunityDrawerMenu.setUserOnlineStatus(mDrawerMenuAdapter, change.isOnline());
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onDrawerOpen(MainActivity.DrawerOpenEvent event) {

View File

@ -102,8 +102,6 @@ public class SettingsActivity extends BaseActivity {
super.onStart();
ACTION_MAP = new MapBuilder<String, Runnable>()
.put(getString(R.string.text_theme_color), () -> selectThemeColor(getActivity()))
.put(getString(R.string.text_check_for_updates), () -> new UpdateCheckDialog(getActivity())
.show())
.put(getString(R.string.text_issue_report), () -> startActivity(new Intent(getActivity(), IssueReporterActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)))
.put(getString(R.string.text_about_me_and_repo), () -> startActivity(new Intent(getActivity(), AboutActivity_.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)))
.put(getString(R.string.text_licenses), () -> showLicenseDialog())

View File

@ -1,97 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.autojs.autojs.ui.edit.EditActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<com.stardust.theme.widget.ThemeColorToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:theme="@style/ToolBarStyle"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:title="@string/app_name"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:orientation="horizontal">
<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/edit"
android:layout_width="40dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_edit_white_24dp"
app:icon_color="@android:color/white"
app:text="@string/text_edit"/>
<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/run"
android:layout_width="40dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_play_arrow_white_48dp"
app:icon_color="@android:color/white"
app:text="@string/text_run"/>
</LinearLayout>
</com.stardust.theme.widget.ThemeColorToolbar>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff"
android:orientation="vertical"
tools:showIn="@layout/activity_edit">
<com.jecelyin.editor.v2.view.EditorView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.jecelyin.editor.v2.core.widget.JecEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff"
android:enabled="true"
android:gravity="start|top"
android:inputType="textMultiLine"
android:padding="5dp"
android:scrollbarThumbVertical="@android:color/transparent"
android:scrollbarTrackVertical="@null"
android:scrollbars="vertical"/>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progress_view"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:indeterminate="true"
android:visibility="gone"/>
</com.jecelyin.editor.v2.view.EditorView>
</LinearLayout>
</LinearLayout>

View File

@ -13,7 +13,8 @@
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_marginBottom="5dp">
android:layout_marginBottom="5dp"
android:visibility="gone">
<View
android:id="@+id/shadow"
@ -44,20 +45,21 @@
<!-- android:textColor="@android:color/white"-->
<!-- android:textSize="16sp"/>-->
<ImageView
android:id="@+id/default_cover"
android:layout_width="match_parent"
android:layout_height="118dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/avatar"
android:alpha="0.08"
android:src="@drawable/android_eating_half"
android:tint="#000000"/>
<!-- <ImageView-->
<!-- android:id="@+id/default_cover"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="118dp"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_toRightOf="@+id/avatar"-->
<!-- android:alpha="0.08"-->
<!-- android:src="@drawable/android_eating_half"-->
<!-- android:tint="#000000"/>-->
</RelativeLayout>
<LinearLayout
android:layout_marginTop="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -93,9 +95,9 @@
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
android:src="@drawable/ic_ali_settings"
android:tint="#666666"/>
app:tint="#666666" />
<TextView
android:layout_width="wrap_content"
@ -120,9 +122,9 @@
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
android:src="@drawable/ic_ali_exit"
android:tint="#666666"/>
app:tint="#666666" />
<TextView
android:layout_width="wrap_content"