Beispiel #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.script_manager);
    setTitle("sl4a");
    File sl4a = null;
    mBaseDir = new File(new GetPath().path(this) + "/sl4a/scripts/");
    Log.i("mBaseDir: " + mBaseDir.getAbsolutePath());
    sl4a = mBaseDir.getParentFile();
    if (!sl4a.exists()) {
      sl4a.mkdirs();
      try {
        FileUtils.chmod(sl4a, 0755);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    File tfile = new File(mBaseDir.getAbsolutePath() + "/template/");
    if (!tfile.exists()) {
      tfile.mkdirs(); // 创建模版路径
    }
    if (!FileUtils.makeDirectories(mBaseDir, 0755)) {
      new AlertDialog.Builder(this)
          .setTitle("Error")
          .setMessage(
              getString(R.string.s_Failedtocreate)
                  + "\n"
                  + mBaseDir
                  + "\n"
                  + getString(R.string.s_PleaseCheck))
          .setIcon(android.R.drawable.ic_dialog_alert)
          .setPositiveButton("Ok", null)
          .show();
    }

    mCurrentDir = mBaseDir;
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mAdapter = new ScriptManagerAdapter(this);
    mObserver = new ScriptListObserver();
    mAdapter.registerDataSetObserver(mObserver);
    mConfiguration = ((BaseApplication) getApplication()).getInterpreterConfiguration();
    // mManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mList = (JazzyListView) findViewById(android.R.id.list);
    registerForContextMenu(mList);
    updateAndFilterScriptList(mQuery);
    mList.setAdapter(mAdapter);
    ActivityFlinger.attachView(mList, this);
    ActivityFlinger.attachView(getWindow().getDecorView(), this);
    startService(IntentBuilders.buildTriggerServiceIntent());
    UsageTrackingConfirmation.show(this);
    Analytics.trackActivity(this);
    setupJazziness(JazzyHelper.HELIX);
    mList.setOnItemClickListener(listItemClick);
    mList.setOnScrollListener(scrollListener);
    new CrashEmail(this, "*****@*****.**");
  }
Beispiel #2
0
 @Override
 public void onScrollStateChanged(AbsListView view, int scrollState) {
   switch (scrollState) {
     case OnScrollListener.SCROLL_STATE_IDLE:
       // 当不滚动时
       // 判断是否滚动到底部
       if (mList.getLastVisiblePosition() == (mList.getCount() - 1)) {
         setupJazziness(getEffects());
       }
       // 判断是否滚动到顶部
       if (mList.getFirstVisiblePosition() == 1) {
         setupJazziness(getEffects());
       }
   }
 }
Beispiel #3
0
 private void setupJazziness(int effect) {
   mList.setTransitionEffect(effect);
 }
Beispiel #4
0
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
          final File file = (File) mList.getItemAtPosition(position);
          mCurrent = file;
          if (file.isDirectory()) {
            mCurrentDir = file;
            mAdapter.notifyDataSetInvalidated();
            return;
          }
          if (FacadeConfiguration.getSdkLevel() <= 3
              || !mPreferences.getBoolean("use_quick_menu", true)) {
            doDialogMenu();
            return;
          }

          final QuickAction actionMenu = new QuickAction(view);

          ActionItem terminal = new ActionItem();
          terminal.setIcon(getResources().getDrawable(R.drawable.terminal));
          terminal.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  Intent intent = new Intent(ScriptManager.this, ScriptingLayerService.class);
                  intent.setAction(Constants.ACTION_LAUNCH_FOREGROUND_SCRIPT);
                  intent.putExtra(Constants.EXTRA_SCRIPT_PATH, file.getPath());
                  startService(intent);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem background = new ActionItem();
          background.setIcon(getResources().getDrawable(R.drawable.background));
          background.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  Intent intent = new Intent(ScriptManager.this, ScriptingLayerService.class);
                  intent.setAction(Constants.ACTION_LAUNCH_BACKGROUND_SCRIPT);
                  intent.putExtra(Constants.EXTRA_SCRIPT_PATH, file.getPath());
                  startService(intent);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem edit = new ActionItem();
          edit.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_edit));
          edit.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  editScript(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem delete = new ActionItem();
          delete.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_delete));
          delete.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  delete(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem rename = new ActionItem();
          rename.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_save));
          rename.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  rename(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem external = new ActionItem();
          external.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_directions));
          external.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  // externalEditor(file);
                  dismissQuickActions(actionMenu);
                  if (!file.getAbsolutePath().endsWith(".pyc") && !file.isDirectory()) {
                    // 非文件夹或者非pyc文件提示无法反编译
                    Crouton.cancelAllCroutons();
                    Crouton.showText(
                        ScriptManager.this, getString(R.string.s_Cannotdecompile), Style.ALERT);
                  } else {
                    Decompile.show(ScriptManager.this, file.getAbsolutePath());
                  }
                }
              });

          actionMenu.addActionItems(terminal, background, edit, rename, delete, external);
          actionMenu.setAnimStyle(QuickAction.ANIM_GROW_FROM_CENTER);
          actionMenu.show();
        }