-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline Termux:Widget into the main Termux app
- Loading branch information
Showing
31 changed files
with
133 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include(":termux-api", ":termux-app", ":terminal-emulator", ":terminal-view", ":termux-style", ":termux-widget") | ||
include(":termux-api", ":termux-app", ":terminal-emulator", ":terminal-view", ":termux-style") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
termux-app/src/main/java/com/termux/widget/TermuxWidgetPathLister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.termux.widget; | ||
|
||
import android.util.Log; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.function.Consumer; | ||
|
||
public class TermuxWidgetPathLister { | ||
|
||
public static void listPaths(Consumer<String> onFile) { | ||
var visited = new HashSet<String>(); | ||
for (var parentPath : new String[]{ | ||
TermuxWidgetConstants.TERMUX_SHORTCUT_SCRIPTS_DIR_PATH, | ||
TermuxWidgetConstants.TERMUX_SHORTCUT_SCRIPTS_DIR_PATH_LEGACY, | ||
}) { | ||
var parentDir = new File(parentPath); | ||
listPathsInternal(parentDir, visited, onFile); | ||
} | ||
} | ||
|
||
private static void listPathsInternal(File directory, Set<String> visited, Consumer<String> onFile) { | ||
try { | ||
var canonicalPath = directory.getCanonicalPath(); | ||
if (!visited.add(canonicalPath)) { | ||
Log.w(TermuxWidgetConstants.LOG_TAG, "Avoiding visiting directory again: " + directory.getAbsolutePath()); | ||
return; | ||
} | ||
} catch (IOException e) { | ||
Log.e(TermuxWidgetConstants.LOG_TAG, "Exception resolving canonical path for: " + directory.getAbsolutePath(), e); | ||
return; | ||
} | ||
|
||
var children = directory.listFiles(); | ||
|
||
if (children == null) { | ||
return; | ||
} | ||
|
||
for (var child : children) { | ||
if (child.isFile()) { | ||
if (!child.canExecute()) { | ||
if (!child.setExecutable(true)) { | ||
Log.e(TermuxWidgetConstants.LOG_TAG, "Unable to set file to executable: " + child.getAbsolutePath()); | ||
} | ||
} | ||
onFile.accept(child.getAbsolutePath()); | ||
} else if (child.isDirectory()) { | ||
listPathsInternal(child, visited, onFile); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.