diff --git a/app/llx/api_doc/doc.sh b/app/llx/api_doc/doc.sh index 7b117da..e5d91c5 100755 --- a/app/llx/api_doc/doc.sh +++ b/app/llx/api_doc/doc.sh @@ -16,6 +16,20 @@ javadoc \ sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/Lightning.html sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/LL.html +sed -i 's/getEvent_/getEvent/g' html/reference/net/pierrox/lightning_launcher/script/api/Event.html sed -i 's/getEvent_/getEvent/g' html/reference/current.xml -scp -r html pierrot@ruby:~/tmp + +echo "beta? y/n [n]" +read answer +if [ "$answer" = "y" ]; then + dir=api-beta +else + dir=api +fi +rm -rf llx-$dir +cp -r html llx-$dir +tar czf llx-$dir.tar.gz llx-$dir +scp llx-$dir.tar.gz pierrot@vmail:/home/www/lightninglauncher.com/docs/www/scripting/reference/downloadable +ssh pierrot@vmail "cd /home/www/lightninglauncher.com/docs/www/scripting/reference && rm -rf $dir && tar xf downloadable/llx-$dir.tar.gz && mv llx-$dir $dir" +rm -rf llx-$dir.tar.gz llx-$dir diff --git a/app/llx/api_doc/overview.html b/app/llx/api_doc/overview.html index 2698c27..6d59827 100644 --- a/app/llx/api_doc/overview.html +++ b/app/llx/api_doc/overview.html @@ -3,8 +3,8 @@

Lightning Launcher Scripting API

Introduction

-

Starting at version 10 (alpha 9.9), Lightning Launcher has support for extending its behavior through JavaScript. This is an advanced and extremly powerful feature, and for this reason it requires some care.

-

The description of LL script APIs can be found here {@link net.pierrox.lightning_launcher.script.api}. The {@link LL} objet is the entry point for most things.

+

Starting at version 10 (alpha 9.9), Lightning Launcher has support for extending its behavior through JavaScript. This is an advanced and extremely powerful feature, and for this reason it requires some care.

+

The description of LL script APIs can be found here {@link net.pierrox.lightning_launcher.script.api}. The {@link LL} object is the entry point for most things.

Available Android classes

