Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terminal user interface- command line
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arjun Sundaram
Terminal user interface- command line
Commits
a77ca118
Commit
a77ca118
authored
9 years ago
by
Francesco Andreuzzi
Browse files
Options
Downloads
Patches
Plain Diff
new param: -u
parent
6a648b82
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/ohi/andre/consolelauncher/commands/raw/search.java
+33
-25
33 additions, 25 deletions
...n/java/ohi/andre/consolelauncher/commands/raw/search.java
with
33 additions
and
25 deletions
app/src/main/java/ohi/andre/consolelauncher/commands/raw/search.java
+
33
−
25
View file @
a77ca118
...
@@ -22,6 +22,7 @@ public class search implements CommandAbstraction {
...
@@ -22,6 +22,7 @@ public class search implements CommandAbstraction {
private
final
int
PLAYSTORE
=
11
;
private
final
int
PLAYSTORE
=
11
;
private
final
int
FILE
=
12
;
private
final
int
FILE
=
12
;
private
final
int
YOUTUBE
=
13
;
private
final
int
YOUTUBE
=
13
;
private
final
int
URL
=
14
;
private
final
String
YOUTUBE_PREFIX
=
"https://www.youtube.com/results?search_query="
;
private
final
String
YOUTUBE_PREFIX
=
"https://www.youtube.com/results?search_query="
;
private
final
String
GOOGLE_PREFIX
=
"http://www.google.com/#q="
;
private
final
String
GOOGLE_PREFIX
=
"http://www.google.com/#q="
;
...
@@ -32,6 +33,7 @@ public class search implements CommandAbstraction {
...
@@ -32,6 +33,7 @@ public class search implements CommandAbstraction {
private
final
String
FILE_PARAM
=
"-f"
;
private
final
String
FILE_PARAM
=
"-f"
;
private
final
String
GOOGLE_PARAM
=
"-g"
;
private
final
String
GOOGLE_PARAM
=
"-g"
;
private
final
String
YOUTUBE_PARAM
=
"-y"
;
private
final
String
YOUTUBE_PARAM
=
"-y"
;
private
final
String
URL_PARAM
=
"-u"
;
private
final
int
MIN_FILE_RATE
=
6
;
private
final
int
MIN_FILE_RATE
=
6
;
...
@@ -39,31 +41,24 @@ public class search implements CommandAbstraction {
...
@@ -39,31 +41,24 @@ public class search implements CommandAbstraction {
public
String
exec
(
ExecInfo
info
)
{
public
String
exec
(
ExecInfo
info
)
{
String
param
=
info
.
get
(
String
.
class
,
0
);
String
param
=
info
.
get
(
String
.
class
,
0
);
List
<
String
>
args
=
info
.
get
(
ArrayList
.
class
,
1
);
List
<
String
>
args
=
info
.
get
(
ArrayList
.
class
,
1
);
if
(
args
==
null
)
if
(
args
==
null
)
{
return
info
.
res
.
getString
(
R
.
string
.
output_nothing_found
);
return
info
.
res
.
getString
(
R
.
string
.
output_nothing_found
);
}
int
type
;
switch
(
param
)
{
if
(
param
.
equals
(
PLAYSTORE_PARAM
))
case
PLAYSTORE_PARAM:
type
=
PLAYSTORE
;
else
if
(
param
.
equals
(
FILE_PARAM
))
type
=
FILE
;
else
if
(
param
.
equals
(
YOUTUBE_PARAM
))
type
=
YOUTUBE
;
else
if
(
param
.
equals
(
GOOGLE_PARAM
))
type
=
GOOGLE
;
else
return
info
.
res
.
getString
(
R
.
string
.
output_invalid_param
);
if
(
type
==
GOOGLE
)
return
google
(
args
,
info
.
context
,
info
.
res
);
else
if
(
type
==
PLAYSTORE
)
return
playstore
(
args
,
info
.
context
,
info
.
res
);
return
playstore
(
args
,
info
.
context
,
info
.
res
);
else
if
(
type
==
FILE
)
case
YOUTUBE_PARAM:
return
file
(
args
,
info
.
currentDirectory
,
info
.
res
);
else
if
(
type
==
YOUTUBE
)
return
youTube
(
args
,
info
.
context
,
info
.
res
);
return
youTube
(
args
,
info
.
context
,
info
.
res
);
case
FILE_PARAM:
return
null
;
return
file
(
args
,
info
.
currentDirectory
,
info
.
res
);
case
GOOGLE_PARAM:
return
google
(
args
,
info
.
context
,
info
.
res
);
case
URL_PARAM:
return
url
(
args
.
get
(
0
),
info
.
context
,
info
.
res
);
default
:
return
info
.
res
.
getString
(
R
.
string
.
output_invalid_param
);
}
}
}
private
String
google
(
List
<
String
>
args
,
Context
c
,
Resources
res
)
{
private
String
google
(
List
<
String
>
args
,
Context
c
,
Resources
res
)
{
...
@@ -88,6 +83,18 @@ public class search implements CommandAbstraction {
...
@@ -88,6 +83,18 @@ public class search implements CommandAbstraction {
return
res
.
getString
(
R
.
string
.
output_searchingplaystore
)
+
" "
+
flat
(
args
);
return
res
.
getString
(
R
.
string
.
output_searchingplaystore
)
+
" "
+
flat
(
args
);
}
}
private
String
url
(
String
url
,
Context
c
,
Resources
res
)
{
if
(!
url
.
startsWith
(
"http://"
)
&&
!
url
.
startsWith
(
"https://"
))
{
url
=
"http://"
+
url
;
}
Uri
uri
=
Uri
.
parse
(
url
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
);
c
.
startActivity
(
intent
);
return
res
.
getString
(
R
.
string
.
output_search_url
)
+
Tuils
.
SPACE
+
url
;
}
private
String
file
(
List
<
String
>
args
,
File
cd
,
Resources
res
)
{
private
String
file
(
List
<
String
>
args
,
File
cd
,
Resources
res
)
{
String
header
=
res
.
getString
(
R
.
string
.
output_search_file
)
+
Tuils
.
SPACE
+
cd
.
getAbsolutePath
();
String
header
=
res
.
getString
(
R
.
string
.
output_search_file
)
+
Tuils
.
SPACE
+
cd
.
getAbsolutePath
();
...
@@ -173,7 +180,8 @@ public class search implements CommandAbstraction {
...
@@ -173,7 +180,8 @@ public class search implements CommandAbstraction {
PLAYSTORE_PARAM
,
PLAYSTORE_PARAM
,
FILE_PARAM
,
FILE_PARAM
,
GOOGLE_PARAM
,
GOOGLE_PARAM
,
YOUTUBE_PARAM
YOUTUBE_PARAM
,
URL_PARAM
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment