diff --git a/app/build.gradle b/app/build.gradle index a33a8d792e5e047db6d65b38de6ede0e66d35052..fdc7b155af1f733ad933f76fe061d85613deff68 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,20 +1,22 @@ apply plugin: 'com.android.application' -apply plugin: 'versionPlugin' - android { signingConfigs { config { + keyAlias 'mykey' + keyPassword 'Dodici12' + storeFile file('/Users/francescoandreuzzi/Programming/Android/Build/my-release-key.keystore') + storePassword 'Dodici12' } } - compileSdkVersion 23 - buildToolsVersion '24.0.0' + compileSdkVersion 25 + buildToolsVersion '25.0.1' defaultConfig { applicationId "ohi.andre.consolelauncher" minSdkVersion 8 targetSdkVersion 23 - versionCode 75 - versionName "4.5" + versionCode 77 + versionName "4.7" } buildTypes { @@ -22,18 +24,10 @@ android { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + zipAlignEnabled true } } - versionPlugin { - buildTypesMatcher = 'release' - - supportBuildNumber = true - buildNumberPrefix = 'b' - - fileNameFormat = 't-ui-vrs_$versionName' - } - compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 @@ -45,4 +39,6 @@ android { compile 'commons-io:commons-io:2.4' } +} +dependencies { } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index eded6f3d64a48d262f3d01fe31ac410c7b0062a9..7d098eebda50f1b87b1adb237764503d1457dc62 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,6 +52,7 @@ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize" android:launchMode="singleTask" android:stateNotNeeded="true" + android:excludeFromRecents="true" android:windowSoftInputMode="stateAlwaysVisible|adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/app/src/main/java/ohi/andre/consolelauncher/UIManager.java b/app/src/main/java/ohi/andre/consolelauncher/UIManager.java index bab6b7df7eb2fa324dea3639b0aacd761bd6ce89..b4c6ad3cd97b07b6f8c65fab191b08c1081968f9 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.os.Build; import android.os.Handler; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.view.GestureDetector; import android.view.GestureDetector.OnDoubleTapListener; import android.view.Gravity; @@ -28,8 +29,16 @@ import android.widget.TextView; import java.io.File; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import ohi.andre.comparestring.Compare; import ohi.andre.consolelauncher.commands.ExecInfo; +import ohi.andre.consolelauncher.managers.AppsManager; +import ohi.andre.consolelauncher.managers.ContactManager; +import ohi.andre.consolelauncher.managers.FileManager; +import ohi.andre.consolelauncher.managers.MusicManager; import ohi.andre.consolelauncher.managers.PreferencesManager; import ohi.andre.consolelauncher.managers.SkinManager; import ohi.andre.consolelauncher.managers.SuggestionsManager; @@ -125,6 +134,9 @@ public class UIManager implements OnTouchListener { String lastWord = inputText.substring(lastSpace != -1 ? lastSpace + 1 : 0); String before = inputText.substring(0, lastSpace + 1); + boolean execOnClick = (boolean) v.getTag(R.id.exec_on_click_id); + int suggestionType = (int) v.getTag(R.id.suggestion_type_id); + StringBuilder builder = new StringBuilder(); if (suggestedText.equals(File.separator)) { builder.append(before); @@ -136,12 +148,64 @@ public class UIManager implements OnTouchListener { builder.append(before); builder.append(suggestedText); } else { - builder.append(before); - builder.append(suggestedText); + if(!suggestedText.contains(Tuils.SPACE)) { + builder.append(before); + builder.append(suggestedText); + } else { + String[] suggestParts = suggestedText.split(Tuils.SPACE); + String[] inputParts = inputText.split(Tuils.SPACE); + + boolean useScrollCompare; + int minRate; + switch (suggestionType) { + case SuggestionsManager.Suggestion.TYPE_APP: + useScrollCompare = AppsManager.USE_SCROLL_COMPARE; + minRate = SuggestionsManager.MIN_APPS_RATE; + break; + case SuggestionsManager.Suggestion.TYPE_SONG: + useScrollCompare = MusicManager.USE_SCROLL_COMPARE; + minRate = SuggestionsManager.MIN_SONGS_RATE; + break; + case SuggestionsManager.Suggestion.TYPE_CONTACT: + useScrollCompare = ContactManager.USE_SCROLL_COMPARE; + minRate = SuggestionsManager.MIN_CONTACTS_RATE; + break; + case SuggestionsManager.Suggestion.TYPE_FILE: + useScrollCompare = FileManager.USE_SCROLL_COMPARE; + minRate = SuggestionsManager.MIN_FILE_RATE; + break; + default: + builder.append(before); + builder.append(suggestedText); + return; + } + + int count; + for(count = 0; count < inputParts.length; count++) { + int rate = useScrollCompare ? Compare.scrollComparison(inputParts[count], suggestParts[0]) : + Compare.linearComparison(inputParts[count], suggestParts[0]); + + if(rate >= minRate) { + break; + } + } + + List<String> finalText = new ArrayList<>(Arrays.asList(inputParts)); + for(int c = 0; c < suggestParts.length; c++) { + if(finalText.size() > c + count) { + finalText.set(c + count, suggestParts[c]); + } else { + finalText.add(suggestParts[c]); + } + } + + builder.append(Tuils.toPlanString(finalText, Tuils.SPACE)); + } } mTerminalAdapter.setInput(builder.toString()); - if (executeOnSuggestionClick && v.getId() == SuggestionsManager.Suggestion.EXEC_ON_CLICK) { + + if (executeOnSuggestionClick && execOnClick) { mTerminalAdapter.simulateEnter(); } else { mTerminalAdapter.focusInputEnd(); diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/raw/call.java b/app/src/main/java/ohi/andre/consolelauncher/commands/raw/call.java index 39b6039517f1ae8ab2f80594e7d2ed4e648a4567..2d1222f38e2c5489a5bc3b728d524812faa19250 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/raw/call.java +++ b/app/src/main/java/ohi/andre/consolelauncher/commands/raw/call.java @@ -6,9 +6,12 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.support.v4.content.ContextCompat; +import java.util.List; + import ohi.andre.consolelauncher.R; import ohi.andre.consolelauncher.commands.CommandAbstraction; import ohi.andre.consolelauncher.commands.ExecInfo; +import ohi.andre.consolelauncher.tuils.Tuils; public class call implements CommandAbstraction { @@ -63,7 +66,14 @@ public class call implements CommandAbstraction { @Override public String onNotArgEnough(ExecInfo info, int nArgs) { - return info.res.getString(helpRes()); + if (ContextCompat.checkSelfPermission(info.context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { + return info.res.getString(R.string.output_nopermissions); + } + + List<String> contacts = info.contacts.listNamesAndNumbers(); + Tuils.addPrefix(contacts, " "); + Tuils.insertHeaders(contacts, false); + return Tuils.toPlanString(contacts); } @Override diff --git a/app/src/main/java/ohi/andre/consolelauncher/commands/raw/contacts.java b/app/src/main/java/ohi/andre/consolelauncher/commands/raw/contacts.java deleted file mode 100755 index aceef23f4bfe5d73557360879a8d7fa14fdc150e..0000000000000000000000000000000000000000 --- a/app/src/main/java/ohi/andre/consolelauncher/commands/raw/contacts.java +++ /dev/null @@ -1,68 +0,0 @@ -package ohi.andre.consolelauncher.commands.raw; - -import android.Manifest; -import android.content.pm.PackageManager; -import android.support.v4.content.ContextCompat; - -import java.util.List; - -import ohi.andre.consolelauncher.R; -import ohi.andre.consolelauncher.commands.CommandAbstraction; -import ohi.andre.consolelauncher.commands.ExecInfo; -import ohi.andre.consolelauncher.tuils.Tuils; - -public class contacts implements CommandAbstraction { - - @Override - public String exec(ExecInfo info) { - if (ContextCompat.checkSelfPermission(info.context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { - return info.res.getString(R.string.output_nopermissions); - } - - List<String> contacts = info.contacts.listNamesAndNumbers(); - Tuils.addPrefix(contacts, " "); - Tuils.insertHeaders(contacts, false); - return Tuils.toPlanString(contacts); - } - - @Override - public int helpRes() { - return R.string.help_contacts; - } - - @Override - public int minArgs() { - return 0; - } - - @Override - public int maxArgs() { - return 0; - } - - @Override - public int[] argType() { - return null; - } - - @Override - public int priority() { - return 2; - } - - @Override - public String[] parameters() { - return null; - } - - @Override - public String onNotArgEnough(ExecInfo info, int nArgs) { - return null; - } - - @Override - public int notFoundRes() { - return 0; - } - -} diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/MusicManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/MusicManager.java index 0872d3c2a22211d4ae8a1874e3b8fe7174573f4c..e721e556809d9889db2af60f35b1ec8572a7465f 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/MusicManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/MusicManager.java @@ -23,14 +23,12 @@ public class MusicManager implements OnCompletionListener { public static final boolean USE_SCROLL_COMPARE = true; - private File songFolder; + private List<File> files; private MediaPlayer mp; private int currentSongIndex = 0; private File currentSong = null; - private boolean randomActive; - // headset broadcast private BroadcastReceiver headsetReceiver = new HeadsetBroadcast(new Runnable() { @Override @@ -46,9 +44,17 @@ public class MusicManager implements OnCompletionListener { c.registerReceiver(headsetReceiver, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); - randomActive = Boolean.parseBoolean(preferencesManager.getValue(PreferencesManager.PLAY_RANDOM)); + boolean randomActive = Boolean.parseBoolean(preferencesManager.getValue(PreferencesManager.PLAY_RANDOM)); - songFolder = new File(preferencesManager.getValue(PreferencesManager.SONGSFOLDER)); + if(Boolean.parseBoolean(preferencesManager.getValue(PreferencesManager.FROM_MEDIASTORE))) { + files = Tuils.getMediastoreSongs(c); + } else { + files = Tuils.getSongsInFolder(new File(preferencesManager.getValue(PreferencesManager.SONGSFOLDER))); + } + + if(randomActive) { + Collections.shuffle(files); + } } public boolean initPlayer() { @@ -62,23 +68,22 @@ public class MusicManager implements OnCompletionListener { // return the path by complete name public String getPath(String name) { - File file = new File(songFolder, name); - if (!file.exists()) { - return null; + int count = 0; + File file = files.get(count); + while(!file.getName().equals(name)) { + if(count == files.size()) { + return null; + } + file = files.get(++count); } return file.getAbsolutePath(); } // return names public List<String> getNames() { - List<File> songs = Tuils.getSongsInFolder(songFolder); - if(songs == null) { - return null; - } - List<String> names = new ArrayList<>(); - for (File file : songs) + for (File file : files) names.add(file.getName()); Collections.sort(names); @@ -88,10 +93,10 @@ public class MusicManager implements OnCompletionListener { // return paths public List<String> getPaths() { - List<File> songs = Tuils.getSongsInFolder(songFolder); + List<String> paths = new ArrayList<>(); - for (File file : songs) + for (File file : files) paths.add(file.getAbsolutePath()); return paths; @@ -106,28 +111,21 @@ public class MusicManager implements OnCompletionListener { } private boolean prepareSong(int songIndex) { - if (songFolder == null) + if (files == null) return false; List<String> songs = getPaths(); - if (randomActive) { - Random random = new Random(); - int totalSongs = songs.size(); - - int newSong; - do { - newSong = random.nextInt(totalSongs); - } while (songIndex == newSong); - songIndex = newSong; - } else { - if (songIndex >= songs.size()) - songIndex -= songs.size(); - else if (songIndex < 0) - songIndex += songs.size(); - - currentSongIndex = songIndex; + if(songs == null) { + return false; } + if (songIndex >= songs.size()) + songIndex -= songs.size(); + else if (songIndex < 0) + songIndex += songs.size(); + + currentSongIndex = songIndex; + return prepareSong(songs.get(songIndex)); } diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/PreferencesManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/PreferencesManager.java index ab290658cdd2b99ae2c7271d8da364cbe4507623..47b6a360a0a6d96736807e89abdf59ed767fce37 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/PreferencesManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/PreferencesManager.java @@ -51,6 +51,7 @@ public class PreferencesManager { public static final String PLAY_RANDOM = "playRandom"; public static final String SONGSFOLDER = "songsFolder"; + public static final String FROM_MEDIASTORE = "fromMediastore"; public static final String USE_SYSTEMWP = "useSystemWallpaper"; public static final String FULLSCREEN = "fullscreen"; 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 56fb5a432d843ea3b67e22207817ad267e92c785..15b5aa51ca63a41a7296baebd1bb53d7fa8e4d6f 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/SkinManager.java @@ -3,6 +3,7 @@ package ohi.andre.consolelauncher.managers; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; +import android.util.Log; import java.util.HashMap; @@ -47,7 +48,7 @@ public class SkinManager { private boolean useSystemWp; private boolean showSuggestions; - private HashMap<Integer, ColorDrawable> suggestionBgs = new HashMap<>(); + private HashMap<Integer, Integer> suggestionBgs = new HashMap<>(); private int suggestionTextColor; @@ -117,75 +118,79 @@ public class SkinManager { try { multicolorSuggestions = Boolean.parseBoolean(prefs.getValue(PreferencesManager.USE_MULTICOLOR_SUGGESTIONS)); } catch (Exception e) { - transparentSuggestions = true; - } - if(multicolorSuggestions) { - transparentSuggestions = !multicolorSuggestions; + multicolorSuggestions = false; } - if(!transparentSuggestions && !multicolorSuggestions) { - int defaultSuggestionBg; - try { - defaultSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.DEFAULT_SUGGESTION_BG)); - } catch (Exception e) { - defaultSuggestionBg = defaultSuggestionBgDefault; - } - suggestionBgs.put(null, new ColorDrawable(defaultSuggestionBg)); + if(multicolorSuggestions) { + transparentSuggestions = false; } if(transparentSuggestions) { - suggestionBgs.put(null, null); - } - - if(multicolorSuggestions) { - - int appSuggestionBg; - try { - appSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.APP_SUGGESTION_BG)); - } catch (Exception e) { - appSuggestionBg = appSuggestionBgDefault; - } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_APP, new ColorDrawable(appSuggestionBg)); - - int contactSuggestionBg; - try { - contactSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.CONTACT_SUGGESTION_BG)); - } catch (Exception e) { - contactSuggestionBg = contactSuggestionBgDefault; - } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_CONTACT, new ColorDrawable(contactSuggestionBg)); + suggestionBgs.put(0, Color.TRANSPARENT); - int commandSuggestionsBg; - try { - commandSuggestionsBg = Color.parseColor(prefs.getValue(PreferencesManager.COMMAND_SUGGESTION_BG)); - } catch (Exception e) { - commandSuggestionsBg = commandSuggestionsBgDefault; - } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_COMMAND, new ColorDrawable(commandSuggestionsBg)); - - int songSuggestionBg; - try { - songSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.SONG_SUGGESTION_BG)); - } catch (Exception e) { - songSuggestionBg = songSuggestionBgDefault; + if(suggestionTextColor == bgColor) { + suggestionTextColor = Color.GREEN; } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_SONG, new ColorDrawable(songSuggestionBg)); - - int fileSuggestionBg; + } else { + int defaultSuggestionBg; try { - fileSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.FILE_SUGGESTION_BG)); + defaultSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.DEFAULT_SUGGESTION_BG)); } catch (Exception e) { - fileSuggestionBg = fileSuggestionBgDeafult; + defaultSuggestionBg = defaultSuggestionBgDefault; } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_FILE, new ColorDrawable(fileSuggestionBg)); - - int aliasSuggestionBg; - try { - aliasSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.ALIAS_SIGGESTION_BG)); - } catch (Exception e) { - aliasSuggestionBg = aliasSuggestionBgDefault; + suggestionBgs.put(0, defaultSuggestionBg); + + + if(multicolorSuggestions) { + + int appSuggestionBg; + try { + appSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.APP_SUGGESTION_BG)); + } catch (Exception e) { + appSuggestionBg = appSuggestionBgDefault; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_APP, appSuggestionBg); + + int contactSuggestionBg; + try { + contactSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.CONTACT_SUGGESTION_BG)); + } catch (Exception e) { + contactSuggestionBg = contactSuggestionBgDefault; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_CONTACT, contactSuggestionBg); + + int commandSuggestionsBg; + try { + commandSuggestionsBg = Color.parseColor(prefs.getValue(PreferencesManager.COMMAND_SUGGESTION_BG)); + } catch (Exception e) { + commandSuggestionsBg = commandSuggestionsBgDefault; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_COMMAND, commandSuggestionsBg); + + int songSuggestionBg; + try { + songSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.SONG_SUGGESTION_BG)); + } catch (Exception e) { + songSuggestionBg = songSuggestionBgDefault; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_SONG, songSuggestionBg); + + int fileSuggestionBg; + try { + fileSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.FILE_SUGGESTION_BG)); + } catch (Exception e) { + fileSuggestionBg = fileSuggestionBgDeafult; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_FILE, fileSuggestionBg); + + int aliasSuggestionBg; + try { + aliasSuggestionBg = Color.parseColor(prefs.getValue(PreferencesManager.ALIAS_SIGGESTION_BG)); + } catch (Exception e) { + aliasSuggestionBg = aliasSuggestionBgDefault; + } + suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_ALIAS, aliasSuggestionBg); } - suggestionBgs.put(SuggestionsManager.Suggestion.TYPE_ALIAS, new ColorDrawable(aliasSuggestionBg)); } } } @@ -227,7 +232,11 @@ public class SkinManager { } public ColorDrawable getSuggestionBg(Integer type) { - return suggestionBgs.get(type); + if(transparentSuggestions) { + type = 0; + } + + return new ColorDrawable(suggestionBgs.get(type)); } public int getSuggestionTextColor() { diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/SuggestionsManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/SuggestionsManager.java index 9e13955a3dca8d7e9ee38136c84874beb69a0406..43fe6692fc91fd5e0aae62553b9247bc4a405bfd 100644 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/SuggestionsManager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/SuggestionsManager.java @@ -1,5 +1,7 @@ package ohi.andre.consolelauncher.managers; +import android.util.Log; + import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -20,13 +22,13 @@ public class SuggestionsManager { private static final int MIN_COMMAND_RATE = 1; private static final int MIN_COMMAND_PRIORITY = 5; - private static final int MIN_APPS_RATE = 3; + public static final int MIN_APPS_RATE = 3; - private static final int MIN_CONTACTS_RATE = 2; + public static final int MIN_CONTACTS_RATE = 2; - private static final int MIN_FILE_RATE = 2; + public static final int MIN_FILE_RATE = 2; - private static final int MIN_SONGS_RATE = 2; + public static final int MIN_SONGS_RATE = 2; // use to place something at the top private static final int MAX_RATE = 100; @@ -289,9 +291,6 @@ public class SuggestionsManager { public static final int TYPE_SONG = 14; public static final int TYPE_CONTACT = 15; - public static final int EXEC_ON_CLICK = 10; - public static final int NONE = 11; - public String text; public boolean exec; public int rate; 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 7dcc163d194f42f0f085aa903e7b34952fcc70f3..8205f188b028859a5ba4549861c9014c010f63c1 100644 --- a/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java +++ b/app/src/main/java/ohi/andre/consolelauncher/managers/TerminalMAnager.java @@ -63,6 +63,9 @@ public class TerminalManager { }; private SkinManager mSkinManager; + private String originalInput; + private List<InputText> propertyText = new ArrayList<>(); + private OnNewInputListener mInputListener; public TerminalManager(TextView terminalView, EditText inputView, TextView prefixView, TextView submitView, SkinManager skinManager, @@ -106,8 +109,8 @@ public class TerminalManager { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE - || (physicalEnter && actionId == EditorInfo.IME_ACTION_UNSPECIFIED)) { +// physical enter is temporary ignores + if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE) { onNewInput(); return true; } else @@ -118,6 +121,8 @@ public class TerminalManager { private void setupNewInput() { mInputView.setText(Tuils.EMPTYSTRING); + originalInput = Tuils.EMPTYSTRING; + propertyText = new ArrayList<>(); mCurrentOutputId++; requestInputFocus(); } @@ -324,4 +329,17 @@ public class TerminalManager { }); } + public static class InputText { + + String original; + CharSequence shownText; + Runnable onClick; + + public InputText(String original, CharSequence shownText, Runnable onClick) { + this.original = original; + this.shownText = shownText; + this.onClick = onClick; + } + } + } diff --git a/app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java b/app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java index e624ef5be9197e6b486ca7d74ed71b71f95c3538..da7ce33921f0cba58daa07e6f21a3af9c8b70f07 100644 --- a/app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java +++ b/app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java @@ -14,11 +14,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.*/ +import android.graphics.Color; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.HorizontalScrollView; import android.widget.TextView; +import ohi.andre.consolelauncher.R; import ohi.andre.consolelauncher.managers.SkinManager; import ohi.andre.consolelauncher.managers.SuggestionsManager; @@ -87,19 +90,21 @@ public class SuggestionRunnable implements Runnable { } String s = suggestions[count].text; - if (count < toRecycle.length) { - toRecycle[count].setId(suggestions[count].exec ? SuggestionsManager.Suggestion.EXEC_ON_CLICK : - SuggestionsManager.Suggestion.NONE); + if (toRecycle != null && count < toRecycle.length) { + toRecycle[count].setTag(R.id.exec_on_click_id, suggestions[count].exec); + toRecycle[count].setTag(R.id.suggestion_type_id, suggestions[count].type); + toRecycle[count].setText(s); - toRecycle[count].setBackgroundDrawable(null); toRecycle[count].setBackgroundDrawable(skinManager.getSuggestionBg(suggestions[count].type)); } else { int space = suggestions.length - (count + 1); if (toAdd != null && space < toAdd.length) { - toAdd[space].setId(suggestions[count].exec ? SuggestionsManager.Suggestion.EXEC_ON_CLICK : - SuggestionsManager.Suggestion.NONE); + toAdd[space].setTag(R.id.exec_on_click_id, suggestions[count].exec); + toAdd[space].setTag(R.id.suggestion_type_id, suggestions[count].type); + toAdd[space].setText(s); toAdd[space].setBackgroundDrawable(skinManager.getSuggestionBg(suggestions[count].type)); + if(toAdd[space].getParent() == null) { suggestionsView.addView(toAdd[space], suggestionViewParams); } else { 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 36f40e3f2ca56fd171c78ebb97dd92e7b5241fff..c376ca3f40a9979a1be5ac4a1db6745d2948ca15 100755 --- a/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java +++ b/app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java @@ -8,11 +8,14 @@ import android.app.ActivityManager; import android.app.ActivityManager.MemoryInfo; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Environment; +import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.Patterns; @@ -393,4 +396,35 @@ public class Tuils { return new File(Tuils.getInternalDirectoryPath(), TUI_FOLDER); } + public static List<File> getMediastoreSongs(Context activity) { + ContentResolver cr = activity.getContentResolver(); + + List<File> paths = new ArrayList<>(); + + Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + String selection = MediaStore.Audio.Media.IS_MUSIC + "!= 0"; + String sortOrder = MediaStore.Audio.Media.TITLE + " ASC"; + Cursor cur = cr.query(uri, null, selection, null, sortOrder); + int count = 0; + + if(cur != null) + { + count = cur.getCount(); + + if(count > 0) + { + while(cur.moveToNext()) + { + String data = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.DATA)); + paths.add(new File(data)); + } + + } + } + + cur.close(); + + return paths; + } + } diff --git a/app/src/main/res/drawable/cursor.xml b/app/src/main/res/drawable/cursor.xml index 20e05b5ea1e5b804e70fc359d6a07f62d8ddcb1b..bff8d95fc8742741f692822102f61944bf8b614e 100644 --- a/app/src/main/res/drawable/cursor.xml +++ b/app/src/main/res/drawable/cursor.xml @@ -4,6 +4,5 @@ <solid android:color="#FFFFFFFF" /> <size - android:width="@dimen/cursor_width" - android:height="@dimen/input_height" /> + android:width="@dimen/cursor_width"/> </shape> \ No newline at end of file diff --git a/app/src/main/res/layout-v12/input_group.xml b/app/src/main/res/layout-v12/input_group.xml index fa03d42089ba3338f29398e6dd4c183a748ba2f1..f7ae2b6d58a183b28b63bff549e742a34bf73419 100644 --- a/app/src/main/res/layout-v12/input_group.xml +++ b/app/src/main/res/layout-v12/input_group.xml @@ -3,24 +3,27 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="9" - android:orientation="horizontal"> + android:orientation="horizontal" + android:gravity="center_vertical"> <TextView android:id="@+id/prefix_view" android:layout_width="wrap_content" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" + + android:paddingTop="@dimen/input_padding"/> <EditText android:id="@+id/input_view" android:layout_width="0dp" - android:layout_height="@dimen/input_height" + android:layout_height="wrap_content" android:layout_weight="7" - android:paddingTop="@dimen/input_padding" - android:background="@null" android:imeOptions="actionGo|flagNoFullscreen" + android:paddingTop="@dimen/input_padding" + android:lines="1" android:singleLine="true" android:textCursorDrawable="@drawable/cursor" /> @@ -28,10 +31,12 @@ <Button android:id="@+id/submit_tv" android:layout_width="0dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_weight="2" android:background="@null" - android:text="↲" /> + android:text="↲" + + android:paddingTop="@dimen/input_padding"/> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/input_group.xml b/app/src/main/res/layout/input_group.xml index e92ea59282e9322567c80c2f1e822f64ae30304d..1fed2c35ab055dd66ca950d1b53753cd80418050 100644 --- a/app/src/main/res/layout/input_group.xml +++ b/app/src/main/res/layout/input_group.xml @@ -2,34 +2,39 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal"> + android:orientation="horizontal" + android:gravity="center_vertical"> <TextView android:id="@+id/prefix_view" android:layout_width="wrap_content" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + + android:paddingTop="@dimen/input_padding"/> <EditText android:id="@+id/input_view" android:layout_width="0dp" - android:layout_height="@dimen/input_height" + android:layout_height="wrap_content" android:layout_weight="1" - android:paddingTop="@dimen/input_padding" - android:background="@null" android:imeOptions="actionGo|flagNoFullscreen" + android:paddingTop="@dimen/input_padding" + android:lines="1" android:singleLine="true"/> <Button android:id="@+id/submit_tv" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_marginRight="20dp" android:background="@null" - android:text="↲" /> + android:text="↲" + + android:paddingTop="@dimen/input_padding"/> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 60d00418be924803ce64c9116e51d1c1749fff20..e7a121f85d03925ed743e20939aaa181232497f6 100755 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 65649542e03fafe3c6531ec96081d9a02028ce2c..627c57a57a199a5414c97bd0820ca511a6964ab2 100755 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 54b0160cd0da9b609f0207cffb4216144236539f..12cc9cba8c3a38efce86d264369f320e5d1dda89 100755 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index de31fd30c541092f07b0504462496691db1e827e..41fc64a8a383145d56c4d7fa84e66596b54a8a84 100755 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index bdaef34cd2ee2444c86048747e66753b7cb8223f..7acc991f0d64732d6cd0895bcbe4b3bdfdd313b2 100755 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/raw/settings.txt b/app/src/main/res/raw/settings.txt index f2d6a6f36522145af730af706d369fe3f5f81b90..bc15a21c09a8b4f8181626478be6f15eea2a8a55 100755 --- a/app/src/main/res/raw/settings.txt +++ b/app/src/main/res/raw/settings.txt @@ -1,5 +1,5 @@ // do not edit the settingsVersion property! -settingsVersion=4.4 +settingsVersion=4.7 // when you are ready go back to t-ui and type "restart" to see changes @@ -39,6 +39,7 @@ keepAliveWithNotification=true openKeyboardOnStart=true // music +fromMediastore=true playRandom=true songsFolder=/sdcard/Music diff --git a/app/src/main/res/values-h1024dp/dimension.xml b/app/src/main/res/values-h1024dp/dimension.xml index 37ce1610e4ed7145c1f95e40cdc87c6e31bfab9c..8b27ae190b155347e3887d481bfa4c1311eb0de5 100755 --- a/app/src/main/res/values-h1024dp/dimension.xml +++ b/app/src/main/res/values-h1024dp/dimension.xml @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <dimen name="input_height">60dp</dimen> - <dimen name="input_padding">45dp</dimen> + <dimen name="input_padding">35dp</dimen> <dimen name="suggestion_height">60dp</dimen> </resources> diff --git a/app/src/main/res/values-h320dp/dimension.xml b/app/src/main/res/values-h320dp/dimension.xml index 19c2112667d0f4802c60606bcda20d18311bc284..a2b8595dbf4b464786559ed8e4e29240d288c3d8 100755 --- a/app/src/main/res/values-h320dp/dimension.xml +++ b/app/src/main/res/values-h320dp/dimension.xml @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <dimen name="input_height">50dp</dimen> - <dimen name="input_padding">35dp</dimen> + <dimen name="input_padding">25dp</dimen> <dimen name="suggestion_height">50dp</dimen> </resources> diff --git a/app/src/main/res/values-h720dp/dimension.xml b/app/src/main/res/values-h720dp/dimension.xml index 307ab5100d7b13474b5d34196057f894c69a755c..1a3e50a7031ae8a38c3227246725f845b26fedb8 100755 --- a/app/src/main/res/values-h720dp/dimension.xml +++ b/app/src/main/res/values-h720dp/dimension.xml @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <dimen name="input_height">60dp</dimen> - <dimen name="input_padding">45dp</dimen> + <dimen name="input_padding">30dp</dimen> <dimen name="suggestion_height">55dp</dimen> </resources> diff --git a/app/src/main/res/values/dimension.xml b/app/src/main/res/values/dimension.xml index d5200cf39693ad6e235bc057141a02f956fb9704..91adf6ab2db393c26c1aaa6cf686753e0baf85f2 100755 --- a/app/src/main/res/values/dimension.xml +++ b/app/src/main/res/values/dimension.xml @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <dimen name="input_height">35dp</dimen> - <dimen name="input_padding">25dp</dimen> + <dimen name="input_padding">15dp</dimen> <dimen name="suggestion_height">40dp</dimen> <dimen name="cursor_width">8dp</dimen> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb7bf7e292f0bc791e0d27a7964a509df0eac6bc..3ae93fe8817d206e64f38dcf7fb5f3d7fda4955f 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,10 +4,10 @@ <string name="app_name">T-UI</string> <string name="separator_text">>></string> <string name="separator_text_su">$</string> - <string name="su">T-UI got SU permissions</string> - <string name="nosu">Seems that your device isn\'t properly rooted</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 at least Storage permission to make t-ui work</string> - <string name="permission_error">t-ui has not the permissions to do this</string> + <string name="permission_error">t-ui hasn\'t the permission to do that</string> <string name="version_label">Version:</string> <!-- app mgr --> @@ -21,13 +21,13 @@ <string name="error_label">Errors:</string> <!-- pending operation --> - <string name="starting_app">Starting:</string> + <string name="starting_app">Launching:</string> <string name="calling">Calling:</string> <string name="sharing">Sharing:</string> <!-- various outputs --> <string name="output_nothingfound">No matches</string> - <string name="output_nopermissions">You didn\'t grant the permission to do this</string> + <string name="output_nopermissions">You didn\'t grant the permission to do that</string> <!-- search--> <string name="output_searchingplaystore">Play Store search:</string> diff --git a/build.gradle b/build.gradle index c8451c01f0b16b4969ffe85f7ba4450ceb63bba4..8f59b3829cadf907a4bd66f9c99c2dd62b8dcb73 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' - classpath 'com.github.hamsterksu:android-appversion-gradle-plugin:1.2.0' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files