Some Android classes can be directly used through scripting (creation of new instances, access to static fields - aka constants - and method calls). The list of supported classes are: @@ -35,26 +35,26 @@

  • TaskerIntent
  • ActionCodes
  • -Other classes can be accessed through their fully qualified name. For instance, should you need to access accelerometers, you may want to use android.hardware.Sensor.TYPE_ACCELEROMETER. Using LL.bindClass(String name) will conveniently suppress the need for explicit package naming (Sensor.TYPE_ACCELEROMETER would be enough if LL.bindClass("android.hardware.Sensor"); has been called previously. +Other classes can be accessed through their fully qualified name. For instance, should you need to access accelerometers, you may want to use android.hardware.Sensor.TYPE_ACCELEROMETER. Using bindClass(String name) will conveniently suppress the need for explicit package naming (Sensor.TYPE_ACCELEROMETER would be enough if bindClass("android.hardware.Sensor"); has been called previously.

    Things to be aware of

    Use the new Script Editor icon (in your app drawer) to quickly edit scripts. No need to configure events and select run a script: just launch the script editor and it will open on the last edited script.

    DOs and DON'Ts

    -

    Use and absuse from variables

    +

    Use and abuse from variables

    API calls are expensive, and you never know what is hidden behind. It is a good idea to keep return values in local variables to minimize API calls. For instance:

    -    alert(LL.getEvent().getTouchX()+" / "+LL.getEvent().getTouchY()); /* BAD */
    +    alert(getEvent().getTouchX()+" / "+getEvent().getTouchY()); /* BAD */
     
    -    var e = LL.getEvent();
    +    var e = getEvent();
         alert(e.getTouchX()+" / "+e.getTouchY()); /* BETTER */
         

    Not suitable for (smooth) animations

    While it is possible to move, rotate or change items configuration, performances may not be enough to sustain a 60Hz animation rate.

    Timers

    -

    It is possible to set timers using setTimeout. Pay special attention to clear these timers when needed, LL won't do this for you. If you don't clear timers, you may severly increase CPU use and battery consumption.

    +

    It is possible to set timers using setTimeout. Pay special attention to clear these timers when needed, LL won't do this for you. If you don't clear timers, you may severely increase CPU use and battery consumption.

    Object references

    Avoid keeping references to objects returned by LL APIs in the script side, otherwise you may leak data. It is possible to use

    self
    to store data that are kept between two script execution (and can be shared between scripts), but try to avoid this as much as possible.

    diff --git a/app/llx/app/build.gradle b/app/llx/app/build.gradle index b21d113..0f00e6a 100644 --- a/app/llx/app/build.gradle +++ b/app/llx/app/build.gradle @@ -42,16 +42,16 @@ if(project.hasProperty("signing.properties") && new File(project.property("signi } android { - compileSdkVersion 26 - buildToolsVersion '26.0.2' + compileSdkVersion 28 defaultConfig { - versionCode 325 - versionName "14.3-beta3 (ec5b56b)" + versionCode 328 + versionName "14.3-beta7 (x)" buildConfigField "boolean", "IS_BETA", "true" // change in core too + buildConfigField "boolean", "HAS_UEC", "false" minSdkVersion 14 - targetSdkVersion 26 + targetSdkVersion 28 } // dexOptions { diff --git a/app/llx/app/src/main/AndroidManifest.xml b/app/llx/app/src/main/AndroidManifest.xml index 3863939..555fb60 100644 --- a/app/llx/app/src/main/AndroidManifest.xml +++ b/app/llx/app/src/main/AndroidManifest.xml @@ -14,9 +14,10 @@ - + + @@ -28,8 +29,10 @@ + android:name="net.pierrox.lightning_launcher.USE_SCRIPT_SERVICE" + android:protectionLevel="dangerous" + android:label="@string/permission_label" + android:description="@string/permission_description"/> - - + + - - - + @@ -84,12 +87,12 @@ android:excludeFromRecents="true" android:windowSoftInputMode="adjustNothing" android:configChanges="keyboardHidden|orientation|screenSize|mcc|mnc"> - + - + @@ -104,13 +107,13 @@ - + - + - + - + - + - + - + @@ -199,7 +202,7 @@ - + - + @@ -322,7 +325,7 @@ - + - - + diff --git a/app/llx/app/src/main/aidl/net/pierrox/lightning_launcher/plugin/IPluginService.aidl b/app/llx/app/src/main/aidl/net/pierrox/lightning_launcher/plugin/IPluginService.aidl deleted file mode 100644 index 66f27a7..0000000 --- a/app/llx/app/src/main/aidl/net/pierrox/lightning_launcher/plugin/IPluginService.aidl +++ /dev/null @@ -1,25 +0,0 @@ -package net.pierrox.lightning_launcher.plugin; - -interface IPluginService { - - /** - * @returns id of the newly created script, or -1 if the name/path combination already exists - */ - int createScript(String code, String name, String path, int flags); - - /** - * @returns id of the newly created or overwritten script - */ - int createOrOverwriteScript(String code, String name, String path, int flags); - - - /** - * runs the script with the given id and optional data - */ - void runScript(int id, String data); - - /** - * runs the given code. Code must end with a return statement - */ - String runCode(String code); -} diff --git a/app/llx/app/src/main/java/fr/xgouchet/texteditor/ui/AdvancedEditText.java b/app/llx/app/src/main/java/fr/xgouchet/texteditor/ui/AdvancedEditText.java index 0de8f8c..5608eb4 100755 --- a/app/llx/app/src/main/java/fr/xgouchet/texteditor/ui/AdvancedEditText.java +++ b/app/llx/app/src/main/java/fr/xgouchet/texteditor/ui/AdvancedEditText.java @@ -534,7 +534,21 @@ public class AdvancedEditText extends EditText implements OnKeyListener, OnGestu mHighlightedLine = line; } } - + + /** + * Like {@link EditText#getSelectionStart()} but returns the real start, even with a 'negative' selection. + */ + public int getTrueSelectionStart() { + return Math.min(super.getSelectionStart(), super.getSelectionEnd()); + } + + /** + * Like {@link EditText#getSelectionEnd()} but returns the real end, even with a 'negative' selection. + */ + public int getTrueSelectionEnd() { + return Math.max(super.getSelectionStart(), super.getSelectionEnd()); + } + /** The line numbers paint */ protected Paint mPaintNumbers; /** The line numbers paint */ diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/LLAppPhone.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/LLAppPhone.java index 6e8ffc5..22c4199 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/LLAppPhone.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/LLAppPhone.java @@ -11,6 +11,7 @@ import net.pierrox.lightning_launcher.activities.AppDrawerX; import net.pierrox.lightning_launcher.activities.Dashboard; import net.pierrox.lightning_launcher.activities.LockScreen; import net.pierrox.lightning_launcher.activities.ScriptEditor; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.data.Page; import net.pierrox.lightning_launcher.engine.Screen; import net.pierrox.lightning_launcher.overlay.WindowService; @@ -132,7 +133,7 @@ public abstract class LLAppPhone extends LLApp { // FIXME rename this to displayDashboardPage or better @Override public void displayPagerPage(int page, boolean reset_navigation_history) { - Screen homeScreen = getScreen(Screen.Identity.HOME); + Screen homeScreen = getScreen(ScreenIdentity.HOME); if(homeScreen != null) { homeScreen.loadRootItemLayout(page, reset_navigation_history, true, true); } else { diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/AppDrawerX.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/AppDrawerX.java index 58dbaa3..53715ff 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/AppDrawerX.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/AppDrawerX.java @@ -40,6 +40,7 @@ import android.widget.Toast; import android.widget.ViewAnimator; import net.pierrox.lightning_launcher.LLApp; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.configuration.GlobalConfig; import net.pierrox.lightning_launcher.configuration.ItemConfig; import net.pierrox.lightning_launcher.configuration.PageConfig; @@ -1682,8 +1683,8 @@ public class AppDrawerX extends Dashboard implements EditTextIme.OnEditTextImeLi } @Override - public Identity getIdentity() { - return Identity.APP_DRAWER; + public ScreenIdentity getIdentity() { + return ScreenIdentity.APP_DRAWER; } @Override diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ApplyTemplate.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ApplyTemplate.java index db7b40b..33bbd6c 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ApplyTemplate.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ApplyTemplate.java @@ -242,7 +242,6 @@ public class ApplyTemplate extends ResourceWrapperActivity { cb_wallpaper.setText(R.string.tmpl_w); builder.setView(content); - builder.setMessage(getString(R.string.apply_tmpl_m, mTemplateDisplayName)); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java index f2d36fa..c76c1fd 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java @@ -2,6 +2,7 @@ package net.pierrox.lightning_launcher.activities; import java.io.File; import java.io.FileFilter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; @@ -20,13 +21,14 @@ import net.pierrox.lightning_launcher.data.FileUtils; import net.pierrox.lightning_launcher.data.Folder; import net.pierrox.lightning_launcher.data.Item; import net.pierrox.lightning_launcher.data.Page; -import net.pierrox.lightning_launcher.engine.LightningEngine; import net.pierrox.lightning_launcher.data.Utils; +import net.pierrox.lightning_launcher.util.FileProvider; import net.pierrox.lightning_launcher_extreme.R; import org.json.JSONObject; import android.Manifest; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -36,10 +38,12 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.database.Cursor; import android.graphics.Rect; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; +import android.provider.OpenableColumns; import android.view.View; import android.view.View.OnLongClickListener; import android.widget.AdapterView; @@ -60,6 +64,8 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli private static final int DIALOG_CONFIRM_DELETE=6; private static final int REQUEST_SELECT_PAGES_FOR_EXPORT = 1; + private static final int REQUEST_SELECT_FILE_TO_IMPORT = 2; + private static final int REQUEST_SELECT_FILE_TO_LOAD = 3; private ListView mListView; private TextView mEmptyView; @@ -79,7 +85,12 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli Button backup = (Button) findViewById(R.id.backup); backup.setText(R.string.backup_t); backup.setOnClickListener(this); - + + Button import_ = (Button) findViewById(R.id.import_); + import_.setText(R.string.import_t); + import_.setOnClickListener(this); + import_.setOnLongClickListener(this); + Button export = (Button) findViewById(R.id.export); export.setText(R.string.tmpl_e_t); export.setOnClickListener(this); @@ -161,6 +172,10 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli exportArchive(true); break; + case R.id.import_: + selectFileToLoadOrImport(true); + break; + case R.id.export: exportArchive(false); break; @@ -168,9 +183,17 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli } @Override - public boolean onLongClick(View arg0) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.pierrox.net/cmsms/applications/lightning-launcher/templates.html"))); - return true; + public boolean onLongClick(View view) { + switch(view.getId()) { + case R.id.export: + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.pierrox.net/cmsms/applications/lightning-launcher/templates.html"))); + return true; + + case R.id.import_: + selectFileToLoadOrImport(false); + return true; + } + return false; } @Override @@ -234,7 +257,7 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli if(mArchiveName != null || mArchiveUri != null) { builder = new AlertDialog.Builder(this); builder.setTitle(R.string.br_rc); - builder.setMessage(mArchiveName==null ? mArchiveUri.getLastPathSegment() : mArchiveName); + builder.setMessage(mArchiveName==null ? getNameForUri(mArchiveUri) : mArchiveName); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -297,8 +320,10 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli case 3: Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); - shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(FileUtils.LL_EXT_DIR +"/"+mArchiveName))); + Uri uri = FileProvider.getUriForFile(new File(FileUtils.LL_EXT_DIR +"/"+mArchiveName)); + shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("application/zip"); + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.br_s))); break; case 4: @@ -359,6 +384,14 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli doExportTemplate(mArchiveName, all_pages); } + } else if(requestCode == REQUEST_SELECT_FILE_TO_IMPORT){ + if(resultCode == RESULT_OK) { + importFile(data.getData()); + } + } else if(requestCode == REQUEST_SELECT_FILE_TO_LOAD){ + if(resultCode == RESULT_OK) { + loadArchive(data.getData(), null); + } } else { super.onActivityResult(requestCode, resultCode, data); } @@ -570,4 +603,83 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli } } } + + /** + * Request the user to pick an archive. + * @param only_load true to directly load the archive without first importing it in the LL_EXT_DIR directory. + */ + private void selectFileToLoadOrImport(boolean only_load) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("*/*"); + intent.addCategory(Intent.CATEGORY_OPENABLE); + startActivityForResult(Intent.createChooser(intent, getString(R.string.import_t)), only_load ? REQUEST_SELECT_FILE_TO_LOAD : REQUEST_SELECT_FILE_TO_IMPORT); + } + + @SuppressLint("StaticFieldLeak") + private void importFile(final Uri uri) { + new AsyncTask() { + private ProgressDialog mDialog; + + @Override + protected void onPreExecute() { + mDialog = new ProgressDialog(BackupRestore.this); + mDialog.setMessage(getString(R.string.importing)); + mDialog.setCancelable(false); + mDialog.show(); + } + + @Override + protected File doInBackground(Void... voids) { + InputStream is = null; + FileOutputStream os = null; + File outFile = null; + try { + String name = getNameForUri(uri); + outFile = new File(FileUtils.LL_EXT_DIR, name); + + is = getContentResolver().openInputStream(uri); + os = new FileOutputStream(outFile); + FileUtils.copyStream(is, os); + return outFile; + } catch (IOException e) { + if(outFile != null) { + outFile.delete(); + } + return null; + } finally { + try { if(is != null) is.close(); } catch(IOException e) {} + try { if(os != null) os.close(); } catch(IOException e) {} + } + } + + @Override + protected void onPostExecute(File outFile) { + mDialog.dismiss(); + if(outFile != null) { + loadArchivesList(); + loadArchive(null, outFile.getName()); + } else { + Toast.makeText(BackupRestore.this, R.string.import_e, Toast.LENGTH_SHORT).show(); + } + } + }.execute((Void) null); + } + + private String getNameForUri(Uri uri) { + String name = null; + if (uri.getScheme().equals("content")) { + Cursor cursor = getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null); + try { + if (cursor != null && cursor.moveToFirst()) { + name = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + } + } finally { + cursor.close(); + } + } + if (name == null) { + name = uri.getLastPathSegment(); + } + return name; + } } diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Customize.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Customize.java index 477c306..4660392 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Customize.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Customize.java @@ -33,6 +33,7 @@ import com.readystatesoftware.systembartint.SystemBarTintManager; import net.pierrox.lightning_launcher.API; import net.pierrox.lightning_launcher.LLApp; import net.pierrox.lightning_launcher.Version; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.configuration.FolderConfig; import net.pierrox.lightning_launcher.configuration.FolderConfig.FolderAnimation; import net.pierrox.lightning_launcher.configuration.GlobalConfig; @@ -247,8 +248,8 @@ public class Customize extends ResourceWrapperActivity implements } else { mScreen = new Screen(this, 0) { @Override - public Identity getIdentity() { - return Identity.CUSTOMIZE; + public ScreenIdentity getIdentity() { + return ScreenIdentity.CUSTOMIZE; } @Override @@ -518,7 +519,7 @@ public class Customize extends ResourceWrapperActivity implements } else if (preference == mPGReset) { displayDialog(DIALOG_CONFIRM_RESET_PAGE); } else if (preference == mPGBackgroundSelectSystemWallpaper) { - startActivity(Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), getString(R.string.wp_select_t))); + startActivity(Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), getString(R.string.bg_sys_wp_select_t))); } else if (preference == mPGBackgroundSelectScreenWallpaper) { ImagePicker.startActivity(this, REQUEST_PICK_SCREEN_WALLPAPER); } else if (preference == mPGApplyIconPack) { @@ -1189,11 +1190,17 @@ public class Customize extends ResourceWrapperActivity implements if (Build.VERSION.SDK_INT >= 19) { mPreferencesPageSystemBars.add(mPGSystemBarsStatusBarColor = new LLPreferenceColor(this, ID_mPGSystemBarsStatusBarColor, R.string.sbc_t, 0, pc.statusBarColor, null, true)); + if (Build.VERSION.SDK_INT >= 23) { + mPreferencesPageSystemBars.add(mPGSystemBarsStatusBarLight = new LLPreferenceCheckBox(this, ID_mPGSystemBarsStatusBarLight, R.string.sbl_t, 0, pc.statusBarLight, null)); + } mPreferencesPageSystemBars.add(mPGSystemBarsStatusBarOverlap = new LLPreferenceCheckBox(this, ID_mPGSystemBarsStatusBarOverlap, R.string.sbo_t, 0, pc.statusBarOverlap, null)); if (mSystemBarTintManager == null || (mSystemBarTintManager != null && mSystemBarTintManager.getConfig().hasNavigationBar())) { mPreferencesPageSystemBars.add(new LLPreferenceCategory(this, R.string.nb_c)); mPreferencesPageSystemBars.add(mPGSystemBarsNavigationBarColor = new LLPreferenceColor(this, ID_mPGSystemBarsNavigationBarColor, R.string.nbc_t, 0, pc.navigationBarColor, null, true)); + if (Build.VERSION.SDK_INT >= 26) { + mPreferencesPageSystemBars.add(mPGSystemBarsNavigationBarLight = new LLPreferenceCheckBox(this, ID_mPGSystemBarsNavigationBarLight, R.string.nbl_t, 0, pc.navigationBarLight, null)); + } mPreferencesPageSystemBars.add(mPGSystemBarsNavBarOverlap = new LLPreferenceCheckBox(this, ID_mPGSystemBarsNavBarOverlap, R.string.nbo_t, 0, pc.navigationBarOverlap, null)); } } @@ -1310,6 +1317,7 @@ public class Customize extends ResourceWrapperActivity implements is_folder_page ? R.string.this_folder_feel_t : R.string.folder_feel_t, R.string.folder_feel_s)); mPreferencesPageFolderFeel = new ArrayList(); + mPreferencesPageFolderFeel.add(mPGFolderFeelOutsideTapClose = new LLPreferenceCheckBox(this, ID_mPGFolderFeelOutsideTapClose, R.string.otc_t, 0, fc.outsideTapClose, fc_def == null ? null : fc_def.outsideTapClose)); mPreferencesPageFolderFeel.add(mPGFolderFeelAutoClose = new LLPreferenceCheckBox(this, ID_mPGFolderFeelAutoClose, R.string.auto_close_t, R.string.auto_close_s, fc.autoClose, fc_def == null ? null : fc_def.autoClose)); if(!is_folder_page) { mPreferencesPageFolderFeel.add(mPGFolderFeelCloseOther = new LLPreferenceCheckBox(this, ID_mPGFolderFeelCloseOther, R.string.cof_t, R.string.cof_s, fc.closeOther, fc_def == null ? null : fc_def.closeOther)); @@ -1636,7 +1644,9 @@ public class Customize extends ResourceWrapperActivity implements if(mPGSystemBarsStatusBarOverlap != null) pc.statusBarOverlap = mPGSystemBarsStatusBarOverlap.isChecked(); if(mPGSystemBarsNavBarOverlap != null) pc.navigationBarOverlap = mPGSystemBarsNavBarOverlap.isChecked(); if(mPGSystemBarsStatusBarColor != null) pc.statusBarColor = mPGSystemBarsStatusBarColor.getColor(); + if(mPGSystemBarsStatusBarLight != null) pc.statusBarLight = mPGSystemBarsStatusBarLight.isChecked(); if(mPGSystemBarsNavigationBarColor != null) pc.navigationBarColor = mPGSystemBarsNavigationBarColor.getColor(); + if(mPGSystemBarsNavigationBarLight != null) pc.navigationBarLight = mPGSystemBarsNavigationBarLight.isChecked(); pc.statusBarHide = mPGSystemBarsHideStatusBar.isChecked(); if(is_app_drawer) { pc.autoExit = mPGMiscAutoExit.isChecked(); @@ -1660,6 +1670,7 @@ public class Customize extends ResourceWrapperActivity implements fc.animationIn = (FolderAnimation) mPGFolderLookAnimOpen.getValueEnum(); fc.animationOut = (FolderAnimation) mPGFolderLookAnimClose.getValueEnum(); fc.animFade = mPGFolderLookAnimFade.isChecked(); + fc.outsideTapClose = mPGFolderFeelOutsideTapClose.isChecked(); fc.autoClose = mPGFolderFeelAutoClose.isChecked(); if(!is_folder) { fc.closeOther = mPGFolderFeelCloseOther.isChecked(); @@ -2099,7 +2110,9 @@ public class Customize extends ResourceWrapperActivity implements private LLPreferenceCheckBox mPGSystemBarsStatusBarOverlap; private LLPreferenceCheckBox mPGSystemBarsNavBarOverlap; private LLPreferenceColor mPGSystemBarsStatusBarColor; + private LLPreferenceCheckBox mPGSystemBarsStatusBarLight; private LLPreferenceColor mPGSystemBarsNavigationBarColor; + private LLPreferenceCheckBox mPGSystemBarsNavigationBarLight; private LLPreferenceColor mPGAppDrawerABTextColor; private LLPreference mPGAppDrawerABBackground; @@ -2163,6 +2176,7 @@ public class Customize extends ResourceWrapperActivity implements private LLPreferenceEventAction mPageEventMenu; private LLPreference mPGFolderFeel; + private LLPreferenceCheckBox mPGFolderFeelOutsideTapClose; private LLPreferenceCheckBox mPGFolderFeelAutoClose; private LLPreferenceCheckBox mPGFolderFeelCloseOther; private LLPreferenceCheckBox mPGFolderFeelAnimGlitchFix; @@ -2226,6 +2240,7 @@ public class Customize extends ResourceWrapperActivity implements private static final int ID_mPGZoomScrollDisableDiagonal = 90; private static final int ID_mPGZoomScrollEnablePinch = 91; private static final int ID_mPGFolderFeel = 92; + private static final int ID_mPGFolderFeelOutsideTapClose = 515; private static final int ID_mPGFolderFeelAutoClose = 93; private static final int ID_mPGFolderFeelAnimGlitchFix = 94; private static final int ID_mPGMisc = 95; @@ -2276,7 +2291,9 @@ public class Customize extends ResourceWrapperActivity implements private static final int ID_mPGSystemBarsNavBarOverlap = 164; private static final int ID_mPGSystemBars = 165; private static final int ID_mPGSystemBarsStatusBarColor = 166; + private static final int ID_mPGSystemBarsStatusBarLight = 513; private static final int ID_mPGSystemBarsNavigationBarColor = 167; + private static final int ID_mPGSystemBarsNavigationBarLight = 514; private static final int ID_mGCAppStyle = 168; private static final int ID_mPGADCategories = 190; private static final int ID_mPGBackgroundScaleType = 191; diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Dashboard.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Dashboard.java index ad1ddaa..c057182 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Dashboard.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/Dashboard.java @@ -86,6 +86,7 @@ import com.readystatesoftware.systembartint.SystemBarTintManager; import net.pierrox.lightning_launcher.API; import net.pierrox.lightning_launcher.LLApp; import net.pierrox.lightning_launcher.Version; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.configuration.DynamicTextConfig; import net.pierrox.lightning_launcher.configuration.FolderConfig; import net.pierrox.lightning_launcher.configuration.GlobalConfig; @@ -525,7 +526,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis mUndoStack.setUndoListener(this); - if(BuildConfig.IS_BETA) { + if(BuildConfig.HAS_UEC) { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { @@ -862,7 +863,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis mScreen.runAction(mEngine, "SHORTCUT", eventAction); handled = true; } else { - if(intent.hasExtra(LightningIntent.INTENT_EXTRA_PAGE)) { + if(intent.hasExtra(LightningIntent.INTENT_EXTRA_DESKTOP)) { mScreen.executeGoToDesktopPositionIntent(intent); handled = true; } @@ -944,7 +945,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis case REQUEST_SELECT_SHORTCUT_FOR_ADD1: ComponentName cn = data.getComponent(); if(cn != null && cn.getClassName().endsWith(".activities.ShortcutsS")) { - Intent shortcut = PhoneUtils.createDesktopBookmarkShortcut(this, il, null, null, null); + Intent shortcut = PhoneUtils.createDesktopBookmarkShortcut(this, il, null, null, null, true); newItem=Utils.addAndroidShortcutFromIntent(this, shortcut, page, mScreen.getLastTouchedAddX(), mScreen.getLastTouchedAddY(), scale); mUndoStack.storePageAddItem(newItem); } else { @@ -1761,10 +1762,10 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis if(mNoScriptCounter == 5) { ScriptManager sm = mEngine.getScriptManager(); Script easter_egg = sm.createScriptForFile(getString(R.string.mi_nost), "/"+getPackageName().replace('.', '/')); - easter_egg.setSourceText("LL.bindClass('android.view.animation.AccelerateDecelerateInterpolator');\n" + - "LL.bindClass('android.view.animation.AnimationUtils');\n" + + easter_egg.setSourceText("bindClass('android.view.animation.AccelerateDecelerateInterpolator');\n" + + "bindClass('android.view.animation.AnimationUtils');\n" + "\n" + - "var item = LL.getEvent().getItem();\n" + + "var item = getEvent().getItem();\n" + "\n" + "var properties = item.getProperties();\n" + "var was_on_grid = properties.getBoolean('i.onGrid');\n" + @@ -2768,7 +2769,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis mHandler.removeCallbacks(mSetLiveWallpaperVisibility); mSetLiveWallpaperVisibility = null; } - final Screen lwp = LLApp.get().getScreen(Screen.Identity.LIVE_WALLPAPER); + final Screen lwp = LLApp.get().getScreen(ScreenIdentity.LIVE_WALLPAPER); if(lwp != null) { if(delay != 0) { mSetLiveWallpaperVisibility = new Runnable() { @@ -3281,7 +3282,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis private void addBookmark() { ItemLayout il = mScreen.getTargetOrTopmostItemLayout(); Page page = il.getPage(); - Intent intent = PhoneUtils.createDesktopBookmarkShortcut(this, il, null, null, null); + Intent intent = PhoneUtils.createDesktopBookmarkShortcut(this, il, null, null, null, true); Item item = Utils.addAndroidShortcutFromIntent(this, intent, page, mScreen.getLastTouchedAddX(), mScreen.getLastTouchedAddY(), il.getCurrentScale()); mUndoStack.storePageAddItem(item); boolean wasInEditMode = il.getEditMode(); @@ -3324,37 +3325,21 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis @TargetApi(Build.VERSION_CODES.O) private void addPinnedShortcut(Intent intent) { - Parcelable extra = intent.getParcelableExtra(LauncherApps.EXTRA_PIN_ITEM_REQUEST); - if(extra instanceof LauncherApps.PinItemRequest) { - LauncherApps.PinItemRequest request = (LauncherApps.PinItemRequest) extra; - if (request.getRequestType() == LauncherApps.PinItemRequest.REQUEST_TYPE_SHORTCUT) { - final LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE); - ShortcutInfo shortcutInfo = request.getShortcutInfo(); + Utils.ShortcutDescription sd = Utils.createPinItemRequestFromIntent(this, intent); + if(sd != null) { + final ItemLayout il = mScreen.getTargetOrTopmostItemLayout(); + Page page = il.getPage(); + float scale = il.getCurrentScale(); + final Item newItem = Utils.addShortcut(sd.name, sd.icon, sd.intent, page, Utils.POSITION_AUTO, Utils.POSITION_AUTO, scale, true); - final Drawable iconDrawable = launcherApps.getShortcutIconDrawable(shortcutInfo, Utils.getLauncherIconDensity()); - Bitmap icon = Utils.createBitmapFromDrawable(iconDrawable); - - Intent si = new Intent(Shortcut.INTENT_ACTION_APP_SHORTCUT); - si.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_ID, shortcutInfo.getId()); - si.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_PKG, shortcutInfo.getPackage()); - si.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_DISABLED_MSG, shortcutInfo.getDisabledMessage()); - - final ItemLayout il = mScreen.getTargetOrTopmostItemLayout(); - Page page = il.getPage(); - float scale = il.getCurrentScale(); - final Item newItem = Utils.addShortcut(shortcutInfo.getShortLabel().toString(), icon, si, page, Utils.POSITION_AUTO, Utils.POSITION_AUTO, scale, true); - - mUndoStack.storePageAddItem(newItem); - editItem(il, newItem); - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - mScreen.ensureItemViewVisible(il.getItemView(newItem), false); - } - }, 1000); - - request.accept(); - } + mUndoStack.storePageAddItem(newItem); + editItem(il, newItem); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + mScreen.ensureItemViewVisible(il.getItemView(newItem), false); + } + }, 1000); } } @@ -6135,8 +6120,8 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis } @Override - public Identity getIdentity() { - return Identity.HOME; + public ScreenIdentity getIdentity() { + return ScreenIdentity.HOME; } @Override @@ -7378,5 +7363,12 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis startActivity(new Intent(Dashboard.this, Dashboard.class)); System.exit(0); } + + @Override + public void onSystemBarsSizeChanged() { + Page page = mScreen.getCurrentRootPage(); + if(page != null) { + configureSystemBarsPadding(page.config); + } } } } diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/LockScreen.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/LockScreen.java index ddbdd66..048b87f 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/LockScreen.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/LockScreen.java @@ -15,6 +15,7 @@ import android.view.View; import android.view.Window; import android.view.WindowManager; import net.pierrox.lightning_launcher.LLApp; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.configuration.GlobalConfig; import net.pierrox.lightning_launcher.data.EventAction; import net.pierrox.lightning_launcher.data.Item; @@ -221,8 +222,8 @@ public class LockScreen extends Dashboard { } @Override - public Identity getIdentity() { - return Identity.LOCK; + public ScreenIdentity getIdentity() { + return ScreenIdentity.LOCK; } @Override diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScreenManager.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScreenManager.java index b813dfa..726271f 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScreenManager.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScreenManager.java @@ -39,6 +39,7 @@ import android.widget.Toast; import net.pierrox.lightning_launcher.API; import net.pierrox.lightning_launcher.LLApp; import net.pierrox.lightning_launcher.LLAppPhone; +import net.pierrox.lightning_launcher.api.ScreenIdentity; import net.pierrox.lightning_launcher.configuration.GlobalConfig; import net.pierrox.lightning_launcher.data.Item; import net.pierrox.lightning_launcher.data.LightningIntent; @@ -159,8 +160,8 @@ public class ScreenManager extends ResourceWrapperActivity implements OnClickLis private void init() { mScreen = new net.pierrox.lightning_launcher.engine.Screen(this, 0) { @Override - public Identity getIdentity() { - return Identity.DESKTOP_PREVIEW; + public ScreenIdentity getIdentity() { + return ScreenIdentity.DESKTOP_PREVIEW; } @Override @@ -418,7 +419,7 @@ public class ScreenManager extends ResourceWrapperActivity implements OnClickLis int p = (Integer)v.getTag(); Screen screen = mScreens.get(getScreenIndex(p)); Page page = mLightningEngine.getOrLoadPage(p); - Intent shortcut = PhoneUtils.createDesktopBookmarkShortcut(this, null, page, screen.label, screen.icon); + Intent shortcut = PhoneUtils.createDesktopBookmarkShortcut(this, null, page, screen.label, screen.icon, true); setResult(RESULT_OK, shortcut); finish(); } else if(mMode==SCREEN_MODE_SELECT_MULTIPLE) { @@ -636,7 +637,7 @@ public class ScreenManager extends ResourceWrapperActivity implements OnClickLis Intent intent = s.getIntent(); ComponentName cn=intent.getComponent(); if(cn!=null && cn.compareTo(ll_component_name)==0) { - if(intent.hasExtra(LightningIntent.INTENT_EXTRA_PAGE) && intent.getIntExtra(LightningIntent.INTENT_EXTRA_PAGE, 0)==screen.page) { + if(intent.hasExtra(LightningIntent.INTENT_EXTRA_DESKTOP) && intent.getIntExtra(LightningIntent.INTENT_EXTRA_DESKTOP, 0)==screen.page) { // it looks like a screen&position shortcut if(update_icon) { icon_dir.mkdirs(); diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScriptEditor.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScriptEditor.java index df827fc..1108ac0 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScriptEditor.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/ScriptEditor.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.text.Editable; import android.text.TextWatcher; +import android.util.Pair; import android.util.SparseArray; import android.view.GestureDetector; import android.view.KeyEvent; @@ -49,9 +50,8 @@ import net.pierrox.lightning_launcher.Version; import net.pierrox.lightning_launcher.data.FileUtils; import net.pierrox.lightning_launcher.data.Utils; import net.pierrox.lightning_launcher.engine.LightningEngine; -import net.pierrox.lightning_launcher.script.ScriptManager; import net.pierrox.lightning_launcher.script.Script; -import net.pierrox.lightning_launcher.script.api.Array; +import net.pierrox.lightning_launcher.script.ScriptManager; import net.pierrox.lightning_launcher.script.api.Box; import net.pierrox.lightning_launcher.script.api.Container; import net.pierrox.lightning_launcher.script.api.Desktop; @@ -64,17 +64,17 @@ import net.pierrox.lightning_launcher.script.api.ImageNinePatch; import net.pierrox.lightning_launcher.script.api.ImageScript; import net.pierrox.lightning_launcher.script.api.ImageSvg; import net.pierrox.lightning_launcher.script.api.Item; -import net.pierrox.lightning_launcher.script.api.LL; import net.pierrox.lightning_launcher.script.api.Lightning; import net.pierrox.lightning_launcher.script.api.PageIndicator; import net.pierrox.lightning_launcher.script.api.Panel; import net.pierrox.lightning_launcher.script.api.PropertyEditor; import net.pierrox.lightning_launcher.script.api.PropertySet; import net.pierrox.lightning_launcher.script.api.RectL; -import net.pierrox.lightning_launcher.script.api.Shortcut; import net.pierrox.lightning_launcher.script.api.StopPoint; import net.pierrox.lightning_launcher.util.FileAndDirectoryPickerDialog; import net.pierrox.lightning_launcher.util.FileProvider; +import net.pierrox.lightning_launcher.util.Indentation; +import net.pierrox.lightning_launcher.util.Search; import net.pierrox.lightning_launcher_extreme.BuildConfig; import net.pierrox.lightning_launcher_extreme.R; @@ -100,6 +100,7 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic private static final String PREF_LAST_SCRIPT_ID = "se_lsi"; private static final String PREF_LAST_SCRIPT_LINE = "se_lsl"; private static final String PREF_WORDWRAP = "se_w"; + private static final String PREF_AUTOINDENT = "se_ind"; private static final String PREF_FONT_SIZE = "se_fs"; private static final String PREF_DIRECTORY = "se_d"; private static final String PREF_SUB_DIRS = "se_sd"; @@ -123,6 +124,8 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic private CheckBox mMenuCustom; private ArrayAdapter