diff --git a/app/build.gradle b/app/build.gradle index 26ba779558d721bef24342454e4e4f8bebaee11f..da509ca2091a103db26ff158564529d7b6f7d31c 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { minSdkVersion 8 targetSdkVersion 23 - versionCode 111 - versionName "6.0e" + versionCode 113 + versionName "6.0g" } buildTypes { @@ -47,6 +47,4 @@ android { output.outputFile.name.replace("app-release.apk", "${x}/${variant.applicationId}_${variant.versionName}_${new Date().format("dd-MM_hh.mm.ss")}.apk")) } } -} -dependencies { } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 83368d5ae174b2a12e4baa5bc528766b348531af..64565b3e497f219d4a4ad2cfbb586e119eaf55f9 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,6 +29,7 @@ <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <!-- features --> <uses-feature android:name="android.hardware.camera" diff --git a/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java b/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java index 816f3c09dcf08274fabd7e631f8af5a251b2959e..5ace3e550cb339753b8a64c2c1aec81e5cddfa9f 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java +++ b/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java @@ -60,7 +60,7 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { private UIManager ui; private MainManager main; - private boolean openKeyboardOnStart, fullscreen; + private boolean openKeyboardOnStart, fullscreen, canApplyTheme; private CommandExecuter ex = new CommandExecuter() { @@ -119,7 +119,6 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { } }; - static final boolean DEBUG = BuildConfig.BUILD_TYPE.startsWith("debug"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -130,17 +129,15 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { return; } - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (!(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && - ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && + ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, - LauncherActivity.STARTING_PERMISSION); - return; - } + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, LauncherActivity.STARTING_PERMISSION); + } + else { + canApplyTheme = true; + finishOnCreate(); } - - finishOnCreate(); } private void finishOnCreate() { @@ -189,7 +186,11 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { } } - NotificationManager.create(); + try { + NotificationManager.create(); + } catch (Exception e) { + Tuils.toFile(e); + } boolean notifications = XMLPrefsManager.get(boolean.class, NotificationManager.Options.show_notifications); if(notifications) { LocalBroadcastManager.getInstance(this).registerReceiver(onNotice, new IntentFilter("Msg")); @@ -207,7 +208,7 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { ViewGroup mainView = (ViewGroup) findViewById(R.id.mainview); main = new MainManager(this, in, out, sugg); - ui = new UIManager(main.getMainPack(), this, mainView, ex, main.getMainPack()); + ui = new UIManager(main.getMainPack(), this, mainView, ex, main.getMainPack(), canApplyTheme); main.setRedirectionListener(ui.buildRedirectionListener()); main.setHintable(ui.getHintable()); main.setRooter(ui.getRooter()); @@ -382,14 +383,19 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { case STARTING_PERMISSION: int count = 0; while(count < permissions.length && count < grantResults.length) { - if( (permissions[count].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE) || permissions[count].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) - && grantResults[count] == PackageManager.PERMISSION_DENIED) { + if(grantResults[count] == PackageManager.PERMISSION_DENIED) { Toast.makeText(this, R.string.permissions_toast, Toast.LENGTH_LONG).show(); - finish(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + finish(); + } + }, 2000); return; } count++; } + canApplyTheme = false; finishOnCreate(); break; case COMMAND_SUGGESTION_REQUEST_PERMISSION: diff --git a/app/src/main/java/ohi/andre/consolelauncher/UIManager.java b/app/src/main/java/ohi/andre/consolelauncher/UIManager.java index 40f77b61733047be5a27a2a2bfe6f39adbb935f3..929af44f77d7f3085aaf213e5a9fb1714f2e7142 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/UIManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/UIManager.java @@ -10,6 +10,7 @@ import android.graphics.Typeface; import android.os.Handler; import android.text.Editable; import android.text.TextWatcher; +import android.util.DisplayMetrics; import android.view.GestureDetector; import android.view.GestureDetector.OnDoubleTapListener; import android.view.Gravity; @@ -424,7 +425,7 @@ public class UIManager implements OnTouchListener { lastSuggestionThread.start(); } - protected UIManager(ExecutePack info, final Context context, final ViewGroup rootView, final CommandExecuter tri, MainPack mainPack) { + protected UIManager(ExecutePack info, final Context context, final ViewGroup rootView, final CommandExecuter tri, MainPack mainPack, boolean canApplyTheme) { policy = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); component = new ComponentName(context, PolicyReceiver.class); @@ -441,7 +442,7 @@ public class UIManager implements OnTouchListener { this.info.skinManager = skinManager; - if (!skinManager.useSystemWp) { + if (!skinManager.useSystemWp || !canApplyTheme) { rootView.setBackgroundColor(skinManager.bgColor); } else { rootView.setBackgroundColor(skinManager.overlayColor); @@ -460,6 +461,15 @@ public class UIManager implements OnTouchListener { }); } + int rightMM, leftMM, topMM, bottomMM; + rightMM = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.right_margin_mm); + leftMM = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.left_margin_mm); + topMM = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.top_margin_mm); + bottomMM = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.bottom_margin_mm); + + DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); + rootView.setPadding(Tuils.mmToPx(metrics, leftMM), Tuils.mmToPx(metrics, topMM), Tuils.mmToPx(metrics, rightMM), Tuils.mmToPx(metrics, bottomMM)); + TextView[] ts = { (TextView) rootView.findViewById(R.id.tv0), (TextView) rootView.findViewById(R.id.tv1), diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/CommandGroup.java b/app/src/main/java/ohi/andre/consolelauncher/commands/CommandGroup.java index 36ec753faf43a332d6501020c2b30fcf10e81405..e00fc3d1901370800900be190fe4f91b61cf3e3e 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/CommandGroup.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/CommandGroup.java @@ -1,6 +1,7 @@ package ohi.andre.consolelauncher.commands; import android.content.Context; +import android.os.Build; import java.io.IOException; import java.lang.reflect.Constructor; @@ -9,6 +10,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import ohi.andre.consolelauncher.commands.specific.APICommand; import ohi.andre.consolelauncher.tuils.Tuils; public class CommandGroup { @@ -32,7 +34,7 @@ public class CommandGroup { while (iterator.hasNext()) { String s = iterator.next(); CommandAbstraction ca = buildCommand(s); - if(ca != null) { + if(ca != null && ( !(ca instanceof APICommand) || ((APICommand) ca).willWorkOn(Build.VERSION.SDK_INT))) { cmdAbs.add(ca); } else { iterator.remove(); diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/airplane.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/airplane.java index 4842eb2403d5f060d769a9949a5dad4fe7fdaa60..07c61cc7e536e7a064ba77bb9ac9484062013c89 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/airplane.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/airplane.java @@ -6,14 +6,14 @@ import android.os.Build; import android.provider.Settings; import ohi.andre.consolelauncher.R; -import ohi.andre.consolelauncher.commands.CommandAbstraction; import ohi.andre.consolelauncher.commands.ExecutePack; import ohi.andre.consolelauncher.commands.main.MainPack; +import ohi.andre.consolelauncher.commands.specific.APICommand; /** * Created by andre on 03/12/15. */ -public class airplane implements CommandAbstraction { +public class airplane extends APICommand { @Override public String exec(ExecutePack pack) { @@ -27,8 +27,8 @@ public class airplane implements CommandAbstraction { info.context.sendBroadcast(intent); return info.res.getString(R.string.output_airplane) + !isEnabled; - } else - return info.res.getString(R.string.output_nofeature); + } + return null; } private boolean isEnabled(Context context) { @@ -69,4 +69,9 @@ public class airplane implements CommandAbstraction { public String onNotArgEnough(ExecutePack info, int nArgs) { return null; } + + @Override + public boolean willWorkOn(int api) { + return api < Build.VERSION_CODES.JELLY_BEAN_MR1; + } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/calc.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/calc.java index 8cf5756d7ced09f602bb02e035dbf36e73d72edb..d4b549a5cdb17fd78fc32140439679cd67520456 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/calc.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/calc.java @@ -18,7 +18,7 @@ public class calc extends PermanentSuggestionCommand { try { return String.valueOf(Tuils.eval(pack.get(String.class, 0))); } catch (Exception e) { - return ((MainPack) pack).res.getString(R.string.output_invalidcalc) + Tuils.NEWLINE + e.toString(); + return e.toString(); } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/data.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/data.java index 7240a73174f29883f792d1fb21c31b99db81db2c..f8a5fe119dcd5dc618b5f5fd97253bb8c0583f4a 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/data.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/data.java @@ -10,34 +10,25 @@ import android.os.Build; import java.lang.reflect.Field; import ohi.andre.consolelauncher.R; -import ohi.andre.consolelauncher.commands.CommandAbstraction; import ohi.andre.consolelauncher.commands.ExecutePack; import ohi.andre.consolelauncher.commands.main.MainPack; +import ohi.andre.consolelauncher.commands.specific.APICommand; import ohi.andre.consolelauncher.tuils.Tuils; -public class data implements CommandAbstraction { +public class data extends APICommand { @Override public String exec(ExecutePack pack) { - boolean active = pack.get(boolean.class, 0); - MainPack info = (MainPack) pack; - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - active = toggle(info); - return info.res.getString(R.string.output_data) + Tuils.SPACE + Boolean.toString(active); - } else { -// ShellUtils.CommandResult result = ShellUtils.execCommand("svc data " + (active ? "enable" : "disable"), true, null); - return pack.context.getString(R.string.output_nofeature); - } + boolean active = toggle(info); + return info.res.getString(R.string.output_data) + Tuils.SPACE + Boolean.toString(active); } private boolean toggle(MainPack info) { if (info.connectivityMgr == null) { try { init(info); - } catch (Exception e) { - e.printStackTrace(); - } + } catch (Exception e) {} } boolean mobileConnected; @@ -80,17 +71,17 @@ public class data implements CommandAbstraction { @Override public int minArgs() { - return 1; + return 0; } @Override public int maxArgs() { - return 1; + return 0; } @Override public int[] argType() { - return new int[] {CommandAbstraction.BOOLEAN}; + return new int[0]; } @Override @@ -100,13 +91,7 @@ public class data implements CommandAbstraction { @Override public String onNotArgEnough(ExecutePack info, int nArgs) { - MainPack pack = (MainPack) info; - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - boolean active = toggle(pack); - return pack.res.getString(R.string.mobile_data) + Tuils.SPACE + active; - } else { - return pack.res.getString(helpRes()); - } + return null; } @Override @@ -114,4 +99,8 @@ public class data implements CommandAbstraction { return onNotArgEnough(info, 0); } + @Override + public boolean willWorkOn(int api) { + return api < Build.VERSION_CODES.LOLLIPOP; + } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/listen.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/listen.java index dd99825b189e322f1122fc601617c93eed0eec50..350af9b2e40914dfdb260b99b12221f2ba35cff2 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/listen.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/listen.java @@ -19,7 +19,7 @@ public class listen extends music { String path = info.player.getPath(name); if (info.player.jukebox(path)) return info.res.getString(R.string.output_playing) + " " + name; - return info.res.getString(R.string.output_nothingfound); + return info.res.getString(R.string.output_nothing_found); } @Override @@ -56,7 +56,7 @@ public class listen extends music { @Override public String onArgNotFound(ExecutePack pack, int index) { MainPack info = (MainPack) pack; - return info.res.getString(R.string.output_nothingfound); + return info.res.getString(R.string.output_nothing_found); } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/location.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/location.java index f33f69a9213907cd36fd2bd7220be077eadc6e13..bfe57402c50c4e0751f6510934220ba03188160c 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/location.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/location.java @@ -14,15 +14,15 @@ import android.support.v4.app.ActivityCompat; import ohi.andre.consolelauncher.LauncherActivity; import ohi.andre.consolelauncher.R; -import ohi.andre.consolelauncher.commands.CommandAbstraction; import ohi.andre.consolelauncher.commands.ExecutePack; import ohi.andre.consolelauncher.commands.main.MainPack; +import ohi.andre.consolelauncher.commands.specific.APICommand; /** * Created by francescoandreuzzi on 10/05/2017. */ -public class location implements CommandAbstraction { +public class location extends APICommand { @Override public String exec(ExecutePack pack) throws Exception { @@ -68,7 +68,8 @@ public class location implements CommandAbstraction { main.locationManager.requestSingleUpdate(gpsStatus ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER, locationListener, Looper.getMainLooper()); return null; - } else return context.getString(R.string.output_nofeature); + } + return null; } @Override @@ -105,4 +106,9 @@ public class location implements CommandAbstraction { public String onNotArgEnough(ExecutePack pack, int nArgs) { return null; } + + @Override + public boolean willWorkOn(int api) { + return api >= Build.VERSION_CODES.GINGERBREAD; + } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/shellcommands.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/shellcommands.java index f9ad8ed30264a5a1c9a58e1428f08b5016f6b5ac..2a99036f5a99d62ac40f663a6455a747140e375e 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/shellcommands.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/shellcommands.java @@ -33,7 +33,7 @@ public class shellcommands implements CommandAbstraction { }); Tuils.addPrefix(commands, Tuils.DOUBLE_SPACE); - Tuils.addSeparator(commands, Tuils.TRIBLE_SPACE); + Tuils.addSeparator(commands, Tuils.SPACE); Tuils.insertHeaders(commands, true); return Tuils.toPlanString(commands, Tuils.EMPTYSTRING); diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tui.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tui.java index 26b1f8d4396ca01793e039e901ccfbc01519d506..f1060a565d2d596cb012a1b485c93234bb1b5f4a 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tui.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tui.java @@ -11,7 +11,6 @@ import ohi.andre.consolelauncher.R; import ohi.andre.consolelauncher.commands.ExecutePack; import ohi.andre.consolelauncher.commands.main.MainPack; import ohi.andre.consolelauncher.commands.specific.ParamCommand; -import ohi.andre.consolelauncher.managers.FileManager; import ohi.andre.consolelauncher.tuils.Tuils; import ohi.andre.consolelauncher.tuils.stuff.PolicyReceiver; @@ -49,7 +48,7 @@ public class tui extends ParamCommand { reset { @Override public String exec(ExecutePack pack) { - FileManager.rm(Tuils.getFolder()); + Tuils.getFolder().delete(); return null; } }, diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/uninstall.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/uninstall.java index 949d893d873c561f0a60354de5965806b20df7fe..b338b9c9968caa768cf755bafb51ef3cb3894304 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/uninstall.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/uninstall.java @@ -17,11 +17,6 @@ public class uninstall implements CommandAbstraction { MainPack info = (MainPack) pack; String packageName = info.get(AppsManager.LaunchInfo.class, 0).componentName.getPackageName(); -// if (info.getSu()) { -// try { -// return ShellUtils.execCommand("su pm uninstall " + packageName, true, null).toString(); -// } catch (Exception e) {} -// } Uri packageURI = Uri.parse("package:" + packageName); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/specific/APICommand.java b/app/src/main/java/ohi/andre/consolelauncher/commands/specific/APICommand.java new file mode 100644 index 0000000000000000000000000000000000000000..eead85e44d7090dc5450f51149d2d4e3f9c60d1c --- /dev/null +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/specific/APICommand.java @@ -0,0 +1,12 @@ +package ohi.andre.consolelauncher.commands.specific; + +import ohi.andre.consolelauncher.commands.CommandAbstraction; + +/** + * Created by francescoandreuzzi on 01/08/2017. + */ + +public abstract class APICommand implements CommandAbstraction { + + public abstract boolean willWorkOn(int api); +} diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java index 31d9e7671ded0b7044980753c08c243e6006ea34..5c0708c3ca79558e6a848e93e7c0dcc0b07ff25c 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java @@ -311,7 +311,7 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { writeTo(d, file); } } catch (Exception e) { - Tuils.write(Tuils.getStackTrace(e)); + Tuils.toFile(e); } for(Map.Entry<String, ?> entry : this.preferences.getAll().entrySet()) { @@ -382,6 +382,8 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { } private void appUninstalled(String packageName) { + outputable.onOutput(context.getString(R.string.app_uninstalled) + Tuils.SPACE + packageName); + List<LaunchInfo> infos = AppUtils.findLaunchInfosWithPackage(packageName, appsHolder.getApps()); for(LaunchInfo i : infos) appsHolder.remove(i); } diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java index e81a56e930745513c61bf8b5adc8c98b5bfefcd8..c622d14d12c6ef90abddb67c860d898c0cd0aa9a 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java @@ -8,12 +8,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import ohi.andre.consolelauncher.MainManager; import ohi.andre.consolelauncher.tuils.Tuils; public class FileManager { @@ -21,33 +16,11 @@ public class FileManager { public static final int FILE_NOTFOUND = 10; public static final int ISDIRECTORY = 11; public static final int IOERROR = 12; - public static final int ISFILE = 13; - public static final int NOT_WRITEABLE = 14; - public static final int NOT_READABLE = 15; - - public static final int MIN_FILE_RATE = 4; - - public static final boolean USE_SCROLL_COMPARE = true; private static final String ASTERISK = "*"; private static final String DOT = Tuils.DOT; public static String writeOn(File file, String text) { -// try { -// ShellUtils.CommandResult result = ShellUtils.execCommand("echo " + "\"" + text + "\"" + " > " + file.getAbsolutePath(), false, null); -// if(result.result == 0) { -// return null; -// } else { -// result = ShellUtils.execCommand("echo " + "\"" + text + "\"" + " > " + file.getAbsolutePath(), true, null); -// if(result.result == 0) { -// return null; -// } -// return result.toString(); -// } -// } catch (Exception e) { -// return e.toString(); -// } - try { FileOutputStream stream = new FileOutputStream(file); stream.write(text.getBytes()); @@ -61,104 +34,6 @@ public class FileManager { } } - public static int mv(File[] files, File where) throws IOException { - if (files == null || files.length == 0 || where == null) { - return FileManager.FILE_NOTFOUND; - } - - if (!where.isDirectory()) { - return FileManager.ISFILE; - } - - for (File f : files) { - mv(f, where); - } - - return 0; - } - - private static int mv(File f, File where) throws IOException { - MainManager.interactive.addCommand("mv " + Tuils.SPACE + f.getAbsolutePath() + Tuils.SPACE + where.getAbsolutePath()); - return 0; - } - - public static int rm(File[] files) { - if (files == null || files.length == 0) { - return FileManager.FILE_NOTFOUND; - } - - for (File f : files) { - rm(f); - } - - return 0; - } - - public static int rm(File f) { - MainManager.interactive.addCommand("rm " + (f.isDirectory() ? "-r" : Tuils.EMPTYSTRING) + Tuils.SPACE + f.getAbsolutePath()); - return 0; - } - - public static int cp(File[] files, File where) throws IOException { - if (files == null || files.length == 0 || where == null) { - return FileManager.FILE_NOTFOUND; - } - - if (!where.isDirectory()) { - return FileManager.ISFILE; - } - - for (File f : files) { - cp(f, where); - } - - return 0; - } - - private static int cp(File f, File where) throws IOException { - MainManager.interactive.addCommand("cp " + Tuils.SPACE + f.getAbsolutePath() + Tuils.SPACE + where.getAbsolutePath()); - return 0; - } - - public static List<File> lsFile(File f, boolean showHidden) { -// ShellUtils.CommandResult r = ShellUtils.execCommand("test -w \"" + f.getAbsolutePath()+ "\"", false, null); -// if(r.result != 0) { -// return null; -// } - - if(!f.isDirectory()) { - return null; - } - -// ShellUtils.CommandResult rr = ShellUtils.execCommand("test -r \"" + f.getAbsolutePath()+ "\"", false, null); -// if(rr.result != 0) { -// return null; -// } - - File[] content = f.listFiles(); - - Arrays.sort(content, new Comparator<File>() { - @Override - public int compare(File lhs, File rhs) { - if (lhs.isDirectory() && !rhs.isDirectory()) - return -1; - if (rhs.isDirectory() && !lhs.isDirectory()) - return 1; - - return Tuils.alphabeticCompare(lhs.getName(), rhs.getName()); - } - }); - - List<File> files = new ArrayList<>(); - for (File u : content) { - if (!u.isHidden() || showHidden) { - files.add(u); - } - } - - return files; - } - public static int openFile(Context c, File file) { if (file == null) { return FileManager.FILE_NOTFOUND; diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java index 153aeffecfa94d9a7475172aba926f3bef385905..c5e48fc5a2521c9155792cce7bde950d1d9e9c28 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java @@ -10,8 +10,6 @@ import ohi.andre.consolelauncher.managers.suggestions.SuggestionsManager; public class SkinManager implements Parcelable { - public static final int SYSTEM_WALLPAPER = -1; - public static final int SUGGESTION_PADDING_VERTICAL = 15; public static final int SUGGESTION_PADDING_HORIZONTAL = 15; public static final int SUGGESTION_MARGIN = 20; @@ -45,11 +43,8 @@ public class SkinManager implements Parcelable { globalFontSize = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.font_size); useSystemWp = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.system_wallpaper); - if (useSystemWp) { - bgColor = SYSTEM_WALLPAPER; - overlayColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.overlay_color); - } - else bgColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.bg_color); + overlayColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.overlay_color); + bgColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.bg_color); deviceColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.device_color); ramColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.ram_color); diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java index 4e4a19e0ba6434b4687559c6effe6b564ff60479..4ed6db6ecf06bf797907408ced71033d6bf26cea 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java @@ -278,6 +278,30 @@ public class XMLPrefsManager { public String defaultValue() { return "#"; } + }, + left_margin_mm { + @Override + public String defaultValue() { + return "0"; + } + }, + right_margin_mm { + @Override + public String defaultValue() { + return "0"; + } + }, + top_margin_mm { + @Override + public String defaultValue() { + return "0"; + } + }, + bottom_margin_mm { + @Override + public String defaultValue() { + return "0"; + } }; @Override diff --git a/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java b/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java index a5ca000a3d2aed0fa05fe42cd1098507ecd6a107..5b1568ab404940eb979acec7f9aa6d260f0e614d 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java +++ b/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java @@ -387,6 +387,10 @@ public class Tuils { return -1; } + public static int mmToPx(DisplayMetrics metrics, int mm) { + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, mm, metrics); + } + public static void insertHeaders(List<String> s, boolean newLine) { char current = 0; for (int count = 0; count < s.size(); count++) { @@ -451,35 +455,6 @@ public class Tuils { } catch (FileNotFoundException e1) {} } - static FileOutputStream logStream = null; - public static void openLogStream(String name) { - closeStream(); - - try { - File file = new File(Tuils.getFolder(), name); - logStream = new FileOutputStream(file); - } catch (FileNotFoundException e) {} - } - - public static void write(Throwable t) { - write(Tuils.getStackTrace(t)); - } - - public static void write(String line) { - if(logStream != null) try { - logStream.write((line + Tuils.NEWLINE).getBytes()); - } catch (IOException e) {} - } - - public static void closeStream() { - if(logStream != null) { - try { - logStream.close(); - logStream = null; - } catch (IOException e) {} - } - } - public static String toPlanString(List<String> strings, String separator) { if(strings != null) { String[] object = new String[strings.size()]; diff --git a/app/src/main/res/values-v21/strings.xml b/app/src/main/res/values-v21/strings.xml deleted file mode 100755 index 170ddf6200d0bf02a640c6c20b5cc255f4aea33a..0000000000000000000000000000000000000000 --- a/app/src/main/res/values-v21/strings.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="help_data">[ROOT ONLY!] Turn on or off mobile data. - \n\nUsage: - \n>>data true - </string> -</resources> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 420929d5a719cd77c1bc4844cf8103b298b3166f..0f08e2628dfd0ec835f3bb6c430f0c82998e91ba 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,51 +2,49 @@ <!-- various text --> <string name="app_name">T-UI</string> - <string name="notification_reader">Notification Reader</string> - <string name="separator_text">>></string> - <string name="separator_text_su">$</string> - <string name="su">T-UI got SU permission</string> - <string name="nosu">Your device isn\'t rooted</string> - <string name="permissions_toast">You have to grant Storage permission</string> <string name="version_label">Version:</string> - <string name="output_error">An unknown error has occurred</string> <string name="location_off">Turn on GPS or network location</string> - <string name="invalid_integer">Invalid integer</string> - <string name="activity_not_found">Ativity not found</string> - <string name="use_suc">su: use "su -c" instead</string> + <string name="share_label">Share</string> + <string name="output_about">Francesco Andreuzzi (Italy)\n\t-> Programmer</string> + <string name="output_refresh">Refresh: apps, alias, music, contacts</string> + <string name="output_rate">Thank you!</string> + <string name="start_notification">T-UI started</string> + <string name="tui_running">T-UI is running</string> - <!-- busy --> - <string name="busy">T-UI is busy, wait until the execution finishes or use the command \"ctrlc\"</string> - <string name="busy_hint">type \"ctrlc\" to stop</string> + <!-- files --> + <string name="output_error">An unknown error has occurred</string> + <string name="output_isdirectory">This is a directory</string> + <string name="output_filenotfound">File not found</string> + <!-- notifications --> + <string name="notification_reader">Notification Reader</string> + + <!-- helps texts --> <string name="rate_donate_text">\nDo you like my work? Rate on Play Store (command: >>rate) or offer me a coffee (command: >>donate). Thank you for using T-UI. \n\nYou can disable this message with the command\nconfig -set donation_message false</string> <string name="firsthelp_text">First time with t-ui? Use the command \"tutorial\" or \"help\"</string> + <string name="permissions_toast">You have to grant Storage permission</string> + <string name="output_usedefapp">You can use "apps -default_app" instead</string> - <!-- app mgr --> + <!-- apps --> <string name="output_appnotfound">Application not found</string> - <string name="output_hideapp">state: hidden</string> - <string name="output_unhideapp">state: shown</string> - - <!-- label --> - <string name="share_label">Share</string> - <string name="adminrequest_label">Lock the screen on double tap</string> - <string name="error_label">Errors:</string> + <string name="activity_not_found">Activity not found</string> + <string name="app_installed">App installed:</string> + <string name="app_uninstalled">App uninstalled:</string> <!-- pending operation --> <string name="calling">Calling:</string> <string name="restarting">t-ui will be closed in some seconds. Click the home button to restart it</string> - <!-- various outputs --> - <string name="output_nothingfound">No matches</string> + <!-- various errors --> <string name="output_nopermissions">You didn\'t grant the permission</string> <string name="output_waitingpermission">Waiting permission</string> - <string name="output_invalidcalc">calc encountered this error:</string> <string name="output_problemcamera">There was a problem while connecting to your device camera</string> <string name="output_numberformat">Wrong number format</string> <string name="output_invalidarg">Invalid argument</string> <string name="output_lessarg">Less arguments than expected</string> - <string name="output_usedefapp">You can use "apps -default_app" instead</string> + <string name="invalid_integer">Invalid integer</string> + <string name="output_nothing_found">Nothing was found</string> <!-- alias --> <string name="output_aliasnotfound">Alias not found:</string> @@ -59,32 +57,18 @@ \n\nExample: \nhelp exit </string> - <string name="help_tuixt_exit">Exit from tuixt (changes won\'t be saved)</string> + <string name="help_tuixt_exit">Exit from tuixt</string> <string name="help_tuixt_save">Save changes</string> <string name="tuixt_back_pressed">You pressed back key</string> <string name="tuixt_saved">Saved</string> <string name="tuixt_reading">Reading</string> <string name="tuixt_label">TUIXT</string> - <!-- search--> - <string name="output_nothing_found">Nothing was found</string> - <!-- phone --> <string name="output_wifi">WiFi active:</string> <string name="output_data">Mobile Data active:</string> <string name="output_bluetooth">Bluetooth active:</string> - <string name="output_airplane">Airplane Mode active:</string> - <string name="output_nofeature">This feature isn\'t available on your Android version</string> - - <!-- files --> - <string name="output_isfile">Cant\'t write here. It\'s a file</string> - <string name="output_isdirectory">This is a directory</string> - <string name="output_filenotfound">File not found</string> - <string name="output_noreadable">This file is not readable</string> - <string name="output_nowriteable">You can\'t write or delete this file</string> - - <!-- install/uninstall --> - <string name="app_installed">App installed:</string> + <string name="output_airplane">Airplane mode active:</string> <!-- music --> <string name="output_playing">Playing:</string> @@ -99,7 +83,6 @@ <string name="output_commandnotfound">Command not found.\nTry to use \">>help\" or \">>tutorial\"</string> <string name="output_toomanyargs">More arguments than expected</string> <string name="output_invalid_param">Invalid option:</string> - <string name="output_commandexitvalue">Command returned </string> <!-- flash --> <string name="output_flashon">Flashlight ON</string> @@ -111,49 +94,34 @@ <string name="mobile_data">Mobile data:</string> <string name="wifi">WiFi:</string> - <!-- infos --> - <string name="output_about">Francesco Andreuzzi (Italy)\n\t-> Programmer - \n\nLuke Winward\n\t-> Design & Testing - \n\n\nOpen Source Libraries: - \nCompareString - </string> - <string name="output_refresh">Refresh: apps, alias, music, contacts</string> - <string name="output_rate">Thank you!</string> - <!-- contacts --> - <string name="sms_hint">write your SMS or nothing to abort</string> + <string name="sms_hint">write your SMS or nothing to cancel</string> <string name="output_numbernotfound">Contact not found</string> <string name="output_smsnotsent">SMS not sent</string> <string name="output_smssent">SMS sent</string> - <string name="help_airplane">Toggle Airplane Mode</string> + <string name="help_airplane">Toggle airplane mode</string> <string name="help_alias">Manage your aliases \n\nUsage: - \n-add -> add a new alias - \n-rm -> remove an existing alias + \n-add [aliasName] [alias content] -> add a new alias + \n-rm [aliasName] -> remove an existing alias \n-ls -> list your aliases \n-file -> open alias.xml - \n\nExample: - \n>>alias -add bip echo beeeeeep - \n>>alias -rm bip</string> + </string> <string name="help_apps">Manage your apps \n\nUsage: - \n>>apps [option] [app name] - \n\n-lsh -> show hidden apps - \n-show -> show an hidden app - \n-hide -> hide an app - \n-l -> show details about an app - \n-ps -> show Google Play Store page for an app - \n-st -> show Settings details for an app - \n-default_app -> change the default_app at the specified index ("apps -default_app index appName") - \n-frc -> force t-ui to launch an app + \n-lsh -> show hidden apps + \n-show [appName] -> re-show an hidden app + \n-hide [appName] -> hide an app + \n-l [appName] -> show details about an app + \n-ps [appName] -> show Google Play Store page for an app + \n-st [appName] -> show Settings details for an app + \n-default_app [index] [appName or most_used or null] -> set the default_app at the specified index + \n-frc [appName] -> force t-ui to launch an app \n-file -> open apps.xml - \nno option -> list your apps - \n\nExample: - \n>>apps -st T-UI </string> - <string name="help_bluetooth">Toggle Bluetooth</string> + <string name="help_bluetooth">Toggle bluetooth</string> <string name="help_clear">Clear the screen</string> <string name="help_calc" formatted="false">Perform basic operations (+ - * / % ^ sqrt) \nExample: @@ -167,157 +135,103 @@ \n5 </string> <string name="help_call">Make a call - \nUsage: call [number] OR [name] - \n\nExample: - \n>>call James - \n>>call 3283456789 + \nUsage: call [number] OR [contactName] </string> - <string name="help_community">Go to the t-ui community on Google+</string> + <string name="help_community">Show the t-ui community on Google+</string> <string name="help_config">Manage your config files. \nUsage: - \n>>config [option] [file OR config_entry] [*value] - \n\n-set -> set the value of a config node - \n-open -> open a config file - \n-get -> get the value of an option - \n\nExample: - \n>>config -set bg_color #ff0000aa - \n>>config -open suggestions.xml</string> - <string name="help_cp">Copy one or more files to a folder - \nUsage: - \n>>[su] cp [files] [folder] - \n\nExample: - \n>>su cp fool.txt fool2.png myFolder - \n>>cp myFile.txt myFolder + \n-set [option] [value] -> set the value of a config node + \n-open [file] -> open a config file + \n-get [option] -> get the value of an option </string> - <string name="help_data">Toggle mobile data. Will always turn off if WiFi is active</string> - <string name="help_donate">Donate something to the developer</string> + <string name="help_data">Toggle mobile data</string> + <string name="help_donate">Offer a coffee to the developer (PayPal only)</string> <string name="help_flash">Toggle the flashlight</string> - <string name="help_help">Print the list of commands, or info about a command + <string name="help_help">Print a list of the available commands, or info about a command \nUsage: \n>>help [command] </string> - <string name="help_mv">Move one or more files to a folder - \nUsage: - \n>>[su] mv [files] [folder] - \n\n>>su mv fool.txt fool2.png myFolder - \n>>mv fool.txt myFolder - </string> <string name="help_next">Play the next track in the queue</string> <string name="help_listen">Play a specific track \nUsage: - \n>>listen trackname + \n>>listen [songName] </string> - <string name="help_previous">Play the last track played</string> - <string name="help_rate">Help T-UI with a positive rate (or negative, I don\'t know)\t;)</string> + <string name="help_previous">Play the last played track</string> + <string name="help_rate">Leave a feedback on the Play Store page</string> <string name="help_refresh">Refresh apps, alias, music, contacts</string> <string name="help_restart">Restart t-ui and load modified values</string> - <string name="help_rm">Remove a file: - \nUsage: - \n>>[su] rm [files] - \n\nExample: - \n\n>>su rm fool.txt fool2.png - \n>>rm Downloads/fool.txt - </string> <string name="help_search">Search something somewhere - \nUsage: - \nsearch [option] something - \n\n-g -> (Google Search) - \n-p -> (Google Play Store) - \n-f -> (Files) - \n-y -> (YouTube) - \n\nExample: - \n>>search -p T-UI + \n\nUsage: + \n-gg [search this...] -> Google Search + \n-ps [search this...] -> Google Play Store + \n-file [search this...] -> Files + \n-yt [search this...] -> YouTube + \n-dd [search this...] -> DuckDuck Go </string> <string name="help_share">Share a file \nUsage: - \n>>share pathToFile - \n\nExample: - \n>>share fool.jpg + \n>>share [pathToFile] </string> - <string name="help_shellcommands">Print Terminal Emulator commands</string> - <string name="help_status">Get infos about battery charge, wifi status and mobile data</string> + <string name="help_shellcommands">Print the commands in /system/bin and /system/xbin</string> + <string name="help_status">Get info about battery charge, wifi status and mobile data</string> <string name="help_stop">Stop the player</string> <string name="help_time">Print the current time with the given format \n\nUsage: - \n$ time [index]</string> - <string name="help_track">Print informations about the current track</string> - <string name="help_tracks">Print all of the tracks in your music folder</string> + \n$ time [index] (index means the index of the desired time_format</string> + <string name="help_track">Print info about the current track</string> + <string name="help_tracks">Print a list of the tracks in your music folder</string> <string name="help_tuixt">Open the text editor. \nUsage: - \n>>tuixt [text file] + \n>>tuixt [textFile] </string> - <string name="help_tui">Usage: - \nt>>tui [option] - \n\n-rm -> remove t-ui + <string name="help_tui"> + Usage: + \n-rm -> remove t-ui \n-about -> show info about the developer and the current version</string> - \n-reset -> Removes t-ui folder and resets default settings (restart required) + \n-reset -> removes the t-ui folder and resets default settings (restart required) + \n-folder -> print the path of the t-ui folder <string name="help_tutorial">Open the tutorial page on GitHub</string> <string name="help_uninstall">Uninstall an application \nUsage: - \n>>uninstall appName OR packageName - \n\nExample: - \n>>uninstall dropbox + \n>>uninstall [appName] </string> <string name="help_wifi">Toggle wifi</string> <string name="help_sms">Send an SMS. \nUsage: - \n>>sms [contact name] OR [phone number] {newline} + \n>>sms [contactName] OR [number] \n>>[text] - \n\nExample: - \n>>sms John Smith - \n>>Hi John, I need to talk you about T-UI, it\'s a fantastic launcher!</string> - <string name="help_vibrate">Vibrates your device. + </string> + <string name="help_vibrate">Vibrate your device. \nUsage: - \n>>vibrate [ms] - \n\nExample: - \n\nvibrate 2000</string> - <string name="help_beep">Emits a beep. + \n>>vibrate [milliseconds]</string> + <string name="help_beep">Emit a beep. \nUsage: \n>>beep</string> <string name="help_notifications">Manage your notifications. - \n\n-inc -> include an application - \n-exc -> exclude an application - \n-clr -> set the color to be used for the application + \n\nUsage: + \n-inc [appName] -> include an application + \n-exc [appName] -> exclude an application + \n-clr [color] [appName] -> set the color to be used for the application \n-file -> open notifications.xml - \n-title_filter -> set a filter over notifications title ([id] [regex]) - \n-text_filter -> set a filter over notifications text ([id] [regex]) - \n-apply_filter -> apply a filter to a particular application ([id] [application]) - \n-access -> show the system settings page dedicated to the Notification Access - \n\nExample: - \n\nnotifications -inc Clock - \nnotifications -clr Settings #FF0000</string> + \n-title_filter [ID] [regex] -> set a filter over notifications title with a given ID + \n-text_filter [ID] [regex] -> set a filter over notifications text with a given ID + \n-apply_filter [ID] [appName] -> apply a filter (or a group of filters) to a single application + \n-access -> show the system settings page dedicated to the Notification Access</string> <string name="help_location">Show the current location</string> <string name="help_cntcts">Manage your contacts. - \nUsage: - \ncntcts [option] [*optional* contact] - \n\n-ls -> list your contacts - \n-l -> show details about a contact + \n\nUsage: + \n-ls -> list your contacts + \n-l [contactName] -> show details about a contact \n-add -> create a new contact - \n-edit -> edit an existing contact - \n-rm -> remove a contact - \n\nExample: - \n\ncntcts -edit James Pike - \ncntcts -add</string> + \n-edit [contactName] -> edit an existing contact + \n-rm [contactName] -> remove a contact</string> <string name="help_exit">Close T-UI and reset launcher preferences</string> <!-- linux --> <string name="help_ctrlc">Interrupt the current shell process and create a new one</string> - <string name="help_open">Open a file with the default application + <string name="help_open">Open a file \nUsage: \n>>open [pathToFile] - \n\nExample: - \n>>open docs/fool.txt </string> - <string name="help_ls">Print a list of the files in a directory - \nUsage: - \n>>ls [directory] - \n\nExample: - \n>>ls Downloads - </string> - - <string name="start_notification">T-UI started</string> - <string name="tui_running">T-UI is running</string> - - </resources> diff --git a/settings.gradle b/settings.gradle index 92098412bad323815a6aa08244e63f4816e6e993..e7b4def49cb53d9aa04228dd3edb14c9e635e003 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':emulatorview' +include ':app'