First commit
13
.gitignore
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
4
.idea/encodings.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||||
|
</project>
|
15
.idea/gradle.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||||
|
</compositeConfiguration>
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
86
.idea/markdown-navigator.xml
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MarkdownProjectSettings" wasCopied="false">
|
||||||
|
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
||||||
|
<PanelProvider>
|
||||||
|
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
||||||
|
</PanelProvider>
|
||||||
|
</PreviewSettings>
|
||||||
|
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
|
||||||
|
<PegdownExtensions>
|
||||||
|
<option name="ABBREVIATIONS" value="false" />
|
||||||
|
<option name="ANCHORLINKS" value="true" />
|
||||||
|
<option name="ASIDE" value="false" />
|
||||||
|
<option name="ATXHEADERSPACE" value="true" />
|
||||||
|
<option name="AUTOLINKS" value="false" />
|
||||||
|
<option name="DEFINITIONS" value="false" />
|
||||||
|
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
||||||
|
<option name="FENCED_CODE_BLOCKS" value="true" />
|
||||||
|
<option name="FOOTNOTES" value="false" />
|
||||||
|
<option name="HARDWRAPS" value="false" />
|
||||||
|
<option name="HTML_DEEP_PARSER" value="false" />
|
||||||
|
<option name="INSERTED" value="false" />
|
||||||
|
<option name="QUOTES" value="false" />
|
||||||
|
<option name="RELAXEDHRULES" value="true" />
|
||||||
|
<option name="SMARTS" value="false" />
|
||||||
|
<option name="STRIKETHROUGH" value="true" />
|
||||||
|
<option name="SUBSCRIPT" value="false" />
|
||||||
|
<option name="SUPERSCRIPT" value="false" />
|
||||||
|
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
||||||
|
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
||||||
|
<option name="TABLES" value="true" />
|
||||||
|
<option name="TASKLISTITEMS" value="true" />
|
||||||
|
<option name="TOC" value="false" />
|
||||||
|
<option name="WIKILINKS" value="false" />
|
||||||
|
</PegdownExtensions>
|
||||||
|
<ParserOptions>
|
||||||
|
<option name="ADMONITION_EXT" value="false" />
|
||||||
|
<option name="ATTRIBUTES_EXT" value="false" />
|
||||||
|
<option name="COMMONMARK_LISTS" value="true" />
|
||||||
|
<option name="DUMMY" value="false" />
|
||||||
|
<option name="EMOJI_SHORTCUTS" value="true" />
|
||||||
|
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
||||||
|
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
||||||
|
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
||||||
|
<option name="GFM_TABLE_RENDERING" value="true" />
|
||||||
|
<option name="GITBOOK_URL_ENCODING" value="false" />
|
||||||
|
<option name="GITHUB_LISTS" value="false" />
|
||||||
|
<option name="GITHUB_WIKI_LINKS" value="false" />
|
||||||
|
<option name="GITLAB_EXT" value="false" />
|
||||||
|
<option name="GITLAB_MATH_EXT" value="false" />
|
||||||
|
<option name="GITLAB_MERMAID_EXT" value="false" />
|
||||||
|
<option name="HEADER_ID_NON_ASCII_TO_LOWERCASE" value="false" />
|
||||||
|
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
||||||
|
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
||||||
|
<option name="MACROS_EXT" value="false" />
|
||||||
|
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
||||||
|
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
||||||
|
<option name="PLANTUML_FENCED_CODE" value="false" />
|
||||||
|
<option name="PUML_FENCED_CODE" value="false" />
|
||||||
|
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
||||||
|
</ParserOptions>
|
||||||
|
</ParserSettings>
|
||||||
|
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0" mathConversion="0">
|
||||||
|
<GeneratorProvider>
|
||||||
|
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
||||||
|
</GeneratorProvider>
|
||||||
|
<headerTop />
|
||||||
|
<headerBottom />
|
||||||
|
<bodyTop />
|
||||||
|
<bodyBottom />
|
||||||
|
</HtmlSettings>
|
||||||
|
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
|
||||||
|
<StylesheetProvider>
|
||||||
|
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
||||||
|
</StylesheetProvider>
|
||||||
|
<ScriptProviders />
|
||||||
|
<cssText />
|
||||||
|
<cssUriHistory />
|
||||||
|
</CssSettings>
|
||||||
|
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
|
||||||
|
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
||||||
|
<LinkMapSettings>
|
||||||
|
<textMaps />
|
||||||
|
</LinkMapSettings>
|
||||||
|
</component>
|
||||||
|
</project>
|
3
.idea/markdown-navigator/profiles_settings.xml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<component name="MarkdownNavigator.ProfileManager">
|
||||||
|
<settings default="" pdf-export="" plain-text-search-scope="Project Files" />
|
||||||
|
</component>
|
9
.idea/misc.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
674
LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
{one line to give the program's name and a brief idea of what it does.}
|
||||||
|
Copyright (C) {year} {name of author}
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
{project} Copyright (C) {year} {fullname}
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
68
README.md
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# NS-USBloader mobile
|
||||||
|
|
||||||
|
![License](https://img.shields.io/badge/License-GPLv3-blue.svg) [![Releases](https://img.shields.io/github/downloads/developersu/ns-usbloader-mobile/total.svg)]() [![LatestVer](https://img.shields.io/github/release/developersu/ns-usbloader-mobile.svg)]()
|
||||||
|
|
||||||
|
NS-USBloader mobile is Android implementation of the [original NS-USBloader](https://github.com/developersu/ns-usbloader).
|
||||||
|
|
||||||
|
Sometimes I add new posts about this project [on my home page](https://developersu.blogspot.com/search/label/NS-USBloader).
|
||||||
|
|
||||||
|
![Screenshot](https://live.staticflickr.com/65535/48244373567_d447630001_o.png)
|
||||||
|
|
||||||
|
#### License
|
||||||
|
|
||||||
|
Source code license [GNU General Public License v3](https://github.com/developersu/ns-usbloader-mobile/blob/master/LICENSE)
|
||||||
|
|
||||||
|
Logo font: [Play](https://fonts.google.com/specimen/Play) by Jonas Hecksher. Open Font License distribution.
|
||||||
|
|
||||||
|
|
||||||
|
### System requirements
|
||||||
|
|
||||||
|
* Minimum: Android 4.0 (Ice Cream Sandwich)
|
||||||
|
|
||||||
|
* Maximum: Android 9.0 (Q)
|
||||||
|
|
||||||
|
* USB-OTG support
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
1. Open TinFoil/GoldLeaf
|
||||||
|
2. Connect NS to Android device using OTG cable.
|
||||||
|
3. Allow interaction request. Application opens.
|
||||||
|
4. Click 'hamburger' menu-button and select application you'd like to use.
|
||||||
|
5. Select NSP on your device. One-by-one each time clicking on button (I know it's not perfect)
|
||||||
|
6. Click upload button.
|
||||||
|
|
||||||
|
Note: use short usb cable.
|
||||||
|
|
||||||
|
#### Bugs
|
||||||
|
|
||||||
|
If you're Samsung owner, it would be better to not rotating your phone during transfer. Or minimizing. Well, on my elder device it causes application failure. But you can try if you're curious, and report/update a bug. Please mention your device model.
|
||||||
|
|
||||||
|
### Other notes
|
||||||
|
|
||||||
|
'Status' = 'Uploaded' that appears in the table does not mean that file has been installed. It means that it has been sent to NS without any issues! That's what this app about.
|
||||||
|
Handling successful/failed installation is a purpose of the other side application: TinFoil/GoldLeaf. And they don't provide any feedback interfaces so I can't detect success/failure.
|
||||||
|
|
||||||
|
#### Translators!
|
||||||
|
|
||||||
|
Wait a bit.
|
||||||
|
|
||||||
|
#### TODO:
|
||||||
|
|
||||||
|
- [ ] Tinfoil NET transfer support
|
||||||
|
- [ ] Better UI
|
||||||
|
- [ ] Multi-select files (if possible)
|
||||||
|
|
||||||
|
|
||||||
|
#### Support this app
|
||||||
|
|
||||||
|
If you like this app, just give a star.
|
||||||
|
|
||||||
|
If you want to make a donation*, refer to this page:
|
||||||
|
|
||||||
|
[Yandex.Money](https://money.yandex.ru/to/410014301951665)
|
||||||
|
|
||||||
|
PayPal: To-be-done. One day. Thank you if you reading till this moment.
|
||||||
|
|
||||||
|
* [EN] Please note! This is non-commercial application. Any received money considered as a gift.
|
||||||
|
* [RU] Пожалуйста обратите внимание! Это некоммерческое приложение. Перечисленные средства расцениваются как подарок.
|
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
37
app/build.gradle
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.0"
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.blogspot.developersu.ns_usbloader"
|
||||||
|
minSdkVersion 15
|
||||||
|
targetSdkVersion 29
|
||||||
|
versionCode 1
|
||||||
|
versionName "0.1"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
android.defaultConfig.vectorDrawables.useSupportLibrary = true
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = '1.8'
|
||||||
|
targetCompatibility = '1.8'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||||
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
|
}
|
21
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.InstrumentationRegistry;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||||
|
|
||||||
|
assertEquals("com.blogspot.developersu.ns_usbloader", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
80
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.blogspot.developersu.ns_usbloader">
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.usb.host" />
|
||||||
|
|
||||||
|
<uses-permission android:name="com.blogspot.developersu.ns_usbloader.ACTION_USB_PERMISSION" /> <!-- TODO: REMOVE -->
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<activity
|
||||||
|
android:name=".AboutActivity"
|
||||||
|
android:label="@string/title_activity_about"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<!-- TODO: ADD CUSTOM INTENTS WE USE -->
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
|
||||||
|
android:resource="@xml/device_filter" />
|
||||||
|
<meta-data
|
||||||
|
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
|
||||||
|
android:resource="@xml/device_filter" />
|
||||||
|
<!--
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<action android:name="android.intent.action.EDIT" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data
|
||||||
|
android:mimeType="application/octet-stream"
|
||||||
|
android:host="*"
|
||||||
|
android:pathPattern=".*\\.nsp"
|
||||||
|
/>
|
||||||
|
</intent-filter>
|
||||||
|
-->
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".NsBroadcastReceiver"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
|
||||||
|
<action android:name="com.blogspot.developersu.ns_usbloader.SERVICE_TRANSFER_TASK_FINISHED" />
|
||||||
|
<!--
|
||||||
|
<action android:name="com.blogspot.developersu.ns_usbloader.ACTION_USB_PERMISSION" />
|
||||||
|
<action android:name="com.blogspot.developersu.ns_usbloader.RISE_NOTIFICATION_OR_ACTIVITY" /> to handle if not handled by internally-registered receiver of MainActivity
|
||||||
|
-->
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
|
||||||
|
android:resource="@xml/device_filter" />
|
||||||
|
<meta-data
|
||||||
|
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
|
||||||
|
android:resource="@xml/device_filter" />
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
<service android:name=".Service.CommunicationsService" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
BIN
app/src/main/ic_launcher-web.png
Normal file
After Width: | Height: | Size: 20 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
|
||||||
|
public class AboutActivity extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item){
|
||||||
|
if (item.getItemId() == android.R.id.home)
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_about);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
TextView t1 = (TextView) findViewById(R.id.textView1);
|
||||||
|
t1.append(" v."+BuildConfig.VERSION_NAME);
|
||||||
|
TextView t2 = (TextView) findViewById(R.id.textView2);
|
||||||
|
t2.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
TextView t4 = (TextView) findViewById(R.id.textView4);
|
||||||
|
t4.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
|
||||||
|
public class LoperHelpers {
|
||||||
|
|
||||||
|
public static String getFileNameFromUri(Uri item, Context context){
|
||||||
|
|
||||||
|
String result = null;
|
||||||
|
|
||||||
|
Cursor cursor = context.getContentResolver().query(item, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
result = cursor.getString(
|
||||||
|
cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
||||||
|
);
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFileSizeFromUri(Uri item, Context context){
|
||||||
|
long result = -1;
|
||||||
|
Cursor cursor = context.getContentResolver().query(item, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
result = cursor.getLong(
|
||||||
|
cursor.getColumnIndex(OpenableColumns.SIZE)
|
||||||
|
);
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,535 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.view.GravityCompat;
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.hardware.usb.UsbDevice;
|
||||||
|
import android.hardware.usb.UsbManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.blogspot.developersu.ns_usbloader.Model.NsResultReciever;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.Service.CommunicationsService;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.View.NSPElement;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.View.NspItemsAdapter;
|
||||||
|
import com.google.android.material.navigation.NavigationView;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
// TODO: add ImageAsset for notification icon instead of SVG-like
|
||||||
|
// TODO NOTE: If service execution has been finished in background, then no UI updates will come
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity implements NsResultReciever.Receiver,
|
||||||
|
NavigationView.OnNavigationItemSelectedListener { //TODO: FIX?
|
||||||
|
|
||||||
|
private static final int ADD_NSP_INTENT_CODE = 1;
|
||||||
|
|
||||||
|
private RecyclerView recyclerView;
|
||||||
|
private NspItemsAdapter mAdapter;
|
||||||
|
private ArrayList<NSPElement> mDataset;
|
||||||
|
|
||||||
|
private BroadcastReceiver innerBroadcastReceiver;
|
||||||
|
|
||||||
|
private UsbDevice usbDevice;
|
||||||
|
private boolean isUsbDeviceAccessible;
|
||||||
|
|
||||||
|
private Button selectBtn;
|
||||||
|
private Button uploadToNsBtn;
|
||||||
|
private ProgressBar progressBarMain;
|
||||||
|
|
||||||
|
private NavigationView drawerNavView;
|
||||||
|
|
||||||
|
private NsResultReciever nsResultReciever;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelableArrayList("DATASET_LIST", mDataset);
|
||||||
|
outState.putParcelable("USB_DEVICE", usbDevice);
|
||||||
|
outState.putBoolean("IS_USB_DEV_ACCESSIBLE", isUsbDeviceAccessible);
|
||||||
|
if (drawerNavView.getCheckedItem() != null)
|
||||||
|
outState.putInt("PROTOCOL", drawerNavView.getCheckedItem().getItemId());
|
||||||
|
else
|
||||||
|
outState.putInt("PROTOCOL", R.id.nav_tf_usb);
|
||||||
|
outState.putParcelable("RECEIVER", nsResultReciever);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// Configure intent to receive attached NS
|
||||||
|
innerBroadcastReceiver = new InnerBroadcastReceiver();
|
||||||
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
|
intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
|
||||||
|
intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
|
||||||
|
intentFilter.addAction(NsConstants.REQUEST_NS_ACCESS_INTENT);
|
||||||
|
intentFilter.addAction(NsConstants.SERVICE_TRANSFER_TASK_FINISHED_INTENT);
|
||||||
|
registerReceiver(innerBroadcastReceiver, intentFilter);
|
||||||
|
nsResultReciever.setReceiver(this);
|
||||||
|
blockUI(CommunicationsService.isServiceActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
unregisterReceiver(innerBroadcastReceiver);
|
||||||
|
SharedPreferences.Editor preferencesEditor = getSharedPreferences("NSUSBloader", MODE_PRIVATE).edit();
|
||||||
|
if (drawerNavView.getCheckedItem() != null){
|
||||||
|
switch (drawerNavView.getCheckedItem().getItemId()){
|
||||||
|
case R.id.nav_tf_usb:
|
||||||
|
preferencesEditor.putInt("PROTOCOL", NsConstants.PROTO_TF_USB);
|
||||||
|
break;
|
||||||
|
case R.id.nav_tf_net:
|
||||||
|
preferencesEditor.putInt("PROTOCOL", NsConstants.PROTO_TF_NET);
|
||||||
|
break;
|
||||||
|
case R.id.nav_gl:
|
||||||
|
preferencesEditor.putInt("PROTOCOL", NsConstants.PROTO_GL_USB);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
preferencesEditor.putInt("PROTOCOL", NsConstants.PROTO_TF_USB);
|
||||||
|
preferencesEditor.apply();
|
||||||
|
nsResultReciever.setReceiver(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_main_toolbar, menu);
|
||||||
|
MenuItem selectAllBtn = menu.findItem(R.id.select_all);
|
||||||
|
selectAllBtn.setOnMenuItemClickListener(menuItem -> {
|
||||||
|
if (drawerNavView.getCheckedItem() != null) {
|
||||||
|
if (drawerNavView.getCheckedItem().getItemId() == R.id.nav_gl)
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.one_item_for_gl_notification), Snackbar.LENGTH_LONG).show();
|
||||||
|
else {
|
||||||
|
if (mDataset.isEmpty())
|
||||||
|
return true;
|
||||||
|
for (NSPElement element: mDataset){
|
||||||
|
element.setSelected(true);
|
||||||
|
}
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
// Handle back button push when drawer opened
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
|
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Drawer actions
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationItemSelected(MenuItem item) {
|
||||||
|
// Handle navigation view item clicks here.
|
||||||
|
int id = item.getItemId();
|
||||||
|
|
||||||
|
if (id == R.id.nav_tf_usb) {
|
||||||
|
// TODO: make something useful
|
||||||
|
}
|
||||||
|
else if (id == R.id.nav_tf_net) {
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
else if (id == R.id.nav_gl) { // TODO: SET LISTENER
|
||||||
|
if (! mDataset.isEmpty()){
|
||||||
|
for (NSPElement element: mDataset){
|
||||||
|
element.setSelected(false);
|
||||||
|
}
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (id == R.id.nav_about) {
|
||||||
|
//Log.i("LPR", "ABOUT");
|
||||||
|
startActivity(new Intent(this, AboutActivity.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
// Initialize ToolBar
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
|
drawerNavView = findViewById(R.id.nav_view);
|
||||||
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
|
drawer.addDrawerListener(toggle);
|
||||||
|
toggle.syncState();
|
||||||
|
drawerNavView.setNavigationItemSelectedListener(this);
|
||||||
|
|
||||||
|
// Initialize Progress Bar
|
||||||
|
progressBarMain = findViewById(R.id.mainProgressBar);
|
||||||
|
// Configure data set in case it's restored from screen rotation or something
|
||||||
|
if (savedInstanceState != null){
|
||||||
|
//Log.i("LPR", "NOT EMPTY INSTANCE-"+getIntent().getAction());
|
||||||
|
mDataset = savedInstanceState.getParcelableArrayList("DATASET_LIST");
|
||||||
|
// Restore USB device information
|
||||||
|
usbDevice = savedInstanceState.getParcelable("USB_DEVICE");
|
||||||
|
isUsbDeviceAccessible = savedInstanceState.getBoolean("IS_USB_DEV_ACCESSIBLE", false);
|
||||||
|
drawerNavView.setCheckedItem(savedInstanceState.getInt("PROTOCOL", R.id.nav_tf_usb));
|
||||||
|
nsResultReciever = savedInstanceState.getParcelable("RECEIVER");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mDataset = new ArrayList<>();
|
||||||
|
usbDevice = getIntent().getParcelableExtra(UsbManager.EXTRA_DEVICE); // If it's started initially, then check if it's started from notification.
|
||||||
|
if (usbDevice != null){
|
||||||
|
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
|
// If somehow we can't get system service
|
||||||
|
if (usbManager == null) {
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), "Internal issue: getSystemService(Context.USB_SERVICE) returned null");
|
||||||
|
return; // ??? HOW ???
|
||||||
|
}
|
||||||
|
isUsbDeviceAccessible = usbManager.hasPermission(usbDevice);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isUsbDeviceAccessible = false;
|
||||||
|
switch (getSharedPreferences("NSUSBloader", MODE_PRIVATE).getInt("PROTOCOL", NsConstants.PROTO_TF_USB)){
|
||||||
|
case NsConstants.PROTO_TF_USB:
|
||||||
|
drawerNavView.setCheckedItem(R.id.nav_tf_usb);
|
||||||
|
break;
|
||||||
|
case NsConstants.PROTO_TF_NET:
|
||||||
|
drawerNavView.setCheckedItem(R.id.nav_tf_net);
|
||||||
|
break;
|
||||||
|
case NsConstants.PROTO_GL_USB:
|
||||||
|
drawerNavView.setCheckedItem(R.id.nav_gl);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
nsResultReciever = new NsResultReciever(new Handler()); // We will set callback in onResume and unset onPause
|
||||||
|
}
|
||||||
|
|
||||||
|
recyclerView = findViewById(R.id.recyclerView);
|
||||||
|
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
mAdapter = new NspItemsAdapter(mDataset);
|
||||||
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
ItemTouchHelper.Callback ithCallBack = new ItemTouchHelper.Callback() {
|
||||||
|
@Override
|
||||||
|
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||||
|
return makeMovementFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||||
|
mAdapter.move(viewHolder.getAdapterPosition(), target.getAdapterPosition());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||||
|
NspItemsAdapter.NspViewHolder nspViewHolder = (NspItemsAdapter.NspViewHolder) viewHolder;
|
||||||
|
mDataset.remove(nspViewHolder.getData());
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
updateUploadBtnState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(ithCallBack);
|
||||||
|
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||||
|
// Select files button
|
||||||
|
selectBtn = findViewById(R.id.buttonSelect);
|
||||||
|
selectBtn.setOnClickListener(e->{
|
||||||
|
Intent fileChooser = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
//fileChooser.setType("*/*");
|
||||||
|
fileChooser.setType("application/octet-stream");
|
||||||
|
|
||||||
|
if (fileChooser.resolveActivity(getPackageManager()) != null)
|
||||||
|
startActivityForResult(
|
||||||
|
Intent.createChooser(fileChooser, getString(R.string.select_file_btn))
|
||||||
|
, ADD_NSP_INTENT_CODE);
|
||||||
|
else
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), getResources().getString(R.string.install_file_explorer));
|
||||||
|
});
|
||||||
|
// Upload to NS button
|
||||||
|
uploadToNsBtn = findViewById(R.id.buttonUpload);
|
||||||
|
|
||||||
|
updateUploadBtnState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUploadBtnState(){
|
||||||
|
if (mAdapter.getItemCount() > 0)
|
||||||
|
uploadToNsBtn.setEnabled(true);
|
||||||
|
else
|
||||||
|
uploadToNsBtn.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
//Snackbar.make(findViewById(android.R.id.content), requestCode+" "+resultCode, Snackbar.LENGTH_SHORT).show();
|
||||||
|
if (requestCode != ADD_NSP_INTENT_CODE || data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Uri uri = data.getData();
|
||||||
|
|
||||||
|
if (uri == null)
|
||||||
|
return;
|
||||||
|
if (uri.getScheme() == null || ! uri.getScheme().equals("content"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String fileName = LoperHelpers.getFileNameFromUri(uri, this);
|
||||||
|
long fileSize = LoperHelpers.getFileSizeFromUri(uri, this);
|
||||||
|
|
||||||
|
if (fileName == null || fileSize < 0) {
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), getResources().getString(R.string.popup_not_supported));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! fileName.endsWith(".nsp")){
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), getResources().getString(R.string.popup_wrong_file));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean shouldBeAdded = true;
|
||||||
|
for (NSPElement element: mDataset){
|
||||||
|
if (element.getFilename().equals(fileName)) {
|
||||||
|
shouldBeAdded = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSPElement element;
|
||||||
|
if (shouldBeAdded){
|
||||||
|
element = new NSPElement(uri, fileName, fileSize);
|
||||||
|
if (drawerNavView.getCheckedItem() != null && drawerNavView.getCheckedItem().getItemId() != R.id.nav_gl)
|
||||||
|
element.setSelected(true);
|
||||||
|
mDataset.add(element);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
// Enable upload button
|
||||||
|
updateUploadBtnState();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
private void uploadFilesTemp(){
|
||||||
|
ArrayList<NSPElement> toSentArray = new ArrayList<>();
|
||||||
|
for (NSPElement element: mDataset){
|
||||||
|
if (element.isSelected())
|
||||||
|
toSentArray.add(element);
|
||||||
|
}
|
||||||
|
if (toSentArray.isEmpty()) {
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.nothing_selected_message), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent serviceStartIntent = new Intent(this, CommunicationsService.class);
|
||||||
|
serviceStartIntent.putExtra(NsConstants.NS_RESULT_RECEIVER, nsResultReciever);
|
||||||
|
serviceStartIntent.putParcelableArrayListExtra(NsConstants.SERVICE_CONTENT_NSP_LIST, toSentArray);
|
||||||
|
if (drawerNavView.getCheckedItem() == null) {
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.no_protocol_selected_message), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (drawerNavView.getCheckedItem().getItemId()){
|
||||||
|
case R.id.nav_tf_usb:
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_TF_USB);
|
||||||
|
break;
|
||||||
|
case R.id.nav_tf_net:
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_TF_NET);
|
||||||
|
break;
|
||||||
|
case R.id.nav_gl:
|
||||||
|
if (toSentArray.size() > 1){
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.one_item_for_gl_notification), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_GL_USB);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
startService(serviceStartIntent);
|
||||||
|
blockUI(true);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
private void uploadFiles(){
|
||||||
|
//**************************************************************************************************************************************
|
||||||
|
try{
|
||||||
|
int id = drawerNavView.getCheckedItem().getItemId();
|
||||||
|
if (id == R.id.nav_tf_net) {
|
||||||
|
Toast.makeText(getApplicationContext(), "Not supported yet", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NullPointerException npe){
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.no_protocol_selected_message), Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
//**************************************************************************************************************************************
|
||||||
|
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
|
// If somehow we can't get system service
|
||||||
|
if (usbManager == null) {
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), "Internal issue: getSystemService(Context.USB_SERVICE) returned null");
|
||||||
|
return; // ??? HOW ???
|
||||||
|
}
|
||||||
|
// If device not connected
|
||||||
|
if (usbDevice == null){
|
||||||
|
HashMap<String, UsbDevice> deviceHashMap;
|
||||||
|
|
||||||
|
deviceHashMap = usbManager.getDeviceList();
|
||||||
|
|
||||||
|
for (UsbDevice device : deviceHashMap.values()) {
|
||||||
|
if (device.getVendorId() == 1406 && device.getProductId() == 12288) {
|
||||||
|
usbDevice = device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If it's still not connected then it's really not connected.
|
||||||
|
if (usbDevice == null) {
|
||||||
|
NsNotificationPopUp.getAlertWindow(this, getResources().getString(R.string.popup_error), getResources().getString(R.string.ns_not_found_in_connected));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If we have NS connected check for permissions
|
||||||
|
if (! usbManager.hasPermission(usbDevice)){
|
||||||
|
usbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(this, 0, new Intent(NsConstants.REQUEST_NS_ACCESS_INTENT), 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! isUsbDeviceAccessible){
|
||||||
|
usbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(this, 0, new Intent(NsConstants.REQUEST_NS_ACCESS_INTENT), 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent serviceStartIntent;
|
||||||
|
ArrayList<NSPElement> toSentArray = new ArrayList<>();
|
||||||
|
for (NSPElement element: mDataset){
|
||||||
|
if (element.isSelected())
|
||||||
|
toSentArray.add(element);
|
||||||
|
}
|
||||||
|
if (toSentArray.isEmpty()) {
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.nothing_selected_message), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serviceStartIntent = new Intent(this, CommunicationsService.class);
|
||||||
|
serviceStartIntent.putExtra(NsConstants.NS_RESULT_RECEIVER, nsResultReciever);
|
||||||
|
serviceStartIntent.putParcelableArrayListExtra(NsConstants.SERVICE_CONTENT_NSP_LIST, toSentArray);
|
||||||
|
if (drawerNavView.getCheckedItem() == null) {
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.no_protocol_selected_message), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (drawerNavView.getCheckedItem().getItemId()){
|
||||||
|
case R.id.nav_tf_usb:
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_TF_USB);
|
||||||
|
break;
|
||||||
|
case R.id.nav_tf_net:
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_TF_NET);
|
||||||
|
break;
|
||||||
|
case R.id.nav_gl:
|
||||||
|
if (toSentArray.size() > 1){
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.one_item_for_gl_notification), Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, NsConstants.PROTO_GL_USB);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
serviceStartIntent.putExtra(NsConstants.SERVICE_CONTENT_NS_DEVICE, usbDevice);
|
||||||
|
startService(serviceStartIntent);
|
||||||
|
blockUI(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void blockUI(boolean shouldBeBlocked){
|
||||||
|
if (shouldBeBlocked){
|
||||||
|
selectBtn.setEnabled(false);
|
||||||
|
recyclerView.setLayoutFrozen(true);
|
||||||
|
uploadToNsBtn.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.ic_cancel), null, null);
|
||||||
|
uploadToNsBtn.setText(R.string.interrupt_btn);
|
||||||
|
uploadToNsBtn.setOnClickListener(e -> {
|
||||||
|
CommunicationsService.cancel();
|
||||||
|
});
|
||||||
|
progressBarMain.setVisibility(ProgressBar.VISIBLE);
|
||||||
|
progressBarMain.setIndeterminate(true);//TODO
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selectBtn.setEnabled(true);
|
||||||
|
recyclerView.setLayoutFrozen(false);
|
||||||
|
uploadToNsBtn.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.ic_upload_btn), null, null);
|
||||||
|
uploadToNsBtn.setText(R.string.upload_btn);
|
||||||
|
uploadToNsBtn.setOnClickListener(e -> {
|
||||||
|
//this.uploadFiles();
|
||||||
|
this.uploadFiles();
|
||||||
|
});
|
||||||
|
progressBarMain.setVisibility(ProgressBar.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle service updates
|
||||||
|
@Override
|
||||||
|
public void onRecieveResults(int code, Bundle bundle) {
|
||||||
|
if (code == NsConstants.NS_RESULT_PROGRESS_INDETERMINATE)
|
||||||
|
progressBarMain.setIndeterminate(true);
|
||||||
|
else{ // Else NsConstants.NS_RESULT_PROGRESS_VALUE ; ALSO THIS PART IS FULL OF SHIT
|
||||||
|
if (progressBarMain.isIndeterminate())
|
||||||
|
progressBarMain.setIndeterminate(false);
|
||||||
|
progressBarMain.setProgress(bundle.getInt("POSITION"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Deal with global broadcast intents
|
||||||
|
private class InnerBroadcastReceiver extends BroadcastReceiver{
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction() == null)
|
||||||
|
return;
|
||||||
|
switch (intent.getAction()) {
|
||||||
|
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
|
||||||
|
usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||||
|
UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
|
||||||
|
if (usbManager == null)
|
||||||
|
break; // ???
|
||||||
|
if (usbManager.hasPermission(usbDevice))
|
||||||
|
isUsbDeviceAccessible = true;
|
||||||
|
else {
|
||||||
|
isUsbDeviceAccessible = false;
|
||||||
|
usbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(context, 0, new Intent(NsConstants.REQUEST_NS_ACCESS_INTENT), 0));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NsConstants.REQUEST_NS_ACCESS_INTENT:
|
||||||
|
isUsbDeviceAccessible = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
|
||||||
|
break;
|
||||||
|
case UsbManager.ACTION_USB_DEVICE_DETACHED:
|
||||||
|
usbDevice = null;
|
||||||
|
isUsbDeviceAccessible = false;
|
||||||
|
CommunicationsService.cancel();
|
||||||
|
break;
|
||||||
|
case NsConstants.SERVICE_TRANSFER_TASK_FINISHED_INTENT:
|
||||||
|
ArrayList<NSPElement> nspElements = intent.getParcelableArrayListExtra(NsConstants.SERVICE_CONTENT_NSP_LIST);
|
||||||
|
for (int i=0; i < mDataset.size(); i++){
|
||||||
|
for (NSPElement recievedNSPe : nspElements)
|
||||||
|
if (recievedNSPe.getFilename().equals(mDataset.get(i).getFilename()))
|
||||||
|
mDataset.get(i).setStatus(recievedNSPe.getStatus());
|
||||||
|
}
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
blockUI(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//Log.i("LPR", "INTERNAL BR REC: " + intent.getAction()+" "+isUsbDeviceAccessible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.Model;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
|
|
||||||
|
public class NsResultReciever extends ResultReceiver {
|
||||||
|
|
||||||
|
public interface Receiver{
|
||||||
|
void onRecieveResults(int code, Bundle bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Receiver mReceiver;
|
||||||
|
|
||||||
|
public NsResultReciever(Handler handler) {
|
||||||
|
super(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceiver(Receiver receiver){
|
||||||
|
this.mReceiver = receiver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onReceiveResult(int resultCode, Bundle resultData) {
|
||||||
|
if (mReceiver != null)
|
||||||
|
mReceiver.onRecieveResults(resultCode, resultData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.hardware.usb.UsbDevice;
|
||||||
|
import android.hardware.usb.UsbManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
|
||||||
|
public class NsBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
private static final String NOTIFICATION_NS_CONNECTED_CHAN_ID = "com.blogspot.developersu.ns_usbloader.CHAN_ID_NS_CONNECTED";
|
||||||
|
private static final int NOTIFICATION_NS_CONNECTED_ID = 42;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction() == null)
|
||||||
|
return;
|
||||||
|
switch (intent.getAction()) {
|
||||||
|
case UsbManager.ACTION_USB_DEVICE_ATTACHED: {
|
||||||
|
showNotification(context, intent.getParcelableExtra(UsbManager.EXTRA_DEVICE));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case UsbManager.ACTION_USB_DEVICE_DETACHED: {
|
||||||
|
hideNotification(context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NsConstants.SERVICE_TRANSFER_TASK_FINISHED_INTENT:
|
||||||
|
String issues = intent.getStringExtra("ISSUES");
|
||||||
|
if (issues != null) {
|
||||||
|
Toast.makeText(context, context.getString(R.string.transfers_service_stopped) + " " + issues, Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Toast.makeText(context, context.getString(R.string.transfers_service_stopped), Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNotification(Context context, UsbDevice usbDevice){
|
||||||
|
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NOTIFICATION_NS_CONNECTED_CHAN_ID);
|
||||||
|
notification.setSmallIcon(R.drawable.ic_notification)
|
||||||
|
.setContentTitle(context.getString(R.string.ns_connected_info))
|
||||||
|
//.setAutoCancel(true)
|
||||||
|
.setOngoing(true) // Prevent swipe-notification-to-remove
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
|
.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class).putExtra(UsbManager.EXTRA_DEVICE, usbDevice), 0));
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
CharSequence notificationChanName = context.getString(R.string.notification_channel_name);
|
||||||
|
String notificationChanDesc = context.getString(R.string.notification_channel_description);
|
||||||
|
|
||||||
|
NotificationChannel channel = new NotificationChannel(
|
||||||
|
NOTIFICATION_NS_CONNECTED_CHAN_ID,
|
||||||
|
notificationChanName,
|
||||||
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
|
channel.setDescription(notificationChanDesc);
|
||||||
|
// Register the channel with the system; you can't change the importance
|
||||||
|
// or other notification behaviors after this
|
||||||
|
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
notificationManager.notify(NOTIFICATION_NS_CONNECTED_ID, notification.build());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NotificationManagerCompat.from(context).notify(NOTIFICATION_NS_CONNECTED_ID, notification.build()); // TODO: 42 is shit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideNotification(Context context){
|
||||||
|
NotificationManagerCompat.from(context).cancel(NOTIFICATION_NS_CONNECTED_ID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
public class NsConstants {
|
||||||
|
public static final String NS_RESULT_RECEIVER = "RECEIVER";
|
||||||
|
// Request permissions to access NS USB device
|
||||||
|
public static final String REQUEST_NS_ACCESS_INTENT = "com.blogspot.developersu.ns_usbloader.ACTION_USB_PERMISSION";
|
||||||
|
// Get in BroadcastReceiver and MainActivity's broadcastReceiver information regarding finished process
|
||||||
|
public static final String SERVICE_TRANSFER_TASK_FINISHED_INTENT = "com.blogspot.developersu.ns_usbloader.SERVICE_TRANSFER_TASK_FINISHED";
|
||||||
|
// To get data inside IntentService
|
||||||
|
public static final String SERVICE_CONTENT_NSP_LIST = "NSP_LIST";
|
||||||
|
public static final String SERVICE_CONTENT_PROTOCOL = "PROTOCOL";
|
||||||
|
public static final String SERVICE_CONTENT_NS_DEVICE = "DEVICE";
|
||||||
|
// Result Reciever possible codes
|
||||||
|
public static final int NS_RESULT_PROGRESS_INDETERMINATE = -1; // upper limit would be 0; value would be 0
|
||||||
|
public static final int NS_RESULT_PROGRESS_VALUE = 0;
|
||||||
|
// Declare TF/GL names
|
||||||
|
public static final int PROTO_TF_USB = 10;
|
||||||
|
public static final int PROTO_TF_NET = 20;
|
||||||
|
public static final int PROTO_GL_USB = 30;
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
|
public class NsNotificationPopUp {
|
||||||
|
public static void getAlertWindow(Context context, String titile, String message){
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle(titile)
|
||||||
|
.setMessage(message)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
dialogInterface.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.PFS;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data class to hold NCA, tik, xml etc. meta-information
|
||||||
|
* */
|
||||||
|
public class NCAFile {
|
||||||
|
//private int ncaNumber;
|
||||||
|
private byte[] ncaFileName;
|
||||||
|
private long ncaOffset;
|
||||||
|
private long ncaSize;
|
||||||
|
|
||||||
|
//public void setNcaNumber(int ncaNumber){ this.ncaNumber = ncaNumber; }
|
||||||
|
public void setNcaFileName(byte[] ncaFileName) { this.ncaFileName = ncaFileName; }
|
||||||
|
public void setNcaOffset(long ncaOffset) { this.ncaOffset = ncaOffset; }
|
||||||
|
public void setNcaSize(long ncaSize) { this.ncaSize = ncaSize; }
|
||||||
|
|
||||||
|
//public int getNcaNumber() {return this.ncaNumber; }
|
||||||
|
public byte[] getNcaFileName() { return ncaFileName; }
|
||||||
|
public byte[] getNcaFileNameLength() { return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(ncaFileName.length).array(); }
|
||||||
|
public long getNcaOffset() { return ncaOffset; }
|
||||||
|
public long getNcaSize() { return ncaSize; }
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.PFS;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in GoldLeaf USB protocol
|
||||||
|
* */
|
||||||
|
public class PFSProvider {
|
||||||
|
private static final byte[] PFS0 = new byte[]{(byte)0x50, (byte)0x46, (byte)0x53, (byte)0x30}; // PFS0, and what did you think?
|
||||||
|
|
||||||
|
private BufferedInputStream bufferedInStream;
|
||||||
|
private String nspFileName;
|
||||||
|
private NCAFile[] ncaFiles;
|
||||||
|
private long bodySize;
|
||||||
|
private int ticketID = -1;
|
||||||
|
|
||||||
|
public PFSProvider(InputStream inputStream, String nspFileName){
|
||||||
|
if (inputStream == null || nspFileName == null)
|
||||||
|
return;
|
||||||
|
this.bufferedInStream = new BufferedInputStream(inputStream); // TODO: refactor?
|
||||||
|
this.nspFileName = nspFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean init() {
|
||||||
|
if (nspFileName == null || bufferedInStream == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int filesCount;
|
||||||
|
int stringTableSize;
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] fileStartingBytes = new byte[12];
|
||||||
|
// Read PFS0, files count, stringTableSize, padding (4 zero bytes)
|
||||||
|
if (bufferedInStream.read(fileStartingBytes) != 12){
|
||||||
|
bufferedInStream.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check PFS0
|
||||||
|
if (! Arrays.equals(PFS0, Arrays.copyOfRange(fileStartingBytes, 0, 4))){
|
||||||
|
bufferedInStream.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get files count
|
||||||
|
filesCount = ByteBuffer.wrap(Arrays.copyOfRange(fileStartingBytes, 4, 8)).order(ByteOrder.LITTLE_ENDIAN).getInt();
|
||||||
|
if (filesCount <= 0 ) {
|
||||||
|
bufferedInStream.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get stringTableSize
|
||||||
|
stringTableSize = ByteBuffer.wrap(Arrays.copyOfRange(fileStartingBytes, 8, 12)).order(ByteOrder.LITTLE_ENDIAN).getInt();
|
||||||
|
if (stringTableSize <= 0 ){
|
||||||
|
bufferedInStream.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//*********************************************************************************************
|
||||||
|
// Create NCA set
|
||||||
|
this.ncaFiles = new NCAFile[filesCount];
|
||||||
|
// Collect files from NSP
|
||||||
|
byte[] ncaInfoArr = new byte[24]; // should be unsigned long, but.. java.. u know my pain man
|
||||||
|
|
||||||
|
HashMap<Integer, Long> ncaNameOffsets = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
long nca_offset;
|
||||||
|
long nca_size;
|
||||||
|
long nca_name_offset;
|
||||||
|
|
||||||
|
for (int i=0; i < filesCount; i++){
|
||||||
|
if (bufferedInStream.read(ncaInfoArr) != 24) {
|
||||||
|
bufferedInStream.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nca_offset = ByteBuffer.wrap(Arrays.copyOfRange(ncaInfoArr, 4, 12)).order(ByteOrder.LITTLE_ENDIAN).getLong();
|
||||||
|
nca_size = ByteBuffer.wrap(Arrays.copyOfRange(ncaInfoArr, 12, 20)).order(ByteOrder.LITTLE_ENDIAN).getLong();
|
||||||
|
nca_name_offset = ByteBuffer.wrap(Arrays.copyOfRange(ncaInfoArr, 20, 24)).order(ByteOrder.LITTLE_ENDIAN).getInt(); // yes, cast from int to long.
|
||||||
|
|
||||||
|
NCAFile ncaFile = new NCAFile();
|
||||||
|
ncaFile.setNcaOffset(nca_offset);
|
||||||
|
ncaFile.setNcaSize(nca_size);
|
||||||
|
this.ncaFiles[i] = ncaFile;
|
||||||
|
|
||||||
|
ncaNameOffsets.put(i, nca_name_offset);
|
||||||
|
}
|
||||||
|
// Final offset
|
||||||
|
byte[] bufForInt = new byte[4];
|
||||||
|
if ((bufferedInStream.read(bufForInt) != 4))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Calculate position including stringTableSize for body size offset
|
||||||
|
//bodySize = bufferedInStream.getFilePointer()+stringTableSize;
|
||||||
|
bodySize = filesCount*24+16+stringTableSize;
|
||||||
|
//*********************************************************************************************
|
||||||
|
bufferedInStream.mark(stringTableSize);
|
||||||
|
// Collect file names from NCAs
|
||||||
|
List<Byte> ncaFN; // Temporary
|
||||||
|
byte[] b = new byte[1]; // Temporary
|
||||||
|
for (int i=0; i < filesCount; i++){
|
||||||
|
ncaFN = new ArrayList<>();
|
||||||
|
if (bufferedInStream.skip(ncaNameOffsets.get(i)) != ncaNameOffsets.get(i)) // Files cont * 24(bit for each meta-data) + 4 bytes goes after all of them + 12 bit what were in the beginning
|
||||||
|
return false;
|
||||||
|
while ((bufferedInStream.read(b)) != -1){
|
||||||
|
if (b[0] == 0x00)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
ncaFN.add(b[0]);
|
||||||
|
}
|
||||||
|
// TODO: CHANGE TO ncaFN.toArray();
|
||||||
|
|
||||||
|
byte[] exchangeTempArray = new byte[ncaFN.size()];
|
||||||
|
for (int j=0; j < ncaFN.size(); j++)
|
||||||
|
exchangeTempArray[j] = ncaFN.get(j);
|
||||||
|
// Find and store ticket (.tik)
|
||||||
|
if (new String(exchangeTempArray, "UTF-8").toLowerCase().endsWith(".tik"))
|
||||||
|
this.ticketID = i;
|
||||||
|
this.ncaFiles[i].setNcaFileName(Arrays.copyOf(exchangeTempArray, exchangeTempArray.length));
|
||||||
|
|
||||||
|
bufferedInStream.reset();
|
||||||
|
}
|
||||||
|
bufferedInStream.close();
|
||||||
|
}
|
||||||
|
catch (IOException ioe){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return file name as byte array
|
||||||
|
* */
|
||||||
|
public byte[] getBytesNspFileName(){
|
||||||
|
return nspFileName.getBytes();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return file name as String
|
||||||
|
* */
|
||||||
|
/* Legacy code; leave for now
|
||||||
|
public String getStringNspFileName(){
|
||||||
|
return nspFileName;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Return file name length as byte array
|
||||||
|
* */
|
||||||
|
public byte[] getBytesNspFileNameLength(){
|
||||||
|
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(getBytesNspFileName().length).array();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return NCA count inside of file as byte array
|
||||||
|
* */
|
||||||
|
public byte[] getBytesCountOfNca(){
|
||||||
|
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(ncaFiles.length).array();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return NCA count inside of file as int
|
||||||
|
* */
|
||||||
|
public int getIntCountOfNca(){
|
||||||
|
return ncaFiles.length;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return requested-by-number NCA file inside of file
|
||||||
|
* */
|
||||||
|
public NCAFile getNca(int ncaNumber){
|
||||||
|
return ncaFiles[ncaNumber];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return bodySize
|
||||||
|
* */
|
||||||
|
public long getBodySize(){
|
||||||
|
return bodySize;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return special NCA file: ticket
|
||||||
|
* (sugar)
|
||||||
|
* */
|
||||||
|
public int getNcaTicketID(){
|
||||||
|
return ticketID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,582 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.Service;
|
||||||
|
|
||||||
|
import android.app.IntentService;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.hardware.usb.UsbDevice;
|
||||||
|
import android.hardware.usb.UsbDeviceConnection;
|
||||||
|
import android.hardware.usb.UsbEndpoint;
|
||||||
|
import android.hardware.usb.UsbInterface;
|
||||||
|
import android.hardware.usb.UsbManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.blogspot.developersu.ns_usbloader.NsConstants;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.PFS.PFSProvider;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.R;
|
||||||
|
import com.blogspot.developersu.ns_usbloader.View.NSPElement;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
public class CommunicationsService extends IntentService {
|
||||||
|
private static final String SERVICE_TAG = "com.blogspot.developersu.ns_usbloader.Service.CommunicationsService";
|
||||||
|
|
||||||
|
private static AtomicBoolean isActive = new AtomicBoolean(false);
|
||||||
|
private static AtomicBoolean interrupt = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
private ResultReceiver resultReceiver;
|
||||||
|
|
||||||
|
public static boolean isServiceActive(){
|
||||||
|
return isActive.get();
|
||||||
|
}
|
||||||
|
public static void cancel(){
|
||||||
|
interrupt.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunicationsService() {
|
||||||
|
super(SERVICE_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<NSPElement> nspElements;
|
||||||
|
private UsbDeviceConnection deviceConnection;
|
||||||
|
private UsbInterface usbInterface;
|
||||||
|
private UsbEndpoint epIn;
|
||||||
|
private UsbEndpoint epOut;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
private String issueDescription;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
isActive.set(true);
|
||||||
|
interrupt.set(false);
|
||||||
|
status = getResources().getString(R.string.status_failed_to_upload);
|
||||||
|
resultReceiver = intent.getParcelableExtra(NsConstants.NS_RESULT_RECEIVER);
|
||||||
|
nspElements = intent.getParcelableArrayListExtra(NsConstants.SERVICE_CONTENT_NSP_LIST);
|
||||||
|
final int protocol = intent.getIntExtra(NsConstants.SERVICE_CONTENT_PROTOCOL, -1); // -1 since it's impossible
|
||||||
|
UsbDevice usbDevice = intent.getParcelableExtra(NsConstants.SERVICE_CONTENT_NS_DEVICE);
|
||||||
|
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
|
if (nspElements == null || usbDevice == null || usbManager == null || protocol < 0) {
|
||||||
|
reportExecutionFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Start process
|
||||||
|
usbInterface = usbDevice.getInterface(0);
|
||||||
|
epIn = usbInterface.getEndpoint(0); // For bulk read
|
||||||
|
epOut = usbInterface.getEndpoint(1); // For bulk write
|
||||||
|
|
||||||
|
deviceConnection = usbManager.openDevice(usbDevice);
|
||||||
|
if ( ! deviceConnection.claimInterface(usbInterface, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (protocol == NsConstants.PROTO_TF_USB){
|
||||||
|
new TinFoil();
|
||||||
|
}
|
||||||
|
else if (protocol == NsConstants.PROTO_GL_USB){
|
||||||
|
new GoldLeaf();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NSPElement e: nspElements)
|
||||||
|
e.setStatus(status);
|
||||||
|
/*
|
||||||
|
Log.i("LPR", "Status " +status);
|
||||||
|
Log.i("LPR", "issue " +issueDescription);
|
||||||
|
Log.i("LPR", "Interrupt " +interrupt.get());
|
||||||
|
Log.i("LPR", "Active " +isActive.get());
|
||||||
|
*/
|
||||||
|
reportExecutionFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetProgressBar(){
|
||||||
|
resultReceiver.send(NsConstants.NS_RESULT_PROGRESS_INDETERMINATE, Bundle.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateProgressBar(int currentPosition){
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("POSITION", currentPosition);
|
||||||
|
resultReceiver.send(NsConstants.NS_RESULT_PROGRESS_VALUE, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportExecutionFinish(){
|
||||||
|
deviceConnection.releaseInterface(usbInterface);
|
||||||
|
deviceConnection.close();
|
||||||
|
isActive.set(false);
|
||||||
|
Intent executionFinishIntent = new Intent(NsConstants.SERVICE_TRANSFER_TASK_FINISHED_INTENT);
|
||||||
|
executionFinishIntent.putExtra(NsConstants.SERVICE_CONTENT_NSP_LIST, nspElements);
|
||||||
|
if (issueDescription != null) {
|
||||||
|
executionFinishIntent.putExtra("ISSUES", issueDescription);
|
||||||
|
}
|
||||||
|
this.sendBroadcast(executionFinishIntent);
|
||||||
|
interrupt.set(false);
|
||||||
|
}
|
||||||
|
/*============================================================================================*/
|
||||||
|
/**
|
||||||
|
* Sending any byte array to USB device
|
||||||
|
* @return 'false' if no issues
|
||||||
|
* 'true' if errors happened
|
||||||
|
* */
|
||||||
|
private boolean writeToUsb(byte[] message){
|
||||||
|
int result;
|
||||||
|
result = deviceConnection.bulkTransfer(epOut, message, message.length, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint OUT = 0x01
|
||||||
|
//Log.i("LPR", "RES: "+result);
|
||||||
|
return (result != message.length);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reading what USB device responded.
|
||||||
|
* @return byte array if data read successful
|
||||||
|
* 'null' if read failed
|
||||||
|
* */
|
||||||
|
private byte[] readFromUsb(){
|
||||||
|
byte[] readBuffer = new byte[512];
|
||||||
|
// We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb.
|
||||||
|
int result;
|
||||||
|
result = deviceConnection.bulkTransfer(epIn, readBuffer, 512, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint IN = 0x81
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
return Arrays.copyOf(readBuffer, result);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/*============================================================================================*/
|
||||||
|
private class TinFoil{
|
||||||
|
TinFoil(){
|
||||||
|
|
||||||
|
if (!sendListOfNSP())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (proceedCommands()) // REPORT SUCCESS
|
||||||
|
status = getResources().getString(R.string.status_uploaded); // Don't change status that is already set to FAILED TODO: FIX
|
||||||
|
}
|
||||||
|
// Send what NSP will be transferred
|
||||||
|
|
||||||
|
private boolean sendListOfNSP(){
|
||||||
|
// Send list of NSP files:
|
||||||
|
// Proceed "TUL0"
|
||||||
|
if (writeToUsb("TUL0".getBytes())) { // new byte[]{(byte) 0x54, (byte) 0x55, (byte) 0x76, (byte) 0x30} //"US-ASCII"?
|
||||||
|
issueDescription = "TF Send list of files: handshake failure";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Collect file names
|
||||||
|
StringBuilder nspListNamesBuilder = new StringBuilder(); // Add every title to one stringBuilder
|
||||||
|
for(NSPElement element: nspElements) {
|
||||||
|
nspListNamesBuilder.append(element.getFilename()); // And here we come with java string default encoding (UTF-16)
|
||||||
|
nspListNamesBuilder.append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] nspListNames = nspListNamesBuilder.toString().getBytes(); // android's .getBytes() default == UTF8
|
||||||
|
ByteBuffer byteBuffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); // integer = 4 bytes; BTW Java is stored in big-endian format
|
||||||
|
byteBuffer.putInt(nspListNames.length); // This way we obtain length in int converted to byte array in correct Big-endian order. Trust me.
|
||||||
|
byte[] nspListSize = byteBuffer.array();
|
||||||
|
|
||||||
|
// Sending NSP list
|
||||||
|
if (writeToUsb(nspListSize)) { // size of the list we're going to transfer goes...
|
||||||
|
issueDescription = "TF Send list of files: [send list length]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(new byte[8])) { // 8 zero bytes goes...
|
||||||
|
issueDescription = "TF Send list of files: [send padding]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(nspListNames)) { // list of the names goes...
|
||||||
|
issueDescription = "TF Send list of files: [send list itself]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// After we sent commands to NS, this chain starts
|
||||||
|
|
||||||
|
private boolean proceedCommands(){
|
||||||
|
final byte[] magic = new byte[]{(byte) 0x54, (byte) 0x55, (byte) 0x43, (byte) 0x30}; // eq. 'TUC0' @ UTF-8 (actually ASCII lol, u know what I mean)
|
||||||
|
|
||||||
|
byte[] receivedArray;
|
||||||
|
|
||||||
|
while (true){
|
||||||
|
if (interrupt.get()) // Check if user interrupted process.
|
||||||
|
return false;
|
||||||
|
receivedArray = readFromUsb();
|
||||||
|
if (receivedArray == null)
|
||||||
|
return false; // catches exception
|
||||||
|
|
||||||
|
if (!Arrays.equals(Arrays.copyOfRange(receivedArray, 0,4), magic)) // Bytes from 0 to 3 should contain 'magic' TUC0, so must be verified like this
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 8th to 12th(explicits) bytes in returned data stands for command ID as unsigned integer (Little-endian). Actually, we have to compare arrays here, but in real world it can't be greater then 0/1/2, thus:
|
||||||
|
// BTW also protocol specifies 4th byte to be 0x00 kinda indicating that that this command is valid. But, as you may see, never happens other situation when it's not = 0.
|
||||||
|
if (receivedArray[8] == 0x00){ //0x00 - exit
|
||||||
|
return true; // All interaction with USB device should be ended (expected);
|
||||||
|
}
|
||||||
|
else if ((receivedArray[8] == 0x01) || (receivedArray[8] == 0x02)){ //0x01 - file range; 0x02 unknown bug on backend side (dirty hack).
|
||||||
|
if (!fileRangeCmd()) // issueDescription inside
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This is what returns requested file (files)
|
||||||
|
* Executes multiple times
|
||||||
|
* @return 'true' if everything is ok
|
||||||
|
* 'false' is error/exception occurs
|
||||||
|
* */
|
||||||
|
|
||||||
|
private boolean fileRangeCmd(){
|
||||||
|
byte[] receivedArray;
|
||||||
|
// Here we take information of what other side wants
|
||||||
|
receivedArray = readFromUsb();
|
||||||
|
if (receivedArray == null) {
|
||||||
|
issueDescription = "TF Unable to get meta information @fileRangeCmd()";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// range_offset of the requested file. In the begining it will be 0x10.
|
||||||
|
long receivedRangeSize = ByteBuffer.wrap(Arrays.copyOfRange(receivedArray, 0,8)).order(ByteOrder.LITTLE_ENDIAN).getLong();
|
||||||
|
byte[] receivedRangeSizeRAW = Arrays.copyOfRange(receivedArray, 0,8);
|
||||||
|
long receivedRangeOffset = ByteBuffer.wrap(Arrays.copyOfRange(receivedArray, 8,16)).order(ByteOrder.LITTLE_ENDIAN).getLong();
|
||||||
|
|
||||||
|
// Requesting UTF-8 file name required:
|
||||||
|
receivedArray = readFromUsb();
|
||||||
|
if (receivedArray == null) {
|
||||||
|
issueDescription = "TF Unable to get file name @fileRangeCmd()";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String receivedRequestedNSP;
|
||||||
|
try {
|
||||||
|
receivedRequestedNSP = new String(receivedArray, "UTF-8"); //TODO:FIX
|
||||||
|
}
|
||||||
|
catch (java.io.UnsupportedEncodingException uee){
|
||||||
|
issueDescription = "TF UnsupportedEncodingException @fileRangeCmd()";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sending response header
|
||||||
|
if (!sendResponse(receivedRangeSizeRAW)) // Get receivedRangeSize in 'RAW' format exactly as it has been received. It's simply.
|
||||||
|
return false; // issueDescription handled by method
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedInputStream bufferedInStream = null;
|
||||||
|
|
||||||
|
for (NSPElement e: nspElements){
|
||||||
|
if (e.getFilename().equals(receivedRequestedNSP)){
|
||||||
|
InputStream elementIS = getContentResolver().openInputStream(e.getUri());
|
||||||
|
if (elementIS == null) {
|
||||||
|
issueDescription = "TF Unable to obtain InputStream";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bufferedInStream = new BufferedInputStream(elementIS); // TODO: refactor?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferedInStream == null) {
|
||||||
|
issueDescription = "TF Unable to create BufferedInputStream";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] readBuf ;//= new byte[1048576]; // eq. Allocate 1mb
|
||||||
|
|
||||||
|
if (bufferedInStream.skip(receivedRangeOffset) != receivedRangeOffset){
|
||||||
|
issueDescription = "TF Requested skip is out of file size. Nothing to transmit.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long readFrom = 0;
|
||||||
|
// 'End Offset' equal to receivedRangeSize.
|
||||||
|
int readPice = 16384; // = 8Mb
|
||||||
|
|
||||||
|
while (readFrom < receivedRangeSize){
|
||||||
|
if (interrupt.get()) // Check if user interrupted process.
|
||||||
|
return true;
|
||||||
|
if ((readFrom + readPice) >= receivedRangeSize )
|
||||||
|
readPice = (int)(receivedRangeSize - readFrom); // TODO: Troubles could raise here
|
||||||
|
|
||||||
|
readBuf = new byte[readPice]; // TODO: not perfect moment, consider refactoring.
|
||||||
|
|
||||||
|
if (bufferedInStream.read(readBuf) != readPice) {
|
||||||
|
issueDescription = "TF Reading of stream suddenly ended";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//write to USB
|
||||||
|
if (writeToUsb(readBuf)) {
|
||||||
|
issueDescription = "TF Failure during NSP transmission.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
readFrom += readPice;
|
||||||
|
|
||||||
|
updateProgressBar((int) ((readFrom+1)/(receivedRangeSize/100+1)));
|
||||||
|
Log.i("LPR", "CO: "+readFrom+"RRS: "+receivedRangeSize+"RES: "+(readFrom+1/(receivedRangeSize/100+1)));
|
||||||
|
}
|
||||||
|
bufferedInStream.close();
|
||||||
|
|
||||||
|
resetProgressBar();
|
||||||
|
} catch (java.io.IOException ioe){
|
||||||
|
issueDescription = "TF IOException: "+ioe.getMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send response header.
|
||||||
|
* @return true if everything OK
|
||||||
|
* false if failed
|
||||||
|
* */
|
||||||
|
private boolean sendResponse(byte[] rangeSize){ // This method as separate function itself for application needed as a cookie in the middle of desert.
|
||||||
|
if (writeToUsb(new byte[] { (byte) 0x54, (byte) 0x55, (byte) 0x43, (byte) 0x30, // 'TUC0'
|
||||||
|
(byte) 0x01, // CMD_TYPE_RESPONSE = 1
|
||||||
|
(byte) 0x00, (byte) 0x00, (byte) 0x00, // kinda padding. Guys, didn't you want to use integer value for CMD semantic?
|
||||||
|
(byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00} ) // Send integer value of '1' in Little-endian format.
|
||||||
|
){
|
||||||
|
issueDescription = "TF Sending response: [1/3]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(writeToUsb(rangeSize)) { // Send EXACTLY what has been received
|
||||||
|
issueDescription = "TF Sending response: [2/3]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(writeToUsb(new byte[12])) { // kinda another one padding
|
||||||
|
issueDescription = "TF Sending response: [3/3] FAIL";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* GoldLeaf processing
|
||||||
|
* */
|
||||||
|
private class GoldLeaf{
|
||||||
|
// CMD G L U C
|
||||||
|
private final byte[] CMD_GLUC = new byte[]{0x47, 0x4c, 0x55, 0x43};
|
||||||
|
private final byte[] CMD_ConnectionRequest = new byte[]{0x00, 0x00, 0x00, 0x00}; // Write-only command
|
||||||
|
private final byte[] CMD_NSPName = new byte[]{0x02, 0x00, 0x00, 0x00}; // Write-only command
|
||||||
|
private final byte[] CMD_NSPData = new byte[]{0x04, 0x00, 0x00, 0x00}; // Write-only command
|
||||||
|
|
||||||
|
private final byte[] CMD_ConnectionResponse = new byte[]{0x01, 0x00, 0x00, 0x00};
|
||||||
|
private final byte[] CMD_Start = new byte[]{0x03, 0x00, 0x00, 0x00};
|
||||||
|
private final byte[] CMD_NSPContent = new byte[]{0x05, 0x00, 0x00, 0x00};
|
||||||
|
private final byte[] CMD_NSPTicket = new byte[]{0x06, 0x00, 0x00, 0x00};
|
||||||
|
private final byte[] CMD_Finish = new byte[]{0x07, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
GoldLeaf(){
|
||||||
|
String fileName;
|
||||||
|
InputStream fileInputStream;
|
||||||
|
try {
|
||||||
|
fileInputStream = getContentResolver().openInputStream(nspElements.get(0).getUri());
|
||||||
|
fileName = nspElements.get(0).getFilename();
|
||||||
|
}
|
||||||
|
catch (java.io.FileNotFoundException fnfe){
|
||||||
|
issueDescription = "GL FileNotFoundException @GoldLeaf()";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PFSProvider pfsElement = new PFSProvider(fileInputStream, fileName);
|
||||||
|
if (!pfsElement.init()) {
|
||||||
|
issueDescription = "GL File provided have incorrect structure and won't be uploaded.";
|
||||||
|
status = getResources().getString(R.string.status_wrong_file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initGoldLeafProtocol(pfsElement))
|
||||||
|
status = getResources().getString(R.string.status_uploaded); // else - no change status that is already set to FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean initGoldLeafProtocol(PFSProvider pfsElement){
|
||||||
|
// Go parse commands
|
||||||
|
byte[] readByte;
|
||||||
|
|
||||||
|
// Go connect to GoldLeaf
|
||||||
|
if (writeToUsb(CMD_GLUC)){
|
||||||
|
issueDescription = "GL Initiating GoldLeaf connection: 1/2";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(CMD_ConnectionRequest)){
|
||||||
|
issueDescription = "GL Initiating GoldLeaf connection: 2/2";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
readByte = readFromUsb();
|
||||||
|
if (readByte == null)
|
||||||
|
return false;
|
||||||
|
if (Arrays.equals(readByte, CMD_GLUC)) {
|
||||||
|
readByte = readFromUsb();
|
||||||
|
if (readByte == null)
|
||||||
|
return false;
|
||||||
|
if (Arrays.equals(readByte, CMD_ConnectionResponse)) {
|
||||||
|
if (!handleConnectionResponse(pfsElement))
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Arrays.equals(readByte, CMD_Start)) {
|
||||||
|
if (!handleStart(pfsElement))
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Arrays.equals(readByte, CMD_NSPContent)) {
|
||||||
|
if (!handleNSPContent(pfsElement, true))
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Arrays.equals(readByte, CMD_NSPTicket)) {
|
||||||
|
if (!handleNSPContent(pfsElement, false))
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Arrays.equals(readByte, CMD_Finish)) { // All good
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* ConnectionResponse command handler
|
||||||
|
* */
|
||||||
|
private boolean handleConnectionResponse(PFSProvider pfsElement){
|
||||||
|
if (writeToUsb(CMD_GLUC)) {
|
||||||
|
issueDescription = "GL 'ConnectionResponse' command: INFO: [1/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(CMD_NSPName)) {
|
||||||
|
issueDescription = "GL 'ConnectionResponse' command: INFO: [2/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(pfsElement.getBytesNspFileNameLength())) {
|
||||||
|
issueDescription = "GL 'ConnectionResponse' command: INFO: [3/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(pfsElement.getBytesNspFileName())) {
|
||||||
|
issueDescription = "GL 'ConnectionResponse' command: INFO: [4/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start command handler
|
||||||
|
* */
|
||||||
|
private boolean handleStart(PFSProvider pfsElement){
|
||||||
|
|
||||||
|
if (writeToUsb(CMD_GLUC)) {
|
||||||
|
issueDescription = "GL Handle 'Start' command: [Send command prepare]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(CMD_NSPData)) {
|
||||||
|
issueDescription = "GL Handle 'Start' command: [Send command]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(pfsElement.getBytesCountOfNca())) {
|
||||||
|
issueDescription = "GL Handle 'Start' command: [Send length]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ncaCount = pfsElement.getIntCountOfNca();
|
||||||
|
|
||||||
|
for (int i = 0; i < ncaCount; i++){
|
||||||
|
if (writeToUsb(pfsElement.getNca(i).getNcaFileNameLength())) {
|
||||||
|
issueDescription = "GL Handle 'Start' command: File # "+i+"/"+ncaCount+" step: [1/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(pfsElement.getNca(i).getNcaFileName())) {
|
||||||
|
issueDescription = "GL Handle 'Start' command: File # "+i+"/"+ncaCount+" step: [2/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(pfsElement.getBodySize()+pfsElement.getNca(i).getNcaOffset()).array())) { // offset. real.
|
||||||
|
issueDescription = "GL Handle 'Start' command: File # "+i+"/"+ncaCount+" step: [3/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(pfsElement.getNca(i).getNcaSize()).array())) { // size
|
||||||
|
issueDescription = "GL Handle 'Start' command: File # "+i+"/"+ncaCount+" step: [4/4]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* NSPContent command handler
|
||||||
|
* isItRawRequest - if True, just ask NS what's needed
|
||||||
|
* - if False, send ticket
|
||||||
|
* */
|
||||||
|
private boolean handleNSPContent(PFSProvider pfsElement, boolean isItRawRequest){
|
||||||
|
int requestedNcaID;
|
||||||
|
|
||||||
|
if (isItRawRequest) {
|
||||||
|
byte[] readByte = readFromUsb();
|
||||||
|
if (readByte == null || readByte.length != 4) {
|
||||||
|
issueDescription = "GL Handle 'Content' command: [Read requested ID]";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
requestedNcaID = ByteBuffer.wrap(readByte).order(ByteOrder.LITTLE_ENDIAN).getInt();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
requestedNcaID = pfsElement.getNcaTicketID();
|
||||||
|
}
|
||||||
|
|
||||||
|
long realNcaOffset = pfsElement.getNca(requestedNcaID).getNcaOffset()+pfsElement.getBodySize();
|
||||||
|
long realNcaSize = pfsElement.getNca(requestedNcaID).getNcaSize();
|
||||||
|
|
||||||
|
long readFrom = 0;
|
||||||
|
|
||||||
|
int readPice = 16384; // 8mb NOTE: consider switching to 1mb 1048576
|
||||||
|
byte[] readBuf;
|
||||||
|
|
||||||
|
try{
|
||||||
|
BufferedInputStream bufferedInStream = new BufferedInputStream(getContentResolver().openInputStream(nspElements.get(0).getUri())); // TODO: refactor?
|
||||||
|
if (bufferedInStream.skip(realNcaOffset) != realNcaOffset) {
|
||||||
|
issueDescription = "GL Failed to skip NCA offset";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (readFrom < realNcaSize){
|
||||||
|
if (interrupt.get()) // Check if user interrupted process.
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (readPice > (realNcaSize - readFrom))
|
||||||
|
readPice = (int)(realNcaSize - readFrom); // TODO: Troubles could raise here
|
||||||
|
readBuf = new byte[readPice];
|
||||||
|
if (bufferedInStream.read(readBuf) != readPice) {
|
||||||
|
issueDescription = "GL Failed to read data from file.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeToUsb(readBuf)) {
|
||||||
|
issueDescription = "GL Failed to write data into NS.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
readFrom += readPice;
|
||||||
|
|
||||||
|
updateProgressBar((int) ((readFrom+1)/(realNcaSize/100+1)));
|
||||||
|
}
|
||||||
|
bufferedInStream.close();
|
||||||
|
|
||||||
|
resetProgressBar();
|
||||||
|
}
|
||||||
|
catch (java.io.IOException ioe){
|
||||||
|
issueDescription = "GL Failed to read NCA ID "+requestedNcaID+". IO Exception: "+ioe.getMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.View;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
public class NSPElement implements Parcelable {
|
||||||
|
private Uri uri;
|
||||||
|
private String filename;
|
||||||
|
private long size;
|
||||||
|
private String status;
|
||||||
|
private boolean selected;
|
||||||
|
|
||||||
|
public NSPElement(Uri uri, String filename, long size){
|
||||||
|
this.uri = uri;
|
||||||
|
this.filename = filename;
|
||||||
|
this.size = size;
|
||||||
|
this.status = "";
|
||||||
|
this.selected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri getUri() { return uri; }
|
||||||
|
public String getFilename() { return filename; }
|
||||||
|
public long getSize() { return size; }
|
||||||
|
|
||||||
|
public String getStatus() { return status; }
|
||||||
|
public void setStatus(String status) { this.status = status; }
|
||||||
|
|
||||||
|
public boolean isSelected() { return selected; }
|
||||||
|
public void setSelected(boolean selected) { this.selected = selected; }
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
/ Parcelable shit next
|
||||||
|
/-----------------------*/
|
||||||
|
private NSPElement(Parcel parcel){
|
||||||
|
uri = Uri.parse(parcel.readString());
|
||||||
|
filename = parcel.readString();
|
||||||
|
size = parcel.readLong();
|
||||||
|
status = parcel.readString();
|
||||||
|
selected = parcel.readByte() == 0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel outParcel, int flags) {
|
||||||
|
outParcel.writeString(uri.toString());
|
||||||
|
outParcel.writeString(filename);
|
||||||
|
outParcel.writeLong(size);
|
||||||
|
outParcel.writeString(status);
|
||||||
|
outParcel.writeByte((byte) (selected ? 0x1 : 0x0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<NSPElement> CREATOR
|
||||||
|
= new Parcelable.Creator<NSPElement>() {
|
||||||
|
public NSPElement createFromParcel(Parcel in) {
|
||||||
|
return new NSPElement(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPElement[] newArray(int size) {
|
||||||
|
return new NSPElement[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader.View;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.blogspot.developersu.ns_usbloader.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class NspItemsAdapter extends RecyclerView.Adapter<NspItemsAdapter.NspViewHolder> {
|
||||||
|
private ArrayList<NSPElement> mDataset;
|
||||||
|
|
||||||
|
public static class NspViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
CheckedTextView nspCTV;
|
||||||
|
TextView sizeTV;
|
||||||
|
TextView statusTV;
|
||||||
|
NSPElement nspElement;
|
||||||
|
|
||||||
|
NspViewHolder(View itemTV) {
|
||||||
|
super(itemTV);
|
||||||
|
nspCTV = itemTV.findViewById(R.id.checkedCTV);
|
||||||
|
sizeTV = itemTV.findViewById(R.id.sizeTV);
|
||||||
|
statusTV = itemTV.findViewById(R.id.statusTV);
|
||||||
|
nspCTV.setOnClickListener(e->{
|
||||||
|
nspCTV.toggle();
|
||||||
|
nspElement.setSelected(nspCTV.isChecked());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void setData(NSPElement element){
|
||||||
|
nspElement = element;
|
||||||
|
nspCTV.setText(element.getFilename());
|
||||||
|
sizeTV.setText(getCuteSize(element.getSize()));
|
||||||
|
nspCTV.setChecked(element.isSelected());
|
||||||
|
statusTV.setText(element.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCuteSize(long byteSize){
|
||||||
|
if (byteSize/1024.0/1024.0/1024.0 > 1)
|
||||||
|
return String.format("%.2f", byteSize/1024.0/1024.0/1024.0)+" GB";
|
||||||
|
else if (byteSize/1024.0/1024.0 > 1)
|
||||||
|
return String.format("%.2f", byteSize/1024.0/1024.0)+" MB";
|
||||||
|
else
|
||||||
|
return String.format("%.2f", byteSize/1024.0)+" kB";
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPElement getData(){
|
||||||
|
return nspElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NspItemsAdapter(ArrayList<NSPElement> mDataset){
|
||||||
|
this.mDataset = mDataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(int fromPosition, int toPostition){
|
||||||
|
if (fromPosition < toPostition){
|
||||||
|
int i = fromPosition;
|
||||||
|
while(i < toPostition)
|
||||||
|
Collections.swap(mDataset, i, ++i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int i = fromPosition;
|
||||||
|
while(i > toPostition)
|
||||||
|
Collections.swap(mDataset, i, --i);
|
||||||
|
}
|
||||||
|
notifyItemMoved(fromPosition, toPostition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public NspViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View tv = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.nsp_item, parent, false);
|
||||||
|
return new NspViewHolder(tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull NspViewHolder holder, int position) {
|
||||||
|
holder.setData(mDataset.get(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mDataset.size();
|
||||||
|
}
|
||||||
|
}
|
11
app/src/main/res/color/textview_colors.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:state_enabled="false"
|
||||||
|
android:color="#c8c8c8"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:state_enabled="true"
|
||||||
|
android:color="@android:color/white"
|
||||||
|
/>
|
||||||
|
</selector>
|
23
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="69.23077"
|
||||||
|
android:viewportHeight="69.23077">
|
||||||
|
<group android:translateX="12.115385"
|
||||||
|
android:translateY="12.115385">
|
||||||
|
<path
|
||||||
|
android:pathData="m11.547,28.4101a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589zM15.3874,24.473a2.1594,2.1594 0,0 0,-2.1996 2.1177,2.1594 2.1594,0 0,0 2.1172,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1167,-2.2006l-0.0422,2.1589zM7.7065,24.473a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1172,-2.2006l-0.0422,2.1589zM11.547,20.5348a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589z"
|
||||||
|
android:strokeWidth="0.39261311"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m11.5069,6.2997a4.5,4.5 0,0 1,4.4992 4.5006,4.5 4.5,0 0,1 -4.5004,4.4994A4.5,4.5 0,0 1,7.006 10.7995,4.5 4.5,0 0,1 11.506,6.2997"
|
||||||
|
android:strokeWidth="0.27272743"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m35.0919,7.0506 l-1.9662,3.4048h1.4026V27.8581l-3.58,-3.3885c-0.2311,-0.2884 -0.3933,-0.6657 -0.4023,-1.0538 0,-1.5701 -0.0004,-2.5026 -0.001,-2.8458 0.6628,-0.2326 1.1413,-0.8576 1.1413,-1.6005 0,-0.9398 -0.7627,-1.7026 -1.7028,-1.7026 -0.9406,0 -1.703,0.7627 -1.703,1.7026 0,0.7429 0.4782,1.3678 1.1404,1.6005l-0.0005,2.8124c0,0.7622 0.4182,1.561 0.9085,2.0693 -0.0146,-0.0139 -0.0301,-0.0283 0.0003,0.0008 0.0121,0.0108 3.7979,3.5951 3.7979,3.5951 0.2308,0.2878 0.3919,0.6649 0.4012,1.0527v1.9687c-1.3006,0.261 -2.2804,1.4094 -2.2804,2.7871 0,1.5707 1.2732,2.8439 2.8434,2.8439 1.5707,0 2.8439,-1.2732 2.8439,-2.8439 0,-1.3779 -0.9807,-2.5264 -2.2823,-2.7873v-1.9342c0,-0.005 0.0003,-0.0099 0,-0.015v-4.2781c0.0098,-0.3871 0.1712,-0.7637 0.4023,-1.0512 0,0 3.7855,-3.5835 3.7977,-3.5946 0.0304,-0.0287 0.0145,-0.0144 0.0003,-0.0003 0.4902,-0.5084 0.9081,-1.3074 0.9081,-2.0698l-0.0004,-2.7104h1.1416v-3.4056h-3.4053v3.4057h1.1401c0,0 -0.0012,0.7139 -0.0012,2.7436 -0.0089,0.3882 -0.1709,0.7659 -0.402,1.0542l-3.5808,3.3892V10.4554h1.4049z"
|
||||||
|
android:strokeWidth="0.06804519"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
17
app/src/main/res/drawable/ic_cancel.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M12,2C17.53,2 22,6.47 22,12 22,17.53 17.53,22 12,22 6.47,22 2,17.53 2,12 2,6.47 6.47,2 12,2M15.59,7 L12,10.59 8.41,7 7,8.41 10.59,12 7,15.59 8.41,17 12,13.41 15.59,17 17,15.59 13.41,12 17,8.41Z"
|
||||||
|
android:fillColor="#ec0000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M7,15.59 L10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59 15.59,17 12,13.41 8.41,17Z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="0"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
</vector>
|
41
app/src/main/res/drawable/ic_file_select_file.xml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M20.5,4V15.5C20.5,15.8057 20.3194,16 20.0139,16 15.9953,15.99 12.0324,16.0059 8.0139,16 7.6853,16 7.5,15.8074 7.5,15.5V4c4.5216,-0.0068 8.7421,0 13,0z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="0.03780191"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M8,0C6.8954,0 6,0.8954 6,2L6,18C6,19.1 6.89,20 8,20L20,20C21.1046,20 22,19.1046 22,18L22,2C22,0.9048 21.0898,0 20,0L8,0zM8,2L20,2C20.3112,2 20.5,2.2044 20.5,2.5L20.5,15.5C20.5,15.79 20.2984,16 20,16L8,16C7.7044,16 7.5,15.8034 7.5,15.5L7.5,2.5C7.5,2.2083 7.7122,2 8,2z"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m10.0996,1.1992h7.8008c0.1,0.0021 0.0996,0.0018 0.0996,0.1016v0.0996C18,1.4962 18.0004,1.4979 17.9004,1.5H10.0996C9.9996,1.5057 10,1.504 10,1.4004v-0.0996c0,-0.0997 -0.0004,-0.1034 0.0996,-0.1016z"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m11,17h6l-3,2z"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m2,4v18c0,1.1046 0.8954,2 2,2H20V22H4V4Z"
|
||||||
|
android:fillColor="#1c1c1c"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M7.5,4V2.5C7.5,2.2294 7.6945,2 8,2c4.0186,0.01 7.9815,-0.0059 12,0 0.3325,0 0.5022,0.2203 0.5,0.5V4c-4.5216,0.0068 -8.7421,-0 -13,0z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="0.03780191"
|
||||||
|
android:fillColor="#ec0000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12.297,15 L8.7125,11.4154 10.346,9.7819 12.297,11.7387 18,6.0299 19.6335,7.6635Z"
|
||||||
|
android:strokeWidth="0.57722491"/>
|
||||||
|
</vector>
|
12
app/src/main/res/drawable/ic_fullsize_logo_android.xml
Normal file
9
app/src/main/res/drawable/ic_info.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
|
||||||
|
</vector>
|
24
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="67.16418"
|
||||||
|
android:viewportHeight="67.16418">
|
||||||
|
<group android:translateX="11.082089"
|
||||||
|
android:translateY="11.082089">
|
||||||
|
<path
|
||||||
|
android:pathData="m9.0061,-0.0004c-5.0208,0 -9,4.9479 -9,8 -0.0058,11.1771 -0.0102,18.2996 0,29.0003 0,3.1375 3.9791,8 9,8l12.9491,0L21.9552,-0.0004Z"
|
||||||
|
android:strokeWidth="0.99999994"
|
||||||
|
android:fillColor="#00c8fc"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m23.9793,-0.0004l0,45.0003l21.0207,0L45,-0.0004Z"
|
||||||
|
android:strokeWidth="0.99999994"
|
||||||
|
android:fillColor="#ec0000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m21.967,-0.0004c-0.0065,-0 -0.0119,0.0054 -0.0119,0.0119V44.9881c0,0.0065 0.0054,0.0119 0.0119,0.0119h2.0004c0.0065,0 0.0119,-0.0054 0.0119,-0.0119V0.0115c0,-0.0065 -0.0054,-0.0119 -0.0119,-0.0119z"
|
||||||
|
android:strokeWidth="0.26458332"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
23
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="69.23077"
|
||||||
|
android:viewportHeight="69.23077">
|
||||||
|
<group android:translateX="12.115385"
|
||||||
|
android:translateY="12.115385">
|
||||||
|
<path
|
||||||
|
android:pathData="m11.547,28.4101a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589zM15.3874,24.473a2.1594,2.1594 0,0 0,-2.1996 2.1177,2.1594 2.1594,0 0,0 2.1172,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1167,-2.2006l-0.0422,2.1589zM7.7065,24.473a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1172,-2.2006l-0.0422,2.1589zM11.547,20.5348a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589z"
|
||||||
|
android:strokeWidth="0.39261311"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m11.5069,6.2997a4.5,4.5 0,0 1,4.4992 4.5006,4.5 4.5,0 0,1 -4.5004,4.4994A4.5,4.5 0,0 1,7.006 10.7995,4.5 4.5,0 0,1 11.506,6.2997"
|
||||||
|
android:strokeWidth="0.27272743"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m35.0919,7.0506 l-1.9662,3.4048h1.4026V27.8581l-3.58,-3.3885c-0.2311,-0.2884 -0.3933,-0.6657 -0.4023,-1.0538 0,-1.5701 -0.0004,-2.5026 -0.001,-2.8458 0.6628,-0.2326 1.1413,-0.8576 1.1413,-1.6005 0,-0.9398 -0.7627,-1.7026 -1.7028,-1.7026 -0.9406,0 -1.703,0.7627 -1.703,1.7026 0,0.7429 0.4782,1.3678 1.1404,1.6005l-0.0005,2.8124c0,0.7622 0.4182,1.561 0.9085,2.0693 -0.0146,-0.0139 -0.0301,-0.0283 0.0003,0.0008 0.0121,0.0108 3.7979,3.5951 3.7979,3.5951 0.2308,0.2878 0.3919,0.6649 0.4012,1.0527v1.9687c-1.3006,0.261 -2.2804,1.4094 -2.2804,2.7871 0,1.5707 1.2732,2.8439 2.8434,2.8439 1.5707,0 2.8439,-1.2732 2.8439,-2.8439 0,-1.3779 -0.9807,-2.5264 -2.2823,-2.7873v-1.9342c0,-0.005 0.0003,-0.0099 0,-0.015v-4.2781c0.0098,-0.3871 0.1712,-0.7637 0.4023,-1.0512 0,0 3.7855,-3.5835 3.7977,-3.5946 0.0304,-0.0287 0.0145,-0.0144 0.0003,-0.0003 0.4902,-0.5084 0.9081,-1.3074 0.9081,-2.0698l-0.0004,-2.7104h1.1416v-3.4056h-3.4053v3.4057h1.1401c0,0 -0.0012,0.7139 -0.0012,2.7436 -0.0089,0.3882 -0.1709,0.7659 -0.402,1.0542l-3.5808,3.3892V10.4554h1.4049z"
|
||||||
|
android:strokeWidth="0.06804519"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
35
app/src/main/res/drawable/ic_logo_android.xml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="50dp"
|
||||||
|
android:height="50dp"
|
||||||
|
android:viewportWidth="45"
|
||||||
|
android:viewportHeight="45">
|
||||||
|
<path
|
||||||
|
android:pathData="m9.0061,-0.0004c-5.0208,0 -9,4.9479 -9,8 -0.0058,11.1771 -0.0102,18.2996 0,29.0003 0,3.1375 3.9791,8 9,8l12.9491,0L21.9552,-0.0004Z"
|
||||||
|
android:strokeWidth="0.99999994"
|
||||||
|
android:fillColor="#00c8fc"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m23.9793,-0.0004l0,45.0003l21.0207,0L45,-0.0004Z"
|
||||||
|
android:strokeWidth="0.99999994"
|
||||||
|
android:fillColor="#ec0000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m11.547,28.4101a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589zM15.3874,24.473a2.1594,2.1594 0,0 0,-2.1996 2.1177,2.1594 2.1594,0 0,0 2.1172,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1167,-2.2006l-0.0422,2.1589zM7.7065,24.473a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1172,2.1594 2.1594,0 0,0 -2.1172,-2.2006l-0.0422,2.1589zM11.547,20.5348a2.1594,2.1594 0,0 0,-2.2001 2.1177,2.1594 2.1594,0 0,0 2.1177,2.2001 2.1594,2.1594 0,0 0,2.2006 -2.1167,2.1594 2.1594,0 0,0 -2.1167,-2.2011l-0.0427,2.1589z"
|
||||||
|
android:strokeWidth="0.39261311"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m11.5069,6.2997a4.5,4.5 0,0 1,4.4992 4.5006,4.5 4.5,0 0,1 -4.5004,4.4994A4.5,4.5 0,0 1,7.006 10.7995,4.5 4.5,0 0,1 11.506,6.2997"
|
||||||
|
android:strokeWidth="0.27272743"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m35.0919,7.0506 l-1.9662,3.4048h1.4026V27.8581l-3.58,-3.3885c-0.2311,-0.2884 -0.3933,-0.6657 -0.4023,-1.0538 0,-1.5701 -0.0004,-2.5026 -0.001,-2.8458 0.6628,-0.2326 1.1413,-0.8576 1.1413,-1.6005 0,-0.9398 -0.7627,-1.7026 -1.7028,-1.7026 -0.9406,0 -1.703,0.7627 -1.703,1.7026 0,0.7429 0.4782,1.3678 1.1404,1.6005l-0.0005,2.8124c0,0.7622 0.4182,1.561 0.9085,2.0693 -0.0146,-0.0139 -0.0301,-0.0283 0.0003,0.0008 0.0121,0.0108 3.7979,3.5951 3.7979,3.5951 0.2308,0.2878 0.3919,0.6649 0.4012,1.0527v1.9687c-1.3006,0.261 -2.2804,1.4094 -2.2804,2.7871 0,1.5707 1.2732,2.8439 2.8434,2.8439 1.5707,0 2.8439,-1.2732 2.8439,-2.8439 0,-1.3779 -0.9807,-2.5264 -2.2823,-2.7873v-1.9342c0,-0.005 0.0003,-0.0099 0,-0.015v-4.2781c0.0098,-0.3871 0.1712,-0.7637 0.4023,-1.0512 0,0 3.7855,-3.5835 3.7977,-3.5946 0.0304,-0.0287 0.0145,-0.0144 0.0003,-0.0003 0.4902,-0.5084 0.9081,-1.3074 0.9081,-2.0698l-0.0004,-2.7104h1.1416v-3.4056h-3.4053v3.4057h1.1401c0,0 -0.0012,0.7139 -0.0012,2.7436 -0.0089,0.3882 -0.1709,0.7659 -0.402,1.0542l-3.5808,3.3892V10.4554h1.4049z"
|
||||||
|
android:strokeWidth="0.06804519"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m21.967,-0.0004c-0.0065,-0 -0.0119,0.0054 -0.0119,0.0119V44.9881c0,0.0065 0.0054,0.0119 0.0119,0.0119h2.0004c0.0065,0 0.0119,-0.0054 0.0119,-0.0119V0.0115c0,-0.0065 -0.0054,-0.0119 -0.0119,-0.0119z"
|
||||||
|
android:strokeWidth="0.26458332"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_net.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3 3,-3c-1.65,-1.66 -4.34,-1.66 -6,0zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z"/>
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_notification.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="45dp"
|
||||||
|
android:height="45dp"
|
||||||
|
android:viewportWidth="45"
|
||||||
|
android:viewportHeight="45">
|
||||||
|
<path
|
||||||
|
android:pathData="m9.0062,-0.0005c-5.0208,0 -9,4.9479 -9,8 -0.0058,11.1771 -0.0102,18.2996 0,29.0003 0,3.1375 3.9791,8 9,8L21.9552,44.9998L21.9552,-0.0005ZM23.9794,-0.0005L23.9794,44.9998L44.9998,44.9998L44.9998,-0.0005ZM11.5063,6.2999l0.0005,0A4.5,4.5 45,0 1,16.0063 10.8004,4.5 4.5,45 0,1 11.5058,15.2998 4.5,4.5 135,0 1,7.0058 10.7993,4.5 4.5,135 0,1 11.5063,6.2999ZM35.0919,7.0507 L37.0582,10.4552l-1.4051,0l0,13.147l3.5812,-3.3889c0.2312,-0.2882 0.3926,-0.666 0.4015,-1.0542 0,-2.0297 0.0016,-2.7435 0.0016,-2.7435l-1.14,0L38.4974,13.0095l3.405,0l0,3.406l-1.1415,0l0.0005,2.7099c0,0.7611 -0.4162,1.5591 -0.9054,2.0676 -0.0019,0.0017 -0.0003,0.0004 -0.0026,0.0026l-0.0005,0c-0.0123,0.0111 -3.7977,3.5946 -3.7977,3.5946 -0.2311,0.2875 -0.3922,0.6645 -0.402,1.0516l0,4.2778c0.0003,0.0051 0,0.01 0,0.015l0,1.9342c1.3016,0.261 2.282,1.4095 2.282,2.7874 0,1.5707 -1.2731,2.8438 -2.8438,2.8438 -1.5702,0 -2.8438,-1.2731 -2.8438,-2.8438 0,-1.3776 0.9799,-2.5265 2.2805,-2.7874l0,-1.9684c-0.0093,-0.3879 -0.1702,-0.7649 -0.401,-1.0526 -0,0 -3.7856,-3.5844 -3.7977,-3.5951 -0.0304,-0.0291 -0.0151,-0.0149 -0.0005,-0.001 -0.4903,-0.5084 -0.9085,-1.3069 -0.9085,-2.0691l0.0005,-2.8127c-0.6623,-0.2326 -1.1405,-0.8575 -1.1405,-1.6004 0,-0.9399 0.7627,-1.7022 1.7033,-1.7022 0.9402,0 1.7027,0.7624 1.7027,1.7022 0,0.7429 -0.4787,1.3678 -1.1415,1.6004 0.0005,0.3432 0.0011,1.2757 0.0011,2.8458 0.009,0.3881 0.1714,0.7658 0.4026,1.0542L34.5281,27.8582L34.5281,10.4552l-1.4025,0zM11.5471,20.5347 L11.5058,22.6937 11.5486,20.5347a2.1594,2.1594 0,0 1,2.1167 2.2014,2.1594 2.1594,0 0,1 -2.2009,2.1167 2.1594,2.1594 0,0 1,-2.1177 -2.2004,2.1594 2.1594,0 0,1 2.2004,-2.1177zM7.7065,24.4729 L7.6652,26.632 7.7075,24.4729a2.1594,2.1594 135,0 1,2.1172 2.2004,2.1594 2.1594,0 0,1 -2.2004,2.1172A2.1594,2.1594 0,0 1,5.5066 26.5906,2.1594 2.1594,45 0,1 7.7065,24.4729ZM15.3877,24.4729 L15.3469,26.632 15.3887,24.4729a2.1594,2.1594 45,0 1,2.1167 2.2004,2.1594 2.1594,135 0,1 -2.2004,2.1172A2.1594,2.1594 0,0 1,13.1878 26.5906,2.1594 2.1594,45 0,1 15.3877,24.4729ZM11.5471,28.4102 L11.5058,30.5692 11.5486,28.4102a2.1594,2.1594 0,0 1,2.1167 2.2009,2.1594 2.1594,135 0,1 -2.2009,2.1167 2.1594,2.1594 0,0 1,-2.1177 -2.1999,2.1594 2.1594,45 0,1 2.2004,-2.1177z"
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
/>
|
||||||
|
</vector>
|
25
app/src/main/res/drawable/ic_upload_btn.xml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="26dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="26"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M4.0078,0C1.5078,0 0,1.4883 0,3.9844V15.9883C0,18.418 1.4927,20 4.0078,20H6.5V0Z"
|
||||||
|
android:fillColor="#00b3c7"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M3.1016,2.957C4.1485,2.9562 4.9978,3.8046 4.998,4.8516 4.9988,5.8993 4.1493,6.7488 3.1016,6.748 2.0546,6.7478 1.2062,5.8985 1.207,4.8516 1.2073,3.8054 2.0554,2.9573 3.1016,2.957Z"
|
||||||
|
android:fillColor="#fffafa"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m19.5,0v20c1.0041,-0.0007 1.6599,0 2.4922,0C24.4141,20 26,18.4961 26,15.9961V3.9766C26,1.5195 24.5087,0 22.0039,0Z"
|
||||||
|
android:fillColor="#ec0000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m22.8652,11.1484c1.0477,-0.0008 1.8973,0.8488 1.8965,1.8965 -0.0003,1.047 -0.8495,1.8953 -1.8965,1.8945 -1.0462,-0.0003 -1.8942,-0.8483 -1.8945,-1.8945 -0.0008,-1.047 0.8476,-1.8962 1.8945,-1.8965z"
|
||||||
|
android:fillColor="#ffffff"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="m13,3 l-6.4512,9.5195h4.0313c0,1.5664 -0.0077,5.8901 -0.0078,6.6113h4.8477v-6.6113h4.0313zM8.334,20v1.334h9.332L17.666,20ZM8.334,22.666L8.334,24h9.332v-1.334z"
|
||||||
|
android:strokeWidth="0.80649775"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_usb.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M15,7v4h1v2h-3V5h2l-3,-4 -3,4h2v8H8v-2.07c0.7,-0.37 1.2,-1.08 1.2,-1.93 0,-1.21 -0.99,-2.2 -2.2,-2.2 -1.21,0 -2.2,0.99 -2.2,2.2 0,0.85 0.5,1.56 1.2,1.93V13c0,1.11 0.89,2 2,2h3v3.05c-0.71,0.37 -1.2,1.1 -1.2,1.95 0,1.22 0.99,2.2 2.2,2.2 1.21,0 2.2,-0.98 2.2,-2.2 0,-0.85 -0.49,-1.58 -1.2,-1.95V15h3c1.11,0 2,-0.89 2,-2v-2h1V7h-4z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/side_nav_bar.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<gradient
|
||||||
|
android:angle="135"
|
||||||
|
android:endColor="#00718d"
|
||||||
|
android:centerColor="#0090b4"
|
||||||
|
android:startColor="@color/colorAccent"
|
||||||
|
android:type="linear" />
|
||||||
|
</shape>
|
BIN
app/src/main/res/font/play.ttf
Normal file
25
app/src/main/res/layout/activity_about.xml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".AboutActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/content_about" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
29
app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
tools:openDrawer="start" >
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/app_bar_main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
android:id="@+id/nav_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:headerLayout="@layout/nav_header_main"
|
||||||
|
app:menu="@menu/activity_main_drawer"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
-->
|
||||||
|
</androidx.drawerlayout.widget.DrawerLayout>
|
37
app/src/main/res/layout/app_bar_main.xml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:fontFamily="@font/play"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
android:theme="@style/ToolbarTheme"
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
-->
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/content_main" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
73
app/src/main/res/layout/content_about.xml
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:context=".AboutActivity"
|
||||||
|
tools:showIn="@layout/activity_about">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:contentDescription="application logo"
|
||||||
|
app:srcCompat="@drawable/ic_fullsize_logo_android" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/about_line_1"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_line_2"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_line_3"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView4"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_line_4"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_line_5"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView6"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_line_6"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
</LinearLayout>
|
79
app/src/main/res/layout/content_main.xml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
|
tools:context=".MainActivity"
|
||||||
|
tools:showIn="@layout/app_bar_main">
|
||||||
|
<!--android:orientation="vertical"-->
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recyclerView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:padding="2dp"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/mainProgressBar"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/mainProgressBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:max="100"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/buttonSelect"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonSelect"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:layout_marginRight="4dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:drawableTop="@drawable/ic_file_select_file"
|
||||||
|
android:text="@string/select_file_btn"
|
||||||
|
android:theme="@style/ControlButton"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/guideline2"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonUpload"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:layout_marginLeft="4dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:drawableTop="@drawable/ic_upload_btn"
|
||||||
|
android:text="@string/upload_btn"
|
||||||
|
android:theme="@style/ControlButton"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/guideline2" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Guideline
|
||||||
|
android:id="@+id/guideline2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintGuide_percent="0.5" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
38
app/src/main/res/layout/nav_header_main.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/nav_header_height"
|
||||||
|
android:background="@drawable/side_nav_bar"
|
||||||
|
android:gravity="bottom"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
|
app:srcCompat="@drawable/ic_logo_android" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:fontFamily="@font/play"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
<!--
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/nav_header_subtitle" />
|
||||||
|
-->
|
||||||
|
</LinearLayout>
|
47
app/src/main/res/layout/nsp_item.xml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="2dp"
|
||||||
|
app:cardElevation="@dimen/cardview_default_elevation">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<CheckedTextView
|
||||||
|
android:id="@+id/checkedCTV"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@android:color/background_light"
|
||||||
|
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sizeTV"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/checkedCTV"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/checkedCTV"
|
||||||
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/statusTV"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/sizeTV"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/checkedCTV"
|
||||||
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
40
app/src/main/res/menu/activity_main_drawer.xml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:showIn="navigation_view"
|
||||||
|
>
|
||||||
|
|
||||||
|
<item android:title="@string/transfer_protocol">
|
||||||
|
<menu>
|
||||||
|
<group android:checkableBehavior="single">
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_tf_usb"
|
||||||
|
android:icon="@drawable/ic_usb"
|
||||||
|
android:title="@string/tf_usb"
|
||||||
|
android:checkable="true"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_tf_net"
|
||||||
|
android:icon="@drawable/ic_net"
|
||||||
|
android:title="@string/tf_net"
|
||||||
|
android:checkable="true"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_gl"
|
||||||
|
android:icon="@drawable/ic_usb"
|
||||||
|
android:title="@string/gl"
|
||||||
|
android:checkable="true"
|
||||||
|
/>
|
||||||
|
</group>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:title="@string/other">
|
||||||
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_about"
|
||||||
|
android:icon="@drawable/ic_info"
|
||||||
|
android:title="@string/about_app" />
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
</menu>
|
8
app/src/main/res/menu/activity_main_toolbar.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
>
|
||||||
|
<item
|
||||||
|
android:id="@+id/select_all"
|
||||||
|
android:title="@android:string/selectAll"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 12 KiB |
34
app/src/main/res/values-ru/strings.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">NS-USBloader</string>
|
||||||
|
<string name="select_file_btn">Выбрать .NSP</string>
|
||||||
|
<string name="popup_wrong_file">Неприавильный тип файла</string>
|
||||||
|
<string name="popup_error">Ошибка</string>
|
||||||
|
<string name="upload_btn">Отправить в NS</string>
|
||||||
|
<string name="install_file_explorer">Не установлено ни одного файлового менеджера.\n Пожалуйста установите один. Например Total Commander.</string>
|
||||||
|
<string name="ns_connected_info">NS подключён</string>
|
||||||
|
<string name="notification_channel_name">Устройство подключено</string>
|
||||||
|
<string name="notification_channel_description">Уведомление повяляется когда пользователь подключает NS к устройству</string>
|
||||||
|
<string name="ns_not_found_in_connected">NS не найден среди подключенных устройств.</string>
|
||||||
|
<string name="transfer_protocol">Протокол</string>
|
||||||
|
<string name="transfer_transport">Транспортный уровень</string>
|
||||||
|
<string name="nothing_selected_message">Ничего не выбрано</string>
|
||||||
|
<string name="transfers_service_stopped">Сервис передачи данных завершился.</string>
|
||||||
|
<string name="interrupt_btn">Прервать</string>
|
||||||
|
<string name="navigation_drawer_open">Открыть панель навигации</string>
|
||||||
|
<string name="navigation_drawer_close">Закрыть панель навигации</string>
|
||||||
|
<string name="about_app">О приложении</string>
|
||||||
|
<string name="other">Другое</string>
|
||||||
|
<string name="one_item_for_gl_notification">Только один файл может быть выделен для GoldLeaf</string>
|
||||||
|
<string name="no_protocol_selected_message">Не выбрано ни одного протокола</string>
|
||||||
|
<string name="title_activity_about">О приложении</string>
|
||||||
|
<string name="about_line_2">Это приложение <a href="https://www.gnu.org/licenses/gpl-3.0.html">распространяется под лицензией GNU GPLv3.</a></string>
|
||||||
|
<string name="about_line_3">Автор: Дмитрий Исаенко.</string>
|
||||||
|
<string name="about_line_4">Домашняя страница: <a href="https://github.com/developersu/ns-usbloader-mobile">https://github.com/developersu/ns-usbloader-mobile</a></string>
|
||||||
|
<string name="about_line_5">Переводчики: Если таковые имеются, то все они указаны на домашней странице.</string>
|
||||||
|
<string name="about_line_6">Если вам нравится эта программа, можете поставить звёздочку на GitHub. Если вы хотите поддержать приложение, пожалуйста обратитесь к домашней странице проекта за информацией. Пожалуйста учтите, что это некоммерческое приложение. Ваши вложения рассматриваются как подарок, и, вероятнее всего, они будут потрачены на покупку шоколадок :)</string>
|
||||||
|
<string name="popup_not_supported">Не поддерживается</string>
|
||||||
|
<string name="status_uploaded">(Передан)</string>
|
||||||
|
<string name="status_failed_to_upload">(Передача провалилась)</string>
|
||||||
|
<string name="status_wrong_file">(Плохой NSP файл)</string>
|
||||||
|
</resources>
|
6
app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#ec0000</color>
|
||||||
|
<color name="colorPrimaryDark">#ce0000</color>
|
||||||
|
<color name="colorAccent">#00c8fc</color>
|
||||||
|
</resources>
|
8
app/src/main/res/values/dimens.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||||
|
<dimen name="nav_header_height">150dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
</resources>
|
37
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">NS-USBloader</string>
|
||||||
|
<string name="select_file_btn">Select .NSP</string>
|
||||||
|
<string name="popup_wrong_file">Incorrect file type</string>
|
||||||
|
<string name="popup_error">Error</string>
|
||||||
|
<string name="upload_btn">Upload to NS</string>
|
||||||
|
<string name="install_file_explorer">No file explorer installed.\\n Please install one. For example Total Commander.</string>
|
||||||
|
<string name="ns_connected_info">NS Connected</string>
|
||||||
|
<string name="notification_channel_name">Device connected</string>
|
||||||
|
<string name="notification_channel_description">Notification appears when user connects NS to device</string>
|
||||||
|
<string name="ns_not_found_in_connected">NS not found in connected devices.</string>
|
||||||
|
<string name="transfer_protocol">Protocol</string>
|
||||||
|
<string name="transfer_transport">Transport level</string>
|
||||||
|
<string name="nothing_selected_message">Nothing selected</string>
|
||||||
|
<string name="transfers_service_stopped">Data transfer service has been finished.</string>
|
||||||
|
<string name="interrupt_btn">Interrupt</string>
|
||||||
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
|
<string name="tf_usb" translatable="false">TinFoil USB</string>
|
||||||
|
<string name="gl" translatable="false">GoldLeaf</string>
|
||||||
|
<string name="tf_net" translatable="false">TinFoil NET</string>
|
||||||
|
<string name="about_app">About this app</string>
|
||||||
|
<string name="other">Other</string>
|
||||||
|
<string name="one_item_for_gl_notification">Only one file could be selected for GoldLeaf</string>
|
||||||
|
<string name="no_protocol_selected_message">No protocol selected</string>
|
||||||
|
<string name="title_activity_about">About application</string>
|
||||||
|
<string name="about_line_1" translatable="false">NS-USBloader mobile</string>
|
||||||
|
<string name="about_line_2">This application <a href="https://www.gnu.org/licenses/gpl-3.0.html">licensed under GNU GPLv3</a>.</string>
|
||||||
|
<string name="about_line_3">Author: Dmitry Isaenko.</string>
|
||||||
|
<string name="about_line_4">Home page: <a href="https://github.com/developersu/ns-usbloader-mobile">https://github.com/developersu/ns-usbloader-mobile</a></string>
|
||||||
|
<string name="about_line_5">Translators: If there are any, they\'re noted on home page.</string>
|
||||||
|
<string name="about_line_6">If you found this application useful, you\'re more than welcome to give a star on GitHub page. If you want to support application please refer to home page for information. Please notice: it\'s not a commercial product. Any donations are considered as a gift and most likely would be spent for buying chocolates :)</string>
|
||||||
|
<string name="popup_not_supported">Not supported</string>
|
||||||
|
<string name="status_failed_to_upload">(Upload failure)</string>
|
||||||
|
<string name="status_wrong_file">(Bad NSP)</string>
|
||||||
|
<string name="status_uploaded">(Uploaded)</string>
|
||||||
|
</resources>
|
27
app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<resources>
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ControlButton" parent="Widget.AppCompat.Button">
|
||||||
|
<item name="colorControlHighlight">@color/colorAccent</item>
|
||||||
|
<item name="colorButtonNormal">#65e4fb</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<!--######################################### -->
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||||
|
<item name="fontFamily">@font/play</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
</resources>
|
9
app/src/main/res/xml/device_filter.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<usb-device
|
||||||
|
vendor-id="1406"
|
||||||
|
product-id="12288"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.blogspot.developersu.ns_usbloader;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
27
build.gradle
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
20
gradle.properties
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=true
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Mon Jun 17 23:55:11 MSK 2019
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
172
gradlew
vendored
Executable file
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
1
settings.gradle
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include ':app'
|