feat: intent task

This commit is contained in:
hyb1996
2018-09-28 14:20:21 +08:00
parent 02b1587f6b
commit 9d1fdf3fe9
8 changed files with 46 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;

View File

@@ -30,6 +30,10 @@ public class Explorer {
this(explorerProvider, cacheSize, EventBus.getDefault()); this(explorerProvider, cacheSize, EventBus.getDefault());
} }
public ExplorerProvider getProvider() {
return mExplorerProvider;
}
public void notifyChildrenChanged(ExplorerPage page) { public void notifyChildrenChanged(ExplorerPage page) {
clearCache(page); clearCache(page);
mEventBus.post(new ExplorerChangeEvent(page, CHILDREN_CHANGE, null)); mEventBus.post(new ExplorerChangeEvent(page, CHILDREN_CHANGE, null));

View File

@@ -4,16 +4,16 @@ import com.stardust.pio.PFile;
import java.io.File; import java.io.File;
public class ExplorerSamleItem extends ExplorerFileItem { public class ExplorerSampleItem extends ExplorerFileItem {
public ExplorerSamleItem(PFile file, ExplorerPage parent) { public ExplorerSampleItem(PFile file, ExplorerPage parent) {
super(file, parent); super(file, parent);
} }
public ExplorerSamleItem(String path, ExplorerPage parent) { public ExplorerSampleItem(String path, ExplorerPage parent) {
super(path, parent); super(path, parent);
} }
public ExplorerSamleItem(File file, ExplorerPage parent) { public ExplorerSampleItem(File file, ExplorerPage parent) {
super(file, parent); super(file, parent);
} }

View File

@@ -8,6 +8,7 @@ import com.stardust.pio.PFile;
import com.stardust.pio.PFiles; import com.stardust.pio.PFiles;
import org.autojs.autojs.Pref; import org.autojs.autojs.Pref;
import org.autojs.autojs.model.sample.SampleFile;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
@@ -52,7 +53,7 @@ public class WorkspaceFileProvider extends ExplorerFileProvider {
} }
} else { } else {
if (file.getPath().startsWith(mSampleDir.getPath())) { if (file.getPath().startsWith(mSampleDir.getPath())) {
p.addChild(new ExplorerSamleItem(file, p)); p.addChild(new ExplorerSampleItem(file, p));
} else { } else {
p.addChild(new ExplorerFileItem(file, p)); p.addChild(new ExplorerFileItem(file, p));
} }
@@ -98,6 +99,10 @@ public class WorkspaceFileProvider extends ExplorerFileProvider {
}); });
} }
public static void resetSample(SampleFile sampleFile){
}
@Override @Override
protected ExplorerDirPage createExplorerPage(String path, ExplorerPage parent) { protected ExplorerDirPage createExplorerPage(String path, ExplorerPage parent) {
ExplorerDirPage page = super.createExplorerPage(path, parent); ExplorerDirPage page = super.createExplorerPage(path, parent);

View File

@@ -27,7 +27,11 @@ import org.autojs.autojs.model.explorer.ExplorerFileItem;
import org.autojs.autojs.model.explorer.ExplorerItem; import org.autojs.autojs.model.explorer.ExplorerItem;
import org.autojs.autojs.model.explorer.ExplorerPage; import org.autojs.autojs.model.explorer.ExplorerPage;
import org.autojs.autojs.model.explorer.ExplorerProjectPage; import org.autojs.autojs.model.explorer.ExplorerProjectPage;
import org.autojs.autojs.model.explorer.ExplorerSampleItem;
import org.autojs.autojs.model.explorer.ExplorerSamplePage; import org.autojs.autojs.model.explorer.ExplorerSamplePage;
import org.autojs.autojs.model.explorer.Explorers;
import org.autojs.autojs.model.explorer.WorkspaceFileProvider;
import org.autojs.autojs.model.sample.SampleFile;
import org.autojs.autojs.model.script.ScriptFile; import org.autojs.autojs.model.script.ScriptFile;
import org.autojs.autojs.model.script.Scripts; import org.autojs.autojs.model.script.Scripts;
import org.autojs.autojs.ui.project.BuildActivity; import org.autojs.autojs.ui.project.BuildActivity;
@@ -306,6 +310,8 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
case R.id.action_sort_by_size: case R.id.action_sort_by_size:
sort(ExplorerItemList.SORT_TYPE_SIZE, mDirSortMenuShowing); sort(ExplorerItemList.SORT_TYPE_SIZE, mDirSortMenuShowing);
break; break;
case R.id.reset:
// WorkspaceFileProvider.resetSample(mSelectedItem.toScriptFile());
default: default:
return false; return false;
} }
@@ -487,6 +493,9 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
} }
if (!mExplorerItem.canRename()) { if (!mExplorerItem.canRename()) {
menu.removeItem(R.id.rename); menu.removeItem(R.id.rename);
}
if(mExplorerItem instanceof ExplorerSampleItem){
} }
popupMenu.setOnMenuItemClickListener(ExplorerView.this); popupMenu.setOnMenuItemClickListener(ExplorerView.this);
popupMenu.show(); popupMenu.show();

