add: ui for apk building
This commit is contained in:
1
.idea/inspectionProfiles/Project_Default.xml
generated
1
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -2,6 +2,7 @@
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AndroidLintContentDescription" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintHardcodedText" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<activity android:name=".external.tasker.TaskerScriptEditActivity_"/>
|
||||
<activity android:name=".ui.edit.ViewSampleActivity"/>
|
||||
<activity android:name=".ui.login.LoginActivity_"/>
|
||||
<activity android:name=".ui.build.BuildActivity_"/>
|
||||
<activity android:name=".external.widget.ScriptWidgetSettingsActivity_">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.stardust.scriptdroid.ui.build;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.model.script.ScriptFile;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/10/22.
|
||||
*/
|
||||
@EActivity(R.layout.activity_build)
|
||||
public class BuildActivity extends BaseActivity {
|
||||
|
||||
public static final String EXTRA_SOURCE_FILE = BuildActivity.class.getName() + ".extra_source_file";
|
||||
|
||||
@ViewById(R.id.source_path)
|
||||
EditText mSourcePath;
|
||||
|
||||
@ViewById(R.id.output_path)
|
||||
EditText mOutputPath;
|
||||
|
||||
@ViewById(R.id.app_name)
|
||||
EditText mAppName;
|
||||
|
||||
@ViewById(R.id.package_name)
|
||||
EditText mPackageName;
|
||||
|
||||
@ViewById(R.id.version_name)
|
||||
EditText mVersionName;
|
||||
|
||||
@ViewById(R.id.version_code)
|
||||
EditText mVersionCode;
|
||||
|
||||
@AfterViews
|
||||
void setupViews() {
|
||||
setToolbarAsBack(getString(R.string.text_build_apk));
|
||||
String sourcePath = getIntent().getStringExtra(EXTRA_SOURCE_FILE);
|
||||
if (sourcePath != null) {
|
||||
setupWithSourceFile(new ScriptFile(sourcePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void setupWithSourceFile(ScriptFile file) {
|
||||
mSourcePath.setText(file.getPath());
|
||||
mOutputPath.setText(file.getParent());
|
||||
mAppName.setText(file.getSimplifiedName());
|
||||
mPackageName.setText("org.autojs.example_" + file.getSimplifiedName());
|
||||
}
|
||||
}
|
||||
@@ -86,19 +86,11 @@ public class EditActivity extends BaseActivity {
|
||||
.positiveText(R.string.text_cancel)
|
||||
.negativeText(R.string.text_save_and_exit)
|
||||
.neutralText(R.string.text_exit_directly)
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
mEditor.saveFile();
|
||||
EditActivity.super.finish();
|
||||
}
|
||||
})
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
EditActivity.super.finish();
|
||||
}
|
||||
.onNegative((dialog, which) -> {
|
||||
mEditor.saveFile();
|
||||
EditActivity.super.finish();
|
||||
})
|
||||
.onNeutral((dialog, which) -> EditActivity.super.finish())
|
||||
.show();
|
||||
}
|
||||
|
||||
@@ -107,13 +99,4 @@ public class EditActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
try {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
} catch (RuntimeException e) {
|
||||
// FIXME: 2017/3/20
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.pio.PFiles;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.ui.build.BuildActivity;
|
||||
import com.stardust.scriptdroid.ui.build.BuildActivity_;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
|
||||
@@ -118,11 +120,20 @@ public class EditorMenu {
|
||||
case R.id.action_info:
|
||||
showInfo();
|
||||
return true;
|
||||
case R.id.action_build_apk:
|
||||
startBuildApkActivity();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startBuildApkActivity() {
|
||||
BuildActivity_.intent(mContext)
|
||||
.extra(BuildActivity.EXTRA_SOURCE_FILE, mEditorView.getFile().getPath())
|
||||
.start();
|
||||
}
|
||||
|
||||
|
||||
private boolean onEditOptionsSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
@@ -125,6 +125,10 @@ public class EditorView extends FrameLayout {
|
||||
getContext().unregisterReceiver(mOnRunFinishedReceiver);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
public void handleIntent(Intent intent) {
|
||||
mName = intent.getStringExtra(EXTRA_NAME);
|
||||
handleText(intent);
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_done_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_done_white_48dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 255 B |
BIN
app/src/main/res/drawable-mdpi/ic_done_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_done_white_48dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 199 B |
BIN
app/src/main/res/drawable-xhdpi/ic_done_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_done_white_48dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 308 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_done_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_done_white_48dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 386 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_done_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_done_white_48dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 466 B |
206
app/src/main/res/layout/activity_build.xml
Normal file
206
app/src/main/res/layout/activity_build.xml
Normal file
@@ -0,0 +1,206 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="6dp">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:text="文件"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="?android:textColorSecondary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/source_path"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="脚本文件路径"
|
||||
android:maxLines="1"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/select_source"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@string/text_select"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/output_path"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/text_output_apk_path"
|
||||
android:maxLines="1"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/select_output"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@string/text_select"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:text="@string/text_config"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="?android:textColorSecondary"/>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/app_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/text_app_name"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/package_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/text_package_name"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/version_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/text_version_name"
|
||||
android:text="1.0.0"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/version_code"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/text_version_code"
|
||||
android:text="1"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorFloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|right|bottom"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_done_white_48dp"/>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -136,6 +136,11 @@
|
||||
android:id="@+id/action_open_by_other_apps"
|
||||
android:title="@string/text_open_by_other_apps"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_build_apk"
|
||||
android:title="@string/text_build_apk"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
</item>
|
||||
</menu>
|
||||
@@ -245,6 +245,14 @@
|
||||
<string name="confirm_overwrite_file">文件已存在,要覆盖吗?</string>
|
||||
<string name="text_select_file_to_upload">选择要上传的文件</string>
|
||||
<string name="text_select_file_to_import">选择要导入的文件</string>
|
||||
<string name="text_build_apk">打包应用</string>
|
||||
<string name="text_select">选择</string>
|
||||
<string name="text_output_apk_path">打包应用保存路径</string>
|
||||
<string name="text_config">配置</string>
|
||||
<string name="text_app_name">应用名称</string>
|
||||
<string name="text_package_name">包名</string>
|
||||
<string name="text_version_name">版本名称</string>
|
||||
<string name="text_version_code">版本号</string>
|
||||
|
||||
|
||||
<string-array name="ad_showing_mode_keys">
|
||||
|
||||
Reference in New Issue
Block a user