diff --git a/app/build.gradle b/app/build.gradle index 45809d548642b5bc61908ec917bdada8ff01bf2b..457f2bc54492f65a5f672ff0c9aa078cc1986cad 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { minSdkVersion 8 targetSdkVersion 23 - versionCode 92 - versionName "5.3f" + versionCode 95 + versionName "5.3i" } buildTypes { @@ -32,4 +32,12 @@ android { compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.github.Andre1299:CompareString:1.4.2' } + + applicationVariants.all { variant -> + variant.outputs.each { output -> + output.outputFile = new File( + output.outputFile.parent, + output.outputFile.name.replace("app-release.apk", "${variant.applicationId}_${variant.versionName}.apk")) + } + } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0e3dc448b3becaa78bb5cd60567a698523f7fada..0972875c0f4bb6d98badaecffd779226da890e24 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -60,7 +60,6 @@ <uses-feature android:name="android.hardware.location.gps" android:required="false"/> - <!-- t-ui --> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" @@ -178,16 +177,6 @@ </activity> - <activity android:name=".tuils.tutorial.TutorialActivity" - android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" - android:windowSoftInputMode="stateAlwaysHidden" - - android:excludeFromRecents="true"> - <meta-data - android:name="android.support.PARENT_ACTIVITY" - android:value=".LauncherActivity" /> - </activity> - <service android:name=".managers.notifications.NotificationService" android:label="@string/notification_reader" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" diff --git a/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java b/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java index 64b8276d901aac28464bbede02fc086f6a0e878c..a0531e7cbe76839a4c8111d1520796558a19a262 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java +++ b/app/src/main/java/ohi/andre/consolelauncher/LauncherActivity.java @@ -12,7 +12,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.provider.Settings; @@ -43,7 +42,6 @@ import ohi.andre.consolelauncher.tuils.interfaces.Inputable; import ohi.andre.consolelauncher.tuils.interfaces.Outputable; import ohi.andre.consolelauncher.tuils.interfaces.Reloadable; import ohi.andre.consolelauncher.tuils.stuff.PolicyReceiver; -import ohi.andre.consolelauncher.tuils.tutorial.TutorialActivity; public class LauncherActivity extends AppCompatActivity implements Reloadable { @@ -110,7 +108,7 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { @Override public void onOutput(String output) { try { - ui.setOutput(output, true); + ui.setOutput(output); } catch (NullPointerException e) { e.printStackTrace(); } @@ -146,9 +144,6 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(FIRSTACCESS_KEY, false); editor.commit(); - - Intent intent = new Intent(this, TutorialActivity.class); - startActivity(intent); } try { @@ -269,12 +264,6 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { runOnUiThread(new Runnable() { @Override public void run() { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { -// reloadOver11(); -// } else { -// finish(); -// startActivity(starterIntent); -// } Intent mStartActivity = new Intent(LauncherActivity.this, LauncherActivity.class); int mPendingIntentId = 123456; @@ -287,11 +276,6 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { }); } -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// private void reloadOver11() { -// recreate(); -// } - @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); @@ -356,7 +340,7 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { MainPack info = main.getMainPack(); main.onCommand(info.lastCommand, null); } else { - ui.setOutput(getString(R.string.output_nopermissions), false); + ui.setOutput(getString(R.string.output_nopermissions)); main.sendPermissionNotGrantedWarning(); } break; @@ -375,7 +359,7 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { break; case COMMAND_SUGGESTION_REQUEST_PERMISSION: if (grantResults.length == 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { - ui.setOutput(getString(R.string.output_nopermissions), false); + ui.setOutput(getString(R.string.output_nopermissions)); } break; } @@ -396,11 +380,11 @@ public class LauncherActivity extends AppCompatActivity implements Reloadable { String pack = intent.getStringExtra("package"); String title = intent.getStringExtra("title"); String text = intent.getStringExtra("text"); - String color = intent.getStringExtra("color"); + int color = intent.getIntExtra("color", -1); if(ui != null) { ui.setOutput(pack + ": " + (title == null ? Tuils.EMPTYSTRING : title + (text == null ? Tuils.EMPTYSTRING : " --- ")) + (text == null ? Tuils.EMPTYSTRING : text), - Color.parseColor(color), + color, false); } } diff --git a/app/src/main/java/ohi/andre/consolelauncher/UIManager.java b/app/src/main/java/ohi/andre/consolelauncher/UIManager.java index 320f596d08f7c3d331e88bad277300bc8f166b3a..e0f85d3cef26f5d012e3818cd68c2e7d7e2fc71c 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/UIManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/UIManager.java @@ -9,6 +9,7 @@ import android.graphics.Typeface; import android.os.Handler; import android.text.Editable; import android.text.TextWatcher; +import android.text.format.Time; import android.view.GestureDetector; import android.view.GestureDetector.OnDoubleTapListener; import android.view.Gravity; @@ -17,6 +18,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.HorizontalScrollView; @@ -44,7 +46,8 @@ import ohi.andre.consolelauncher.tuils.stuff.TrashInterfaces; public class UIManager implements OnTouchListener { private final int RAM_DELAY = 3000; - public Handler handler; + private final int BATTERY_DELAY = 20 * 1000; + private final int TIME_DELAY = 1000; protected Context mContext; @@ -60,16 +63,44 @@ public class UIManager implements OnTouchListener { private TerminalManager mTerminalAdapter; private TextView ram; + private TextView device; + private TextView battery; + private TextView time; + + private Runnable batteryRunnable = new Runnable() { + @Override + public void run() { + int percentage = Tuils.getBatteryPercentage(mContext); + + if(percentage >= 50 || !skinManager.manyColorsBattery) battery.setTextColor(skinManager.battery_color_high); + else if(percentage >= 10) battery.setTextColor(skinManager.battery_color_medium); + else battery.setTextColor(skinManager.battery_color_low); + + battery.setText(percentage + "%"); + + battery.postDelayed(batteryRunnable, BATTERY_DELAY); + } + }; + + private String format; + private Runnable timeRunnable = new Runnable() { + @Override + public void run() { + Time t = new Time(); + t.setToNow(); + + time.setText(t.format(format)); + time.postDelayed(this, TIME_DELAY); + } + }; private ActivityManager.MemoryInfo memory; private ActivityManager activityManager; private Runnable ramRunnable = new Runnable() { @Override public void run() { - if (handler != null) { - updateRamDetails(); - handler.postDelayed(this, RAM_DELAY); - } + updateRamDetails(); + ram.postDelayed(this, RAM_DELAY); } }; @@ -319,7 +350,7 @@ public class UIManager implements OnTouchListener { lastSuggestionThread.start(); } - protected UIManager(ExecutePack info, Context context, final ViewGroup rootView, final CommandExecuter tri, DevicePolicyManager mgr, ComponentName name, + protected UIManager(ExecutePack info, final Context context, final ViewGroup rootView, final CommandExecuter tri, DevicePolicyManager mgr, ComponentName name, MainPack mainPack) { rootView.setOnTouchListener(this); @@ -345,19 +376,34 @@ public class UIManager implements OnTouchListener { rootView.setBackgroundColor(skinManager.overlayColor); } +// scrolllllll + if(XMLPrefsManager.get(boolean.class, XMLPrefsManager.Behavior.auto_scroll)) { + rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + int heightDiff = rootView.getRootView().getHeight() - rootView.getHeight(); + if (heightDiff > Tuils.dpToPx(context, 200)) { // if more than 200 dp, it's probably a keyboard... + if(mTerminalAdapter != null) mTerminalAdapter.scrollToEnd(); + } + } + }); + } + ram = (TextView) rootView.findViewById(R.id.ram_tv); - TextView deviceInfo = (TextView) rootView.findViewById(R.id.deviceinfo_tv); + device = (TextView) rootView.findViewById(R.id.deviceinfo_tv); + battery = (TextView) rootView.findViewById(R.id.battery_tv); + time = (TextView) rootView.findViewById(R.id.time_tv); + boolean showRam = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.show_ram); if (showRam) { ram.setTextColor(skinManager.ramColor); - ram.setTextSize(skinManager.getRamSize()); + ram.setTextSize(skinManager.getTextSize()); ram.setTypeface(skinManager.systemFont ? Typeface.DEFAULT : lucidaConsole); memory = new ActivityManager.MemoryInfo(); activityManager = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE); - handler = new Handler(); - handler.postDelayed(ramRunnable, RAM_DELAY); + ram.postDelayed(ramRunnable, RAM_DELAY); } else { ram.setVisibility(View.GONE); ram = null; @@ -367,13 +413,35 @@ public class UIManager implements OnTouchListener { if (showDevice) { String deviceName = skinManager.deviceName; - deviceInfo.setText(deviceName); - deviceInfo.setTextColor(skinManager.deviceColor); - deviceInfo.setTextSize(skinManager.getDeviceSize()); + device.setText(deviceName); + device.setTextColor(skinManager.deviceColor); + device.setTextSize(skinManager.getTextSize()); + device.setTypeface(skinManager.systemFont ? Typeface.DEFAULT : lucidaConsole); + } else { + device.setVisibility(View.GONE); + } - deviceInfo.setTypeface(skinManager.systemFont ? Typeface.DEFAULT : lucidaConsole); + boolean showTime = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.show_time); + if(showTime) { + format = XMLPrefsManager.get(String.class, XMLPrefsManager.Behavior.time_format); + + time.setTextColor(skinManager.time_color); + time.setTextSize(skinManager.getTextSize()); + time.setTypeface(skinManager.systemFont ? Typeface.DEFAULT : lucidaConsole); + + time.post(timeRunnable); } else { - deviceInfo.setVisibility(View.GONE); + time.setVisibility(View.GONE); + } + + boolean showBattery = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.show_battery); + if(showBattery) { + battery.setTextSize(skinManager.getTextSize()); + battery.setTypeface(skinManager.systemFont ? Typeface.DEFAULT : lucidaConsole); + + battery.post(batteryRunnable); + } else { + battery.setVisibility(View.GONE); } final boolean inputBottom = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.input_bottom); @@ -498,7 +566,6 @@ public class UIManager implements OnTouchListener { public void onStart(boolean openKeyboardOnStart) { if(openKeyboardOnStart) openKeyboard(); - mTerminalAdapter.scrollToEnd(); } public void setInput(String s) { @@ -517,12 +584,12 @@ public class UIManager implements OnTouchListener { mTerminalAdapter.setDefaultHint(); } - public void setOutput(String string, boolean fromUser) { - mTerminalAdapter.setOutput(string, fromUser); + public void setOutput(String string) { + mTerminalAdapter.setOutput(string); } public void setOutput(String s, int color, boolean fromUser) { - mTerminalAdapter.setOutput(s, color, fromUser); + mTerminalAdapter.setOutput(s, color); } public void disableSuggestions() { diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/apps.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/apps.java index e35ceba82cf5bd6ffc59faf0714aab1fe70c667c..153d06cb95235a54b8668ce80ddaca13c38897c1 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/apps.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/apps.java @@ -2,6 +2,8 @@ package ohi.andre.consolelauncher.commands.main.raw; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.net.Uri; import java.io.File; @@ -10,7 +12,6 @@ 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.main.Param; import ohi.andre.consolelauncher.commands.specific.ParamCommand; import ohi.andre.consolelauncher.managers.AppsManager; import ohi.andre.consolelauncher.tuils.Tuils; @@ -19,7 +20,7 @@ public class apps extends ParamCommand { private enum Param implements ohi.andre.consolelauncher.commands.main.Param { - lshidden { + lsh { @Override public int[] args() { return new int[0]; @@ -38,7 +39,7 @@ public class apps extends ParamCommand { @Override public String exec(ExecutePack pack) { - ((MainPack) pack).appsManager.hideApp(pack.get(String.class, 1)); + ((MainPack) pack).appsManager.unhideApp(pack.get(String.class, 1)); return null; } }, @@ -54,6 +55,23 @@ public class apps extends ParamCommand { return null; } }, + l { + @Override + public int[] args() { + return new int[] {CommandAbstraction.VISIBLE_PACKAGE}; + } + + @Override + public String exec(ExecutePack pack) { + try { + PackageInfo info = pack.context.getPackageManager().getPackageInfo(pack.get(String.class, 1), PackageManager.GET_PERMISSIONS | PackageManager.GET_ACTIVITIES | + PackageManager.GET_SERVICES | PackageManager.GET_RECEIVERS); + return AppsManager.AppUtils.format(info); + } catch (PackageManager.NameNotFoundException e) { + return e.toString(); + } + } + }, ps { @Override public int[] args() { diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/cntcts.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/cntcts.java index 0154676c191b3e42788ceef003b4ba4561cda980..37ab53247e3d9213535d11d93009863929a13cc7 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/cntcts.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/cntcts.java @@ -15,7 +15,6 @@ 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.main.Param; import ohi.andre.consolelauncher.commands.specific.ParamCommand; import ohi.andre.consolelauncher.managers.ContactManager; import ohi.andre.consolelauncher.tuils.Tuils; @@ -88,7 +87,7 @@ public class cntcts extends ParamCommand { return new int[] {CommandAbstraction.CONTACTNUMBER}; } }, - show { + l { @Override public String exec(ExecutePack pack) { String[] about = ((MainPack) pack).contacts.about(pack.get(String.class, 1)); diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/time.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/time.java index 25ea3e3a3a260fa5ac79e04ce63e9b3500887f73..45eff343f4e10e176b695237f652903a1fadd6f9 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/time.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/time.java @@ -1,10 +1,11 @@ package ohi.andre.consolelauncher.commands.main.raw; -import java.util.Calendar; +import android.text.format.Time; import ohi.andre.consolelauncher.R; import ohi.andre.consolelauncher.commands.CommandAbstraction; import ohi.andre.consolelauncher.commands.ExecutePack; +import ohi.andre.consolelauncher.managers.XMLPrefsManager; /** * Created by andre on 03/12/15. @@ -12,14 +13,9 @@ import ohi.andre.consolelauncher.commands.ExecutePack; public class time implements CommandAbstraction { @Override public String exec(ExecutePack pack) { - Calendar c = Calendar.getInstance(); - int hours = c.get(Calendar.HOUR_OF_DAY); - int minutes = c.get(Calendar.MINUTE); - - if(minutes < 10) - return hours + ":0" + minutes; - else - return hours + ":" + minutes; + Time time = new Time(); + time.setToNow(); + return time.format(XMLPrefsManager.get(String.class, XMLPrefsManager.Behavior.time_format)); } @Override 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 93e22892f0cc842fe7071cd2fcf6baaa389cc098..139a308ec36825f0076ebce355d2ce872d8b2c78 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 @@ -5,11 +5,10 @@ import android.net.Uri; import ohi.andre.consolelauncher.BuildConfig; 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.main.Param; import ohi.andre.consolelauncher.commands.specific.ParamCommand; +import ohi.andre.consolelauncher.managers.FileManager; import ohi.andre.consolelauncher.tuils.Tuils; /** @@ -39,6 +38,13 @@ public class tui extends ParamCommand { MainPack info = (MainPack) pack; return info.res.getString(R.string.version_label) + Tuils.SPACE + BuildConfig.VERSION_NAME + Tuils.NEWLINE + Tuils.NEWLINE + info.res.getString(R.string.output_about); } + }, + reset { + @Override + public String exec(ExecutePack pack) { + FileManager.rm(Tuils.getFolder(), false); + return null; + } }; @Override diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tutorial.java b/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tutorial.java deleted file mode 100755 index 14fea492fc3741acc4503921adb2c19c5390b53d..0000000000000000000000000000000000000000 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/main/raw/tutorial.java +++ /dev/null @@ -1,55 +0,0 @@ -package ohi.andre.consolelauncher.commands.main.raw; - -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.tuils.Tuils; - -public class tutorial implements CommandAbstraction { - - @Override - public String exec(ExecutePack pack) { - MainPack info = (MainPack) pack; - Tuils.showTutorial(info.context); - return null; - } - - @Override - public int minArgs() { - return 0; - } - - @Override - public int maxArgs() { - return 0; - } - - @Override - public int[] argType() { - return new int[0]; - } - - @Override - public int priority() { - return 4; - } - - @Override - public int helpRes() { - return R.string.help_tutorial; - } - - @Override - public String onArgNotFound(ExecutePack info, int index) { - return null; - } - - @Override - public String onNotArgEnough(ExecutePack info, int nArgs) { - return null; - } - -} - - 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 791f664e30bf89af89f04cc6114c024de97a4c29..41220a33696a46a83e53278f54e616dcf6e4c1bd 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/AppsManager.java @@ -8,12 +8,15 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; +import android.content.pm.ServiceInfo; import android.os.Build; import android.os.Handler; import android.support.annotation.NonNull; +import android.text.format.Time; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -239,7 +242,10 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { } catch (Exception e) {} for(Map.Entry<String, ?> entry : this.preferences.getAll().entrySet()) { - if (entry.getValue() instanceof Integer) map.get(entry.getKey()).launchedTimes = (Integer) entry.getValue(); + if (entry.getValue() instanceof Integer) { + AppInfo info = map.get(entry.getKey()); + if(info != null) info.launchedTimes = (Integer) entry.getValue(); + } } for (Map.Entry<String, AppInfo> stringAppInfoEntry : map.entrySet()) { @@ -505,6 +511,7 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { else { AppInfo info = AppUtils.findAppInfo(vl, infos); if(info == null) continue; + suggested.add(new SuggestedApp(info, USER_DEFINIED)); } } @@ -541,28 +548,52 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { } public void attemptInsertSuggestion(AppInfo info) { +// Log.e("andre", "attempt: " + info.toString()); + if (info.launchedTimes == 0 || lastWriteable == -1) { return; } - int index = indexOf(info); - if (index == -1) { - for (int count = 0; count <= lastWriteable; count++) { +// Log.e("andre", String.valueOf(lastWriteable)); - SuggestedApp app = get(count); - if (app.app == null || info.launchedTimes > app.app.launchedTimes) { - SuggestedApp s = suggested.get(count); + int i = Tuils.find(info, suggested); + if(i == -1) { + int index = indexOf(info); + if (index == -1) { + for (int count = 0; count <= lastWriteable; count++) { +// Log.e("andre", "loop: " + count); - AppInfo before = s.app; - s.change(info); + SuggestedApp app = get(count); +// Log.e("andre", app.toString()); - if(before != null) attemptInsertSuggestion(before); + if (app.app == null || info.launchedTimes > app.app.launchedTimes) { +// Log.e("andre", "yes"); + SuggestedApp s = suggested.get(count); - break; +// Log.e("andre", "before it was: " + s.toString()); +// Log.e("andre", suggested.toString()); + + AppInfo before = s.app; + s.change(info); + +// Log.e("andre", suggested.toString()); + + if(before != null) { +// Log.e("andre", "rec"); + attemptInsertSuggestion(before); + } + + break; + } } } } +// else { +// Log.e("andre", "index == -1"); +// Log.e("andre", suggested.toString()); +// } sort(); +// Log.e("andre", suggested.toString()); } // public void updateSuggestion(AppInfo info) { @@ -638,7 +669,17 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { @Override public boolean equals(Object o) { - return this.app != null && o instanceof SuggestedApp && ((SuggestedApp) o).app != null && this.app.equals(((SuggestedApp) o).app); + if(o instanceof SuggestedApp) { + try { + return (app == null && ((SuggestedApp) o).app == null) || app.equals(((SuggestedApp) o).app); + } catch (NullPointerException e) { + return false; + } + } else if(o instanceof AppInfo) { + if(app == null) return false; + return app.equals(o); + } + return false; } @Override @@ -754,7 +795,7 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { } } - private static class AppUtils { + public static class AppUtils { public static void checkEquality(List<AppInfo> list) { @@ -814,6 +855,49 @@ public class AppsManager implements XMLPrefsManager.XmlPrefsElement { } } + public static String format(PackageInfo info) { + StringBuilder builder = new StringBuilder(); + + builder.append(info.packageName).append(Tuils.NEWLINE); + builder.append("vrs: ").append(info.versionCode).append(" - ").append(info.versionName).append(Tuils.NEWLINE).append(Tuils.NEWLINE); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + Time time = new Time(); + time.set(info.firstInstallTime); + builder.append("Install: ").append(time.format(XMLPrefsManager.get(String.class, XMLPrefsManager.Behavior.time_format))).append(Tuils.NEWLINE).append(Tuils.NEWLINE); + } + + ActivityInfo[] a = info.activities; + if(a != null && a.length > 0) { + List<String> as = new ArrayList<>(); + for(ActivityInfo i : a) as.add(i.name.replace(info.packageName, Tuils.EMPTYSTRING)); + builder.append("Activities: ").append(Tuils.NEWLINE).append(Tuils.toPlanString(as, Tuils.NEWLINE)).append(Tuils.NEWLINE).append(Tuils.NEWLINE); + } + + ServiceInfo[] s = info.services; + if(s != null && s.length > 0) { + List<String> ss = new ArrayList<>(); + for(ServiceInfo i : s) ss.add(i.name.replace(info.packageName, Tuils.EMPTYSTRING)); + builder.append("Services: ").append(Tuils.NEWLINE).append(Tuils.toPlanString(ss, Tuils.NEWLINE)).append(Tuils.NEWLINE).append(Tuils.NEWLINE); + } + + ActivityInfo[] r = info.receivers; + if(r != null && r.length > 0) { + List<String> rs = new ArrayList<>(); + for(ActivityInfo i : r) rs.add(i.name.replace(info.packageName, Tuils.EMPTYSTRING)); + builder.append("Receivers: ").append(Tuils.NEWLINE).append(Tuils.toPlanString(rs, Tuils.NEWLINE)).append(Tuils.NEWLINE).append(Tuils.NEWLINE); + } + + String[] p = info.requestedPermissions; + if(p != null && p.length > 0) { + List<String> ps = new ArrayList<>(); + for(String i : p) ps.add(i.substring(i.lastIndexOf(".") + 1)); + builder.append("Permissions: ").append(Tuils.NEWLINE).append(Tuils.toPlanString(ps, ", ")); + } + + return builder.toString(); + } + protected static AppInfo findAppInfo(String packageName, List<AppInfo> infos) { for(AppInfo info : infos) { if(info.packageName.equals(packageName)) { 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 27b4d31893653446f69d0a81aa3e81d2727e202f..8292b0497fa923c29b2287fe7e4fe6eb64f4de51 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java @@ -79,12 +79,10 @@ public class FileManager { } private static int mv(File f, File where, boolean su) throws IOException { + ShellUtils.CommandResult result = ShellUtils.execCommand("mv " + Tuils.SPACE + + f.getAbsolutePath() + Tuils.SPACE + + where.getAbsolutePath(), su, null); - ShellUtils.CommandResult result = ShellUtils.execCommand("mv " + - (f.isDirectory() ? "-r" : Tuils.EMPTYSTRING) + - Tuils.SPACE + - "\"" + f.getAbsolutePath() + "\"" + Tuils.SPACE + - "\"" + where.getAbsolutePath() + "\"", su, null); return result.result; } @@ -101,11 +99,11 @@ public class FileManager { } public static int rm(File f, boolean su) { - ShellUtils.CommandResult result = ShellUtils.execCommand("rm " + (f.isDirectory() ? "-r" : Tuils.EMPTYSTRING) + Tuils.SPACE + - "\"" + f.getAbsolutePath() + "\"", su, null); + f.getAbsolutePath(), su, null); + if(result == null) return IOERROR; return result.result; } @@ -127,11 +125,9 @@ public class FileManager { } private static int cp(File f, File where, boolean su) throws IOException { - ShellUtils.CommandResult result = ShellUtils.execCommand("cp " + - (f.isDirectory() ? "-r" : Tuils.EMPTYSTRING) + - Tuils.SPACE + - "\"" + f.getAbsolutePath() + "\"" + Tuils.SPACE + - "\"" + where.getAbsolutePath() + "\"", su, null); + ShellUtils.CommandResult result = ShellUtils.execCommand("cp " + Tuils.SPACE + + f.getAbsolutePath() + Tuils.SPACE + + where.getAbsolutePath(), su, null); return result.result; } 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 3f857da25fc9fee3dae0a8f2dd8285b0b04ad079..c361c08f74838e46b62562ae6b08051537eb6220 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java @@ -16,17 +16,18 @@ public class SkinManager implements Parcelable { public static final int SUGGESTION_PADDING_HORIZONTAL = 15; public static final int SUGGESTION_MARGIN = 20; - private static final int deviceScale = 3; - private static final int textScale = 2; - private static final int ramScale = 3; private static final int suggestionScale = 0; + private static final int textScale = 3; + + public static final int COLOR_NOT_SET = 16777216; + public int globalFontSize; public String deviceName; - public int deviceColor, inputColor, outputColor, ramColor, bgColor, overlayColor, toolbarColor, enter_color; + public int deviceColor, inputColor, outputColor, ramColor, bgColor, overlayColor, toolbarColor, toolbarBg, enter_color, time_color, battery_color_high, battery_color_medium, battery_color_low; - public boolean useSystemWp, showSuggestions, systemFont, inputBottom, showSubmit; + public boolean useSystemWp, showSuggestions, systemFont, inputBottom, showSubmit, manyColorsBattery; public String username = null; public boolean showUsernameAndDeviceWhenEmpty = true, showUsername = false, showDeviceInSessionInfo = false, linuxAppearence = true, showPath = true; @@ -39,6 +40,8 @@ public class SkinManager implements Parcelable { inputBottom = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.input_bottom); showSubmit = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.show_enter_button); + manyColorsBattery = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.enable_battery_status); + globalFontSize = XMLPrefsManager.get(int.class, XMLPrefsManager.Ui.font_size); useSystemWp = XMLPrefsManager.get(boolean.class, XMLPrefsManager.Ui.system_wallpaper); @@ -53,7 +56,14 @@ public class SkinManager implements Parcelable { inputColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.input_color); outputColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.output_color); toolbarColor = XMLPrefsManager.getColor(XMLPrefsManager.Theme.toolbar_color); + toolbarBg = XMLPrefsManager.getColor(XMLPrefsManager.Theme.toolbar_bg); enter_color = XMLPrefsManager.getColor(XMLPrefsManager.Theme.enter_color); + time_color = XMLPrefsManager.getColor(XMLPrefsManager.Theme.time_color); + battery_color_high = XMLPrefsManager.getColor(XMLPrefsManager.Theme.battery_color_high); + if(manyColorsBattery) { + battery_color_medium = XMLPrefsManager.getColor(XMLPrefsManager.Theme.battery_color_medium); + battery_color_low = XMLPrefsManager.getColor(XMLPrefsManager.Theme.battery_color_low); + } deviceName = XMLPrefsManager.get(String.class, XMLPrefsManager.Ui.deviceName); if (deviceName.length() == 0 || deviceName.equals("null")) { @@ -104,6 +114,63 @@ public class SkinManager implements Parcelable { } } + protected SkinManager(Parcel in) { + globalFontSize = in.readInt(); + deviceName = in.readString(); + deviceColor = in.readInt(); + inputColor = in.readInt(); + outputColor = in.readInt(); + ramColor = in.readInt(); + bgColor = in.readInt(); + overlayColor = in.readInt(); + toolbarColor = in.readInt(); + toolbarBg = in.readInt(); + enter_color = in.readInt(); + time_color = in.readInt(); + battery_color_high = in.readInt(); + battery_color_medium = in.readInt(); + battery_color_low = in.readInt(); + useSystemWp = in.readByte() != 0; + showSuggestions = in.readByte() != 0; + systemFont = in.readByte() != 0; + inputBottom = in.readByte() != 0; + showSubmit = in.readByte() != 0; + manyColorsBattery = in.readByte() != 0; + username = in.readString(); + showUsernameAndDeviceWhenEmpty = in.readByte() != 0; + showUsername = in.readByte() != 0; + showDeviceInSessionInfo = in.readByte() != 0; + linuxAppearence = in.readByte() != 0; + showPath = in.readByte() != 0; + suggDefaultText = in.readInt(); + suggDefaultBg = in.readInt(); + suggAliasText = in.readInt(); + suggAliasBg = in.readInt(); + suggSongText = in.readInt(); + suggSongBg = in.readInt(); + suggContactText = in.readInt(); + suggContactBg = in.readInt(); + suggAppText = in.readInt(); + suggAppBg = in.readInt(); + suggCmdText = in.readInt(); + suggCmdBg = in.readInt(); + suggFileText = in.readInt(); + suggFileBg = in.readInt(); + transparentSuggestions = in.readByte() != 0; + } + + public static final Creator<SkinManager> CREATOR = new Creator<SkinManager>() { + @Override + public SkinManager createFromParcel(Parcel in) { + return new SkinManager(in); + } + + @Override + public SkinManager[] newArray(int size) { + return new SkinManager[size]; + } + }; + public ColorDrawable getSuggestionBg(Integer type) { if(transparentSuggestions) { return new ColorDrawable(Color.TRANSPARENT); @@ -128,47 +195,40 @@ public class SkinManager implements Parcelable { } public int getSuggestionTextColor(Integer type) { - int choosen; + int chosen; + switch (type) { case SuggestionsManager.Suggestion.TYPE_APP: - choosen = suggAppText; + chosen = suggAppText; break; case SuggestionsManager.Suggestion.TYPE_ALIAS: - choosen = suggAliasText; + chosen = suggAliasText; break; case SuggestionsManager.Suggestion.TYPE_COMMAND: - choosen = suggCmdText; + chosen = suggCmdText; break; case SuggestionsManager.Suggestion.TYPE_CONTACT: - choosen = suggContactText; + chosen = suggContactText; break; case SuggestionsManager.Suggestion.TYPE_FILE: - choosen = suggFileText; + chosen = suggFileText; break; case SuggestionsManager.Suggestion.TYPE_SONG: - choosen = suggSongText; + chosen = suggSongText; break; default: - choosen = suggDefaultText; + chosen = suggDefaultText; break; } - if(choosen == -1) choosen = suggDefaultText; - return choosen; - } - - public int getDeviceSize() { - return globalFontSize - deviceScale; + if(chosen == COLOR_NOT_SET) chosen = suggDefaultText; + return chosen; } public int getTextSize() { return globalFontSize - textScale; } - public int getRamSize() { - return globalFontSize - ramScale; - } - public int getSuggestionSize() { return globalFontSize - suggestionScale; } @@ -180,86 +240,47 @@ public class SkinManager implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(this.globalFontSize); - dest.writeString(this.deviceName); - dest.writeInt(this.deviceColor); - dest.writeInt(this.inputColor); - dest.writeInt(this.outputColor); - dest.writeInt(this.ramColor); - dest.writeInt(this.bgColor); - dest.writeByte(this.useSystemWp ? (byte) 1 : (byte) 0); - dest.writeByte(this.showSuggestions ? (byte) 1 : (byte) 0); - dest.writeByte(this.systemFont ? (byte) 1 : (byte) 0); - dest.writeByte(this.inputBottom ? (byte) 1 : (byte) 0); - dest.writeByte(this.showSubmit ? (byte) 1 : (byte) 0); - dest.writeString(this.username); - dest.writeByte(this.showUsernameAndDeviceWhenEmpty ? (byte) 1 : (byte) 0); - dest.writeByte(this.showUsername ? (byte) 1 : (byte) 0); - dest.writeByte(this.showDeviceInSessionInfo ? (byte) 1 : (byte) 0); - dest.writeByte(this.linuxAppearence ? (byte) 1 : (byte) 0); - dest.writeByte(this.showPath ? (byte) 1 : (byte) 0); - dest.writeInt(this.suggDefaultText); - dest.writeInt(this.suggDefaultBg); - dest.writeInt(this.suggAliasText); - dest.writeInt(this.suggAliasBg); - dest.writeInt(this.suggSongText); - dest.writeInt(this.suggSongBg); - dest.writeInt(this.suggContactText); - dest.writeInt(this.suggContactBg); - dest.writeInt(this.suggAppText); - dest.writeInt(this.suggAppBg); - dest.writeInt(this.suggCmdText); - dest.writeInt(this.suggCmdBg); - dest.writeInt(this.suggFileText); - dest.writeInt(this.suggFileBg); - dest.writeByte(this.transparentSuggestions ? (byte) 1 : (byte) 0); + dest.writeInt(globalFontSize); + dest.writeString(deviceName); + dest.writeInt(deviceColor); + dest.writeInt(inputColor); + dest.writeInt(outputColor); + dest.writeInt(ramColor); + dest.writeInt(bgColor); + dest.writeInt(overlayColor); + dest.writeInt(toolbarColor); + dest.writeInt(toolbarBg); + dest.writeInt(enter_color); + dest.writeInt(time_color); + dest.writeInt(battery_color_high); + dest.writeInt(battery_color_medium); + dest.writeInt(battery_color_low); + dest.writeByte((byte) (useSystemWp ? 1 : 0)); + dest.writeByte((byte) (showSuggestions ? 1 : 0)); + dest.writeByte((byte) (systemFont ? 1 : 0)); + dest.writeByte((byte) (inputBottom ? 1 : 0)); + dest.writeByte((byte) (showSubmit ? 1 : 0)); + dest.writeByte((byte) (manyColorsBattery ? 1 : 0)); + dest.writeString(username); + dest.writeByte((byte) (showUsernameAndDeviceWhenEmpty ? 1 : 0)); + dest.writeByte((byte) (showUsername ? 1 : 0)); + dest.writeByte((byte) (showDeviceInSessionInfo ? 1 : 0)); + dest.writeByte((byte) (linuxAppearence ? 1 : 0)); + dest.writeByte((byte) (showPath ? 1 : 0)); + dest.writeInt(suggDefaultText); + dest.writeInt(suggDefaultBg); + dest.writeInt(suggAliasText); + dest.writeInt(suggAliasBg); + dest.writeInt(suggSongText); + dest.writeInt(suggSongBg); + dest.writeInt(suggContactText); + dest.writeInt(suggContactBg); + dest.writeInt(suggAppText); + dest.writeInt(suggAppBg); + dest.writeInt(suggCmdText); + dest.writeInt(suggCmdBg); + dest.writeInt(suggFileText); + dest.writeInt(suggFileBg); + dest.writeByte((byte) (transparentSuggestions ? 1 : 0)); } - - protected SkinManager(Parcel in) { - this.globalFontSize = in.readInt(); - this.deviceName = in.readString(); - this.deviceColor = in.readInt(); - this.inputColor = in.readInt(); - this.outputColor = in.readInt(); - this.ramColor = in.readInt(); - this.bgColor = in.readInt(); - this.useSystemWp = in.readByte() != 0; - this.showSuggestions = in.readByte() != 0; - this.systemFont = in.readByte() != 0; - this.inputBottom = in.readByte() != 0; - this.showSubmit = in.readByte() != 0; - this.username = in.readString(); - this.showUsernameAndDeviceWhenEmpty = in.readByte() != 0; - this.showUsername = in.readByte() != 0; - this.showDeviceInSessionInfo = in.readByte() != 0; - this.linuxAppearence = in.readByte() != 0; - this.showPath = in.readByte() != 0; - this.suggDefaultText = in.readInt(); - this.suggDefaultBg = in.readInt(); - this.suggAliasText = in.readInt(); - this.suggAliasBg = in.readInt(); - this.suggSongText = in.readInt(); - this.suggSongBg = in.readInt(); - this.suggContactText = in.readInt(); - this.suggContactBg = in.readInt(); - this.suggAppText = in.readInt(); - this.suggAppBg = in.readInt(); - this.suggCmdText = in.readInt(); - this.suggCmdBg = in.readInt(); - this.suggFileText = in.readInt(); - this.suggFileBg = in.readInt(); - this.transparentSuggestions = in.readByte() != 0; - } - - public static final Creator<SkinManager> CREATOR = new Creator<SkinManager>() { - @Override - public SkinManager createFromParcel(Parcel source) { - return new SkinManager(source); - } - - @Override - public SkinManager[] newArray(int size) { - return new SkinManager[size]; - } - }; } diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java index 2de232a10279430561d4307524d454c08e7a5d19..2070ddbae6a8918abc65e18447946be02d81c3ac 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java @@ -6,10 +6,12 @@ import android.os.IBinder; import android.text.InputType; import android.text.Spannable; import android.text.SpannableString; +import android.text.TextUtils; import android.text.method.ScrollingMovementMethod; import android.text.style.ForegroundColorSpan; import android.view.KeyEvent; import android.view.View; +import android.view.ViewTreeObserver; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.ImageButton; @@ -46,8 +48,6 @@ public class TerminalManager { public static final int INPUT = 10; public static final int OUTPUT = 11; - private int cmds = 0; - private long lastEnter; private CharSequence prefix; @@ -78,7 +78,19 @@ public class TerminalManager { private boolean defaultHint = true; - public TerminalManager(TextView terminalView, EditText inputView, TextView prefixView, ImageButton submitView, final ImageButton backView, ImageButton nextView, ImageButton deleteView, + private int clearCmdsCount= 0, messagesCmdsCount = 0; + + private int clearAfterCmds, clearAfterMs, maxLines; + private Runnable clearRunnable = new Runnable() { + + @Override + public void run() { + clear(); + mTerminalView.postDelayed(this, clearAfterMs); + } + }; + + public TerminalManager(final TextView terminalView, EditText inputView, TextView prefixView, ImageButton submitView, final ImageButton backView, ImageButton nextView, ImageButton deleteView, ImageButton pasteView, SkinManager skinManager, final Context context, MainPack mainPack) { if (terminalView == null || inputView == null || prefixView == null || skinManager == null) throw new UnsupportedOperationException(); @@ -88,6 +100,10 @@ public class TerminalManager { this.mSkinManager = skinManager; this.mainPack = mainPack; + this.clearAfterMs = XMLPrefsManager.get(int.class, XMLPrefsManager.Behavior.clear_after_seconds) * 1000; + this.clearAfterCmds = XMLPrefsManager.get(int.class, XMLPrefsManager.Behavior.clear_after_cmds); + this.maxLines = XMLPrefsManager.get(int.class, XMLPrefsManager.Behavior.max_lines); + if(skinManager.linuxAppearence) { prefix = "$ "; } else { @@ -109,6 +125,7 @@ public class TerminalManager { } if (backView != null) { + ((View) backView.getParent()).setBackgroundColor(mSkinManager.toolbarBg); backView.setColorFilter(this.mSkinManager.toolbarColor); backView.setOnClickListener(new View.OnClickListener() { @Override @@ -157,6 +174,32 @@ public class TerminalManager { this.mTerminalView.setFocusable(false); setupScroller(); + if(clearAfterMs > 0) this.mTerminalView.postDelayed(clearRunnable, clearAfterMs); + if(maxLines > 0) { + this.mTerminalView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + int count = terminalView.getLayout().getLineCount() - 1; + + if(count > maxLines) { + int excessive = count - maxLines; + + CharSequence text = terminalView.getText(); + while (excessive >= 0) { + int index = TextUtils.indexOf(text, Tuils.NEWLINE); + if(index == -1) break; + text = text.subSequence(index + 1, text.length()); + excessive--; + } + + terminalView.setText(text); + } + + return true; + } + }); + } + View v = mTerminalView; do { v = (View) v.getParent(); @@ -222,9 +265,15 @@ public class TerminalManager { String input = mInputView.getText().toString().trim(); if(input.length() > 0) { + clearCmdsCount++; + messagesCmdsCount++; + + if(clearCmdsCount != 0 && clearAfterCmds > 0 && clearCmdsCount % clearAfterCmds == 0) clear(); + + for (Messager messager : messagers) if (messagesCmdsCount != 0 && messagesCmdsCount % messager.n == 0) writeToView(messager.message, OUTPUT); + writeToView((input.startsWith("su ") ? "# " : prefix) + input, INPUT); - cmds++; if(cmdList.size() == CMD_LIST_SIZE) { cmdList.remove(0); } @@ -242,15 +291,15 @@ public class TerminalManager { return true; } - public void setOutput(String output, boolean fromUser) { - setOutput(output, -1, OUTPUT, fromUser); + public void setOutput(String output) { + setOutput(output, -1, OUTPUT); } - public void setOutput(String output, int color, boolean fromUser) { - setOutput(output, color, -1, fromUser); + public void setOutput(String output, int color) { + setOutput(output, color, -1); } - public void setOutput(String output, int color, int type, boolean fromUser) { + public void setOutput(String output, int color, int type) { if (output == null) return; output = output.trim(); @@ -263,9 +312,6 @@ public class TerminalManager { if(color == -1) writeToView(output, type); else writeToView(color, output); - - if(fromUser) - for (Messager messager : messagers) if (cmds != 0 && cmds % messager.n == 0) writeToView(messager.message, OUTPUT); } public void onBackPressed() { @@ -413,13 +459,8 @@ public class TerminalManager { mTerminalView.setText(Tuils.EMPTYSTRING); } }); - mInputView.post(new Runnable() { - @Override - public void run() { - mInputView.setText(Tuils.EMPTYSTRING); - } - }); cmdList.clear(); + clearCmdsCount = 0; } public static class Messager { 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 3e23aafc57a1460b3cf5b3f1b6c8a7b90ffbc7b6..4803de367a15ce53bd4abaa80c3bb1ebd28642f2 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/XMLPrefsManager.java @@ -63,12 +63,42 @@ public class XMLPrefsManager { return "#ffff9800"; } }, + battery_color_high { + @Override + public String defaultValue() { + return "#4CAF50"; + } + }, + battery_color_medium { + @Override + public String defaultValue() { + return "#FFEB3B"; + } + }, + battery_color_low { + @Override + public String defaultValue() { + return "#FF5722"; + } + }, + time_color { + @Override + public String defaultValue() { + return "#03A9F4"; + } + }, ram_color { @Override public String defaultValue() { return "#fff44336"; } }, + toolbar_bg { + @Override + public String defaultValue() { + return "#00000000"; + } + }, toolbar_color { @Override public String defaultValue() { @@ -172,6 +202,24 @@ public class XMLPrefsManager { return "true"; } }, + show_battery { + @Override + public String defaultValue() { + return "true"; + } + }, + enable_battery_status { + @Override + public String defaultValue() { + return "true"; + } + }, + show_time { + @Override + public String defaultValue() { + return "true"; + } + }, username { @Override public String defaultValue() { @@ -397,6 +445,12 @@ public class XMLPrefsManager { return "true"; } }, + auto_scroll { + @Override + public String defaultValue() { + return "true"; + } + }, donation_message { @Override public String defaultValue() { @@ -420,6 +474,30 @@ public class XMLPrefsManager { public String defaultValue() { return "true"; } + }, + clear_after_cmds { + @Override + public String defaultValue() { + return "20"; + } + }, + clear_after_seconds { + @Override + public String defaultValue() { + return "-1"; + } + }, + max_lines { + @Override + public String defaultValue() { + return "100"; + } + }, + time_format { + @Override + public String defaultValue() { + return "%m/%d/%y %H.%M"; + } }; @Override @@ -815,7 +893,7 @@ public class XMLPrefsManager { } catch (Exception e) { String def = prefsSave.defaultValue(); if(def == null || def.length() == 0) { - return -1; + return SkinManager.COLOR_NOT_SET; } return (int) transform(def, Color.class); } diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/notifications/NotificationService.java b/app/src/main/java/ohi/andre/consolelauncher/managers/notifications/NotificationService.java index 016953a05ef308459af51a8d038950dbffc1b9ea..e2a4c627e86c576ff9d4d121d1a7a1e0b29f23d5 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/notifications/NotificationService.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/notifications/NotificationService.java @@ -7,6 +7,7 @@ package ohi.andre.consolelauncher.managers.notifications; import android.annotation.TargetApi; import android.app.Notification; import android.content.Intent; +import android.graphics.Color; import android.os.Build; import android.os.Handler; import android.service.notification.NotificationListenerService; @@ -112,11 +113,18 @@ public class NotificationService extends NotificationListenerService { if(NotificationManager.textMatches(text) || NotificationManager.titleMatches(title)) return; + int color; + try { + color = Color.parseColor(nApp.color); + } catch (Exception e) { + color = Color.parseColor(default_color); + } + Intent msgrcv = new Intent("Msg"); msgrcv.putExtra("package", pack); msgrcv.putExtra("title", title); msgrcv.putExtra("text", text); - msgrcv.putExtra("color", nApp != null ? nApp.color : default_color); + msgrcv.putExtra("color", color); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(msgrcv); } diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/suggestions/SuggestionsManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/suggestions/SuggestionsManager.java index 7bcad0d5ce98e0edee8b58b127b69c3791889d63..46fe0c9134507f06dc4965f5711a8682f140cea7 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/suggestions/SuggestionsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/suggestions/SuggestionsManager.java @@ -42,7 +42,7 @@ public class SuggestionsManager { private final int MAX_RATE = 100; private final int NO_RATE = -1; - private final int FIRST_INTERVAL = 3; + private final int FIRST_INTERVAL = 5; private boolean showAlias, showAliasWasSet = false; 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 e6a5ac7344485bdf1001b7373dc38258d08a2778..396f3f0932e7d0659f2167be0a5c53e69f77ea18 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java +++ b/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java @@ -12,17 +12,19 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; +import android.os.BatteryManager; import android.os.Build; import android.os.Environment; import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.util.Log; +import android.util.TypedValue; import java.io.DataOutputStream; import java.io.File; @@ -40,7 +42,6 @@ import ohi.andre.consolelauncher.managers.MusicManager; import ohi.andre.consolelauncher.managers.SkinManager; import ohi.andre.consolelauncher.managers.XMLPrefsManager; import ohi.andre.consolelauncher.tuils.stuff.FakeLauncherActivity; -import ohi.andre.consolelauncher.tuils.tutorial.TutorialActivity; public class Tuils { @@ -62,6 +63,19 @@ public class Tuils { return false; } + public static int getBatteryPercentage(Context context) { + + IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + Intent batteryStatus = context.registerReceiver(null, iFilter); + + int level = batteryStatus != null ? batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) : -1; + int scale = batteryStatus != null ? batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1) : -1; + + float batteryPct = level / (float) scale; + + return (int) (batteryPct * 100); + } + public static boolean containsExtension(String[] array, String value) { try { value = value.toLowerCase().trim(); @@ -99,6 +113,11 @@ public class Tuils { return songs; } + public static float dpToPx(Context context, float valueInDp) { + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, valueInDp, metrics); + } + public static boolean hasNotificationAccess(Context context) { String pkgName = BuildConfig.APPLICATION_ID; final String flat = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners"); @@ -129,10 +148,6 @@ public class Tuils { packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP); } - public static void showTutorial(Context context) { - context.startActivity(new Intent(context, TutorialActivity.class)); - } - @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static void openSettingsPage(Context c, String packageName) { Intent intent = new Intent(); @@ -195,6 +210,7 @@ public class Tuils { public static int find(Object o, List list) { for(int count = 0; count < list.size(); count++) { Object x = list.get(count); + if(o instanceof XMLPrefsManager.XMLPrefsSave) { try { if(((XMLPrefsManager.XMLPrefsSave) o).is((String) x)) return count; @@ -207,8 +223,7 @@ public class Tuils { } catch (Exception e) {} } - Object ob = list.get(count); - if(o.equals(ob) || ob.equals(o)) return count; + if(o.equals(x) || x.equals(o)) return count; } return -1; } diff --git a/app/src/main/java/ohi/andre/consolelauncher/tuils/tutorial/TutorialActivity.java b/app/src/main/java/ohi/andre/consolelauncher/tuils/tutorial/TutorialActivity.java deleted file mode 100755 index ed1cb2f517df667edcb6eb02ae79a44a838126e6..0000000000000000000000000000000000000000 --- a/app/src/main/java/ohi/andre/consolelauncher/tuils/tutorial/TutorialActivity.java +++ /dev/null @@ -1,259 +0,0 @@ -package ohi.andre.consolelauncher.tuils.tutorial; - -import android.content.Intent; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.ScrollView; -import android.widget.TextView; - -import ohi.andre.consolelauncher.BuildConfig; -import ohi.andre.consolelauncher.LauncherActivity; -import ohi.andre.consolelauncher.R; -import ohi.andre.consolelauncher.tuils.Animator; -import ohi.andre.consolelauncher.tuils.Tuils; - -public class TutorialActivity extends AppCompatActivity { - - private final int FIRST = 0, END = 7; - - int position = FIRST; - - boolean[] visited = new boolean[END + 1]; - - RelativeLayout root; - TextView back, next, title; - - LayoutInflater inflater; - Resources resources; - - RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - LinearLayout.LayoutParams bigMarginParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - LinearLayout.LayoutParams smallMarginParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - Typeface lucidaConsole; - - private View.OnClickListener nextListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - if(position < END) { - position++; - update(); - } else { - TutorialActivity.this.finish(); - startActivity(new Intent(TutorialActivity.this, LauncherActivity.class)); - } - } - }; - - private View.OnClickListener backListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - if(position > FIRST) { - position--; - update(); - } - } - }; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - resources = getResources(); - setContentView(R.layout.tutorial_base_layout); - - root = (RelativeLayout) findViewById(R.id.tutorial_root); - - RelativeLayout.LayoutParams backParam = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - backParam.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - backParam.addRule(RelativeLayout.ALIGN_PARENT_LEFT); - RelativeLayout.LayoutParams nextParam = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - nextParam.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - nextParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - - containerParams.addRule(RelativeLayout.BELOW, R.id.tutorial_std_title); - containerParams.addRule(RelativeLayout.ABOVE, R.id.tutorial_navigation_container); - bigMarginParams.setMargins(0,0,0,Tuils.dpToPx(resources, resources.getInteger(R.integer.tutorial_items_bigmargin))); - smallMarginParams.setMargins(0,0,0,Tuils.dpToPx(resources, resources.getInteger(R.integer.tutorial_items_smallmargin))); - - back = (TextView) findViewById(R.id.tutorial_navigation_back); - back.setOnClickListener(backListener); - back.setTypeface(lucidaConsole); - - next = (TextView) findViewById(R.id.tutorial_navigation_next); - next.setOnClickListener(nextListener); - next.setTypeface(lucidaConsole); - - title = (TextView) findViewById(R.id.tutorial_std_title); - title.setTypeface(lucidaConsole); - - inflater = getLayoutInflater(); - lucidaConsole = Typeface.createFromAsset(getAssets(), "lucida_console.ttf"); - - update(); - } - - private void update() { - View remove = root.findViewById(R.id.tutorial_container); - if(remove != null) { - root.removeView(remove); - } - - back.setText(R.string.tutorial_navigation_left); - next.setText(R.string.tutorial_navigation_right); - - View view = getView(inflater); - view.setId(R.id.tutorial_container); - - if(position == FIRST) { - TextView introduction = (TextView) view.findViewById(R.id.tutorial_first_title); - introduction.setTypeface(lucidaConsole); - - TextView version = back; - version.setText("vrs. " + BuildConfig.VERSION_NAME); - - title.setText(Tuils.EMPTYSTRING); - - if(!visited[position]) { - Animator nextAnimator = new Animator(next); - Animator versionAnimator = new Animator(version).setChained(nextAnimator); - new Animator(introduction, getString(R.string.tutorial_title)).setChained(versionAnimator).animate(); - } else { - introduction.setText(R.string.tutorial_title); - } - } else if(position == END) { - - TextView author = (TextView) view.findViewById(R.id.tutorial_end_label1); - author.setTypeface(lucidaConsole); - TextView location = (TextView) view.findViewById(R.id.tutorial_end_label2); - location.setTypeface(lucidaConsole); - - title.setText(Tuils.EMPTYSTRING); - - final String email = "andreuzzi.francesco@gmail.com"; - String name = "Francesco Andreuzzi"; - - ImageView git = (ImageView) view.findViewById(R.id.tutorial_end_github), mail = (ImageView) view.findViewById(R.id.tutorial_end_gmail), - googlep = (ImageView) view.findViewById(R.id.tutorial_end_googlep); - - git.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Andre1299/TUI-ConsoleLauncher")); - startActivity(browserIntent); - } - }); - - mail.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_SENDTO); - intent.setData(Uri.parse("mailto:")); - intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email}); - intent.putExtra(Intent.EXTRA_SUBJECT, "About T-UI"); - if (intent.resolveActivity(getPackageManager()) != null) { - startActivity(intent); - } - } - }); - - googlep.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "https://plus.google.com/communities/103936578623101446195") ); - if (intent.resolveActivity(getPackageManager()) != null) { - startActivity(intent); - } - } - }); - - if(!visited[position]) { - Animator a2 = new Animator(location, email); - new Animator(author, name).setChained(a2).animate(); - - new Animator(mail).setChained(new Animator(git).setChained(new Animator(googlep))).animate(); - } else { - location.setText(email); - author.setText(name); - } - } else { - buildTutorial((LinearLayout) view.findViewById(R.id.tutorial_std_container), title, position); - } - - visited[position] = true; - - root.addView(view, 0, containerParams); - } - - private void buildTutorial(LinearLayout container, TextView title, int position) { - TypedArray ta = resources.obtainTypedArray(R.array.tutorial); - CharSequence[] strings = ta.getTextArray(position - 1); - ta.recycle(); - - title.setText(strings[0]); - title.setTypeface(lucidaConsole); - - for(int count = 1; count < strings.length; count++) { - String bigSpaceString = strings[count].subSequence(0,1).toString(), isCommandString = strings[count].subSequence(1,2).toString(); - if(!bigSpaceString.equals("0") && !bigSpaceString.equals("1") && !isCommandString.equals("0") && !isCommandString.equals("1")) { - bigSpaceString = "0"; - isCommandString = "1"; - } else { - strings[count] = strings[count].subSequence(2,strings[count].length()); - } - - boolean bigSpace = bigSpaceString.equals("0"); - boolean isCommand = isCommandString.equals("0"); - - TextView textView = new TextView(this); - - int styleRes = isCommand ? R.style.Tutorial_Text_Primary : R.style.Tutorial_Text_Secondary; - textView.setTextAppearance(this, styleRes); - textView.setTypeface(lucidaConsole); - - container.addView(textView, bigSpace ? bigMarginParams : smallMarginParams); - - if(isCommand && !visited[position]) { - new Animator(textView, strings[count].toString()).animate(); - } else { - textView.setText(strings[count]); - } - } - } - - private View getView(LayoutInflater inflater) { - int res; - if(position == FIRST) { - res = R.layout.tutorial_first_layout; - } else if(position == END) { - res = R.layout.tutorial_end_layout; - } else { - ScrollView scrollView = new ScrollView(this); - scrollView.setClipToPadding(false); - if(Build.VERSION.SDK_INT >= 9) { - scrollView.setOverScrollMode(ScrollView.OVER_SCROLL_NEVER); - } - - LinearLayout container = new LinearLayout(this); - container.setOrientation(LinearLayout.VERTICAL); - container.setId(R.id.tutorial_std_container); - - scrollView.addView(container); - - return scrollView; - } - - return inflater.inflate(res, null); - } -} diff --git a/app/src/main/res/drawable/big_icon.png b/app/src/main/res/drawable/big_icon.png deleted file mode 100755 index 94753f9d9e89d0a41207bbda978216e79cc4bd11..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/drawable/big_icon.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_email.png b/app/src/main/res/drawable/ic_email.png deleted file mode 100755 index 6608943db52b2c0fd79ee9003f4cf08bd215bf40..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/drawable/ic_email.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_git.png b/app/src/main/res/drawable/ic_git.png deleted file mode 100755 index d001e67a3dd88ffbd4461c99bbaec450872b0bfb..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/drawable/ic_git.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_googlep.png b/app/src/main/res/drawable/ic_googlep.png deleted file mode 100755 index bf9148b37fdc0ac29d8b78d8578933bc80351343..0000000000000000000000000000000000000000 Binary files a/app/src/main/res/drawable/ic_googlep.png and /dev/null differ diff --git a/app/src/main/res/drawable/tutorial_end_icon_bg.xml b/app/src/main/res/drawable/tutorial_end_icon_bg.xml deleted file mode 100755 index 58154912a15b71e521477dc44c20d34c698a2bdf..0000000000000000000000000000000000000000 --- a/app/src/main/res/drawable/tutorial_end_icon_bg.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="oval"> - - <solid android:color="@android:color/white"/> - -</shape> \ No newline at end of file diff --git a/app/src/main/res/layout/about_device_view.xml b/app/src/main/res/layout/about_device_view.xml index f154ea30ae8bba496a6ba6759355923c764a8da9..758411b6c6afa0f03a250f771b667e0bdad3d17a 100755 --- a/app/src/main/res/layout/about_device_view.xml +++ b/app/src/main/res/layout/about_device_view.xml @@ -14,4 +14,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/battery_tv" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView android:id="@+id/time_tv" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_base_layout.xml b/app/src/main/res/layout/tutorial_base_layout.xml deleted file mode 100755 index c815b1e23d1501a45e355bbd3f9967701c0b5e20..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/tutorial_base_layout.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/tutorial_root" - - android:layout_width="match_parent" - android:layout_height="match_parent" - - android:background="@color/default_bg_color"> - - <TextView style="@style/Tutorial.Text.Title" - android:paddingBottom="@dimen/tutorial_title_marginbottom"/> - - <LinearLayout android:id="@+id/tutorial_navigation_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - - android:layout_alignParentBottom="true"> - - <TextView style="@style/Tutorial.Navigation.Left"/> - - <TextView style="@style/Tutorial.Navigation.Right"/> - - </LinearLayout> - -</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_end_layout.xml b/app/src/main/res/layout/tutorial_end_layout.xml deleted file mode 100755 index 8615820798e0dea91e8bcd7feaa956a03643c834..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/tutorial_end_layout.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout android:id="@+id/tutorial_logo_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - - android:orientation="vertical" - android:weightSum="2"> - - <LinearLayout android:id="@+id/tutorial_end_icons_container" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - - android:orientation="horizontal" - android:gravity="center_vertical" - - android:weightSum="@integer/tutorial_end_icon_weightsum"> - - <View style="@style/Tutorial.End.IconRow"/> - - <ohi.andre.consolelauncher.tuils.SquareImageView style="@style/Tutorial.End.Icon" - android:id="@+id/tutorial_end_gmail" - - android:src="@drawable/ic_email"/> - - <View style="@style/Tutorial.End.IconRow"/> - - <ohi.andre.consolelauncher.tuils.SquareImageView style="@style/Tutorial.End.Icon" - android:id="@+id/tutorial_end_github" - - android:src="@drawable/ic_git"/> - - <View style="@style/Tutorial.End.IconRow"/> - - <ohi.andre.consolelauncher.tuils.SquareImageView style="@style/Tutorial.End.Icon" - android:id="@+id/tutorial_end_googlep" - - android:src="@drawable/ic_googlep"/> - - <View style="@style/Tutorial.End.IconRow"/> - - </LinearLayout> - - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - - android:orientation="vertical" - android:gravity="center_horizontal" - - android:layout_centerInParent="true"> - - <TextView style="@style/TextAppearance.AppCompat.Body1" - android:id="@+id/tutorial_end_label1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - - android:textColor="@color/default_output_color"/> - - <TextView style="@style/TextAppearance.AppCompat.Body1" - android:id="@+id/tutorial_end_label2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - - android:textColor="@color/default_output_color"/> - - </LinearLayout> - -</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_first_layout.xml b/app/src/main/res/layout/tutorial_first_layout.xml deleted file mode 100755 index 69185c3aca6abf85852e372e29492204171cf69c..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/tutorial_first_layout.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout android:id="@+id/tutorial_logo_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - - android:orientation="vertical" - android:weightSum="2"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - - android:weightSum="@integer/tutorial_bigicon_weightsum" - android:gravity="center"> - - <ImageView - android:layout_width="0dp" - android:layout_weight="@integer/tutorial_bigicon_weight" - android:layout_height="wrap_content" - - android:scaleType="fitCenter" - android:adjustViewBounds="true" - android:src="@drawable/big_icon"/> - - </LinearLayout> - - </LinearLayout> - - <TextView style="@style/Tutorial.Text.Secondary" - android:id="@+id/tutorial_first_title" - - android:layout_centerInParent="true"/> - -</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/values-h1024dp/dimension.xml b/app/src/main/res/values-h1024dp/dimension.xml index 1e0872c3bedfd2348d54f3a4d3cde3a6b508e94a..b3b54efc0532f62bac3740f79a904bcad45dc388 100755 --- a/app/src/main/res/values-h1024dp/dimension.xml +++ b/app/src/main/res/values-h1024dp/dimension.xml @@ -5,8 +5,4 @@ <dimen name="suggestion_height">60dp</dimen> <dimen name="tools_height">35dp</dimen> - <dimen name="tutorial_vertical_margin">26dp</dimen> - - <dimen name="tutorial_title_marginbottom">22dp</dimen> - </resources> diff --git a/app/src/main/res/values-h320dp/dimension.xml b/app/src/main/res/values-h320dp/dimension.xml index fca9b04f82d85a71693c2044b643c08e909bd0e5..159bde8735b736267678bc2c945d65a9b6c11cf3 100755 --- a/app/src/main/res/values-h320dp/dimension.xml +++ b/app/src/main/res/values-h320dp/dimension.xml @@ -5,6 +5,4 @@ <dimen name="suggestion_height">50dp</dimen> <dimen name="tools_height">22dp</dimen> - <dimen name="tutorial_title_marginbottom">15dp</dimen> - </resources> diff --git a/app/src/main/res/values-h720dp/dimension.xml b/app/src/main/res/values-h720dp/dimension.xml index 4f0fbf257c9bbf9d7e117dfaa3ef887cf7fa2409..5367d0f2a4f53f82f73183b44121422cecc527f5 100755 --- a/app/src/main/res/values-h720dp/dimension.xml +++ b/app/src/main/res/values-h720dp/dimension.xml @@ -5,8 +5,4 @@ <dimen name="suggestion_height">55dp</dimen> <dimen name="tools_height">30dp</dimen> - <dimen name="tutorial_vertical_margin">22dp</dimen> - - <dimen name="tutorial_title_marginbottom">18dp</dimen> - </resources> diff --git a/app/src/main/res/values/dimension.xml b/app/src/main/res/values/dimension.xml index f862bd80f136885b9e00b3350e5eb0837b490d9b..73f019e16d3fa44850e04f69cc308e4902e5260f 100755 --- a/app/src/main/res/values/dimension.xml +++ b/app/src/main/res/values/dimension.xml @@ -6,8 +6,4 @@ <dimen name="cursor_width">8dp</dimen> <dimen name="tools_height">15dp</dimen> - <dimen name="tutorial_end_icons_padding">10dp</dimen> - <dimen name="tutorial_navigation_padding">15dp</dimen> - <dimen name="tutorial_title_marginbottom">10dp</dimen> - </resources> diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml deleted file mode 100755 index ca9d4a992d5208b33f75977e3481b6a120cf7030..0000000000000000000000000000000000000000 --- a/app/src/main/res/values/ids.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <item name="tutorial_navigation_next" type="id"/> - <item name="tutorial_navigation_back" type="id"/> - - <item name="tutorial_container" type="id"/> - <item name="tutorial_std_container" type="id"/> - <item name="tutorial_std_title" type="id"/> - -</resources> \ No newline at end of file diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 3b1df68409237660e7e6c143ed6b6f91bc28aa99..775d29df8d32c46638a4322b24349e02220cc845 100755 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -10,13 +10,4 @@ <integer name="tools_view_weightsum">4</integer> <integer name="tools_view_weight">1</integer> - <integer name="tutorial_bigicon_weightsum">3</integer> - <integer name="tutorial_bigicon_weight">1</integer> - - <integer name="tutorial_items_bigmargin">35</integer> - <integer name="tutorial_items_smallmargin">15</integer> - - <integer name="tutorial_end_icon_weightsum">7</integer> - <integer name="tutorial_end_icon_weight">1</integer> - </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 6d07d0b3e5d57022f7db7972deff2906f0e8c6d0..99ea4d5e9baac7d03b30f8dfcee89bff3e7aa208 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -133,9 +133,10 @@ <string name="help_apps">Manage your apps \n\nUsage: \n>>apps [option] [app name] - \n\n-lshidden -> show hidden apps + \n\n-lsh -> show hidden apps \n-show -> show an hidden application \n-hide -> hide an application + \n-l -> show details about an application \n-ps -> show Google Play Store page for this app \n-st -> show Settings details for this app \n-frc -> force t-ui to open this app @@ -161,7 +162,6 @@ \nUsage: call [number] OR [name] (if you don\'t specify a number or a name you will get the list of your contacts) \n\n>>call James </string> - <string name="help_contacts">Print your contacts</string> <string name="help_config">Manage your config files. \nUsage: \n>>config [option] [file OR config_entry] [*value] @@ -236,6 +236,7 @@ \nt>>tui [option] \n\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) <string name="help_tutorial">Go to T-UI tutorial page</string> <string name="help_uninstall">Uninstall an application \nUsage: @@ -274,7 +275,7 @@ \nUsage: \ncntcts [option] [*optional* contact] \n\n-ls -> list your contacts - \n-show -> show details about a contact + \n-l -> show details about a contact \n-new -> create a new contact \n-edit -> edit an existing contact \n-rm -> remove a contact @@ -306,105 +307,6 @@ <string name="start_notification">T-UI started</string> <string name="tui_running">T-UI is running</string> - <!-- tutorial --> - <string name="tutorial_title">A brief introduction</string> - - <string name="tutorial_navigation_right">- - ></string> - <string name="tutorial_navigation_left">< - -</string> - <string name="tutorial_navigation">End</string> - - <string-array name="tutorial_help"> - <item>the command \"help\"</item> - <item>11help gives you information about commands that comes with T-UI. click on the input area on the bottom of the screen and type \"help\".</item> - <item>10$ help</item> - <item>01A\nabout airplane alias aliasfile apps\nB\n...</item> - <item>11\"help\" has also an other important feature: it works like Linux\'s man, therefore it tells you how to use a command. For example:</item> - <item>10$ help search</item> - <item>11will prints this:</item> - <item>@string/help_search</item> - </string-array> - - <string-array name="tutorial_apps"> - <item>how to use your apps</item> - <item>11you can launch an app typing its name (or package name) in the input area. For example</item> - <item>10$ Chrome</item> - <item>01--> com.google.android.apps.chrome.Main</item> - <item>11you should also know something about the command \"apps\", which lets you know what apps are installed on your device and provides some shortcuts (mostly to Play Store and Settings) - \nTherefore, to learn something about this command:</item> - <item>10$ help apps</item> - <item>@string/help_apps</item> - </string-array> - - <string-array name="tutorial_usefulcommands"> - <item>some useful commands</item> - <item>11you can call a contact of yours with the command \"call\"</item> - <item>00$ call Francesco Andreuzzi</item> - <item>11if you want to remove an app from your device use the command \"uninstall\"</item> - <item>00$ uninstall AwfulAppName</item> - <item>11use \"calc\" for quick math operations</item> - <item>00$ calc sqrt(4 * 6 + (189 % 3))</item> - <item>11you can also use rm, cp and mv for file-management</item> - <item>00$ mv /storage/sdcard0/Downloads/file.txt /storage/sdcard1/Docs</item> - <item>11use \"open\" to view files saved on your phone</item> - <item>00$ open /storage/sdcard0/Downloads/file.txt</item> - <item>11use the command \"clear\" to clean the screen, and \"restart\" to reboot T-UI (and apply setting changes)</item> - <item>10$ clear</item> - <item>10$ restart</item> - </string-array> - - <string-array name="tutorial_oscommands"> - <item>control your device</item> - <item>11you can toggle your WI-FI connection with the command \"wifi\"</item> - <item>00$ wifi</item> - <item>11the command \"flash\" lets you turn on or off the flashlight in no time</item> - <item>00$ flash</item> - <item>11there are many commands like these, for example:</item> - <item>10$ airplane</item> - <item>10$ bluetooth</item> - <item>10$ data true</item> - <item>10$ data false</item> - </string-array> - - <string-array name="tutorial_tuixt"> - <item>tuixt - text editor</item> - <item>11the release 5.0 introduced tuixt, the built-in text editor of T-UI. you can start it with this command</item> - <item>10$ tuixt [path to file]</item> - <item>01the file can also be non existent, in that case tuixt will create it</item> - <item>11use the command \"save\" to apply changes on the file, or you will lose them</item> - <item>00$ save</item> - <item>11the command \"exit\" closes tuixt (without saving!) and brings you to your home screen</item> - <item>00$ exit</item> - </string-array> - - <string-array name="tutorial_settings"> - <item>settings and aliases</item> - <item>11T-UI is an highly customizable launcher. you can start using the command \"tuisettings\" which opens a text file called \"settings.txt\"</item> - <item>10$ tuisettings</item> - <item>11as you will see it contains many lines of \"properties\" written with the scheme \"propertyName=propertyValue\". - \ndo not ever edit propertyName, or you\'ll break that feature. just change propertyValue - \nfor example:</item> - <item>11backgroundColor=#ff000000</item> - <item>01if you change #ff000000 (hexadecimal code) to #ffff0000 your background will become red</item> - <item>11aliases are one of the most powerful features of T-UI. you can assign a name to a command you use frequently and make it quicker to use - \nstart using the command \"aliasfile\"</item> - <item>10$ aliasfile</item> - <item>11this will open a file called \"alias.txt\" which already contains two aliases I created to show you how they work. - \nthe scheme is easy to understand: aliasName=command - \nyou can now create your personal aliases appending them to the file (one per line)</item> - <item>11you can use an alias typing its name in the input area and clicking enter. for example</item> - <item>10$ st</item> - <item>01--> com.android.settings.Settings</item> - </string-array> - - <array name="tutorial"> - <item>@array/tutorial_help</item> - <item>@array/tutorial_apps</item> - <item>@array/tutorial_usefulcommands</item> - <item>@array/tutorial_oscommands</item> - <item>@array/tutorial_tuixt</item> - <item>@array/tutorial_settings</item> - </array> - </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6f391a75a9335de28637d38df4588a9ce5e6f060..6d60d4f94237b4ced82f9b9400e65846d6c83f9f 100755 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -35,57 +35,4 @@ <item name="android:scaleType">fitCenter</item> </style> - - <!--tutorial--> - <style name="Tutorial"/> - - <style name="Tutorial.Text" parent="TextAppearance.AppCompat.Subhead"> - <item name="android:layout_width">wrap_content</item> - <item name="android:layout_height">wrap_content</item> - </style> - <style name="Tutorial.Text.Primary" parent="Tutorial.Text"> - <item name="android:textColor">@color/default_input_color</item> - </style> - <style name="Tutorial.Text.Secondary" parent="Tutorial.Text"> - <item name="android:textColor">@color/default_output_color</item> - </style> - <style name="Tutorial.Text.Title" parent="TextAppearance.AppCompat.Title"> - <item name="android:layout_width">wrap_content</item> - <item name="android:layout_height">wrap_content</item> - <item name="android:textColor">@color/default_input_color</item> - <item name="android:id">@id/tutorial_std_title</item> - </style> - - <style name="Tutorial.Navigation" parent="TextAppearance.AppCompat.Headline"> - <item name="android:layout_width">0dp</item> - <item name="android:layout_height">wrap_content</item> - <item name="android:layout_weight">1</item> - - <item name="android:padding">@dimen/tutorial_navigation_padding</item> - <item name="android:gravity">center_horizontal</item> - - <item name="android:textColor">@color/default_input_color</item> - </style> - <style name="Tutorial.Navigation.Right" parent="Tutorial.Navigation"> - <item name="android:text">@string/tutorial_navigation_right</item> - <item name="android:id">@id/tutorial_navigation_next</item> - </style> - <style name="Tutorial.Navigation.Left" parent="Tutorial.Navigation"> - <item name="android:text">@string/tutorial_navigation_left</item> - <item name="android:id">@id/tutorial_navigation_back</item> - </style> - - <style name="Tutorial.End"/> - <style name="Tutorial.End.IconRow"> - <item name="android:layout_width">0dp</item> - <item name="android:layout_weight">@integer/tutorial_end_icon_weight</item> - <item name="android:layout_height">wrap_content</item> - </style> - <style name="Tutorial.End.Icon" parent="Tutorial.End.IconRow"> - <item name="android:adjustViewBounds">true</item> - <item name="android:scaleType">centerCrop</item> - <item name="android:background">@drawable/tutorial_end_icon_bg</item> - <item name="android:padding">@dimen/tutorial_end_icons_padding</item> - </style> - </resources>