View File

@@ -86,6 +86,8 @@ public class TimedTaskSettingActivity extends BaseActivity {
.put(Intent.ACTION_PACKAGE_REMOVED, R.string.text_run_on_package_uninstall) .put(Intent.ACTION_PACKAGE_REMOVED, R.string.text_run_on_package_uninstall)
.put(Intent.ACTION_PACKAGE_REPLACED, R.string.text_run_on_package_update) .put(Intent.ACTION_PACKAGE_REPLACED, R.string.text_run_on_package_update)
.put(Intent.ACTION_HEADSET_PLUG, R.string.text_run_on_headset_plug) .put(Intent.ACTION_HEADSET_PLUG, R.string.text_run_on_headset_plug)
.put(Intent.ACTION_CONFIGURATION_CHANGED, R.string.text_run_on_config_change)
.put(Intent.ACTION_TIME_TICK, R.string.text_run_on_time_tick)
.build(); .build();
private static final BiMap<Integer, String> ACTIONS = BiMaps.<Integer, String>newBuilder() private static final BiMap<Integer, String> ACTIONS = BiMaps.<Integer, String>newBuilder()
@@ -101,6 +103,8 @@ public class TimedTaskSettingActivity extends BaseActivity {
.put(R.id.run_on_package_uninstall, Intent.ACTION_PACKAGE_REMOVED) .put(R.id.run_on_package_uninstall, Intent.ACTION_PACKAGE_REMOVED)
.put(R.id.run_on_package_update, Intent.ACTION_PACKAGE_REPLACED) .put(R.id.run_on_package_update, Intent.ACTION_PACKAGE_REPLACED)
.put(R.id.run_on_headset_plug, Intent.ACTION_HEADSET_PLUG) .put(R.id.run_on_headset_plug, Intent.ACTION_HEADSET_PLUG)
.put(R.id.run_on_config_change, Intent.ACTION_CONFIGURATION_CHANGED)
.put(R.id.run_on_time_tick, Intent.ACTION_TIME_TICK)
.build(); .build();

View File

@@ -375,6 +375,22 @@
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:text="@string/text_run_on_headset_plug"/> android:text="@string/text_run_on_headset_plug"/>
<RadioButton
android:id="@+id/run_on_config_change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingLeft="8dp"
android:text="@string/text_run_on_config_change"/>
<RadioButton
android:id="@+id/run_on_time_tick"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingLeft="8dp"
android:text="@string/text_run_on_time_tick"/>
<RadioButton <RadioButton
android:id="@+id/run_on_other_broadcast" android:id="@+id/run_on_other_broadcast"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -397,6 +413,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/text_broadcast_action" android:hint="@string/text_broadcast_action"
android:maxLines="2"
android:text="@string/text_broadcast_action_prefix"/> android:text="@string/text_broadcast_action_prefix"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>

View File

@@ -419,4 +419,6 @@
<string name="text_run_on_package_uninstall">应用卸载时</string> <string name="text_run_on_package_uninstall">应用卸载时</string>
<string name="text_run_on_package_update">应用更新时</string> <string name="text_run_on_package_update">应用更新时</string>
<string name="text_run_on_headset_plug">耳机插拔时</string> <string name="text_run_on_headset_plug">耳机插拔时</string>
<string name="text_run_on_time_tick">每分钟一次</string>
<string name="text_run_on_config_change">某些设置(屏幕方向,地区等)更改时</string>
</resources> </resources>