diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index afecfe1a..5ac91667 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -21,7 +21,4 @@ Description: What this is about, what happens and what is expected to happen. What needs to be done for it to happen. If a crash is happening a log is needed. Screenshots or demonstration videos are always helpful too. - - About logging: - https://gsantner.net/android-contribution-guide/?packageid=com.github.dfa.diaspora_android&name=dandelion&web=https://github.com/gsantner/dandelion#logcat --> diff --git a/.github/workflows/build-android-project.yml b/.github/workflows/build-android-project.yml new file mode 100644 index 00000000..07923101 --- /dev/null +++ b/.github/workflows/build-android-project.yml @@ -0,0 +1,68 @@ +############################################################################################################################## +# # Cleanup: +#const sleep = ms => () => new Promise((resolve, reject) => window.setTimeout(resolve, ms)); +#Promise.resolve() +#.then(() => { document.getElementsByClassName("details-overlay details-reset position-relative d-inline-block ")[3].children[0].click(); }) +#.then(sleep(500)) +#.then(() => { document.getElementsByClassName("dropdown-item btn-link menu-item-danger")[0].click(); }) +#.then(sleep(1000)) +#.then(() => { document.getElementsByClassName("btn btn-block btn-danger")[0].click();}); +# +# while [ 1 ] ; do sleep 4; xdotool key Up; sleep 0.1; xdotool key Return; done +############################################################################################################################## + +name: "CI" + +on: [push, pull_request] + +jobs: + build: + if: "!contains(github.event.head_commit.message, 'ci skip') && (!contains(github.event_name, 'pull_request') || (contains(github.event_name, 'pull_request') && github.event.pull_request.head.repo.full_name != github.repository))" + runs-on: ubuntu-latest + steps: + + - name: "Checkout: Code" + uses: actions/checkout@v2 + + + - name: "Checkout: Code (PR)" + uses: actions/checkout@v2 + if: "contains(github.event_name, 'pull_request')" + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: "Setup: Java" + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: "Cache: Gradle" + uses: actions/cache@v2 + with: + path: | + ~/.gradle + .gradle + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.*') }} + + - name: "Build: Project with make" + run: make clean all + + - name: "Build: List dist files" + if: always() + run: find dist -type f -maxdepth 2 + + - name: "Artifacts: All" + if: always() + uses: actions/upload-artifact@v2.2.1 + with: + name: "all" + path: dist + retention-days: 5 + + - name: "Artifacts: Android APK" + uses: actions/upload-artifact@v2.2.1 + with: + name: "android-apk" + path: | + dist/*.apk diff --git a/.gitignore b/.gitignore index 6aa6839b..59057232 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ tmp/ ### Gradle ### .gradle build/ +dist/ gradle-app.setting # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b4204f72..00000000 --- a/.travis.yml +++ /dev/null @@ -1,48 +0,0 @@ -language: android -jdk: oraclejdk8 - -before_cache: - # Do not cache a few Gradle files/directories (see https://docs.travis-ci.com/user/languages/java/#Caching) - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - # Android SDK - - $HOME/android-sdk-dl - - $HOME/android-sdk - - # Gradle dependencies - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - - # Android build cache (see http://tools.android.com/tech-docs/build-cache) - - $HOME/.android/build-cache - -install: - # Download and unzip the Android SDK tools (if not already there thanks to the cache mechanism) - # Latest version available here: https://developer.android.com/studio/index.html#downloads - - if test ! -e $HOME/android-sdk-dl/sdk-tools.zip ; then curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip > $HOME/android-sdk-dl/sdk-tools.zip ; fi - - unzip -qq -n $HOME/android-sdk-dl/sdk-tools.zip -d $HOME/android-sdk - - # Install or update Android SDK components (will not do anything if already up to date thanks to the cache mechanism) - - echo y | $HOME/android-sdk/tools/bin/sdkmanager 'tools' > /dev/null - - echo y | $HOME/android-sdk/tools/bin/sdkmanager 'platform-tools' > /dev/null - - echo y | $HOME/android-sdk/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null - - echo y | $HOME/android-sdk/tools/bin/sdkmanager 'platforms;android-27' > /dev/null - - echo y | $HOME/android-sdk/tools/bin/sdkmanager 'extras;google;m2repository' > /dev/null - -branches: - except: - - gh-pages - - l10n_master - - crowdin - -env: - global: - - ANDROID_HOME=$HOME/android-sdk - matrix: - - TASK="clean lintFlavorDefaultDebug --stacktrace" - - TASK="clean build check -x lint --stacktrace" - -script: "./gradlew --no-daemon --parallel $TASK" diff --git a/CHANGELOG.md b/CHANGELOG.md index f6049f2d..a5861d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ -### v1.2.5 -Make youtube links open external/in youtube app (optional) +### Recent changes +- See [Discussions](https://github.com/gsantner/dandelion/discussions), [Issues](https://github.com/gsantner/dandelion/issues) and [Project page](https://github.com/gsantner/dandelion#readme) to see what is going on. + +### v1.4.0 +- Add seconds to 'save picture' date format +- Updated translations +- Added german F-Droid description translation +- Update to Android SDK 29 + +### v1.3.0 +- Add option to open youtube links external/in YouTube app (optional) +- Pull to refresh ### v1.2.3 **Improved:** @@ -13,7 +23,6 @@ Make youtube links open external/in youtube app (optional) **New features:** - All new Aspects and Tags, using a searchable dialog -- A new home - project blog/page: **Fixed:** - Sometimes the Stream went white, which is due an still (>3 years) unfixed Android Support library bug. It should not occur very often anymore due less use of fragments. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7969e4cd..16e6a136 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,6 +1,5 @@ -* **[Gregor Santner](http://gsantner.net)**
~° Current developer of dandelion +* **[Gregor Santner](http://github.com/gsantner)**
~° Development of dandelion * **[Paul Schaub](https://github.com/vanitasvitae)**
~° Development of dandelion * **[Martín Vukovic](martinvukovic AT protonmail DOT com)**
~° Diaspora Native WebApp * **[Gaukler Faun](https://github.com/scoute-dich)**
~° Diaspora Native WebApp additions @@ -30,3 +29,4 @@ Where: * **[Jean Lucas](jean AT 4ray DOT co)**
~° Spanish translation * **[asereze](https://github.com/asereze)**
~° Sardinian translation * **[Xosé M. Lamas](http://xmgz.eu)**
~° Galician translation +* **[massimiliano](https://framagit.org/massimiliano)**
~° Contributor diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..09b21c00 --- /dev/null +++ b/Makefile @@ -0,0 +1,99 @@ +# License of Makefile: Public Domain / CC0 +.PHONY: $(shell sed -n -e '/^$$/ { n ; /^[^ .\#][^ ]*:/ { s/:.*$$// ; p ; } ; }' $(MAKEFILE_LIST)) +.NOTPARALLEL: clean +.DEFAULT_GOAL := all + +env-%: + @: $(if ${${*}},,$(error Environment variable $* not set)) +#################################################################################### + +DIST_DIR = dist +MOVE = mv + +all: $(DIST_DIR) spellcheck lint deptree test build aapt_dump_badging + +#################################################################################### + +$(DIST_DIR): + mkdir -p ${DIST_DIR} + +ANDROID_BUILD_TOOLS := $(shell test -n "$ANDROID_SDK_ROOT" && find "${ANDROID_SDK_ROOT}/build-tools" -iname "aapt" | sort -r | head -n1 | xargs dirname) +TOOL_SPELLCHECKING_ISPELL := $(shell command -v ispell 2> /dev/null) + +FLAVOR := $(or ${FLAVOR},${FLAVOR},Atest) + +.NOTPARALLEL: gradle gradle-analyze-log +gradle: env-ANDROID_SDK_ROOT + mkdir -p $(DIST_DIR)/log/ + chmod +x gradlew + ./gradlew --no-daemon --parallel --stacktrace $A 2>&1 | tee "$(DIST_DIR)/log/gradle.log" + @echo "-----------------------------------------------------------------------------------" + +gradle-analyze-log: + mv "$(DIST_DIR)/log/gradle.log" "$(DIST_DIR)/log/gradle$A.log" + cat "$(DIST_DIR)/log/gradle$A.log" | grep "BUILD " | tail -n1 | grep -q "BUILD SUCCESSFUL in" + +adb: env-ANDROID_SDK_ROOT + "${ANDROID_SDK_ROOT}/platform-tools/adb" $A 2>&1 | tee "$(DIST_DIR)/log/adb-$L.log" + +aapt: env-ANDROID_SDK_ROOT + "${ANDROID_BUILD_TOOLS}/aapt" $A 2>&1 | grep -v 'application-label-' | tee "$(DIST_DIR)/log/aapt$L.log" + +build: + rm -f $(DIST_DIR)/*.apk + $(MAKE) A="clean assembleFlavor$(FLAVOR) -x lint" gradle + find app -type f -newermt '-300 seconds' -iname '*.apk' -not -iname '*unsigned.apk' | xargs cp -R -t $(DIST_DIR)/ + $(MAKE) A="-build" gradle-analyze-log + +lint: + rm -Rf $(DIST_DIR)/lint + mkdir -p $(DIST_DIR)/lint/ + $(MAKE) A="lintFlavorDefaultDebug" gradle + find app -type f -iname 'lint-results-*' | grep -v 'intermediates' | xargs cp -R -t $(DIST_DIR)/lint + $(MAKE) A="-lint" gradle-analyze-log + +test: + rm -Rf $(DIST_DIR)/tests + $(MAKE) A="testFlavorDefaultDebugUnitTest -x lint" gradle + mkdir -p app/build/test-results/testFlavorDefaultDebugUnitTest && echo 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHRlc3RzdWl0ZSBuYW1lPSJkdW1teSIgdGVzdHM9IjEiIHNraXBwZWQ9IjAiIGZhaWx1cmVzPSIwIiBlcnJvcnM9IjAiIHRpbWVzdGFtcD0iMjAyMC0xMi0wOFQwMDowMDowMCIgaG9zdG5hbWU9ImxvY2FsaG9zdCIgdGltZT0iMC4wMSI+CiAgPHByb3BlcnRpZXMvPgogIDx0ZXN0Y2FzZSBuYW1lPSJkdW1teSIgY2xhc3NuYW1lPSJkdW1teSIgdGltZT0iMC4wMSIvPgogIDxzeXN0ZW0tb3V0PjwhW0NEQVRBW11dPjwvc3lzdGVtLW91dD4KICA8c3lzdGVtLWVycj48IVtDREFUQVtdXT48L3N5c3RlbS1lcnI+CjwvdGVzdHN1aXRlPgo=' | base64 -d > 'app/build/test-results/testFlavorDefaultDebugUnitTest/TEST-dummy.xml' + find app -type d -iname 'testFlavorDefaultDebugUnitTest' | xargs cp -R -t $(DIST_DIR)/ + mv ${DIST_DIR}/testFlavorDefaultDebugUnitTest $(DIST_DIR)/tests + $(MAKE) A="-test" gradle-analyze-log + +deptree: + $(MAKE) A="app:dependencies --configuration flavor$(FLAVOR)DebugRuntimeClasspath" gradle + $(MAKE) A="-dependency-tree" gradle-analyze-log + +clean: + $(MAKE) A="clean" gradle + rm -Rf $(DIST_DIR) app/build app/flavor* .idea dist + find . -type f -iname "*.iml" -delete + $(MAKE) $(DIST_DIR) + @echo "-----------------------------------------------------------------------------------" + +install: + $(MAKE) A="install -r $(DIST_DIR)/*.apk" L="install" adb + +run: + $(MAKE) A="shell monkey -p $$(aapt dump badging $(DIST_DIR)/*.apk | grep package: | sed 's@.* name=@@' | sed 's@ .*@@' | xargs | head -n1) -c android.intent.category.LAUNCHER 1" L="run" adb + +aapt_dump_badging: + $(MAKE) A="dump badging $(DIST_DIR)/*.apk" aapt + @echo "-----------------------------------------------------------------------------------" + +spellcheck: + mkdir -p "$(DIST_DIR)/lint/" +ifndef TOOL_SPELLCHECKING_ISPELL + @echo "Tool ispell (spellcheck) not found in PATH. Spellcheck skipped." > "$(DIST_DIR)/lint/stringsxml-spellcheck.txt" +else + @echo "Use ispell for spellchecking the original values/strings.xml" + find . -iname "strings.xml" -path "*/main*/values/*" | head -n1 | xargs cat \ + | grep "@@' | sed 's@@@' | sed 's@\\n@ @g' | sed 's@\\@@g' \ + | ispell -W3 -a | grep ^\& | sed 's@[0-9]@@g' | sort | uniq | cut -d, -f1-4 \ + | sed 's@^..@- @' | column -t -s: \ + > "$(DIST_DIR)/lint/stringsxml-spellcheck.txt" + @echo "\nPotential words with bad spelling:" +endif + @cat "$(DIST_DIR)/lint/stringsxml-spellcheck.txt" + @echo "-----------------------------------------------------------------------------------" + diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 00000000..6139d132 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,96 @@ +# dandelion - News + +## General + +### Installation +You can install and update from [F-Droid](https://f-droid.org/repository/browse/?fdid=com.github.dfa.diaspora_android) or [GitHub](https://github.com/gsantner/dandelion/releases/latest). + +F-Droid is a store for free & open source apps. +The *.apk's available for download are signed by the F-Droid team and guaranteed to correspond to the (open source) source code of dandelion. +Generally this is the recommended way to install dandelion & keep it updated. + + +### Get informed +* Check the [project readme](https://github.com/gsantner/dandelion/tree/news#readme) for general project information. +* Check the [project news](https://github.com/gsantner/dandelion/blob/master/NEWS.md#readme) for more details on what is going on. +* Check the [project git history](https://github.com/gsantner/dandelion/commits/master) for most recent code changes. + +### The right place to ask +If you have questions or found an issue please head to the [dandelion project](https://github.com/gsantner/dandelion/issues/new/choose) and ask there. +[Search](https://github.com/gsantner/dandelion/issues?q=#js-issues-search) for same/similar and related issues/questions before, it might be already answered or resolved. + + +### Navigation +* [dandelion v1.2 - Add dandelior - Searchable Tags and Aspects](#dandelion-v12---add-dandelior---searchable-tags-and-aspects) +* [dandelion v0.1.2 - Aspekte, Pod wechseln](#dandelion-v012---aspekte-pod-wechseln) + + + + + + + + + +------------------------------------------------------------------------------------------------------------------------------------ + +------------------------------------------------------------------------------------------------------------------------------------ + +------------------------------------------------------------------------------------------------------------------------------------ + + +# dandelion\* v1.2 - Add dandelior\* - Searchable Tags and Aspects +_12. August 2018_ + +## dandelior\* is a rebranded version of dandelion\* +dandelior\* is based 100% on the same code and resources as dandelion\*. Its from the same code repository, just a different build flavor. +The main purpose of dandelior\* is the most requested feature till date - to support multiple accounts / another account at dandelion\*. + +- Added an (rebranded) flavor of dandelion: dandelior +- Only differenties in use are other (black) icon and AMOLED colors by default enabled +- Already available on F-Droid + +**New features:** +- All new Aspects and Tags, using a searchable dialog + +**Fixed:** +- Sometimes the Stream went white, which is due an still (3+ years) unfixed Android Support library bug. It should not occur very often anymore due less use of fragments. + +**Improved:** +- Various small tweaks +- Updated translation files + + + + + + + + + +------------------------------------------------------------------------------------------------------------------------------------ + +------------------------------------------------------------------------------------------------------------------------------------ + +------------------------------------------------------------------------------------------------------------------------------------ + + +# dandelion v0.1.2 - Aspekte, Pod wechseln +_05. Juni 2016_ + +In den letzten Tagen hat @gsantner viel Zeit in die inoffizielle diaspora\* Android App ([dandelion\*](https://github.com/gsantner/dandelion)) investiert. + +Dabei wurden unter anderem folgende Änderungen beigesteuert: + +- Allgemeines zur Usability +- Animationen für den Activity-Wechsel und Startup, WebView-Scroll-Top +- Podliste caching +- Aspekt-Liste und Aspekte hinzugefügt +- Verbessertes Sharing aus der App +- Material Progressbar +- Suche verbessert +- Collapsing top menu +- toolbar/actions/menu geändert, fab entfernt +- Refactoring layout & menu files, dialogs +- Überarbeitete Main,Splash,PodSelectionActivity +- Pod wechseln diff --git a/README.md b/README.md index 57ba4cc3..a061ee60 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -[![GitHub release](https://img.shields.io/github/tag/gsantner/dandelion.svg)](https://github.com/gsantner/dandelion/releases) -[![Build Status](https://travis-ci.org/gsantner/dandelion.svg?branch=master)](https://travis-ci.org/gsantner/dandelion) -[![Translate - with Stringlate](https://img.shields.io/badge/stringlate-translate-green.svg)](https://lonamiwebs.github.io/stringlate/translate?git=https%3A%2F%2Fgithub.com%2Fgsantner%2Fdandelion.git&mail=gro.xobliam@@rentnasg) -[![Chat - Matrix](https://img.shields.io/badge/chat-on%20matrix-blue.svg)](https://matrix.to/#/#dandelion:matrix.org) [![Chat - FreeNode IRC](https://img.shields.io/badge/chat-on%20irc-blue.svg)](https://kiwiirc.com/client/irc.freenode.net/?nick=dandelion-anon|?##dandelion) -[![Donate](https://img.shields.io/badge/donate-appreciation-orange.svg)](https://gsantner.net/supportme/?project=dandelion&source=readme) -[![Donate LiberaPay](https://img.shields.io/badge/donate-liberapay-orange.svg)](https://liberapay.com/gsantner/donate) +[![GitHub releases](https://img.shields.io/github/tag/gsantner/dandelion.svg)](https://github.com/gsantner/dandelion/releases) +[![GitHub downloads](https://img.shields.io/github/downloads/gsantner/dandelion/total.svg?logo=github&logoColor=lime)](https://github.com/gsantner/dandelion/releases) +[![Translate on Crowdin](https://img.shields.io/badge/translate-crowdin-green.svg)](https://crowdin.com/project/diaspora-for-android/invite) +[![Chat on Matrix](https://img.shields.io/badge/chat-matrix-blue.svg)](https://matrix.to/#/#dandelion:matrix.org) +[![GitHub CI](https://github.com/gsantner/dandelion/workflows/CI/badge.svg)](https://github.com/gsantner/dandelion/actions) +[![Codacy code quality](https://img.shields.io/codacy/grade/aff869c440bc48b7bd64680e97cbc453)](https://www.codacy.com/app/gsantner/dandelion) # dandelion\* @@ -39,12 +39,11 @@ dandelion\* requires access to the Internet and to external storage to be able t ## Contributions The project is always open for contributions and accepts pull requests. -The project uses [AOSP Java Code Style](https://source.android.com/source/code-style#follow-field-naming-conventions), with one exception: private members are `_camelCase` instead of `mBigCamel`. You may use Android Studios _auto reformat feature_ before sending a PR. See [gsantner's android contribution guide](https://gsantner.net/android-contribution-guide/?packageid=com.github.dfa.diaspora_android&name=dandelion&web=https://github.com/gsantner/dandelion&source=readme#logcat) for more information. +The project uses [AOSP Java Code Style](https://source.android.com/source/code-style#follow-field-naming-conventions), with one exception: private members are `_camelCase` instead of `mBigCamel`. You may use Android Studios _auto reformat feature_ before sending a PR. -Translations can be contributed on GitHub or via [E-Mail](https://gsantner.net/#contact). You can use Stringlate ([![Translate - with Stringlate](https://img.shields.io/badge/stringlate-translate-green.svg)](https://lonamiwebs.github.io/stringlate/translate?git=https%3A%2F%2Fgithub.com%2Fgsantner%2Fdandelion.git)) to translate the project directly on your Android phone. It allows you to export as E-Mail attachement and to post on GitHub. - -Join our IRC or Matrix channel (bridged) and say hello! Don't be afraid to start talking. [![Chat - Matrix](https://img.shields.io/badge/chat-on%20matrix-blue.svg)](https://matrix.to/#/#dandelion:matrix.org) [![Chat - FreeNode IRC](https://img.shields.io/badge/chat-on%20irc-blue.svg)](https://kiwiirc.com/client/irc.freenode.net/?nick=dandelion-anon|?##dandelion) +Translations can be contributed on GitHub. You can use Stringlate ([![Translate - with Stringlate](https://img.shields.io/badge/stringlate-translate-green.svg)](https://lonamiwebs.github.io/stringlate/translate?git=https%3A%2F%2Fgithub.com%2Fgsantner%2Fdandelion.git)) to translate the project directly on your Android phone. It allows you to export as E-Mail attachement and to post on GitHub. +Join our Matrix channel and say hello! Don't be afraid to start talking. [![Chat - Matrix](https://img.shields.io/badge/chat-on%20matrix-blue.svg)](https://matrix.to/#/#dandelion:matrix.org) Note that the main project members are working on this project for free during leisure time, are mostly busy with their job/university/school, and may not react or start coding immediately. @@ -62,23 +61,21 @@ For more licensing informations, see [`3rd party licenses`](/app/src/main/res/ra ## Screenshots
- - - - - + + + + +
- - - - + + + +
### Notice #### Maintainers -- gsantner ([GitHub](https://github.com/gsantner), [Web](https://gsantner.net/supportme/?project=dandelion&source=readme), [diaspora*](https://pod.geraspora.de/people/d1cbdd70095301341e834860008dbc6c)) - - Bitcoin: [1B9ZyYdQoY9BxMe9dRUEKaZbJWsbQqfXU5](https://gsantner.net/supportme/?project=dandelion&source=readme) +- gsantner ([GitHub](https://github.com/gsantner), [diaspora*](https://pod.geraspora.de/people/d1cbdd70095301341e834860008dbc6c)) - vanitasvitae ([GitHub](https://github.com/vanitasvitae), [diaspora*](https://pod.geraspora.de/people/bbd7af90fbec013213e34860008dbc6c)) - - Bitcoin: 1Ao3W6NaQv3xKppviB7RSFKjHo6PGd8RTy diff --git a/SCREENSHOTS.md b/SCREENSHOTS.md deleted file mode 100644 index 9403120d..00000000 --- a/SCREENSHOTS.md +++ /dev/null @@ -1,16 +0,0 @@ -## Screenshots - -
- - - - - -
- -
- - - - -
diff --git a/app/build.gradle b/app/build.gradle index e0565339..09c8527f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,18 +10,20 @@ android { compileSdkVersion rootProject.ext.version_compileSdk defaultConfig { + resValue "string", "manifest_package_id", "com.github.dfa.diaspora_android" + applicationId "com.github.dfa.diaspora_android" + versionName "1.3.5" + versionCode 46 + vectorDrawables.useSupportLibrary = true + minSdkVersion rootProject.ext.version_minSdk targetSdkVersion rootProject.ext.version_compileSdk buildConfigField "boolean", "IS_TEST_BUILD", "false" buildConfigField "boolean", "IS_GPLAY_BUILD", "false" buildConfigField "String[]", "DETECTED_ANDROID_LOCALES", "${findUsedAndroidLocales()}" + buildConfigField "String", "BUILD_DATE", "\"${getBuildDate()}\"" buildConfigField "String", "GITHASH", "\"${getGitHash()}\"" - - resValue "string", "manifest_package_id", "com.github.dfa.diaspora_android" - applicationId "com.github.dfa.diaspora_android" - versionName "1.2.5" - versionCode 40 - vectorDrawables.useSupportLibrary = true + setProperty("archivesBaseName", applicationId + "-v" + versionCode + "-" + versionName) } flavorDimensions "default" @@ -38,7 +40,7 @@ android { applicationId "net.gsantner.dandelior" } - flavorTest { + flavorAtest { applicationId "net.gsantner.secondlion" versionCode = Integer.parseInt(new Date().format('yyMMdd')) versionName = new Date().format('yyMMdd') @@ -88,8 +90,7 @@ android { } lintOptions { - disable 'MissingTranslation' - disable 'InvalidPackage' + disable 'MissingTranslation', 'InvalidPackage', 'ObsoleteLintCustomCheck', 'DefaultLocale', 'UnusedAttribute', 'VectorRaster', 'InflateParams', 'IconLocation', 'UnusedResources', 'TypographyEllipsis' abortOnError false } } @@ -100,7 +101,7 @@ dependencies { // Jars implementation fileTree(dir: 'libs', include: ['*.jar']) - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' // Android standard libs implementation "com.android.support:appcompat-v7:${version_library_appcompat}" @@ -108,16 +109,19 @@ dependencies { implementation "com.android.support:support-v4:${version_library_appcompat}" implementation "com.android.support:customtabs:${version_library_appcompat}" implementation "com.android.support:cardview-v7:${version_library_appcompat}" + implementation "com.android.support:preference-v7:${version_library_appcompat}" // UI libraries implementation "com.github.DASAR:ShiftColorPicker:v0.5" // Tool libraries + implementation 'commons-io:commons-io:2.6' implementation "info.guardianproject.netcipher:netcipher:${version_library_netcipher}" implementation "info.guardianproject.netcipher:netcipher-webkit:${version_library_netcipher}" + //noinspection AnnotationProcessorOnCompilePath implementation "com.jakewharton:butterknife:${version_library_butterknife}" if (enable_plugin_kotlin) { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$version_plugin_kotlin" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${version_plugin_kotlin}" } // Processors diff --git a/app/src/flavorTest/res/drawable-anydpi-v26/ic_launcher.xml b/app/src/flavorAtest/res/drawable-anydpi-v26/ic_launcher.xml similarity index 100% rename from app/src/flavorTest/res/drawable-anydpi-v26/ic_launcher.xml rename to app/src/flavorAtest/res/drawable-anydpi-v26/ic_launcher.xml diff --git a/app/src/flavorTest/res/drawable-anydpi-v26/ic_launcher_round.xml b/app/src/flavorAtest/res/drawable-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from app/src/flavorTest/res/drawable-anydpi-v26/ic_launcher_round.xml rename to app/src/flavorAtest/res/drawable-anydpi-v26/ic_launcher_round.xml diff --git a/app/src/flavorTest/res/drawable-hdpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from app/src/flavorTest/res/drawable-hdpi/ic_launcher.png rename to app/src/flavorAtest/res/drawable-hdpi/ic_launcher.png diff --git a/app/src/flavorTest/res/drawable-hdpi/ic_launcher_round.png b/app/src/flavorAtest/res/drawable-hdpi/ic_launcher_round.png similarity index 100% rename from app/src/flavorTest/res/drawable-hdpi/ic_launcher_round.png rename to app/src/flavorAtest/res/drawable-hdpi/ic_launcher_round.png diff --git a/app/src/flavorAtest/res/drawable-ldpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 00000000..b85b0c40 Binary files /dev/null and b/app/src/flavorAtest/res/drawable-ldpi/ic_launcher.png differ diff --git a/app/src/flavorTest/res/drawable-mdpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from app/src/flavorTest/res/drawable-mdpi/ic_launcher.png rename to app/src/flavorAtest/res/drawable-mdpi/ic_launcher.png diff --git a/app/src/flavorTest/res/drawable-mdpi/ic_launcher_round.png b/app/src/flavorAtest/res/drawable-mdpi/ic_launcher_round.png similarity index 100% rename from app/src/flavorTest/res/drawable-mdpi/ic_launcher_round.png rename to app/src/flavorAtest/res/drawable-mdpi/ic_launcher_round.png diff --git a/app/src/flavorTest/res/drawable-xhdpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from app/src/flavorTest/res/drawable-xhdpi/ic_launcher.png rename to app/src/flavorAtest/res/drawable-xhdpi/ic_launcher.png diff --git a/app/src/flavorTest/res/drawable-xhdpi/ic_launcher_round.png b/app/src/flavorAtest/res/drawable-xhdpi/ic_launcher_round.png similarity index 100% rename from app/src/flavorTest/res/drawable-xhdpi/ic_launcher_round.png rename to app/src/flavorAtest/res/drawable-xhdpi/ic_launcher_round.png diff --git a/app/src/flavorTest/res/drawable-xxhdpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-xxhdpi/ic_launcher.png similarity index 100% rename from app/src/flavorTest/res/drawable-xxhdpi/ic_launcher.png rename to app/src/flavorAtest/res/drawable-xxhdpi/ic_launcher.png diff --git a/app/src/flavorTest/res/drawable-xxhdpi/ic_launcher_round.png b/app/src/flavorAtest/res/drawable-xxhdpi/ic_launcher_round.png similarity index 100% rename from app/src/flavorTest/res/drawable-xxhdpi/ic_launcher_round.png rename to app/src/flavorAtest/res/drawable-xxhdpi/ic_launcher_round.png diff --git a/app/src/flavorTest/res/drawable-xxxhdpi/ic_launcher.png b/app/src/flavorAtest/res/drawable-xxxhdpi/ic_launcher.png similarity index 100% rename from app/src/flavorTest/res/drawable-xxxhdpi/ic_launcher.png rename to app/src/flavorAtest/res/drawable-xxxhdpi/ic_launcher.png diff --git a/app/src/flavorTest/res/drawable-xxxhdpi/ic_launcher_round.png b/app/src/flavorAtest/res/drawable-xxxhdpi/ic_launcher_round.png similarity index 100% rename from app/src/flavorTest/res/drawable-xxxhdpi/ic_launcher_round.png rename to app/src/flavorAtest/res/drawable-xxxhdpi/ic_launcher_round.png diff --git a/app/src/flavorTest/res/drawable/ic_launcher_background.xml b/app/src/flavorAtest/res/drawable/ic_launcher_background.xml similarity index 100% rename from app/src/flavorTest/res/drawable/ic_launcher_background.xml rename to app/src/flavorAtest/res/drawable/ic_launcher_background.xml diff --git a/app/src/flavorTest/res/drawable/ic_launcher_foreground.xml b/app/src/flavorAtest/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from app/src/flavorTest/res/drawable/ic_launcher_foreground.xml rename to app/src/flavorAtest/res/drawable/ic_launcher_foreground.xml diff --git a/app/src/flavorTest/res/ic_launcher-web.png b/app/src/flavorAtest/res/ic_launcher-web.png similarity index 100% rename from app/src/flavorTest/res/ic_launcher-web.png rename to app/src/flavorAtest/res/ic_launcher-web.png diff --git a/app/src/flavorTest/res/values/strings-flavor.xml b/app/src/flavorAtest/res/values/strings-flavor.xml similarity index 100% rename from app/src/flavorTest/res/values/strings-flavor.xml rename to app/src/flavorAtest/res/values/strings-flavor.xml diff --git a/app/src/flavorDandelior/ic_launcher-web.png b/app/src/flavorDandelior/ic_launcher-web.png index 91d4f752..39789cb4 100644 Binary files a/app/src/flavorDandelior/ic_launcher-web.png and b/app/src/flavorDandelior/ic_launcher-web.png differ diff --git a/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher.png index 63a719ac..07dad0c9 100644 Binary files a/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher_round.png index c64eb6a6..07dad0c9 100644 Binary files a/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-hdpi/ic_launcher_round.png differ diff --git a/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher.png index 5ccf4981..66c10bba 100644 Binary files a/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher_round.png index c0ff8a34..66c10bba 100644 Binary files a/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-ldpi/ic_launcher_round.png differ diff --git a/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher.png index 162c8910..1288f555 100644 Binary files a/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher_round.png index 062b3c81..70ce8fb1 100644 Binary files a/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-mdpi/ic_launcher_round.png differ diff --git a/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher.png index 776b6491..37e164bc 100644 Binary files a/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher_round.png index 948fdea3..d9040fa3 100644 Binary files a/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-xhdpi/ic_launcher_round.png differ diff --git a/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher.png index 16a0c5e3..56e46378 100644 Binary files a/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher_round.png index f0f4e870..56e46378 100644 Binary files a/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher.png b/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher.png index 2e04f097..9fe1d567 100644 Binary files a/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher.png and b/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher.png differ diff --git a/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher_round.png b/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher_round.png index abb14898..9fe1d567 100644 Binary files a/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher_round.png and b/app/src/flavorDandelior/res/drawable-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/flavorTest/res/drawable-ldpi/ic_launcher.png b/app/src/flavorTest/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index a4c4ac0b..00000000 Binary files a/app/src/flavorTest/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ba46503f..2e1a7bd1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" + android:requestLegacyExternalStorage="true" android:theme="@style/DiasporaLight"> - @@ -68,6 +70,7 @@ + diff --git a/app/src/main/java/com/github/dfa/diaspora_android/App.java b/app/src/main/java/com/github/dfa/diaspora_android/App.java index 841730e2..150cb378 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/App.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/App.java @@ -36,6 +36,7 @@ import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; import net.gsantner.opoc.util.AdBlock; import net.gsantner.opoc.util.ContextUtils; +import net.gsantner.opoc.util.ShareUtil; public class App extends Application { private volatile static App app; @@ -51,6 +52,7 @@ public class App extends Application { @Override public void onCreate() { super.onCreate(); + ShareUtil.setFileProviderAuthority(BuildConfig.APPLICATION_ID); app = this; final Context c = getApplicationContext(); appSettings = AppSettings.get(); @@ -58,7 +60,7 @@ public class App extends Application { String a = new ContextUtils(this).bcstr("FLAVOR", ""); a += "__"; - if (appSettings.isAppFirstStart() && "flavorDandelior".equals(new ContextUtils(this).bcstr("FLAVOR", ""))){ + if (appSettings.isAppFirstStart() && "flavorDandelior".equals(new ContextUtils(this).bcstr("FLAVOR", ""))) { appSettings.setAmoledColorMode(true); } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/DiasporaStreamFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/DiasporaStreamFragment.java index b583fffe..03517332 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/DiasporaStreamFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/DiasporaStreamFragment.java @@ -128,7 +128,7 @@ public class DiasporaStreamFragment extends BrowserFragment { @Override public boolean onOptionsItemSelected(MenuItem item) { AppLog.d(this, "StreamFragment.onOptionsItemSelected()"); - ShareUtil shu = new ShareUtil(getContext()).setFileProviderAuthority(BuildConfig.APPLICATION_ID); + ShareUtil shu = new ShareUtil(getContext()); PermissionChecker permc = new PermissionChecker(getActivity()); switch (item.getItemId()) { case R.id.action_reload: { @@ -185,7 +185,7 @@ public class DiasporaStreamFragment extends BrowserFragment { if (permc.mkdirIfStoragePermissionGranted(fileSaveDirectory)) { Bitmap bmp = ShareUtil.getBitmapFromWebView(webView); String filename = "dandelion-" + ShareUtil.SDF_SHORT.format(new Date()) + ".jpg"; - _cu.writeImageToFileJpeg(new File(fileSaveDirectory, filename), bmp); + _cu.writeImageToFile(new File(fileSaveDirectory, filename), bmp); Snackbar.make(webView, getString(R.string.saving_screenshot_as) + " " + filename, Snackbar.LENGTH_LONG).show(); } @@ -195,7 +195,7 @@ public class DiasporaStreamFragment extends BrowserFragment { case R.id.action_share_screenshot: { if (permc.doIfExtStoragePermissionGranted(getString(R.string.screenshot_permission__appspecific))) { - shu.shareImage(ShareUtil.getBitmapFromWebView(webView), Bitmap.CompressFormat.JPEG); + shu.shareImage(ShareUtil.getBitmapFromWebView(webView)); } return true; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 9eb6045a..ba8af918 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -565,12 +565,10 @@ public class MainActivity extends ThemedActivity } else if ("sc_activities".equals(action)) { openDiasporaUrl(urls.getActivityUrl()); return; - } - else if ("sc_contacts".equals(action)) { + } else if ("sc_contacts".equals(action)) { onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_aspects)); return; - } - else if ("sc_tags".equals(action)) { + } else if ("sc_tags".equals(action)) { onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_followed_tags)); return; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java index acda2b0d..0a38744e 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java @@ -271,6 +271,8 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference @Override public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) { + AppSettings settings = ((App) getActivity().getApplication()).getSettings(); + DiasporaUrlHelper diasporaUrlHelper = new DiasporaUrlHelper(settings); if (isAdded() && preference.hasKey()) { String key = preference.getKey(); if (key.equals(getString(R.string.pref_key__primary_color__preference_click))) { @@ -279,6 +281,13 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference } else if (key.equals(getString(R.string.pref_key__accent_color__preference_click))) { showColorPickerDialog(2); return true; + } else if (key.equals(getString(R.string.pref_key__manage_theme))) { + Intent intent = new Intent(getActivity(), MainActivity.class); + intent.setAction(MainActivity.ACTION_OPEN_URL); + intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getThemeUrl()); + startActivity(intent); + getActivity().finish(); + return true; } } return super.onPreferenceTreeClick(screen, preference); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java index e0fa9955..3052ea77 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaPodList.java @@ -13,7 +13,7 @@ import java.util.List; /** - * Created by gsantner (https://gsantner.net/ on 30.09.16. + * Created by gsantner (gsantner AT mailbox DOT org on 30.09.16. * DiasporaPodList - List container for DiasporaPod's, with methods to merge with other DiasporaPodLists * DiasporaPod - Data container for a Pod, can include N DiasporaPodUrl's * DiasporaPodUrl - A Url of an DiasporaPod diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaUserProfile.java b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaUserProfile.java index e54b351a..22efea59 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaUserProfile.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/DiasporaUserProfile.java @@ -32,7 +32,7 @@ import org.json.JSONObject; /** * User profile - * Created by gsantner (https://gsantner.net/) on 24.03.16. Part of dandelion*. + * Created by gsantner (gsantner AT mailbox DOT org) on 24.03.16. Part of dandelion*. */ public class DiasporaUserProfile { private static final int MINIMUM_USERPROFILE_LOAD_TIMEDIFF = 5000; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/listener/DiasporaUserProfileChangedListener.java b/app/src/main/java/com/github/dfa/diaspora_android/listener/DiasporaUserProfileChangedListener.java index 644612c4..dc1b67dc 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/listener/DiasporaUserProfileChangedListener.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/listener/DiasporaUserProfileChangedListener.java @@ -21,7 +21,7 @@ package com.github.dfa.diaspora_android.listener; import com.github.dfa.diaspora_android.data.DiasporaUserProfile; /** - * Created by gsantner (https://gsantner.net/) on 26.03.16. + * Created by gsantner (gsantner AT mailbox DOT org) on 26.03.16. * Interface that needs to be implemented by classes that listen for Profile related changes */ public interface DiasporaUserProfileChangedListener { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java index aa885038..abb31703 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java @@ -37,7 +37,7 @@ import butterknife.OnItemSelected; /** * Dialog that helps the user configure a pod - * Created by gsantner (http://gsantner.net) on 06.10.16. + * Created by gsantner on 06.10.16. */ public class PodSelectionDialog extends ThemedAppCompatDialogFragment { public static final String TAG = "com.github.dfa.diaspora_android.ui.PodSelectionDialog"; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java index 8ae76fea..1ced82bb 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java @@ -37,7 +37,7 @@ import java.util.List; /** * Settings - * Created by gsantner (https://gsantner.net/) on 20.03.16. Part of dandelion*. + * Created by gsantner (gsantner AT mailbox DOT org) on 20.03.16. Part of dandelion*. */ @SuppressWarnings("ConstantConditions") public class AppSettings extends SharedPreferencesPropertyBackend { @@ -363,6 +363,10 @@ public class AppSettings extends SharedPreferencesPropertyBackend { return getBool(R.string.pref_key__open_youtube_external_enabled, true); } + public boolean isSwipeRefreshEnabled() { + return getBool(R.string.pref_key__swipe_refresh_enabled, true); + } + public String getScreenRotation() { return getString(R.string.pref_key__screen_rotation, R.string.rotation_val_system); } @@ -447,6 +451,7 @@ public class AppSettings extends SharedPreferencesPropertyBackend { public boolean isAmoledColorMode() { return getBool(R.string.pref_key__primary_color__amoled_mode, false); } + public void setAmoledColorMode(boolean enable) { setBool(R.string.pref_key__primary_color__amoled_mode, enable); } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java index a283540b..b272dac0 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java @@ -62,6 +62,7 @@ public class DiasporaUrlHelper { public static final String SUBURL_NOTIFICATIONS_MENTIONED = "/notifications?type=mentioned"; public static final String SUBURL_NOTIFICATIONS_RESHARED = "/notifications?type=reshared"; public static final String SUBURL_NOTIFICATIONS_STARTED_SHARING = "/notifications?type=started_sharing"; + public static final String SUBURL_THEME = "/user/edit"; public DiasporaUrlHelper(AppSettings settings) { this.settings = settings; @@ -353,4 +354,13 @@ public class DiasporaUrlHelper { } return app.getString(R.string.aspects); } + + /** + * Return a url that points to the settings of the pod. + * + * @return https://(pod-domain.tld)/user/edit + */ + public String getThemeUrl() { + return getPodUrl() + SUBURL_THEME; + } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java index d28716d4..bfc53fd9 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java @@ -21,6 +21,7 @@ package com.github.dfa.diaspora_android.web; import android.content.Context; import android.content.MutableContextWrapper; import android.os.Bundle; +import android.support.v4.widget.SwipeRefreshLayout; import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; @@ -33,7 +34,6 @@ import com.github.dfa.diaspora_android.ui.theme.ThemeHelper; import com.github.dfa.diaspora_android.ui.theme.ThemedFragment; import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppSettings; -import android.support.v4.widget.SwipeRefreshLayout;//pull to refresh /** * Fragment with a webView and a ProgressBar. @@ -94,9 +94,16 @@ public class BrowserFragment extends ThemedFragment { this.setRetainInstance(true); //pull to refresh - swipe = view.findViewById(R.id.swipe); - swipe.setOnRefreshListener(() -> reloadUrl()); - swipe.setDistanceToTriggerSync(2000); + swipe = view.findViewById(R.id.swipe); + swipe.setDistanceToTriggerSync(2000); + swipe.setOnRefreshListener(() -> reloadUrl()); + if (appSettings.isSwipeRefreshEnabled()) { + swipe.setEnabled(true); + } else { + swipe.setRefreshing(false); + swipe.setEnabled(false); + return; + } } @Override diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/ContextMenuWebView.java b/app/src/main/java/com/github/dfa/diaspora_android/web/ContextMenuWebView.java index 277b2caa..e1194c9e 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/ContextMenuWebView.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/ContextMenuWebView.java @@ -78,7 +78,7 @@ public class ContextMenuWebView extends NestedWebView { public boolean onMenuItemClick(MenuItem item) { HitTestResult result = getHitTestResult(); String url = result.getExtra(); - final ShareUtil shu = new ShareUtil(context).setFileProviderAuthority(BuildConfig.APPLICATION_ID); + final ShareUtil shu = new ShareUtil(context); final PermissionChecker permc = new PermissionChecker(parentActivity); final AppSettings appSettings = new AppSettings(context); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/CustomWebViewClient.java b/app/src/main/java/com/github/dfa/diaspora_android/web/CustomWebViewClient.java index 848e1b65..5e0011d8 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/CustomWebViewClient.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/CustomWebViewClient.java @@ -19,7 +19,6 @@ package com.github.dfa.diaspora_android.web; import android.annotation.TargetApi; -import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; @@ -60,7 +59,7 @@ public class CustomWebViewClient extends WebViewClient { || url.startsWith("http://" + host)))) { return false; }//make youtube links open external-->never customtab - else if (appSettings.isOpenYoutubeExternalEnabled()&&(url.startsWith("https://youtube.com/") || url.startsWith("https://www.youtube.com/") || url.startsWith("https://m.youtube.com/") || url.startsWith("https://youtu.be/"))){ + else if (appSettings.isOpenYoutubeExternalEnabled() && (url.startsWith("https://youtube.com/") || url.startsWith("https://www.youtube.com/") || url.startsWith("https://m.youtube.com/") || url.startsWith("https://youtu.be/"))) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); view.getContext().startActivity(intent); return true; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/WebHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/web/WebHelper.java index 44cf8ad3..49d10340 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/WebHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/WebHelper.java @@ -32,7 +32,6 @@ import com.github.dfa.diaspora_android.activity.MainActivity; /** * Created by Gregor Santner on 07.08.16. - * http://gsantner.net */ public class WebHelper { diff --git a/app/src/main/java/net/gsantner/opoc/activity/GsFragmentBase.java b/app/src/main/java/net/gsantner/opoc/activity/GsFragmentBase.java index cab23816..479551d9 100644 --- a/app/src/main/java/net/gsantner/opoc/activity/GsFragmentBase.java +++ b/app/src/main/java/net/gsantner/opoc/activity/GsFragmentBase.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * - * License: Apache 2.0 / Commercial + * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * @@ -16,10 +15,15 @@ import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; +import net.gsantner.opoc.android.dummy.MenuItemDummy; import net.gsantner.opoc.util.ContextUtils; import butterknife.ButterKnife; @@ -33,6 +37,7 @@ public abstract class GsFragmentBase extends Fragment { protected ContextUtils _cu; protected Bundle _savedInstanceState = null; + protected Menu _fragmentMenu = new MenuItemDummy.Menu(); @Override public void onCreate(Bundle savedInstanceState) { @@ -51,6 +56,9 @@ public abstract class GsFragmentBase extends Fragment { _cu = new ContextUtils(inflater.getContext()); _cu.setAppLanguage(getAppLanguage()); _savedInstanceState = savedInstanceState; + if (getLayoutResId() == 0) { + Log.e(getClass().getCanonicalName(), "Error: GsFragmentbase.onCreateview: Returned 0 for getLayoutResId"); + } View view = inflater.inflate(getLayoutResId(), container, false); ButterKnife.bind(this, view); return view; @@ -126,4 +134,27 @@ public abstract class GsFragmentBase extends Fragment { } } } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + super.onCreateOptionsMenu(menu, inflater); + _fragmentMenu = menu; + } + + public Menu getFragmentMenu() { + return _fragmentMenu; + } + + /** + * Get the toolbar from activity + * Requires id to be set to @+id/toolbar + */ + @SuppressWarnings("ConstantConditions") + protected Toolbar getToolbar() { + try { + return (Toolbar) getActivity().findViewById(new ContextUtils(getActivity()).getResId(ContextUtils.ResType.ID, "toolbar")); + } catch (Exception e) { + return null; + } + } } diff --git a/app/src/main/java/net/gsantner/opoc/android/dummy/MenuItemDummy.java b/app/src/main/java/net/gsantner/opoc/android/dummy/MenuItemDummy.java new file mode 100644 index 00000000..5d3b5f97 --- /dev/null +++ b/app/src/main/java/net/gsantner/opoc/android/dummy/MenuItemDummy.java @@ -0,0 +1,351 @@ +/* + * Maintained 2017-2023 by Gregor Santner + * License: Creative Commons Zero (CC0 1.0) / Public Domain + * http://creativecommons.org/publicdomain/zero/1.0/ + * + * You can do whatever you want with this. If we meet some day, and you think it is worth it, + * you can buy me a drink in return. Provided as is without any kind of warranty. Do not blame + * or ask for support if something goes wrong. - Gregor Santner + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package net.gsantner.opoc.android.dummy; + +import android.content.ComponentName; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ActionProvider; +import android.view.ContextMenu; +import android.view.KeyEvent; +import android.view.MenuItem; +import android.view.SubMenu; +import android.view.View; + +public class MenuItemDummy implements MenuItem { + private final int _itemId; + + public MenuItemDummy(final int itemId) { + _itemId = itemId; + } + + @Override + public int getItemId() { + return _itemId; + } + + @Override + public int getGroupId() { + return 0; + } + + @Override + public int getOrder() { + return 0; + } + + @Override + public MenuItem setTitle(CharSequence title) { + return null; + } + + @Override + public MenuItem setTitle(int title) { + return null; + } + + @Override + public CharSequence getTitle() { + return null; + } + + @Override + public MenuItem setTitleCondensed(CharSequence title) { + return null; + } + + @Override + public CharSequence getTitleCondensed() { + return null; + } + + @Override + public MenuItem setIcon(Drawable icon) { + return null; + } + + @Override + public MenuItem setIcon(int iconRes) { + return null; + } + + @Override + public Drawable getIcon() { + return null; + } + + @Override + public MenuItem setIntent(Intent intent) { + return null; + } + + @Override + public Intent getIntent() { + return null; + } + + @Override + public MenuItem setShortcut(char numericChar, char alphaChar) { + return null; + } + + @Override + public MenuItem setNumericShortcut(char numericChar) { + return null; + } + + @Override + public char getNumericShortcut() { + return 0; + } + + @Override + public MenuItem setAlphabeticShortcut(char alphaChar) { + return null; + } + + @Override + public char getAlphabeticShortcut() { + return 0; + } + + @Override + public MenuItem setCheckable(boolean checkable) { + return null; + } + + @Override + public boolean isCheckable() { + return false; + } + + @Override + public MenuItem setChecked(boolean checked) { + return null; + } + + @Override + public boolean isChecked() { + return false; + } + + @Override + public MenuItem setVisible(boolean visible) { + return null; + } + + @Override + public boolean isVisible() { + return false; + } + + @Override + public MenuItem setEnabled(boolean enabled) { + return null; + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public boolean hasSubMenu() { + return false; + } + + @Override + public SubMenu getSubMenu() { + return null; + } + + @Override + public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { + return null; + } + + @Override + public ContextMenu.ContextMenuInfo getMenuInfo() { + return null; + } + + @Override + public void setShowAsAction(int actionEnum) { + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + return null; + } + + @Override + public MenuItem setActionView(View view) { + return null; + } + + @Override + public MenuItem setActionView(int resId) { + return null; + } + + @Override + public View getActionView() { + return null; + } + + @Override + public MenuItem setActionProvider(ActionProvider actionProvider) { + return null; + } + + @Override + public ActionProvider getActionProvider() { + return null; + } + + @Override + public boolean expandActionView() { + return false; + } + + @Override + public boolean collapseActionView() { + return false; + } + + @Override + public boolean isActionViewExpanded() { + return false; + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + return null; + } + + + public static class Menu implements android.view.Menu { + @Override + public MenuItem add(CharSequence title) { + return add(0, 0, 0, ""); + } + + @Override + public MenuItem add(int titleRes) { + return add(0, 0, 0, ""); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, CharSequence title) { + return new MenuItemDummy(itemId); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, int titleRes) { + return add(0, 0, 0, ""); + } + + @Override + public SubMenu addSubMenu(CharSequence title) { + return null; + } + + @Override + public SubMenu addSubMenu(int titleRes) { + return null; + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) { + return null; + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { + return null; + } + + @Override + public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { + return 0; + } + + @Override + public void removeItem(int id) { + } + + @Override + public void removeGroup(int groupId) { + } + + @Override + public void clear() { + } + + @Override + public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { + } + + @Override + public void setGroupVisible(int group, boolean visible) { + } + + @Override + public void setGroupEnabled(int group, boolean enabled) { + } + + @Override + public boolean hasVisibleItems() { + return false; + } + + @Override + public MenuItem findItem(int id) { + return null; + } + + @Override + public int size() { + return 0; + } + + @Override + public MenuItem getItem(int index) { + return null; + } + + @Override + public void close() { + } + + @Override + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + return false; + } + + @Override + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return false; + } + + @Override + public boolean performIdentifierAction(int id, int flags) { + return false; + } + + @Override + public void setQwertyMode(boolean isQwerty) { + } + } +} diff --git a/app/src/main/java/net/gsantner/opoc/android/dummy/TextWatcherDummy.java b/app/src/main/java/net/gsantner/opoc/android/dummy/TextWatcherDummy.java new file mode 100644 index 00000000..e6a5ea94 --- /dev/null +++ b/app/src/main/java/net/gsantner/opoc/android/dummy/TextWatcherDummy.java @@ -0,0 +1,58 @@ +/* + * Maintained 2017-2023 by Gregor Santner + * License: Creative Commons Zero (CC0 1.0) / Public Domain + * http://creativecommons.org/publicdomain/zero/1.0/ + * + * You can do whatever you want with this. If we meet some day, and you think it is worth it, + * you can buy me a drink in return. Provided as is without any kind of warranty. Do not blame + * or ask for support if something goes wrong. - Gregor Santner + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package net.gsantner.opoc.android.dummy; + +import android.text.Editable; +import android.text.TextWatcher; + +import net.gsantner.opoc.util.Callback; + +@SuppressWarnings({"unused", "SpellCheckingInspection"}) +public class TextWatcherDummy implements TextWatcher { + @Override + public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { + } + + @Override + public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { + } + + @Override + public void afterTextChanged(final Editable s) { + } + + public static TextWatcher before(final Callback.a4 impl) { + return new TextWatcherDummy() { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + impl.callback(s, start, count, after); + } + }; + } + + public static TextWatcher on(final Callback.a4 impl) { + return new TextWatcherDummy() { + public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { + impl.callback(s, start, before, count); + } + }; + } + + public static TextWatcher after(final Callback.a1 impl) { + return new TextWatcherDummy() { + public void afterTextChanged(final Editable s) { + impl.callback(s); + } + }; + } +} diff --git a/app/src/main/java/net/gsantner/opoc/format/markdown/SimpleMarkdownParser.java b/app/src/main/java/net/gsantner/opoc/format/markdown/SimpleMarkdownParser.java index 1d3f016b..ea117a8a 100644 --- a/app/src/main/java/net/gsantner/opoc/format/markdown/SimpleMarkdownParser.java +++ b/app/src/main/java/net/gsantner/opoc/format/markdown/SimpleMarkdownParser.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2018- - * https://gsantner.net/ + * Maintained 2018-2023 by Gregor Santner * - * License: Apache 2.0 / Commercial + * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * @@ -125,6 +124,20 @@ public class SimpleMarkdownParser { return text; } }; + public final static SmpFilter FILTER_H_TO_SUP = new SmpFilter() { + @Override + public String filter(String text) { + text = text + .replace("

", "") + .replace("

", "") + .replace("

", "") + .replace("

", "") + .replace("

", "") + .replace("

", "") + ; + return text; + } + }; public final static SmpFilter FILTER_NONE = new SmpFilter() { @Override public String filter(String text) { diff --git a/app/src/main/java/net/gsantner/opoc/preference/PropertyBackend.java b/app/src/main/java/net/gsantner/opoc/preference/PropertyBackend.java index 0847021b..f96af499 100644 --- a/app/src/main/java/net/gsantner/opoc/preference/PropertyBackend.java +++ b/app/src/main/java/net/gsantner/opoc/preference/PropertyBackend.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2018- - * https://gsantner.net/ + * Maintained 2018-2023 by Gregor Santner * - * License: Apache 2.0 / Commercial + * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * diff --git a/app/src/main/java/net/gsantner/opoc/preference/SharedPreferencesPropertyBackend.java b/app/src/main/java/net/gsantner/opoc/preference/SharedPreferencesPropertyBackend.java index 665f1058..9f5c948c 100644 --- a/app/src/main/java/net/gsantner/opoc/preference/SharedPreferencesPropertyBackend.java +++ b/app/src/main/java/net/gsantner/opoc/preference/SharedPreferencesPropertyBackend.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2016- - * https://gsantner.net/ + * Maintained 2016-2023 by Gregor Santner * - * License: Apache 2.0 / Commercial + * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * @@ -42,9 +41,12 @@ import android.support.annotation.StringRes; import android.support.v4.content.ContextCompat; import android.text.TextUtils; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; @@ -57,6 +59,8 @@ public class SharedPreferencesPropertyBackend implements PropertyBackend values, final SharedPreferences pref) { @@ -215,9 +223,7 @@ public class SharedPreferencesPropertyBackend implements PropertyBackend getStringListOne(String key, final SharedPreferences pref) { ArrayList ret = new ArrayList<>(); - String value = pref - .getString(key, ARRAY_SEPARATOR) - .replace(ARRAY_SEPARATOR_SUBSTITUTE, ARRAY_SEPARATOR); + String value = getString(key, ARRAY_SEPARATOR).replace(ARRAY_SEPARATOR_SUBSTITUTE, ARRAY_SEPARATOR); if (value.equals(ARRAY_SEPARATOR) || TextUtils.isEmpty(value)) { return ret; } @@ -273,11 +279,15 @@ public class SharedPreferencesPropertyBackend implements PropertyBackend getIntListOne(String key, final SharedPreferences pref) { ArrayList ret = new ArrayList<>(); - String value = pref.getString(key, ARRAY_SEPARATOR); + String value = getString(key, ARRAY_SEPARATOR); if (value.equals(ARRAY_SEPARATOR)) { return ret; } @@ -357,11 +367,15 @@ public class SharedPreferencesPropertyBackend implements PropertyBackend= 23 || begin < 0) ? 0 : begin; end = (end >= 23 || end < 0) ? 0 : end; int h = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); return h >= begin && h <= end; } + + /** + * Substract current datetime by given amount of days + */ + public Date getDateOfDaysAgo(int days) { + Calendar cal = new GregorianCalendar(); + cal.add(Calendar.DATE, -days); + return cal.getTime(); + } + + /** + * Substract current datetime by given amount of days and check if the given date passed + */ + public boolean didDaysPassedSince(Date date, int days) { + if (date == null || days < 0) { + return false; + } + return date.before(getDateOfDaysAgo(days)); + } + + public boolean afterDaysTrue(String key, int daysSinceLastTime, int firstTime, final SharedPreferences... pref) { + Date d = new Date(System.currentTimeMillis()); + if (!contains(key)) { + d = getDateOfDaysAgo(daysSinceLastTime - firstTime); + setLong(key, d.getTime()); + return firstTime < 1; + } else { + d = new Date(getLong(key, d.getTime())); + } + boolean trigger = didDaysPassedSince(d, daysSinceLastTime); + if (trigger) { + setLong(key, new Date(System.currentTimeMillis()).getTime()); + } + return trigger; + } + + public static void clearDebugLog() { + _debugLog = ""; + } + + public static String getDebugLog() { + return _debugLog; + } + + public static synchronized void appendDebugLog(String text) { + _debugLog += "[" + new Date().toString() + "] " + text + "\n"; + } + + public static boolean ne(final String str) { + return str != null && !str.trim().isEmpty(); + } + + public static boolean fexists(final String fp) { + return ne(fp) && (new File(fp)).exists(); + } } diff --git a/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java b/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java index 76284a11..04c3be4f 100644 --- a/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java +++ b/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java @@ -1,7 +1,6 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing diff --git a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java index 8223c35b..cc703f98 100644 --- a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java +++ b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java @@ -1,7 +1,6 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing @@ -10,44 +9,87 @@ #########################################################*/ package net.gsantner.opoc.ui; +import android.annotation.SuppressLint; import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.graphics.Typeface; +import android.os.Build; import android.support.annotation.ColorInt; +import android.support.annotation.DrawableRes; +import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; import android.support.v7.widget.AppCompatEditText; -import android.text.Editable; +import android.support.v7.widget.TooltipCompat; +import android.text.InputType; +import android.text.Spannable; +import android.text.SpannableString; import android.text.TextUtils; -import android.text.TextWatcher; +import android.view.Gravity; import android.view.KeyEvent; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.Window; import android.view.WindowManager; import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.Checkable; import android.widget.Filter; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; +import net.gsantner.opoc.android.dummy.TextWatcherDummy; import net.gsantner.opoc.util.Callback; import net.gsantner.opoc.util.ContextUtils; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; +import java.util.regex.Pattern; -@SuppressWarnings("WeakerAccess") +@SuppressLint("SetTextI18n") public class SearchOrCustomTextDialog { public static class DialogOptions { - public Callback.a1 callback; - public List data = new ArrayList<>(); - public List highlightData = new ArrayList<>(); + + // Callback for search text or text of single item + @Nullable + public Callback.a1 callback = null; + + // Callback for indices of selected items. + // List will contain single item if isMultiSelectEnabled == false; + @Nullable + public Callback.a1> positionCallback = null; + + public boolean isMultiSelectEnabled = false; + public List data = null; + public List highlightData = null; + public List iconsForData; public String messageText = ""; + public String defaultText = ""; public boolean isSearchEnabled = true; public boolean isDarkDialog = false; + public int dialogWidthDp = WindowManager.LayoutParams.MATCH_PARENT; + public int dialogHeightDp = WindowManager.LayoutParams.WRAP_CONTENT; + public int gravity = Gravity.NO_GRAVITY; + public int searchInputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; + public boolean searchIsRegex = false; + public Callback.a1 highlighter = null; + public String extraFilter = null; + public List preSelected = null; + + public Callback.a0 neutralButtonCallback = null; @ColorInt public int textColor = 0xFF000000; @@ -56,124 +98,219 @@ public class SearchOrCustomTextDialog { @StringRes public int cancelButtonText = android.R.string.cancel; @StringRes + public int neutralButtonText = 0; + @StringRes public int okButtonText = android.R.string.ok; @StringRes - public int titleText = android.R.string.untitled; + public int titleText = 0; @StringRes public int searchHintText = android.R.string.search_go; + @DrawableRes + public int clearInputIcon = android.R.drawable.ic_input_delete; + } + + private static class Adapter extends ArrayAdapter { + @LayoutRes + private final int _layout; + private final int _layoutHeight; + private final LayoutInflater _inflater; + private final DialogOptions _dopt; + private final List _filteredItems; + private final Set _selectedItems; + private final Pattern _extraPattern; + + public static Adapter create(final Context context, final DialogOptions dopt) { + return new Adapter(context, dopt, dopt.isMultiSelectEnabled ? android.R.layout.simple_list_item_multiple_choice : android.R.layout.simple_list_item_1, new ArrayList<>()); + } + + private Adapter(final Context context, final DialogOptions dopt, final int layout, final List filteredItems) { + super(context, layout, filteredItems); + _layout = layout; + _filteredItems = filteredItems; + _inflater = LayoutInflater.from(context); + _dopt = dopt; + _extraPattern = (_dopt.extraFilter == null ? null : Pattern.compile(_dopt.extraFilter)); + _selectedItems = new HashSet<>(_dopt.preSelected != null ? _dopt.preSelected : Collections.emptyList()); + ContextUtils cu = new ContextUtils(context); + _layoutHeight = (int) cu.convertDpToPx(36); + cu.freeContextRef(); + } + + @NonNull + @Override + public View getView(int pos, @Nullable View convertView, @NonNull ViewGroup parent) { + final int index = getItem(pos); + + final TextView textView; + if (convertView == null) { + textView = (TextView) _inflater.inflate(_layout, parent, false); + textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + textView.setMinHeight(_layoutHeight); + } else { + textView = (TextView) convertView; + } + + if (textView instanceof Checkable) { + ((Checkable) textView).setChecked(_selectedItems.contains(index)); + } + + if (index >= 0 && _dopt.iconsForData != null && index < _dopt.iconsForData.size() && _dopt.iconsForData.get(index) != 0) { + textView.setCompoundDrawablesWithIntrinsicBounds(_dopt.iconsForData.get(index), 0, 0, 0); + textView.setCompoundDrawablePadding(32); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + textView.setCompoundDrawableTintList(ColorStateList.valueOf(_dopt.isDarkDialog ? Color.WHITE : Color.BLACK)); + } + } else { + textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } + + final CharSequence text = _dopt.data.get(index).toString(); + if (_dopt.highlightData != null) { + final boolean hl = _dopt.highlightData.contains(text); + textView.setTextColor(hl ? _dopt.highlightColor : _dopt.textColor); + textView.setTypeface(null, hl ? Typeface.BOLD : Typeface.NORMAL); + } + + if (_dopt.highlighter != null) { + Spannable s = new SpannableString(text); + _dopt.highlighter.callback(s); + textView.setText(s); + } else { + textView.setText(text); + } + + return textView; + } + + @NonNull + @Override + public Filter getFilter() { + return new Filter() { + @SuppressWarnings("unchecked") + @Override + protected void publishResults(final CharSequence constraint, final FilterResults results) { + _filteredItems.clear(); + _filteredItems.addAll((List) results.values); + notifyDataSetChanged(); + } + + @Override + protected FilterResults performFiltering(final CharSequence constraint) { + final List resList = new ArrayList<>(); + + if (_dopt.data != null) { + final String fil = constraint.toString(); + final boolean emptySearch = fil.isEmpty(); + for (int i = 0; i < _dopt.data.size(); i++) { + final String str = _dopt.data.get(i).toString(); + final boolean matchExtra = (_extraPattern == null) || _extraPattern.matcher(str).find(); + final Locale locale = Locale.getDefault(); + final boolean matchNormal = str.toLowerCase(locale).contains(fil.toLowerCase(locale)); + final boolean matchRegex = _dopt.searchIsRegex && (str.matches(fil)); + if (matchExtra && (matchNormal || matchRegex || emptySearch)) { + resList.add(i); + } + } + } + + final FilterResults res = new FilterResults(); + res.values = resList; + res.count = resList.size(); + return res; + } + }; + } } public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activity, final DialogOptions dopt) { - final List allItems = new ArrayList<>(dopt.data); - final List filteredItems = new ArrayList<>(allItems); final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, dopt.isDarkDialog ? android.support.v7.appcompat.R.style.Theme_AppCompat_Dialog : android.support.v7.appcompat.R.style.Theme_AppCompat_Light_Dialog ); - - final ArrayAdapter listAdapter = new ArrayAdapter(activity, android.R.layout.simple_list_item_1, filteredItems) { - @NonNull - @Override - public View getView(int pos, @Nullable View convertView, @NonNull ViewGroup parent) { - TextView textView = (TextView) super.getView(pos, convertView, parent); - String text = textView.getText().toString(); - - boolean hl = dopt.highlightData.contains(text); - textView.setTextColor(hl ? dopt.highlightColor : dopt.textColor); - textView.setTypeface(null, hl ? Typeface.BOLD : Typeface.NORMAL); - - return textView; - } - - @Override - public Filter getFilter() { - return new Filter() { - @SuppressWarnings("unchecked") - @Override - protected void publishResults(final CharSequence constraint, final FilterResults results) { - filteredItems.clear(); - filteredItems.addAll((List) results.values); - notifyDataSetChanged(); - } - - @Override - protected FilterResults performFiltering(final CharSequence constraint) { - final FilterResults res = new FilterResults(); - final ArrayList resList = new ArrayList<>(); - final String fil = constraint.toString(); - - for (final CharSequence str : allItems) { - if ("".equals(fil) || str.toString().toLowerCase(Locale.getDefault()).contains(fil.toLowerCase(Locale.getDefault()))) { - resList.add(str); - } - } - res.values = resList; - res.count = resList.size(); - return res; - } - }; - } - }; + final Adapter listAdapter = Adapter.create(activity, dopt); final AppCompatEditText searchEditText = new AppCompatEditText(activity); + searchEditText.setText(dopt.defaultText); searchEditText.setSingleLine(true); searchEditText.setMaxLines(1); searchEditText.setTextColor(dopt.textColor); searchEditText.setHintTextColor((dopt.textColor & 0x00FFFFFF) | 0x99000000); searchEditText.setHint(dopt.searchHintText); + searchEditText.setInputType(dopt.searchInputType == 0 ? searchEditText.getInputType() : dopt.searchInputType); + searchEditText.addTextChangedListener(TextWatcherDummy.after((cbEditable) -> listAdapter.getFilter().filter(cbEditable))); - searchEditText.addTextChangedListener(new TextWatcher() { - @Override - public void afterTextChanged(final Editable arg0) { - listAdapter.getFilter().filter(searchEditText.getText()); - } + final ContextUtils cu = new ContextUtils(activity); + final int margin = (int) cu.convertDpToPx(8); + cu.freeContextRef(); - @Override - public void onTextChanged(final CharSequence arg0, final int arg1, final int arg2, final int arg3) { - } + final LinearLayout searchLayout = new LinearLayout(activity); + searchLayout.setOrientation(LinearLayout.HORIZONTAL); - @Override - public void beforeTextChanged(final CharSequence arg0, final int arg1, final int arg2, final int arg3) { - } - }); + LinearLayout.LayoutParams lp; + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1); + lp.gravity = Gravity.START | Gravity.BOTTOM; + searchLayout.addView(searchEditText, lp); + + // 'Button to clear the search box' + final ImageView clearButton = new ImageView(activity); + clearButton.setImageResource(dopt.clearInputIcon); + TooltipCompat.setTooltipText(clearButton, activity.getString(android.R.string.cancel)); + clearButton.setColorFilter(dopt.isDarkDialog ? Color.WHITE : Color.parseColor("#ff505050")); + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 0); + lp.gravity = Gravity.END | Gravity.CENTER_VERTICAL; + lp.setMargins(margin, 0, (int) (margin * 1.5), 0); + searchLayout.addView(clearButton, lp); + clearButton.setOnClickListener((v) -> searchEditText.setText("")); final ListView listView = new ListView(activity); final LinearLayout linearLayout = new LinearLayout(activity); listView.setAdapter(listAdapter); + listView.setVisibility(dopt.data != null && !dopt.data.isEmpty() ? View.VISIBLE : View.GONE); linearLayout.setOrientation(LinearLayout.VERTICAL); + if (dopt.isSearchEnabled) { - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); - ContextUtils cu = new net.gsantner.opoc.util.ContextUtils(listView.getContext()); - int px = (int) (new net.gsantner.opoc.util.ContextUtils(listView.getContext()).convertDpToPx(8)); - lp.setMargins(px, px / 2, px, px / 2); - linearLayout.addView(searchEditText, lp); + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + lp.setMargins(margin, margin / 2, margin, margin / 2); + linearLayout.addView(searchLayout, lp); } + final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0); layoutParams.weight = 1; linearLayout.addView(listView, layoutParams); if (!TextUtils.isEmpty(dopt.messageText)) { dialogBuilder.setMessage(dopt.messageText); } + dialogBuilder.setView(linearLayout) - .setTitle(dopt.titleText) .setOnCancelListener(null) - .setNegativeButton(dopt.cancelButtonText, null); - if (dopt.isSearchEnabled) { + .setNegativeButton(dopt.cancelButtonText, (dialogInterface, i) -> dialogInterface.dismiss()); + + if (dopt.titleText != 0) { + dialogBuilder.setTitle(dopt.titleText); + } + + // Ok button action + if ((dopt.isSearchEnabled && dopt.callback != null) || (dopt.isMultiSelectEnabled)) { dialogBuilder.setPositiveButton(dopt.okButtonText, (dialogInterface, i) -> { - dialogInterface.dismiss(); - if (dopt.callback != null && !TextUtils.isEmpty(searchEditText.getText().toString())) { - dopt.callback.callback(searchEditText.getText().toString()); + final String searchText = dopt.isSearchEnabled ? searchEditText.getText().toString() : null; + if (dopt.positionCallback != null && !listAdapter._selectedItems.isEmpty()) { + final List sel = new ArrayList<>(listAdapter._selectedItems); + Collections.sort(sel); + dopt.positionCallback.callback(sel); + } else if (dopt.callback != null && !TextUtils.isEmpty(searchText)) { + dopt.callback.callback(searchText); } }); } + // Setup neutralbutton + if (dopt.neutralButtonCallback != null && dopt.neutralButtonText != 0) { + dialogBuilder.setNeutralButton(dopt.neutralButtonText, (dialogInterface, i) -> { + dopt.neutralButtonCallback.callback(); + }); + } + final AlertDialog dialog = dialogBuilder.create(); - listView.setOnItemClickListener((parent, view, position, id) -> { - dialog.dismiss(); - if (dopt.callback != null) { - dopt.callback.callback(filteredItems.get(position).toString()); - } - }); searchEditText.setOnKeyListener((keyView, keyCode, keyEvent) -> { if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { @@ -186,9 +323,72 @@ public class SearchOrCustomTextDialog { return false; }); - if (dialog.getWindow() != null) { - dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + Window w; + if ((w = dialog.getWindow()) != null && dopt.isSearchEnabled) { + w.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } dialog.show(); + if ((w = dialog.getWindow()) != null) { + int ds_w = dopt.dialogWidthDp < 100 ? dopt.dialogWidthDp : ((int) (dopt.dialogWidthDp * activity.getResources().getDisplayMetrics().density)); + int ds_h = dopt.dialogHeightDp < 100 ? dopt.dialogHeightDp : ((int) (dopt.dialogHeightDp * activity.getResources().getDisplayMetrics().density)); + w.setLayout(ds_w, ds_h); + } + + if ((w = dialog.getWindow()) != null && dopt.gravity != Gravity.NO_GRAVITY) { + WindowManager.LayoutParams wlp = w.getAttributes(); + wlp.gravity = dopt.gravity; + w.setAttributes(wlp); + } + + if (dopt.isSearchEnabled) { + searchEditText.requestFocus(); + } + if (dopt.defaultText != null) { + listAdapter.getFilter().filter(searchEditText.getText()); + } + + // Helper function to trigger callback with single item + final Callback.b1 directActivate = (position) -> { + final int index = listAdapter._filteredItems.get(position); + dialog.dismiss(); + if (dopt.callback != null) { + dopt.callback.callback(dopt.data.get(index).toString()); + } + if (dopt.positionCallback != null) { + dopt.positionCallback.callback(Collections.singletonList(index)); + } + return true; + }; + + // Helper function to append selection count to OK button + final Button okButton = dialog.getButton(Dialog.BUTTON_POSITIVE); + final String okText = activity.getString(dopt.okButtonText) + (dopt.isMultiSelectEnabled ? " (%d)" : ""); + final Callback.a0 setOkButtonState = () -> { + okButton.setText(okText.replace("%d", Integer.toString(listAdapter._selectedItems.size()))); + }; + + // Set ok button text initially + setOkButtonState.callback(); + + // Item click action + listView.setOnItemClickListener((parent, textView, pos, id) -> { + if (dopt.isMultiSelectEnabled) { + final int index = listAdapter._filteredItems.get(pos); + if (listAdapter._selectedItems.contains(index)) { + listAdapter._selectedItems.remove(index); + } else { + listAdapter._selectedItems.add(index); + } + if (textView instanceof Checkable) { + ((Checkable) textView).setChecked(listAdapter._selectedItems.contains(index)); + } + setOkButtonState.callback(); + } else { + directActivate.callback(pos); + } + }); + + // long click always activates + listView.setOnItemLongClickListener((parent, view, pos, id) -> directActivate.callback(pos)); } } diff --git a/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java b/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java index b7d60918..741b3b76 100644 --- a/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java +++ b/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2016- - * https://gsantner.net/ + * Maintained 2016-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * @@ -11,14 +10,18 @@ package net.gsantner.opoc.util; import android.app.Activity; +import android.app.ActivityManager; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; +import android.content.res.TypedArray; import android.net.Uri; import android.os.Build; +import android.provider.CalendarContract; +import android.support.annotation.ColorInt; import android.support.annotation.StringRes; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; @@ -29,13 +32,16 @@ import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.util.TypedValue; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.webkit.WebView; import android.widget.ScrollView; +import java.util.List; -@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection"}) + +@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "rawtypes", "UnusedReturnValue"}) public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { //######################## //## Members, Constructors @@ -47,6 +53,12 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { _activity = activity; } + @Override + public void freeContextRef() { + super.freeContextRef(); + _activity = null; + } + //######################## //## Methods //######################## @@ -85,9 +97,11 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { } - public void showSnackBar(@StringRes int stringResId, boolean showLong) { - Snackbar.make(_activity.findViewById(android.R.id.content), stringResId, - showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT).show(); + public Snackbar showSnackBar(@StringRes int stringResId, boolean showLong) { + Snackbar s = Snackbar.make(_activity.findViewById(android.R.id.content), stringResId, + showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT); + s.show(); + return s; } public void showSnackBar(@StringRes int stringResId, boolean showLong, @StringRes int actionResId, View.OnClickListener listener) { @@ -97,18 +111,58 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { .show(); } - public void hideSoftKeyboard() { - InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); - if (imm != null && _activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { - imm.hideSoftInputFromWindow(_activity.getCurrentFocus().getWindowToken(), 0); + public ActivityUtils setSoftKeyboardVisibile(boolean visible, View... editView) { + final Activity activity = _activity; + if (activity != null) { + final View v = (editView != null && editView.length > 0) ? (editView[0]) : (activity.getCurrentFocus() != null && activity.getCurrentFocus().getWindowToken() != null ? activity.getCurrentFocus() : null); + final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); + if (v != null && imm != null) { + Runnable r = () -> { + if (visible) { + v.requestFocus(); + imm.showSoftInput(v, InputMethodManager.SHOW_FORCED); + } else { + imm.hideSoftInputFromWindow(v.getWindowToken(), 0); + } + }; + r.run(); + for (int d : new int[]{100, 350}) { + v.postDelayed(r, d); + } + } } + return this; } - public void showSoftKeyboard() { - InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); - if (imm != null && _activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { - imm.showSoftInput(_activity.getCurrentFocus(), InputMethodManager.SHOW_FORCED); + public ActivityUtils hideSoftKeyboard() { + if (_activity != null) { + InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); + if (imm != null && _activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { + imm.hideSoftInputFromWindow(_activity.getCurrentFocus().getWindowToken(), 0); + } } + return this; + } + + public ActivityUtils showSoftKeyboard() { + if (_activity != null) { + InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); + if (imm != null && _activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { + showSoftKeyboard(_activity.getCurrentFocus()); + } + } + return this; + } + + + public ActivityUtils showSoftKeyboard(View textInputView) { + if (_activity != null) { + InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); + if (imm != null && textInputView != null) { + imm.showSoftInput(textInputView, InputMethodManager.SHOW_FORCED); + } + } + return this; } public void showDialogWithHtmlTextView(@StringRes int resTitleId, String html) { @@ -124,11 +178,15 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) - .setTitle(resTitleId).setView(scroll); - dialog.show(); + .setView(scroll); + if (resTitleId != 0) { + dialog.setTitle(resTitleId); + } + dialogFullWidth(dialog.show(), true, false); } public void showDialogWithRawFileInWebView(String fileInRaw, @StringRes int resTitleId) { @@ -138,11 +196,11 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { .setPositiveButton(android.R.string.ok, null) .setTitle(resTitleId) .setView(wv); - dialog.show(); + dialogFullWidth(dialog.show(), true, false); } // Toggle with no param, else set visibility according to first bool - public void toggleStatusbarVisibility(boolean... optionalForceVisible) { + public ActivityUtils toggleStatusbarVisibility(boolean... optionalForceVisible) { WindowManager.LayoutParams attrs = _activity.getWindow().getAttributes(); int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN; if (optionalForceVisible.length == 0) { @@ -153,9 +211,10 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { attrs.flags |= flag; } _activity.getWindow().setAttributes(attrs); + return this; } - public void showGooglePlayEntryForThisApp() { + public ActivityUtils showGooglePlayEntryForThisApp() { String pkgId = "details?id=" + _activity.getPackageName(); Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId)); goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | @@ -167,9 +226,10 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { _activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/" + pkgId))); } + return this; } - public void setStatusbarColor(int color, boolean... fromRes) { + public ActivityUtils setStatusbarColor(int color, boolean... fromRes) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (fromRes != null && fromRes.length > 0 && fromRes[0]) { color = ContextCompat.getColor(_context, color); @@ -177,13 +237,110 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { _activity.getWindow().setStatusBarColor(color); } + return this; } - public void setLauncherActivityEnabled(Class activityClass, boolean enable) { - Context context = _context.getApplicationContext(); - PackageManager pkg = context.getPackageManager(); - ComponentName component = new ComponentName(context, activityClass); - pkg.setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED - , PackageManager.DONT_KILL_APP); + public ActivityUtils setLauncherActivityEnabled(Class activityClass, boolean enable) { + try { + ComponentName component = new ComponentName(_context, activityClass); + _context.getPackageManager().setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); + } catch (Exception ignored) { + } + return this; + } + + public boolean isLauncherEnabled(Class activityClass) { + try { + ComponentName component = new ComponentName(_context, activityClass); + return _context.getPackageManager().getComponentEnabledSetting(component) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED; + } catch (Exception ignored) { + } + return false; + } + + @ColorInt + public Integer getCurrentPrimaryColor() { + TypedValue typedValue = new TypedValue(); + _context.getTheme().resolveAttribute(getResId(ResType.ATTR, "colorPrimary"), typedValue, true); + return typedValue.data; + } + + @ColorInt + public Integer getCurrentPrimaryDarkColor() { + TypedValue typedValue = new TypedValue(); + _context.getTheme().resolveAttribute(getResId(ResType.ATTR, "colorPrimaryDark"), typedValue, true); + return typedValue.data; + } + + @ColorInt + public Integer getCurrentAccentColor() { + TypedValue typedValue = new TypedValue(); + _context.getTheme().resolveAttribute(getResId(ResType.ATTR, "colorAccent"), typedValue, true); + return typedValue.data; + } + + @ColorInt + public Integer getActivityBackgroundColor() { + TypedArray array = _activity.getTheme().obtainStyledAttributes(new int[]{ + android.R.attr.colorBackground, + }); + int c = array.getColor(0, 0xFF0000); + array.recycle(); + return c; + } + + public ActivityUtils startCalendarApp() { + Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); + builder.appendPath("time"); + builder.appendPath(Long.toString(System.currentTimeMillis())); + Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); + _activity.startActivity(intent); + return this; + } + + /** + * Detect if the activity is currently in splitscreen/multiwindow mode + */ + public boolean isInSplitScreenMode() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return _activity.isInMultiWindowMode(); + } + return false; + } + + /** + * Show dialog in full width / show keyboard + * + * @param dialog Get via dialog.show() + */ + public void dialogFullWidth(AlertDialog dialog, boolean fullWidth, boolean showKeyboard) { + try { + Window w; + if (dialog != null && (w = dialog.getWindow()) != null) { + if (fullWidth) { + w.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); + } + if (showKeyboard) { + w.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); + } + } + } catch (Exception ignored) { + } + } + + // Make activity/app not show up in the recents history - call before finish / System.exit + public ActivityUtils removeActivityFromHistory() { + try { + ActivityManager am = (ActivityManager) _activity.getSystemService(Context.ACTIVITY_SERVICE); + if (am != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + List tasks = am.getAppTasks(); + if (tasks != null && !tasks.isEmpty()) { + tasks.get(0).setExcludeFromRecents(true); + } + } + + } catch (Exception ignored) { + } + return this; } } diff --git a/app/src/main/java/net/gsantner/opoc/util/AdBlock.java b/app/src/main/java/net/gsantner/opoc/util/AdBlock.java index 304a4b85..c5c81678 100644 --- a/app/src/main/java/net/gsantner/opoc/util/AdBlock.java +++ b/app/src/main/java/net/gsantner/opoc/util/AdBlock.java @@ -1,7 +1,6 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing @@ -46,8 +45,9 @@ import java.util.Set; /** * Simple Host-Based AdBlocker */ -@SuppressWarnings({"WeakerAccess", "SpellCheckingInspection", "unused"}) +@SuppressWarnings({"WeakerAccess", "SpellCheckingInspection", "unused", "TryFinallyCanBeTryWithResources"}) public class AdBlock { + private static final Object synchronizeObj = new Object(); private static final AdBlock instance = new AdBlock(); public static AdBlock getInstance() { @@ -61,7 +61,9 @@ public class AdBlock { //######################## private final Set _adblockHostsFromRaw = new HashSet<>(); private final Set _adblockHosts = new HashSet<>(); - private boolean _isLoaded; + private final List> _customBlockCallbacks = new ArrayList<>(); + private boolean _isLoaded = false; + private boolean _isAdblockLogging = false; //######################## //## @@ -72,25 +74,47 @@ public class AdBlock { } public boolean isAdHost(String urlS) { + boolean block = false; if (urlS != null && !urlS.isEmpty() && urlS.startsWith("http")) { try { - URI url = new URI(urlS); + URI url; + try { + url = new URI(urlS); + } catch (Exception e) { + url = new URI(urlS.replaceFirst("[?].*", "")); + } String host = url.getHost().trim(); if (host.startsWith("www.") && host.length() >= 4) { host = host.substring(4); } - return _adblockHosts.contains(host) || _adblockHosts.contains("www." + host); + block = _adblockHosts.contains(host) || _adblockHosts.contains("www." + host); + for (Callback.b3 cb : _customBlockCallbacks) { + if (block) { + break; + } + try { + block = cb.callback(url, urlS, host); + } catch (Exception ignored) { + } + } } catch (URISyntaxException e) { e.printStackTrace(); } } - return false; + + if (_isAdblockLogging) { + Log.d(getClass().getSimpleName(), "UrlAllowed-" + (block ? "N" : "Y") + " " + urlS); + } + return block; } public AdBlock reset() { - _adblockHosts.clear(); - _adblockHosts.addAll(_adblockHostsFromRaw); + synchronized (synchronizeObj) { + _adblockHosts.clear(); + _adblockHosts.addAll(_adblockHostsFromRaw); + _customBlockCallbacks.clear(); + } return this; } @@ -102,7 +126,7 @@ public class AdBlock { return new WebResourceResponse("text/plain", "utf-8", new ByteArrayInputStream("".getBytes())); } - public void addBlockedHosts(String... hosts) { + public AdBlock addBlockedHosts(String... hosts) { for (String host : hosts) { if (host != null) { host = host.trim(); @@ -110,23 +134,29 @@ public class AdBlock { host = host.substring(4); } if (!host.startsWith("#") && !host.startsWith("\"")) { - _adblockHosts.add(host); + synchronized (synchronizeObj) { + _adblockHosts.add(host); + } } } } - + return this; } - public void loadHostsFromRawAssetsAsync(final Context context) { - new Thread(new Runnable() { - @Override - public void run() { - try { + public void loadHostsFromRawAssetsAsync(final Context context, final boolean... debugIgnoreAssets) { + if (debugIgnoreAssets != null && debugIgnoreAssets.length > 0 && debugIgnoreAssets[0]) { + _isLoaded = true; + return; + } + + new Thread(() -> { + try { + synchronized (synchronizeObj) { loadHostsFromRawAssets(context); _isLoaded = true; - } catch (IOException e) { - e.printStackTrace(); } + } catch (IOException e) { + e.printStackTrace(); } }).start(); } @@ -172,4 +202,17 @@ public class AdBlock { } return adblockResIds; } + + // URI uri, String url, String host + public AdBlock addCustomBlockCallback(Callback.b3 cb) { + synchronized (synchronizeObj) { + _customBlockCallbacks.add(cb); + } + return this; + } + + public AdBlock setLogEnabled(boolean isAdblockLogging) { + _isAdblockLogging = isAdblockLogging; + return this; + } } diff --git a/app/src/main/java/net/gsantner/opoc/util/Callback.java b/app/src/main/java/net/gsantner/opoc/util/Callback.java index f7933e29..012cb634 100644 --- a/app/src/main/java/net/gsantner/opoc/util/Callback.java +++ b/app/src/main/java/net/gsantner/opoc/util/Callback.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2018- - * https://gsantner.net/ + * Maintained 2018-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * @@ -12,6 +11,11 @@ package net.gsantner.opoc.util; @SuppressWarnings("unused") public class Callback { + + public interface a0 { + void callback(); + } + public interface a1 { void callback(A arg1); } @@ -31,4 +35,52 @@ public class Callback { public interface a5 { void callback(A arg1, B arg2, C arg3, D arg4, E arg5); } + + public interface b0 { + boolean callback(); + } + + public interface b1 { + boolean callback(A arg1); + } + + public interface b2 { + boolean callback(A arg1, B arg2); + } + + public interface b3 { + boolean callback(A arg1, B arg2, C arg3); + } + + public interface b4 { + boolean callback(A arg1, B arg2, C arg3, D arg4); + } + + public interface b5 { + boolean callback(A arg1, B arg2, C arg3, D arg4, E arg5); + } + + public interface s0 { + String callback(); + } + + public interface s1 { + String callback(A arg1); + } + + public interface s2 { + String callback(A arg1, B arg2); + } + + public interface s3 { + String callback(A arg1, B arg2, C arg3); + } + + public interface s4 { + String callback(A arg1, B arg2, C arg3, D arg4); + } + + public interface s5 { + String callback(A arg1, B arg2, C arg3, D arg4, E arg5); + } } diff --git a/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java index 8e7fae98..483461d8 100644 --- a/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java +++ b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2016- - * https://gsantner.net/ + * Maintained 2016-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * @@ -12,6 +11,7 @@ package net.gsantner.opoc.util; import android.annotation.SuppressLint; import android.app.Activity; +import android.app.ActivityManager; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.ActivityNotFoundException; @@ -38,7 +38,10 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; +import android.os.Environment; import android.os.SystemClock; +import android.os.VibrationEffect; +import android.os.Vibrator; import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; @@ -46,8 +49,12 @@ import android.support.annotation.Nullable; import android.support.annotation.RawRes; import android.support.annotation.StringRes; import android.support.graphics.drawable.VectorDrawableCompat; +import android.support.v4.app.ActivityManagerCompat; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; +import android.support.v4.text.TextUtilsCompat; +import android.support.v4.util.Pair; +import android.support.v4.view.ViewCompat; import android.text.Html; import android.text.InputFilter; import android.text.SpannableString; @@ -59,7 +66,9 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; +import android.view.Surface; import android.view.View; +import android.view.WindowManager; import android.webkit.MimeTypeMap; import android.widget.ImageView; import android.widget.TextView; @@ -68,18 +77,21 @@ import net.gsantner.opoc.format.markdown.SimpleMarkdownParser; import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; +import static android.content.Context.VIBRATOR_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.graphics.Bitmap.CompressFormat; -@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "ObsoleteSdkInt", "deprecation", "SpellCheckingInspection"}) +@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "ObsoleteSdkInt", "deprecation", "SpellCheckingInspection", "TryFinallyCanBeTryWithResources", "UnusedAssignment", "UnusedReturnValue"}) public class ContextUtils { // // Members, Constructors @@ -94,6 +106,9 @@ public class ContextUtils { return _context; } + public void freeContextRef() { + _context = null; + } // // Class Methods @@ -108,39 +123,55 @@ public class ContextUtils { * * @return A valid id if the id could be found, else 0 */ - public int getResId(ResType resType, final String name) { - return _context.getResources().getIdentifier(name, resType.name().toLowerCase(), _context.getPackageName()); + public int getResId(final ResType resType, final String name) { + try { + return _context.getResources().getIdentifier(name, resType.name().toLowerCase(), _context.getPackageName()); + } catch (Exception e) { + return 0; + } } /** * Get String by given string ressource id (nuermic) */ - public String rstr(@StringRes int strResId) { - return _context.getString(strResId); + public String rstr(@StringRes final int strResId) { + try { + return _context.getString(strResId); + } catch (Exception e) { + return null; + } } /** * Get String by given string ressource identifier (textual) */ - public String rstr(String strResKey) { + public String rstr(final String strResKey, Object... a0getResKeyAsFallback) { try { return rstr(getResId(ResType.STRING, strResKey)); } catch (Resources.NotFoundException e) { - return null; + return a0getResKeyAsFallback != null && a0getResKeyAsFallback.length > 0 ? strResKey : null; } } /** * Get drawable from given ressource identifier */ - public Drawable rdrawable(@DrawableRes int resId) { - return ContextCompat.getDrawable(_context, resId); + public Drawable rdrawable(@DrawableRes final int resId) { + try { + return ContextCompat.getDrawable(_context, resId); + } catch (Exception e) { + return null; + } } /** * Get color by given color ressource id */ - public int rcolor(@ColorRes int resId) { + public int rcolor(@ColorRes final int resId) { + if (resId == 0) { + Log.e(getClass().getName(), "ContextUtils::rcolor: resId is 0!"); + return Color.BLACK; + } return ContextCompat.getColor(_context, resId); } @@ -166,20 +197,28 @@ public class ContextUtils { * @param intColor The color coded in int * @param withAlpha Optional; Set first bool parameter to true to also include alpha value */ - public String colorToHexString(int intColor, boolean... withAlpha) { + public static String colorToHexString(final int intColor, final boolean... withAlpha) { boolean a = withAlpha != null && withAlpha.length >= 1 && withAlpha[0]; return String.format(a ? "#%08X" : "#%06X", (a ? 0xFFFFFFFF : 0xFFFFFF) & intColor); } + public static String getAndroidVersion() { + return Build.VERSION.RELEASE + " (" + Build.VERSION.SDK_INT + ")"; + } + public String getAppVersionName() { + PackageManager manager = _context.getPackageManager(); try { - PackageManager manager = _context.getPackageManager(); PackageInfo info = manager.getPackageInfo(getPackageIdManifest(), 0); return info.versionName; } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - return "?"; + try { + PackageInfo info = manager.getPackageInfo(getPackageIdReal(), 0); + return info.versionName; + } catch (PackageManager.NameNotFoundException ignored) { + } } + return "?"; } public String getAppInstallationSource() { @@ -188,7 +227,7 @@ public class ContextUtils { src = _context.getPackageManager().getInstallerPackageName(getPackageIdManifest()); } catch (Exception ignored) { } - if (TextUtils.isEmpty(src)) { + if (src == null || src.trim().isEmpty()) { return "Sideloaded"; } else if (src.toLowerCase().contains(".amazon.")) { return "Amazon Appstore"; @@ -196,7 +235,7 @@ public class ContextUtils { switch (src) { case "com.android.vending": case "com.google.android.feedback": { - return "Google Play Store"; + return "Google Play"; } case "org.fdroid.fdroid.privileged": case "org.fdroid.fdroid": { @@ -219,15 +258,16 @@ public class ContextUtils { * Send a {@link Intent#ACTION_VIEW} Intent with given paramter * If the parameter is an string a browser will get triggered */ - public void openWebpageInExternalBrowser(final String url) { - Uri uri = Uri.parse(url); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - intent.addFlags(FLAG_ACTIVITY_NEW_TASK); + public ContextUtils openWebpageInExternalBrowser(final String url) { try { + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + intent.addFlags(FLAG_ACTIVITY_NEW_TASK); _context.startActivity(intent); - } catch (ActivityNotFoundException e) { + } catch (Exception e) { e.printStackTrace(); } + return this; } /** @@ -235,7 +275,7 @@ public class ContextUtils { */ public String getPackageIdManifest() { String pkg = rstr("manifest_package_id"); - return pkg != null ? pkg : _context.getPackageName(); + return !TextUtils.isEmpty(pkg) ? pkg : _context.getPackageName(); } /** @@ -253,23 +293,36 @@ public class ContextUtils { * of the package set in manifest (root element). * Falls back to applicationId of the app which may differ from manifest. */ - public Object getBuildConfigValue(String fieldName) { - String pkg = getPackageIdManifest() + ".BuildConfig"; + public Object getBuildConfigValue(final String fieldName) { + final String pkg = getPackageIdManifest() + ".BuildConfig"; try { Class c = Class.forName(pkg); return c.getField(fieldName).get(null); } catch (Exception e) { e.printStackTrace(); - return null; } + return null; + } + + public List getBuildConfigFields() { + final String pkg = getPackageIdManifest() + ".BuildConfig"; + final List fields = new ArrayList<>(); + try { + for (Field f : Class.forName(pkg).getFields()) { + fields.add(f.getName()); + } + } catch (Exception e) { + e.printStackTrace(); + } + return fields; } /** * Get a BuildConfig bool value */ - public Boolean bcbool(String fieldName, Boolean defaultValue) { + public Boolean bcbool(final String fieldName, final Boolean defaultValue) { Object field = getBuildConfigValue(fieldName); - if (field != null && field instanceof Boolean) { + if (field instanceof Boolean) { return (Boolean) field; } return defaultValue; @@ -278,9 +331,9 @@ public class ContextUtils { /** * Get a BuildConfig string value */ - public String bcstr(String fieldName, String defaultValue) { + public String bcstr(final String fieldName, final String defaultValue) { Object field = getBuildConfigValue(fieldName); - if (field != null && field instanceof String) { + if (field instanceof String) { return (String) field; } return defaultValue; @@ -289,9 +342,9 @@ public class ContextUtils { /** * Get a BuildConfig string value */ - public Integer bcint(String fieldName, int defaultValue) { + public Integer bcint(final String fieldName, final int defaultValue) { Object field = getBuildConfigValue(fieldName); - if (field != null && field instanceof Integer) { + if (field instanceof Integer) { return (Integer) field; } return defaultValue; @@ -311,26 +364,6 @@ public class ContextUtils { return bcbool("IS_FOSS_BUILD", false); } - /** - * Request a bitcoin donation with given details. - * All parameters are awaited as string resource ids - */ - public void showDonateBitcoinRequest(@StringRes final int srBitcoinId, @StringRes final int srBitcoinAmount, @StringRes final int srBitcoinMessage, @StringRes final int srAlternativeDonateUrl) { - if (!isGooglePlayBuild()) { - String btcUri = String.format("bitcoin:%s?amount=%s&label=%s&message=%s", - rstr(srBitcoinId), rstr(srBitcoinAmount), - rstr(srBitcoinMessage), rstr(srBitcoinMessage)); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(btcUri)); - intent.addFlags(FLAG_ACTIVITY_NEW_TASK); - try { - _context.startActivity(intent); - } catch (ActivityNotFoundException e) { - openWebpageInExternalBrowser(rstr(srAlternativeDonateUrl)); - } - } - } - public String readTextfileFromRawRes(@RawRes int rawResId, String linePrefix, String linePostfix) { StringBuilder sb = new StringBuilder(); BufferedReader br = null; @@ -379,8 +412,8 @@ public class ContextUtils { * Check if app with given {@code packageName} is installed */ public boolean isAppInstalled(String packageName) { - PackageManager pm = _context.getApplicationContext().getPackageManager(); try { + PackageManager pm = _context.getApplicationContext().getPackageManager(); pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { @@ -392,17 +425,17 @@ public class ContextUtils { * Restart the current app. Supply the class to start on startup */ public void restartApp(Class classToStart) { - Intent inte = new Intent(_context, classToStart); - PendingIntent inteP = PendingIntent.getActivity(_context, 555, inte, PendingIntent.FLAG_CANCEL_CURRENT); + Intent intent = new Intent(_context, classToStart); + PendingIntent pendi = PendingIntent.getActivity(_context, 555, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) _context.getSystemService(Context.ALARM_SERVICE); if (_context instanceof Activity) { ((Activity) _context).finish(); } if (mgr != null) { - mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, inteP); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendi); } else { - inte.addFlags(FLAG_ACTIVITY_NEW_TASK); - _context.startActivity(inte); + intent.addFlags(FLAG_ACTIVITY_NEW_TASK); + _context.startActivity(intent); } Runtime.getRuntime().exit(0); } @@ -471,19 +504,25 @@ public class ContextUtils { * {@code androidLC} may be in any of the forms: en, de, de-rAt * If given an empty string, the default (system) locale gets loaded */ - public void setAppLanguage(String androidLC) { + public void setAppLanguage(final String androidLC) { Locale locale = getLocaleByAndroidCode(androidLC); + locale = (locale != null && !androidLC.isEmpty()) ? locale : Resources.getSystem().getConfiguration().locale; + setLocale(locale); + } + + public ContextUtils setLocale(final Locale locale) { Configuration config = _context.getResources().getConfiguration(); - config.locale = (locale != null && !androidLC.isEmpty()) - ? locale : Resources.getSystem().getConfiguration().locale; + config.locale = (locale != null ? locale : Resources.getSystem().getConfiguration().locale); _context.getResources().updateConfiguration(config, null); + Locale.setDefault(locale); + return this; } /** * Try to guess if the color on top of the given {@code colorOnBottomInt} * should be light or dark. Returns true if top color should be light */ - public boolean shouldColorOnTopBeLight(@ColorInt int colorOnBottomInt) { + public boolean shouldColorOnTopBeLight(@ColorInt final int colorOnBottomInt) { return 186 > (((0.299 * Color.red(colorOnBottomInt)) + ((0.587 * Color.green(colorOnBottomInt)) + (0.114 * Color.blue(colorOnBottomInt))))); @@ -492,7 +531,7 @@ public class ContextUtils { /** * Convert a html string to an android {@link Spanned} object */ - public Spanned htmlToSpanned(String html) { + public Spanned htmlToSpanned(final String html) { Spanned result; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY); @@ -519,12 +558,76 @@ public class ContextUtils { /** * Get the private directory for the current package (usually /data/data/package.name/) */ - public String getAppDataDir() { + @SuppressWarnings("StatementWithEmptyBody") + public File getAppDataPrivateDir() { + File filesDir; try { - return _context.getPackageManager().getPackageInfo(getPackageIdReal(), 0).applicationInfo.dataDir; + filesDir = new File(new File(_context.getPackageManager().getPackageInfo(getPackageIdReal(), 0).applicationInfo.dataDir), "files"); } catch (PackageManager.NameNotFoundException e) { - return _context.getFilesDir().getParent(); + filesDir = _context.getFilesDir(); } + if (!filesDir.exists() && filesDir.mkdirs()) ; + return filesDir; + } + + /** + * Get public (accessible) appdata folders + */ + @SuppressWarnings("StatementWithEmptyBody") + public List> getAppDataPublicDirs(boolean internalStorageFolder, boolean sdcardFolders, boolean storageNameWithoutType) { + List> dirs = new ArrayList<>(); + for (File externalFileDir : ContextCompat.getExternalFilesDirs(_context, null)) { + if (externalFileDir == null || Environment.getExternalStorageDirectory() == null) { + continue; + } + boolean isInt = externalFileDir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()); + boolean add = (internalStorageFolder && isInt) || (sdcardFolders && !isInt); + if (add) { + dirs.add(new Pair<>(externalFileDir, getStorageName(externalFileDir, storageNameWithoutType))); + if (!externalFileDir.exists() && externalFileDir.mkdirs()) ; + } + } + return dirs; + } + + public String getStorageName(final File externalFileDir, final boolean storageNameWithoutType) { + boolean isInt = externalFileDir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()); + + String[] split = externalFileDir.getAbsolutePath().split("/"); + if (split.length > 2) { + return isInt ? (storageNameWithoutType ? "Internal Storage" : "") : (storageNameWithoutType ? split[2] : ("SD Card (" + split[2] + ")")); + } else { + return "Storage"; + } + } + + public List> getStorages(final boolean internalStorageFolder, final boolean sdcardFolders) { + List> storages = new ArrayList<>(); + for (Pair pair : getAppDataPublicDirs(internalStorageFolder, sdcardFolders, true)) { + if (pair.first != null && pair.first.getAbsolutePath().lastIndexOf("/Android/data") > 0) { + try { + storages.add(new Pair<>(new File(pair.first.getCanonicalPath().replaceFirst("/Android/data.*", "")), pair.second)); + } catch (IOException ignored) { + } + } + } + return storages; + } + + public File getStorageRootFolder(final File file) { + String filepath; + try { + filepath = file.getCanonicalPath(); + } catch (Exception ignored) { + return null; + } + for (Pair storage : getStorages(false, true)) { + //noinspection ConstantConditions + if (filepath.startsWith(storage.first.getAbsolutePath())) { + return storage.first; + } + } + return null; } /** @@ -532,7 +635,7 @@ public class ContextUtils { * * @param files Files and folders to scan */ - public void mediaScannerScanFile(File... files) { + public void mediaScannerScanFile(final File... files) { if (android.os.Build.VERSION.SDK_INT > 19) { String[] paths = new String[files.length]; for (int i = 0; i < files.length; i++) { @@ -581,8 +684,12 @@ public class ContextUtils { /** * Get a {@link Bitmap} out of a {@link DrawableRes} */ - public Bitmap drawableToBitmap(@DrawableRes int drawableId) { - return drawableToBitmap(ContextCompat.getDrawable(_context, drawableId)); + public Bitmap drawableToBitmap(@DrawableRes final int drawableId) { + try { + return drawableToBitmap(ContextCompat.getDrawable(_context, drawableId)); + } catch (Exception e) { + return null; + } } /** @@ -590,7 +697,7 @@ public class ContextUtils { * Specifying a {@code maxDimen} is also possible and a value below 2000 * is recommended, otherwise a {@link OutOfMemoryError} may occur */ - public Bitmap loadImageFromFilesystem(File imagePath, int maxDimen) { + public Bitmap loadImageFromFilesystem(final File imagePath, final int maxDimen) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(imagePath.getAbsolutePath(), options); @@ -606,7 +713,7 @@ public class ContextUtils { * @param maxDimen Max size of the Bitmap (width or height) * @return the scaling factor that needs to be applied to the bitmap */ - public int calculateInSampleSize(BitmapFactory.Options options, int maxDimen) { + public int calculateInSampleSize(final BitmapFactory.Options options, final int maxDimen) { // Raw height and width of image int height = options.outHeight; int width = options.outWidth; @@ -622,7 +729,7 @@ public class ContextUtils { * Scale the bitmap so both dimensions are lower or equal to {@code maxDimen} * This keeps the aspect ratio */ - public Bitmap scaleBitmap(Bitmap bitmap, int maxDimen) { + public Bitmap scaleBitmap(final Bitmap bitmap, final int maxDimen) { int picSize = Math.min(bitmap.getHeight(), bitmap.getWidth()); float scale = 1.f * maxDimen / picSize; Matrix matrix = new Matrix(); @@ -630,44 +737,27 @@ public class ContextUtils { return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } - /** - * Write the given {@link Bitmap} to {@code imageFile}, in {@link CompressFormat#JPEG} format - */ - public boolean writeImageToFileJpeg(File imageFile, Bitmap image) { - return writeImageToFile(imageFile, image, Bitmap.CompressFormat.JPEG, 95); - } - /** * Write the given {@link Bitmap} to filesystem * * @param targetFile The file to be written in - * @param image The image as android {@link Bitmap} - * @param format One format of {@link CompressFormat}, null will determine based on filename - * @param quality Quality level, defaults to 95 + * @param image Android {@link Bitmap} * @return True if writing was successful */ - public boolean writeImageToFile(File targetFile, Bitmap image, CompressFormat format, Integer quality) { + public boolean writeImageToFile(final File targetFile, final Bitmap image, Integer... a0quality) { + final int quality = (a0quality != null && a0quality.length > 0 && a0quality[0] >= 0 && a0quality[0] <= 100) ? a0quality[0] : 70; + final String lc = targetFile.getAbsolutePath().toLowerCase(Locale.ROOT); + final CompressFormat format = lc.endsWith(".webp") ? CompressFormat.WEBP : (lc.endsWith(".png") ? CompressFormat.PNG : CompressFormat.JPEG); + + boolean ok = false; File folder = new File(targetFile.getParent()); - if (quality == null || quality < 0 || quality > 100) { - quality = 95; - } - if (format == null) { - format = CompressFormat.JPEG; - String lc = targetFile.getAbsolutePath().toLowerCase(Locale.ROOT); - if (lc.endsWith(".png")) { - format = CompressFormat.PNG; - } - if (lc.endsWith(".webp")) { - format = CompressFormat.WEBP; - } - } if (folder.exists() || folder.mkdirs()) { FileOutputStream stream = null; try { - stream = new FileOutputStream(targetFile); // overwrites this image every time + stream = new FileOutputStream(targetFile); image.compress(format, quality, stream); - return true; - } catch (FileNotFoundException ignored) { + ok = true; + } catch (Exception ignored) { } finally { try { if (stream != null) { @@ -677,14 +767,18 @@ public class ContextUtils { } } } - return false; + try { + image.recycle(); + } catch (Exception ignored) { + } + return ok; } /** * Draw text in the center of the given {@link DrawableRes} * This may be useful for e.g. badge counts */ - public Bitmap drawTextOnDrawable(@DrawableRes int drawableRes, String text, int textSize) { + public Bitmap drawTextOnDrawable(@DrawableRes final int drawableRes, final String text, final int textSize) { Resources resources = _context.getResources(); float scale = resources.getDisplayMetrics().density; Bitmap bitmap = drawableToBitmap(drawableRes); @@ -709,7 +803,7 @@ public class ContextUtils { * Try to tint all {@link Menu}s {@link MenuItem}s with given color */ @SuppressWarnings("ConstantConditions") - public void tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) { + public void tintMenuItems(final Menu menu, final boolean recurse, @ColorInt final int iconColor) { for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); try { @@ -726,14 +820,14 @@ public class ContextUtils { /** * Loads {@link Drawable} by given {@link DrawableRes} and applies a color */ - public Drawable tintDrawable(@DrawableRes int drawableRes, @ColorInt int color) { + public Drawable tintDrawable(@DrawableRes final int drawableRes, @ColorInt final int color) { return tintDrawable(rdrawable(drawableRes), color); } /** * Tint a {@link Drawable} with given {@code color} */ - public Drawable tintDrawable(@Nullable Drawable drawable, @ColorInt int color) { + public Drawable tintDrawable(@Nullable Drawable drawable, @ColorInt final int color) { if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable.mutate(), color); @@ -745,7 +839,10 @@ public class ContextUtils { * Try to make icons in Toolbar/ActionBars SubMenus visible * This may not work on some devices and it maybe won't work on future android updates */ - public void setSubMenuIconsVisiblity(Menu menu, boolean visible) { + public void setSubMenuIconsVisiblity(final Menu menu, final boolean visible) { + if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) { + return; + } if (menu.getClass().getSimpleName().equals("MenuBuilder")) { try { @SuppressLint("PrivateApi") Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); @@ -778,7 +875,7 @@ public class ContextUtils { public CharSequence filter(CharSequence src, int start, int end, Spanned dest, int dstart, int dend) { if (src.length() < 1) return null; char last = src.charAt(src.length() - 1); - String illegal = "|\\?*<\":>+[]/'"; + String illegal = "|\\?*<\":>[]/'"; if (illegal.indexOf(last) > -1) return src.subSequence(0, src.length() - 1); return null; } @@ -805,7 +902,7 @@ public class ContextUtils { } - public String getMimeType(File file) { + public String getMimeType(final File file) { return getMimeType(Uri.fromFile(file)); } @@ -814,13 +911,17 @@ public class ContextUtils { * Android/Java's own MimeType map is very very small and detection barely works at all * Hence use custom map for some file extensions */ - public String getMimeType(Uri uri) { + public String getMimeType(final Uri uri) { String mimeType = null; if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) { ContentResolver cr = _context.getContentResolver(); mimeType = cr.getType(uri); } else { - String ext = MimeTypeMap.getFileExtensionFromUrl(uri.toString()); + String filename = uri.toString(); + if (filename.endsWith(".jenc")) { + filename = filename.replace(".jenc", ""); + } + String ext = MimeTypeMap.getFileExtensionFromUrl(filename); mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.toLowerCase()); // Try to guess if the recommended methods fail @@ -854,6 +955,63 @@ public class ContextUtils { } return mimeType; } + + public Integer parseColor(final String colorstr) { + if (colorstr == null || colorstr.trim().isEmpty()) { + return null; + } + try { + return Color.parseColor(colorstr); + } catch (IllegalArgumentException ignored) { + return null; + } + } + + public boolean isDeviceGoodHardware() { + try { + ActivityManager activityManager = (ActivityManager) _context.getSystemService(Context.ACTIVITY_SERVICE); + return !ActivityManagerCompat.isLowRamDevice(activityManager) && + Runtime.getRuntime().availableProcessors() >= 4 && + activityManager.getMemoryClass() >= 128; + } catch (Exception ignored) { + return true; + } + } + + // Vibrate device one time by given amount of time, defaulting to 50ms + // Requires in AndroidManifest to work + @SuppressWarnings("UnnecessaryReturnStatement") + @SuppressLint("MissingPermission") + public void vibrate(final int... ms) { + int ms_v = ms != null && ms.length > 0 ? ms[0] : 50; + Vibrator vibrator = ((Vibrator) _context.getSystemService(VIBRATOR_SERVICE)); + if (vibrator == null) { + return; + } else if (Build.VERSION.SDK_INT >= 26) { + vibrator.vibrate(VibrationEffect.createOneShot(ms_v, VibrationEffect.DEFAULT_AMPLITUDE)); + } else { + vibrator.vibrate(ms_v); + } + } + + /* + Check if Wifi is connected. Requires these permissions in AndroidManifest: + + + */ + @SuppressLint("MissingPermission") + public boolean isWifiConnected(boolean... enabledOnly) { + final boolean doEnabledCheckOnly = enabledOnly != null && enabledOnly.length > 0 && enabledOnly[0]; + final ConnectivityManager connectivityManager = (ConnectivityManager) _context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); + final NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + return wifiInfo != null && (doEnabledCheckOnly ? wifiInfo.isAvailable() : wifiInfo.isConnected()); + } + + // Returns if the device is currently in portrait orientation (landscape=false) + public boolean isDeviceOrientationPortrait() { + final int rotation = ((WindowManager) _context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getOrientation(); + return (rotation == Surface.ROTATION_0) || (rotation == Surface.ROTATION_180); + } } diff --git a/app/src/main/java/net/gsantner/opoc/util/FileUtils.java b/app/src/main/java/net/gsantner/opoc/util/FileUtils.java index 642699c1..7dbd1658 100644 --- a/app/src/main/java/net/gsantner/opoc/util/FileUtils.java +++ b/app/src/main/java/net/gsantner/opoc/util/FileUtils.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * @@ -11,11 +10,14 @@ package net.gsantner.opoc.util; +import android.text.TextUtils; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -28,6 +30,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URLConnection; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -35,20 +38,29 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; -@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "deprecation"}) +@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "deprecation", "TryFinallyCanBeTryWithResources"}) public class FileUtils { // Used on methods like copyFile(src, dst) private static final int BUFFER_SIZE = 4096; public static String readTextFileFast(final File file) { try { - return new String(readCloseBinaryStream(new FileInputStream(file))); + return new String(readCloseStreamWithSize(new FileInputStream(file), (int) file.length())); } catch (FileNotFoundException e) { System.err.println("readTextFileFast: File " + file + " not found."); } return ""; } + public static byte[] readCloseStreamWithSize(final InputStream stream, int size) { + byte[] data = new byte[size]; + try (DataInputStream dis = new DataInputStream(stream)) { + dis.readFully(data); + } catch (IOException ignored) { + } + return data; + } + public static String readTextFile(final File file) { try { return readCloseTextStream(new FileInputStream(file)); @@ -230,6 +242,30 @@ public class FileUtils { } } + public static boolean copyFile(final File src, final FileOutputStream os) { + InputStream is = null; + try { + try { + is = new FileInputStream(src); + byte[] buf = new byte[BUFFER_SIZE]; + int len; + while ((len = is.read(buf)) > 0) { + os.write(buf, 0, len); + } + return true; + } finally { + if (is != null) { + is.close(); + } + if (os != null) { + os.close(); + } + } + } catch (IOException ex) { + return false; + } + } + // Returns -1 if the file did not contain any of the needles, otherwise, // the index of which needle was found in the contents of the file. // @@ -356,44 +392,58 @@ public class FileUtils { */ public static String getMimeType(File file) { String guess = null; - if (file != null && file.exists() && file.isFile()) { - InputStream is = null; - try { - is = new BufferedInputStream(new FileInputStream(file)); - guess = URLConnection.guessContentTypeFromStream(is); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ignored) { + if (file != null) { + if (file.exists() && file.isFile()) { + InputStream is = null; + try { + is = new BufferedInputStream(new FileInputStream(file)); + guess = URLConnection.guessContentTypeFromStream(is); + } catch (Exception ignored) { + } finally { + if (is != null) { + try { + is.close(); + } catch (Exception ignored) { + } } } } - if (guess == null || guess.isEmpty()) { - guess = "*/*"; - int dot = file.getName().lastIndexOf(".") + 1; - if (dot > 0 && dot < file.getName().length()) { - switch (file.getName().substring(dot)) { - case "md": - case "markdown": - case "mkd": - case "mdown": - case "mkdn": - case "mdwn": - case "rmd": - guess = "text/markdown"; - break; - case "txt": - guess = "text/plain"; - break; - } + String filename = file.getName().replace(".jenc", ""); + int dot = filename.lastIndexOf(".") + 1; + if (dot > 0 && dot < filename.length()) { + switch (filename.substring(dot)) { + case "md": + case "markdown": + case "mkd": + case "mdown": + case "mkdn": + case "mdwn": + case "rmd": + guess = "text/markdown"; + break; + case "txt": + guess = "text/plain"; + break; + case "webp": + guess = "image/webp"; + break; + case "jpg": + case "jpeg": + guess = "image/jpeg"; + break; + case "png": + guess = "image/png"; + break; } } + + if (TextUtils.isEmpty(guess)) { + guess = URLConnection.guessContentTypeFromName(filename); + } } - return guess; + + return TextUtils.isEmpty(guess) ? "*/*" : guess; } public static boolean isTextFile(File file) { @@ -405,7 +455,7 @@ public class FileUtils { * Analyze given textfile and retrieve multiple information from it * Information is written back to the {@link AtomicInteger} parameters */ - public static void retrieveTextFileSummary(File file, AtomicInteger numCharacters, AtomicInteger numLines) { + public static void retrieveTextFileSummary(File file, AtomicInteger numCharacters, AtomicInteger numLines, AtomicInteger numWords) { BufferedReader br = null; try { br = new BufferedReader(new FileReader(file)); @@ -413,11 +463,15 @@ public class FileUtils { while ((line = br.readLine()) != null) { numLines.getAndIncrement(); numCharacters.getAndSet(numCharacters.get() + line.length()); + if (!line.equals("")) { + numWords.getAndSet(numWords.get() + line.split("\\s+").length); + } } } catch (Exception e) { e.printStackTrace(); numCharacters.set(-1); numLines.set(-1); + numWords.set(-1); } finally { if (br != null) { try { @@ -438,7 +492,36 @@ public class FileUtils { } String[] units = abbreviation ? new String[]{"B", "kB", "MB", "GB", "TB"} : new String[]{"Bytes", "Kilobytes", "Megabytes", "Gigabytes", "Terabytes"}; int unit = (int) (Math.log10(size) / Math.log10(1024)); - return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, unit)) - + " " + units[unit]; + return new DecimalFormat("#,##0.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)).format(size / Math.pow(1024, unit)) + " " + units[unit]; + } + + public static int[] getTimeDiffHMS(long now, long past) { + int[] ret = new int[3]; + long diff = Math.abs(now - past); + ret[0] = (int) (diff / (1000 * 60 * 60)); // hours + ret[1] = (int) (diff / (1000 * 60)) % 60; // min + ret[2] = (int) (diff / 1000) % 60; // sec + return ret; + } + + public static String getHumanReadableByteCountSI(final long bytes) { + if (bytes < 1000) { + return String.format(Locale.getDefault(), "%d%s", bytes, "B"); + } else if (bytes < 1000000) { + return String.format(Locale.getDefault(), "%.2f%s", (bytes / 1000f), "KB"); + } else if (bytes < 1000000000) { + return String.format(Locale.getDefault(), "%.2f%s", (bytes / 1000000f), "MB"); + } else if (bytes < 1000000000000L) { + return String.format(Locale.getDefault(), "%.2f%s", (bytes / 1000000000f), "GB"); + } else { + return String.format(Locale.getDefault(), "%.2f%s", (bytes / 1000000000000f), "TB"); + } + } + + public static File join(File file, String... childSegments) { + for (final String s : childSegments != null ? childSegments : new String[0]) { + file = new File(file, s); + } + return file; } } diff --git a/app/src/main/java/net/gsantner/opoc/util/NetworkUtils.java b/app/src/main/java/net/gsantner/opoc/util/NetworkUtils.java index 50d11664..dc06674e 100644 --- a/app/src/main/java/net/gsantner/opoc/util/NetworkUtils.java +++ b/app/src/main/java/net/gsantner/opoc/util/NetworkUtils.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * @@ -77,7 +76,7 @@ public class NetworkUtils { int written = 0; final float invLength = 1f / connection.getContentLength(); - byte data[] = new byte[BUFFER_SIZE]; + byte[] data = new byte[BUFFER_SIZE]; while ((count = input.read(data)) != -1) { output.write(data, 0, count); if (invLength != -1f && progressCallback != null) { @@ -150,6 +149,7 @@ public class NetworkUtils { return performCall(url, method, data, null); } + @SuppressWarnings("CharsetObjectCanBeUsed") private static String performCall(final URL url, final String method, final String data, final HttpURLConnection existingConnection) { try { final HttpURLConnection connection = existingConnection != null @@ -160,7 +160,7 @@ public class NetworkUtils { if (data != null && !data.isEmpty()) { connection.setDoOutput(true); final OutputStream output = connection.getOutputStream(); - output.write(data.getBytes(Charset.forName(UTF8))); + output.write(data.getBytes(Charset.forName("UTF-8"))); output.flush(); output.close(); } @@ -220,4 +220,14 @@ public class NetworkUtils { return result; } + + public static void httpGetAsync(final String url, final Callback.a1 callback) { + new Thread(() -> { + try { + String c = NetworkUtils.performCall(url, GET); + callback.callback(c); + } catch (Exception ignored) { + } + }).start(); + } } diff --git a/app/src/main/java/net/gsantner/opoc/util/PermissionChecker.java b/app/src/main/java/net/gsantner/opoc/util/PermissionChecker.java index 6c0efd72..be156745 100644 --- a/app/src/main/java/net/gsantner/opoc/util/PermissionChecker.java +++ b/app/src/main/java/net/gsantner/opoc/util/PermissionChecker.java @@ -1,9 +1,8 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * diff --git a/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java b/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java index 13c2589c..dc467500 100644 --- a/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java +++ b/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java @@ -1,15 +1,16 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ + * Maintained 2017-2023 by Gregor Santner * - * License of this file: Apache 2.0 (Commercial upon request) + * License of this file: Apache 2.0 * https://www.apache.org/licenses/LICENSE-2.0 * https://github.com/gsantner/opoc/#licensing * #########################################################*/ package net.gsantner.opoc.util; +import android.Manifest; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; @@ -37,22 +38,33 @@ import android.provider.MediaStore; import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; +import android.support.annotation.StringRes; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.pm.ShortcutInfoCompat; import android.support.v4.content.pm.ShortcutManagerCompat; import android.support.v4.graphics.drawable.IconCompat; +import android.support.v4.provider.DocumentFile; +import android.support.v4.util.Pair; +import android.support.v7.app.AlertDialog; +import android.support.v7.preference.PreferenceManager; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.webkit.WebView; +import android.widget.ImageView; +import android.widget.Toast; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Locale; @@ -65,27 +77,40 @@ import static android.app.Activity.RESULT_OK; * Also allows to parse/fetch information out of shared information. * (M)Permissions are not checked, wrap ShareUtils methods if neccessary */ -@SuppressWarnings({"UnusedReturnValue", "WeakerAccess", "SameParameterValue", "unused", "deprecation", "ConstantConditions", "ObsoleteSdkInt", "SpellCheckingInspection"}) +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess", "SameParameterValue", "unused", "deprecation", "ConstantConditions", "ObsoleteSdkInt", "SpellCheckingInspection", "JavadocReference", "ConstantLocale"}) public class ShareUtil { public final static String EXTRA_FILEPATH = "real_file_path_2"; - public final static SimpleDateFormat SDF_RFC3339_ISH = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm", Locale.getDefault()); - public final static SimpleDateFormat SDF_SHORT = new SimpleDateFormat("yyMMdd-HHmm", Locale.getDefault()); + public final static SimpleDateFormat SDF_RFC3339_ISH = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss", Locale.getDefault()); + public final static SimpleDateFormat SDF_SHORT = new SimpleDateFormat("yyMMdd-HHmmss", Locale.getDefault()); + public final static SimpleDateFormat SDF_IMAGES = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.getDefault()); //20190511-230845 public final static String MIME_TEXT_PLAIN = "text/plain"; + public final static String PREF_KEY__SAF_TREE_URI = "pref_key__saf_tree_uri"; public final static int REQUEST_CAMERA_PICTURE = 50001; public final static int REQUEST_PICK_PICTURE = 50002; + public final static int REQUEST_SAF = 50003; + + public final static int MIN_OVERWRITE_LENGTH = 5; protected static String _lastCameraPictureFilepath; + protected static String _fileProviderAuthority; protected Context _context; - protected String _fileProviderAuthority; protected String _chooserTitle; - public ShareUtil(Context context) { + public ShareUtil(final Context context) { _context = context; _chooserTitle = "➥"; } + public void setContext(final Context c) { + _context = c; + } + + public void freeContextRef() { + _context = null; + } + public String getFileProviderAuthority() { if (TextUtils.isEmpty(_fileProviderAuthority)) { throw new RuntimeException("Error at ShareUtil.getFileProviderAuthority(): No FileProvider authority provided"); @@ -93,13 +118,12 @@ public class ShareUtil { return _fileProviderAuthority; } - public ShareUtil setFileProviderAuthority(String fileProviderAuthority) { + public static void setFileProviderAuthority(final String fileProviderAuthority) { _fileProviderAuthority = fileProviderAuthority; - return this; } - public ShareUtil setChooserTitle(String title) { + public ShareUtil setChooserTitle(final String title) { _chooserTitle = title; return this; } @@ -110,7 +134,7 @@ public class ShareUtil { * @param file the file * @return Uri for this file */ - public Uri getUriByFileProviderAuthority(File file) { + public Uri getUriByFileProviderAuthority(final File file) { return FileProvider.getUriForFile(_context, getFileProviderAuthority(), file); } @@ -120,9 +144,11 @@ public class ShareUtil { * @param intent Thing to be shared * @param chooserText The title text for the chooser, or null for default */ - public void showChooser(Intent intent, String chooserText) { - _context.startActivity(Intent.createChooser(intent, - chooserText != null ? chooserText : _chooserTitle)); + public void showChooser(final Intent intent, final String chooserText) { + try { + _context.startActivity(Intent.createChooser(intent, chooserText != null ? chooserText : _chooserTitle)); + } catch (Exception ignored) { + } } /** @@ -134,7 +160,7 @@ public class ShareUtil { * @param iconRes Icon resource for the item * @param title Title of the item */ - public void createLauncherDesktopShortcut(Intent intent, @DrawableRes int iconRes, String title) { + public void createLauncherDesktopShortcut(final Intent intent, @DrawableRes final int iconRes, final String title) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (intent.getAction() == null) { @@ -159,7 +185,7 @@ public class ShareUtil { * @param iconRes Icon resource for the item * @param title Title of the item */ - public void createLauncherDesktopShortcutLegacy(Intent intent, @DrawableRes int iconRes, String title) { + public void createLauncherDesktopShortcutLegacy(final Intent intent, @DrawableRes final int iconRes, final String title) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (intent.getAction() == null) { @@ -180,7 +206,7 @@ public class ShareUtil { * @param text The text to share * @param mimeType MimeType or null (uses text/plain) */ - public void shareText(String text, @Nullable String mimeType) { + public void shareText(final String text, @Nullable final String mimeType) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); intent.setType(mimeType != null ? mimeType : MIME_TEXT_PLAIN); @@ -193,7 +219,7 @@ public class ShareUtil { * @param file The file to share * @param mimeType The files mime type */ - public boolean shareStream(File file, String mimeType) { + public boolean shareStream(final File file, final String mimeType) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(EXTRA_FILEPATH, file.getAbsolutePath()); intent.setType(mimeType); @@ -203,6 +229,30 @@ public class ShareUtil { intent.putExtra(Intent.EXTRA_STREAM, fileUri); showChooser(intent, null); return true; + } catch (Exception ignored) { // FileUriExposed(API24) / IllegalArgument + } + return false; + } + + /** + * Share the given files as stream with given mime-type + * + * @param files The files to share + * @param mimeType The files mime type. Usally * / * is the best option + */ + public boolean shareStreamMultiple(final Collection files, final String mimeType) { + ArrayList uris = new ArrayList<>(); + for (File file : files) { + File uri = new File(file.toString()); + uris.add(FileProvider.getUriForFile(_context, getFileProviderAuthority(), file)); + } + + try { + Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); + intent.setType(mimeType); + intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); + showChooser(intent, null); + return true; } catch (Exception e) { // FileUriExposed(API24) / IllegalArgument return false; } @@ -211,14 +261,13 @@ public class ShareUtil { /** * Start calendar application to add new event, with given details prefilled */ - public boolean createCalendarAppointment(@Nullable String title, @Nullable String description, @Nullable String location, @Nullable Long... startAndEndTime) { + public boolean createCalendarAppointment(@Nullable final String title, @Nullable final String description, @Nullable final String location, @Nullable final Long... startAndEndTime) { Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI); if (title != null) { intent.putExtra(CalendarContract.Events.TITLE, title); } if (description != null) { - description = description.length() > 800 ? description.substring(0, 800) : description; - intent.putExtra(CalendarContract.Events.DESCRIPTION, description); + intent.putExtra(CalendarContract.Events.DESCRIPTION, (description.length() > 800 ? description.substring(0, 800) : description)); } if (location != null) { intent.putExtra(CalendarContract.Events.EVENT_LOCATION, location); @@ -245,7 +294,7 @@ public class ShareUtil { * * @param file The file to share */ - public boolean viewFileInOtherApp(File file, @Nullable String type) { + public boolean viewFileInOtherApp(final File file, @Nullable final String type) { // On some specific devices the first won't work Uri fileUri = null; try { @@ -270,17 +319,6 @@ public class ShareUtil { return false; } - /** - * Share the given bitmap with given format - * - * @param bitmap Image - * @param format A {@link Bitmap.CompressFormat}, supporting JPEG,PNG,WEBP - * @return if success, true - */ - public boolean shareImage(Bitmap bitmap, Bitmap.CompressFormat format) { - return shareImage(bitmap, format, 95, "SharedImage"); - } - /** * Share the given bitmap with given format * @@ -290,20 +328,36 @@ public class ShareUtil { * @param quality Quality of the exported image [0-100] * @return if success, true */ - public boolean shareImage(Bitmap bitmap, Bitmap.CompressFormat format, int quality, String imageName) { + public boolean shareImage(final Bitmap bitmap, final Integer... quality) { try { - String ext = format.name().toLowerCase(); - File file = File.createTempFile(imageName, "." + ext.replace("jpeg", "jpg"), _context.getExternalCacheDir()); - if (bitmap != null && new ContextUtils(_context).writeImageToFile(file, bitmap, format, quality)) { - shareStream(file, "image/" + ext); + File file = new File(_context.getCacheDir(), getFilenameWithTimestamp()); + if (bitmap != null && new ContextUtils(_context).writeImageToFile(file, bitmap, quality)) { + String x = FileUtils.getMimeType(file); + shareStream(file, FileUtils.getMimeType(file)); return true; } - } catch (IOException e) { - e.printStackTrace(); + } catch (Exception ignored) { } return false; } + /** + * Generate a filename based off current datetime in filename (year, month, day, hour, minute, second) + * Examples: Screenshot_20210208-184301_Trebuchet.png IMG_20190511-230845.jpg + * + * @param A0prefixA1postfixA2ext All arguments are optional and default values are taken for null + * [0] = Prefix [Screenshot/IMG] + * [1] = Postfix [Trebuchet] + * [2] = File extensions [jpg/png/txt] + * @return Filename + */ + public static String getFilenameWithTimestamp(String... A0prefixA1postfixA2ext) { + final String prefix = (((A0prefixA1postfixA2ext != null && A0prefixA1postfixA2ext.length > 0 && !TextUtils.isEmpty(A0prefixA1postfixA2ext[0])) ? A0prefixA1postfixA2ext[0] : "Screenshot") + "_").trim().replaceFirst("^_$", ""); + final String postfix = ("_" + ((A0prefixA1postfixA2ext != null && A0prefixA1postfixA2ext.length > 1 && !TextUtils.isEmpty(A0prefixA1postfixA2ext[1])) ? A0prefixA1postfixA2ext[1] : "")).trim().replaceFirst("^_$", ""); + final String ext = (A0prefixA1postfixA2ext != null && A0prefixA1postfixA2ext.length > 2 && !TextUtils.isEmpty(A0prefixA1postfixA2ext[2])) ? A0prefixA1postfixA2ext[2] : "jpg"; + return String.format("%s%s%s.%s", prefix.trim(), SDF_IMAGES.format(new Date()), postfix.trim(), ext.toLowerCase().replace(".", "").replace("jpeg", "jpg")); + } + /** * Print a {@link WebView}'s contents, also allows to create a PDF * @@ -312,18 +366,25 @@ public class ShareUtil { * @return {{@link PrintJob}} or null */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) - @SuppressWarnings("deprecation") - public PrintJob print(WebView webview, String jobName) { + public PrintJob print(final WebView webview, final String jobName, final boolean... landscape) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - PrintDocumentAdapter printAdapter; - PrintManager printManager = (PrintManager) webview.getContext().getSystemService(Context.PRINT_SERVICE); + final PrintDocumentAdapter printAdapter; + final PrintManager printManager = (PrintManager) _context.getSystemService(Context.PRINT_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { printAdapter = webview.createPrintDocumentAdapter(jobName); } else { printAdapter = webview.createPrintDocumentAdapter(); } + final PrintAttributes.Builder attrib = new PrintAttributes.Builder(); + if (landscape != null && landscape.length > 0 && landscape[0]) { + attrib.setMediaSize(new PrintAttributes.MediaSize("ISO_A4", "android", 11690, 8270)); + attrib.setMinMargins(new PrintAttributes.Margins(0, 0, 0, 0)); + } if (printManager != null) { - return printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build()); + try { + return printManager.print(jobName, printAdapter, attrib.build()); + } catch (Exception ignored) { + } } } else { Log.e(getClass().getName(), "ERROR: Method called on too low Android API version"); @@ -336,8 +397,7 @@ public class ShareUtil { * See {@link #print(WebView, String) print method} */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) - @SuppressWarnings("deprecation") - public PrintJob createPdf(WebView webview, String jobName) { + public PrintJob createPdf(final WebView webview, final String jobName) { return print(webview, jobName); } @@ -349,21 +409,21 @@ public class ShareUtil { * @return A {@link Bitmap} or null */ @Nullable - public static Bitmap getBitmapFromWebView(WebView webView) { + public static Bitmap getBitmapFromWebView(final WebView webView, final boolean... a0fullpage) { try { //Measure WebView's content - int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); - webView.measure(widthMeasureSpec, heightMeasureSpec); - webView.layout(0, 0, webView.getMeasuredWidth(), webView.getMeasuredHeight()); + if (a0fullpage != null && a0fullpage.length > 0 && a0fullpage[0]) { + int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); + int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + webView.measure(widthMeasureSpec, heightMeasureSpec); + webView.layout(0, 0, webView.getMeasuredWidth(), webView.getMeasuredHeight()); + } //Build drawing cache and store its size webView.buildDrawingCache(); - int measuredWidth = webView.getMeasuredWidth(); - int measuredHeight = webView.getMeasuredHeight(); //Creates the bitmap and draw WebView's content on in - Bitmap bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888); + Bitmap bitmap = Bitmap.createBitmap(webView.getMeasuredWidth(), webView.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(bitmap, 0, bitmap.getHeight(), new Paint()); @@ -382,7 +442,7 @@ public class ShareUtil { * Replace (primary) clipboard contents with given {@code text} * @param text Text to be set */ - public boolean setClipboard(CharSequence text) { + public boolean setClipboard(final CharSequence text) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager cm = ((android.text.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE)); if (cm != null) { @@ -393,7 +453,10 @@ public class ShareUtil { android.content.ClipboardManager cm = ((android.content.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE)); if (cm != null) { ClipData clip = ClipData.newPlainText(_context.getPackageName(), text); - cm.setPrimaryClip(clip); + try { + cm.setPrimaryClip(clip); + } catch (Exception ignored) { + } return true; } } @@ -435,7 +498,7 @@ public class ShareUtil { * @param callback Callback after paste try * @param serverOrNothing Supply one or no hastebin server. If empty, the default gets taken */ - public void pasteOnHastebin(final String text, final Callback.a2 callback, String... serverOrNothing) { + public void pasteOnHastebin(final String text, final Callback.a2 callback, final String... serverOrNothing) { final Handler handler = new Handler(); final String server = (serverOrNothing != null && serverOrNothing.length > 0 && serverOrNothing[0] != null) ? serverOrNothing[0] : "https://hastebin.com"; @@ -457,7 +520,7 @@ public class ShareUtil { * @param body Body (content) text to be prefilled in the mail * @param to recipients to be prefilled in the mail */ - public void draftEmail(String subject, String body, String... to) { + public void draftEmail(final String subject, final String body, final String... to) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); if (subject != null) { @@ -478,7 +541,7 @@ public class ShareUtil { * @param receivingIntent The intent from {@link Activity#getIntent()} * @return A file or null if extraction did not succeed */ - public File extractFileFromIntent(Intent receivingIntent) { + public File extractFileFromIntent(final Intent receivingIntent) { String action = receivingIntent.getAction(); String type = receivingIntent.getType(); File tmpf; @@ -513,6 +576,17 @@ public class ShareUtil { fileStr = fileStr.substring(prefix.length()); } } + + // prefix for External storage (/storage/emulated/0 /// /sdcard/) --> e.g. "content://com.amaze.filemanager/storage_root/file.txt" = "/sdcard/file.txt" + for (String prefix : new String[]{"external/", "media/", "storage_root/"}) { + if (fileStr.startsWith((tmps = prefix))) { + File f = new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileStr.substring(tmps.length()))); + if (f.exists()) { + return f; + } + } + } + // Next/OwnCloud Fileprovider for (String fp : new String[]{"org.nextcloud.files", "org.nextcloud.beta.files", "org.owncloud.files"}) { if (fileProvider.equals(fp) && fileStr.startsWith(tmps = "external_files/")) { @@ -527,6 +601,17 @@ public class ShareUtil { if (fileProvider.equals("com.mi.android.globalFileexplorer.myprovider") && fileStr.startsWith(tmps = "external_files")) { return new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + fileStr.substring(tmps.length()))); } + + if (fileStr.startsWith(tmps = "external_files/")) { + for (String prefix : new String[]{Environment.getExternalStorageDirectory().getAbsolutePath(), "/storage", ""}) { + File f = new File(Uri.decode(prefix + "/" + fileStr.substring(tmps.length()))); + if (f.exists()) { + return f; + } + } + + } + // URI Encoded paths with full path after content://package/ if (fileStr.startsWith("/") || fileStr.startsWith("%2F")) { tmpf = new File(Uri.decode(fileStr)); @@ -557,7 +642,16 @@ public class ShareUtil { throw new RuntimeException("Error: ShareUtil.requestGalleryPicture needs an Activity Context."); } Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - ((Activity) _context).startActivityForResult(intent, REQUEST_PICK_PICTURE); + try { + ((Activity) _context).startActivityForResult(intent, REQUEST_PICK_PICTURE); + } catch (Exception ex) { + Toast.makeText(_context, "No gallery app installed!", Toast.LENGTH_SHORT).show(); + } + } + + public String extractFileFromIntentStr(final Intent receivingIntent) { + File f = extractFileFromIntent(receivingIntent); + return f != null ? f.getAbsolutePath() : null; } /** @@ -565,12 +659,13 @@ public class ShareUtil { * Result ({@link String}) will be available from {@link Activity#onActivityResult(int, int, Intent)}. * It has set resultCode to {@link Activity#RESULT_OK} with same requestCode, if successfully * The requested image savepath has to be stored at caller side (not contained in intent), - * it can be retrieved using {@link #extractResultFromActivityResult(int, int, Intent)}, + * it can be retrieved using {@link #extractResultFromActivityResult(int, int, Intent, Activity...)} * returns null if an error happened. * * @param target Path to file to write to, if folder the filename gets app_name + millis + random filename. If null DCIM folder is used. */ - public String requestCameraPicture(File target) { + @SuppressWarnings("RegExpRedundantEscape") + public String requestCameraPicture(final File target) { if (!(_context instanceof Activity)) { throw new RuntimeException("Error: ShareUtil.requestCameraPicture needs an Activity Context."); } @@ -583,7 +678,7 @@ public class ShareUtil { if (target != null && !target.isDirectory()) { photoFile = target; } else { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss", Locale.getDefault()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss", Locale.ENGLISH); File storageDir = target != null ? target : new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "Camera"); String imageFileName = ((new ContextUtils(_context).rstr("app_name")).replaceAll("[^a-zA-Z0-9\\.\\-]", "_") + "_").replace("__", "_") + sdf.format(new Date()); photoFile = new File(storageDir, imageFileName + ".jpg"); @@ -621,7 +716,9 @@ public class ShareUtil { * Forward all arguments from activity. Only requestCodes from {@link ShareUtil} get analyzed. * Also may forward results via local broadcast */ - public Object extractResultFromActivityResult(int requestCode, int resultCode, Intent data) { + @SuppressLint("ApplySharedPref") + public Object extractResultFromActivityResult(final int requestCode, final int resultCode, final Intent data, final Activity... activityOrNull) { + Activity activity = greedyGetActivity(activityOrNull); switch (requestCode) { case REQUEST_CAMERA_PICTURE: { String picturePath = (resultCode == RESULT_OK) ? _lastCameraPictureFilepath : null; @@ -651,6 +748,10 @@ public class ShareUtil { cursor.close(); } + // Try to grab via file extraction method + data.setAction(Intent.ACTION_VIEW); + picturePath = picturePath != null ? picturePath : extractFileFromIntentStr(data); + // Retrieve image from file descriptor / Cloud, e.g.: Google Drive, Picasa if (picturePath == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { @@ -676,6 +777,18 @@ public class ShareUtil { } break; } + + case REQUEST_SAF: { + if (resultCode == RESULT_OK && data != null && data.getData() != null) { + Uri treeUri = data.getData(); + PreferenceManager.getDefaultSharedPreferences(_context).edit().putString(PREF_KEY__SAF_TREE_URI, treeUri.toString()).commit(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + activity.getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } + return treeUri; + } + break; + } } return null; } @@ -684,7 +797,7 @@ public class ShareUtil { * Send a local broadcast (to receive within app), with given action and string-extra+value. * This is a convenience method for quickly sending just one thing. */ - public void sendLocalBroadcastWithStringExtra(String action, String extra, CharSequence value) { + public void sendLocalBroadcastWithStringExtra(final String action, final String extra, final CharSequence value) { Intent intent = new Intent(action); intent.putExtra(extra, value); LocalBroadcastManager.getInstance(_context).sendBroadcast(intent); @@ -698,7 +811,7 @@ public class ShareUtil { * @param filterActions All {@link IntentFilter} actions to filter for * @return The created instance. Has to be unregistered on {@link Activity} lifecycle events. */ - public BroadcastReceiver receiveResultFromLocalBroadcast(Callback.a2 callback, boolean autoUnregister, String... filterActions) { + public BroadcastReceiver receiveResultFromLocalBroadcast(final Callback.a2 callback, final boolean autoUnregister, final String... filterActions) { IntentFilter intentFilter = new IntentFilter(); for (String filterAction : filterActions) { intentFilter.addAction(filterAction); @@ -726,7 +839,7 @@ public class ShareUtil { * * @param file File that should be edited */ - public void requestPictureEdit(File file) { + public void requestPictureEdit(final File file) { Uri uri = getUriByFileProviderAuthority(file); int flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION; @@ -748,9 +861,10 @@ public class ShareUtil { * * @param file Target file * @param mode 1 for picture, 2 for video, anything else for other - * @return + * @return Media URI */ - public Uri getMediaUri(File file, int mode) { + @SuppressWarnings("TryFinallyCanBeTryWithResources") + public Uri getMediaUri(final File file, final int mode) { Uri uri = MediaStore.Files.getContentUri("external"); uri = (mode != 0) ? (mode == 1 ? MediaStore.Images.Media.EXTERNAL_CONTENT_URI : MediaStore.Video.Media.EXTERNAL_CONTENT_URI) : uri; @@ -776,7 +890,7 @@ public class ShareUtil { * which implement the Chrome Custom Tab interface. This method changes * the customtab intent to use an available compatible browser, if available. */ - public void enableChromeCustomTabsForOtherBrowsers(Intent customTabIntent) { + public void enableChromeCustomTabsForOtherBrowsers(final Intent customTabIntent) { String[] checkpkgs = new String[]{ "com.android.chrome", "com.chrome.beta", "com.chrome.dev", "com.google.android.apps.chrome", "org.chromium.chrome", "org.mozilla.fennec_fdroid", "org.mozilla.firefox", "org.mozilla.firefox_beta", "org.mozilla.fennec_aurora", @@ -822,4 +936,280 @@ public class ShareUtil { customTabIntent.setPackage(pkg); } } + + /*** + * Request storage access. The user needs to press "Select storage" at the correct storage. + * @param activity The activity which will receive the result from startActivityForResult + */ + public void requestStorageAccessFramework(final Activity... activity) { + Activity a = greedyGetActivity(activity); + if (a != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION + | Intent.FLAG_GRANT_WRITE_URI_PERMISSION + | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION + | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION + ); + a.startActivityForResult(intent, REQUEST_SAF); + } + } + + /** + * Get storage access framework tree uri. The user must have granted access via {@link #requestStorageAccessFramework(Activity...)} + * + * @return Uri or null if not granted yet + */ + public Uri getStorageAccessFrameworkTreeUri() { + String treeStr = PreferenceManager.getDefaultSharedPreferences(_context).getString(PREF_KEY__SAF_TREE_URI, null); + if (!TextUtils.isEmpty(treeStr)) { + try { + return Uri.parse(treeStr); + } catch (Exception ignored) { + } + } + return null; + } + + /** + * Get mounted storage folder root (by tree uri). The user must have granted access via {@link #requestStorageAccessFramework(Activity...)} + * + * @return File or null if SD not mounted + */ + public File getStorageAccessFolder() { + Uri safUri = getStorageAccessFrameworkTreeUri(); + if (safUri != null) { + String safUriStr = safUri.toString(); + ContextUtils cu = new ContextUtils(_context); + for (Pair storage : cu.getStorages(false, true)) { + @SuppressWarnings("ConstantConditions") String storageFolderName = storage.first.getName(); + if (safUriStr.contains(storageFolderName)) { + return storage.first; + } + } + cu.freeContextRef(); + } + return null; + } + + /** + * Check whether or not a file is under a storage access folder (external storage / SD) + * + * @param file The file object (file/folder) + * @return Wether or not the file is under storage access folder + */ + public boolean isUnderStorageAccessFolder(final File file) { + if (file != null) { + // When file writeable as is, it's the fastest way to learn SAF isn't required + if (file.canWrite()) { + return false; + } + ContextUtils cu = new ContextUtils(_context); + for (Pair storage : cu.getStorages(false, true)) { + if (file.getAbsolutePath().startsWith(storage.first.getAbsolutePath())) { + cu.freeContextRef(); + return true; + } + } + cu.freeContextRef(); + } + return false; + } + + /** + * Greedy extract Activity from parameter or convert context if it's a activity + */ + private Activity greedyGetActivity(final Activity... activity) { + if (activity != null && activity.length != 0 && activity[0] != null) { + return activity[0]; + } + if (_context instanceof Activity) { + return (Activity) _context; + } + return null; + } + + /** + * Check whether or not a file can be written. + * Requires storage access framework permission for external storage (SD) + * + * @param file The file object (file/folder) + * @param isDir Wether or not the given file parameter is a directory + * @return Wether or not the file can be written + */ + public boolean canWriteFile(final File file, final boolean isDir) { + if (file == null) { + return false; + } else if (file.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()) + || file.getAbsolutePath().startsWith(_context.getFilesDir().getAbsolutePath())) { + boolean s1 = isDir && file.getParentFile().canWrite(); + return !isDir && file.getParentFile() != null ? file.getParentFile().canWrite() : file.canWrite(); + } else { + DocumentFile dof = getDocumentFile(file, isDir); + return dof != null && dof.canWrite(); + } + } + + /** + * Get a {@link DocumentFile} object out of a normal java {@link File}. + * When used on a external storage (SD), use {@link #requestStorageAccessFramework(Activity...)} + * first to get access. Otherwise this will fail. + * + * @param file The file/folder to convert + * @param isDir Wether or not file is a directory. For non-existing (to be created) files this info is not known hence required. + * @return A {@link DocumentFile} object or null if file cannot be converted + */ + @SuppressWarnings("RegExpRedundantEscape") + public DocumentFile getDocumentFile(final File file, final boolean isDir) { + // On older versions use fromFile + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { + return DocumentFile.fromFile(file); + } + + // Get ContextUtils to find storageRootFolder + ContextUtils cu = new ContextUtils(_context); + File baseFolderFile = cu.getStorageRootFolder(file); + cu.freeContextRef(); + + String baseFolder = baseFolderFile == null ? null : baseFolderFile.getAbsolutePath(); + boolean originalDirectory = false; + if (baseFolder == null) { + return null; + } + + String relPath = null; + try { + String fullPath = file.getCanonicalPath(); + if (!baseFolder.equals(fullPath)) { + relPath = fullPath.substring(baseFolder.length() + 1); + } else { + originalDirectory = true; + } + } catch (IOException e) { + return null; + } catch (Exception ignored) { + originalDirectory = true; + } + Uri treeUri; + if ((treeUri = getStorageAccessFrameworkTreeUri()) == null) { + return null; + } + DocumentFile dof = DocumentFile.fromTreeUri(_context, treeUri); + if (originalDirectory) { + return dof; + } + String[] parts = relPath.split("\\/"); + for (int i = 0; i < parts.length; i++) { + DocumentFile nextDof = dof.findFile(parts[i]); + if (nextDof == null) { + try { + nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]); + } catch (Exception ignored) { + nextDof = null; + } + } + dof = nextDof; + } + return dof; + } + + public void showMountSdDialog(@StringRes final int title, @StringRes final int description, @DrawableRes final int mountDescriptionGraphic, final Activity... activityOrNull) { + Activity activity = greedyGetActivity(activityOrNull); + if (activity == null) { + return; + } + + // Image viewer + ImageView imv = new ImageView(activity); + imv.setImageResource(mountDescriptionGraphic); + imv.setAdjustViewBounds(true); + + AlertDialog.Builder dialog = new AlertDialog.Builder(activity); + dialog.setView(imv); + dialog.setTitle(title); + dialog.setMessage(_context.getString(description) + "\n\n"); + dialog.setNegativeButton(android.R.string.cancel, null); + dialog.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> requestStorageAccessFramework(activity)); + AlertDialog dialogi = dialog.create(); + dialogi.show(); + } + + @SuppressWarnings({"ResultOfMethodCallIgnored", "StatementWithEmptyBody"}) + public void writeFile(final File file, final boolean isDirectory, final Callback.a2 writeFileCallback) { + try { + FileOutputStream fileOutputStream = null; + ParcelFileDescriptor pfd = null; + final boolean existingEmptyFile = file.canWrite() && file.length() < MIN_OVERWRITE_LENGTH; + final boolean nonExistingCreatableFile = !file.exists() && file.getParentFile().canWrite(); + if (existingEmptyFile || nonExistingCreatableFile) { + if (isDirectory) { + file.mkdirs(); + } else { + fileOutputStream = new FileOutputStream(file); + } + } else { + DocumentFile dof = getDocumentFile(file, isDirectory); + if (dof != null && dof.getUri() != null && dof.canWrite()) { + if (isDirectory) { + // Nothing to do + } else { + pfd = _context.getContentResolver().openFileDescriptor(dof.getUri(), "rwt"); + fileOutputStream = new FileOutputStream(pfd.getFileDescriptor()); + } + } + } + if (writeFileCallback != null) { + writeFileCallback.callback(fileOutputStream != null || (isDirectory && file.exists()), fileOutputStream); + } + if (fileOutputStream != null) { + try { + fileOutputStream.close(); + } catch (Exception ignored) { + } + } + if (pfd != null) { + pfd.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Call telephone number. + * Non direct call, opens up the dialer and pre-sets the telephone number. User needs to press manually. + * Direct call requires M permission granted, also add permissions to manifest: + * + * + * @param telNo The telephone number to call + * @param directCall Direct call number if possible + */ + @SuppressWarnings("SimplifiableConditionalExpression") + public void callTelephoneNumber(final String telNo, final boolean... directCall) { + Activity activity = greedyGetActivity(); + if (activity == null) { + throw new RuntimeException("Error: ShareUtil::callTelephoneNumber needs to be contstructed with activity context"); + } + boolean ldirectCall = (directCall != null && directCall.length > 0) ? directCall[0] : true; + + + if (android.os.Build.VERSION.SDK_INT >= 23 && ldirectCall && activity != null) { + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CALL_PHONE}, 4001); + ldirectCall = false; + } else { + try { + Intent callIntent = new Intent(Intent.ACTION_CALL); + callIntent.setData(Uri.parse("tel:" + telNo)); + activity.startActivity(callIntent); + } catch (Exception ignored) { + ldirectCall = false; + } + } + } + // Show dialer up with telephone number pre-inserted + if (!ldirectCall) { + Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", telNo, null)); + activity.startActivity(intent); + } + } } diff --git a/app/src/main/res/drawable-ldpi/ic_launcher.png b/app/src/main/res/drawable-ldpi/ic_launcher.png index 8e89a6a9..43583ec9 100644 Binary files a/app/src/main/res/drawable-ldpi/ic_launcher.png and b/app/src/main/res/drawable-ldpi/ic_launcher.png differ diff --git a/app/src/main/res/raw/maintainers.md b/app/src/main/res/raw/maintainers.md index 999f1073..7b1bc7f9 100644 --- a/app/src/main/res/raw/maintainers.md +++ b/app/src/main/res/raw/maintainers.md @@ -1,5 +1,5 @@ * Gregor Santner (gsantner) -~° http://gsantner.net +~° https://github.com/gsantner * Paul Schaub (vanitasvitae) ~° https://github.com/vanitasvitae diff --git a/app/src/main/res/values-af/strings.xml b/app/src/main/res/values-af/strings.xml index d6bd4363..4e4a8035 100644 --- a/app/src/main/res/values-af/strings.xml +++ b/app/src/main/res/values-af/strings.xml @@ -1,10 +1,11 @@ - Maak navigasie balk oop Sluit navigasie balk Herlaai + Sluit + Kanselleer Instellings Kennisgewings @@ -13,6 +14,7 @@ Profiel Aspekte Aktiwiteite + Hou van Opgemerk Aantal keer genoem Publiek @@ -24,10 +26,12 @@ Alle kennisgewings Ook Opgemerk Lewer kommentaar op hierdie plasing + Hou van Aantal keer genoem Herdeel Begin deel + Fout: Kon nie lys van pods verkry nie! Bevestiging Wil jy uitgaan? @@ -52,14 +56,41 @@ met mense Voer asseblief \'n naam in Deel skakel adres + Stoor beeld + Deel beeld + Maak in eksterne webleser oop… + Kopieer skakel adres na knipbord + Kopieer beeld adres na knipbord + Kon nie beeld laai nie + Toestemming geweier. + Pod naam + Protokol + Pod adres + Vermiste waarde + Versteek status balk + Wys titel + Voorkoms + Netwerk + Pod verstellings + Gebruiker + Algemeen + Admin + Tema en kleure + Primêre kleur + Kleur van die nutsbalke + Kontras kleur + Kleur van die vorderingsbalk + AMOLED modus + Uitgebreide Kennisgewings + Taal Fontgrootte Normaal @@ -75,6 +106,7 @@ Landskap Laai Tor voorkeure + Volmag Gasheer Poort Toep moet herlaai om volmag te deaktiveer @@ -82,6 +114,11 @@ Persoonlike instellings + Bestuur Hutsmerke + Onvolg Hutsmerke + Verander rekening + Vee Buffer + Vee WebBuffer skoon Diverse Volle herstel @@ -92,7 +129,29 @@ Toepassing Toestel diaspora * Pod + Tope weergawe: %1$s + Android Weergawe%1$s + Toestel naam%1$s + Kodenaam: %1$s + Pod profiel naam: %1$s + Pod domein: %1$s + Verkry die bron + Vertaal hierdie Toep! + Die toepassing is nie in jou taal beskikbaar? Jy kan dit verander! Hoekom help jy ons nie met die vertaling nie? Ons gebruik Stringlate om enigiemand te help om toepassing te vertaal. + Laat ek vertaal + Gee terugvoer! + dandelion * is nog in ontwikkeling, so as jy voorstelle of enige soort terugvoer het, gebruik asseblief ons probleem volger laat ons weet! + Raporteer foute + Deel die toep + Haai! Loer na #dandelion! %1$s - Bemagtig om Youtube links oop te maak in eksterne Toeps - Youtube links + Handhawers + %1$s<br><br>baie dankie! + GNU GPLv3+ Lisensie + Derdeparty biblioteke + Vertel my meer + Bemagtig om Youtube links oop te maak in eksterne Toeps + Youtube links + Verander die tema van jou rekening + Trek om te verfris diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 0336f316..d09bf9c8 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -1,5 +1,4 @@ - @@ -20,6 +19,7 @@ المظهر + عام تغيير لغة التطبيق. اعد فتح التطبيق لتفعيل التغيير diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-az/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-bg/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-bn/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-bs/strings.xml b/app/src/main/res/values-bs/strings.xml index dbdd3fbf..51109f4f 100644 --- a/app/src/main/res/values-bs/strings.xml +++ b/app/src/main/res/values-bs/strings.xml @@ -1,25 +1,41 @@ - + Otvori navigacijsku ladicu + Zatvorite navigacijsku ladicu + Zatvori + Otkaži + Podešavanja + Traži + Popis izmjena + Više + Sakrij statusnu traku + Izgled + Opće + Promijeni jezik programa. Iznova pokrenite program da aktivirate promjenu + Jezik + Osnovni + Razno + O programu + Saradnici diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 84a39af3..3ad40c44 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -1,10 +1,11 @@ - Obre el calaix de navegació Tanca el calaix de navegació Recarrega + Tanca + Cancel·la Configuració Notificacions @@ -200,6 +201,9 @@ diaspora*. Si voleu contribuir, endavant! Actualment som un equip molt petit, de S\'utilitzen les següents biblioteques: Prenem alguna inspiració i codi de LeafPic. Aneu a comprovar-ho, també és programari gratuït! Expliqueu-me més - Activeu-ho per obrir enllaços de Youtube en aplicacions externes - Enllaços de YouTube + Activeu-ho per obrir enllaços de Youtube en aplicacions externes + Enllaços de YouTube + Canvia el tema del vostre compte + Feu lliscar per actualitzar + S\'està lliscant cap avall a la part superior de la pàgina per actualitzar.\nCal que reinicieu l\'aplicació perquè els canvis tinguin efecte. diff --git a/app/src/main/res/values-ckb/strings.xml b/app/src/main/res/values-ckb/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-ckb/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 5969d641..63534efb 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -1,10 +1,11 @@ - Otevøít navigaèní panel Zavøít navigaèní panel Aktualizovat + Konec + Rakovina Nastavení Oznámení @@ -20,6 +21,7 @@ Hledat Kontakty Seznam změn + Statistika Všechna oznámení Také komentováno @@ -29,21 +31,37 @@ Sdílen Začalo sdílení + Error: Nemohl získat seznam podů! + Omlouvám se, musíte být připojeni k internetu, abyste mohli pokračovat dál Potvrzení Chceš opustit aplikaci? Více O aplikaci | Pomoc + Zlaté rány Veřejné aktivity Nahlášení + Sdílejte odkaz jako text + Šablony obrázku webových stránek + Podívejte se na snímek webové stránky + Uložit obrázek + Uložit snímky jako: + Zapnutá adresa … Nový příspěvek Jít nahoru + Hledat štítky nebo osoby Ukončit aplikaci + Pohled na pracovní plochu Sdílet… + tagy + lidmi + Prosím přidejte jméno + Sdílejte adresu odkazu Uložit obrázek Sdílet obrázek Otevřít v externím prohlížeči… Zkopírovat link do schránky + Kopírovat adresu obrázku do schránky Nemohl být načten obrázek @@ -56,7 +74,11 @@ Adresa Podu Chybějící hodnota Zavolat poslední navštívenou stránku ve streamu? + Hide bar at the main view at the view. Schovat statusbar + Zobrazit titul v hlavním pohledu + Zobrazit titul + Launcher shortcut Horní nástrojová lišta načítá stream Pro otevření streamu klikni na práznou plochu v horní nástrojové liště @@ -67,14 +89,20 @@ Obsluha + Navigační šprýmař + Ovládejte viditelnost položek v navigačním šuplíku Uživatel Obecné Administrátor + Téma a zmatek + Ovládání, které barvy jsou používány v průběhu aplikace Primární barva Barva nástrojové lišty Akcentová barva Barva detailů + AMOLED model + Pro procházení barvy s AMOLED zobrazujeme příjemnou černou barvu v mnoha částech aplikace. Rozšířené oznámení Rozšiř oznámení zvonku pomocí výběrového menu, které zobrazuje kategorie oznámení @@ -89,6 +117,7 @@ Obrovské Načítej obrázky + Útok obrázku na např. uložte mobilní data Rotace obrazovky Kontroluj automatickou rotaci @@ -104,15 +133,31 @@ Veď datovou cestu dandelion*, aby se obešla brána Firewall.\nMůže být vyžadován restart. Toto nemusí fungovat na všech přístrojích. Host Port + Při restartu musíte zakázat používání proxy serveru + načtený panel proxy Osobní nastavení + Otevřte nastavení účtu diaspory + Spravte Váš seznam kontaktů + Řídit Hashtagy + Unfollow již následoval hashts Změna konta + Erase local session data and switch to another diaspora* pod/účet + Chcete změnit svůj účet? Vyprázdnit cache + Smazat cache WebView + Automaticky skryjí horní a dolní lišty při každém hodnocení. + Lity rozumových nástrojů + Konečný společný přístup Přidat referenci této aplikace ke sdílenému textu: [via #dandelion] Různé Celkový reset + Podařilo se vám smazat všechna nastavení související s aplikací a přihlásit se ze všech účtů. + Toto přepíše všechna změněná nastavení aplikace do výchozích hodnot a vymaže vás ze všech podů. + Uživatelné základní Adcker může být součástí např. v embedded views. + Blokové reklamy Informace Licence Debugging @@ -133,16 +178,26 @@ dandelion* je svobodný software (free as in Freedom) a řídí se myšlenkami projektu diaspora*. Pokud chceš přispívat, jen do toho! Momentálně jsme velmi malý tým, takže jsme velmi vděční za jakýkoli druh pomoci! Ke zdrojovému kódu Přelož aplikaci! + Pokud si nejste jistí, že jste se rozhodli pro něco, co potřebujete? Chci překládat Dej zpětnou vazbu! dandelion* je stále ve vývoji, takže pokud máš jakékoli návrhy, neváhej nám zanechat zpětnou vazbu pomocí užití našeho bug trackeru! Nahlásit chybu Řekni o aplikaci ostatním! Řekni svým přátelům a rodině o diaspora* a #dadelion! Proč nezačít blogovat o Tvých zkušenostech? Rádi o Tobě uslyšíme! + Sdílejte chuť + Hey! Podívejte se na #dandelion! %1$s Vývojáři Spolupracovníci %1$s<br><br>Děkujeme! GNU GPLv3+ Licence + Knihovny třetí strany + Následující knihovny jsou využívány: + We took some inspiration and code from LeafPic. Řekni mi více + Umožnit otevřít Youtube odkazy na externí aplikace + Youtube odkazy + Změňte téma vašeho účtu + Pull osvěžit diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 6b588930..6d783039 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -1,5 +1,4 @@ - Genindlæs diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ec6e122b..54bc3bbe 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1,10 +1,11 @@ - NavDrawer öffnen NavDrawer schließen Aktualisieren + Schließen + Abbrechen Einstellungen Benachrichtigungen @@ -81,7 +82,9 @@ nachträglich erteilen. Öffne dafür: Systemeinstellungen - Apps - dandelion*. Zuletzt besuchte Seite im Stream aufrufen? Statusleiste in Hauptansicht verstecken Statusleiste verstecken + Titel in der Hauptansicht anzeigen Titel anzeigen + Launcher Verknüpfung Obere Werkzeugleiste lädt Stream Klicks auf leere Flächen der oberen Werkzeugleiste öffnen den Stream @@ -201,4 +204,9 @@ nachträglich erteilen. Öffne dafür: Systemeinstellungen - Apps - dandelion*. Die folgenden Bibliotheken werden genutzt: Wir haben ein wenig bei LeafPic gespickt. Schaut euch das mal an, es handelt sich dabei auch um freie Software! Erzähl mir mehr + Einschalten um YouTube Links in einer externen App zu öffnen + YouTube Links + Thema des Accounts ändern + Pull-To-Refresh + In der Website von ganz oben nach unten ziehen um zu aktualisieren.\nDu musst die App neu starten damit die Änderungen wirksam werden. diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index dbdd3fbf..43d88f4b 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-eo/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2568c56e..603085a5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,10 +1,11 @@ - Abrir el panel de navegación Cerrar el panel de navegación Refrescar + Cerrar + Cancelar Ajustes Notificaciones @@ -198,6 +199,9 @@ Se utilizan las siguientes bibliotecas: Tomamos algo de inspiración y código de LeafPic. ¡Venga, tomad prestado, es software libre también! Saber más - Habilitar para abrir enlaces de Youtube en aplicaciones externas - Enlaces de YouTube + Habilitar para abrir enlaces de Youtube en aplicaciones externas + Enlaces de YouTube + Cambiar el tema de tu cuenta + Tirar para refrescar + Deslizar hacia abajo la parte superior de la página para refrescar.\n Necesita reiniciar la aplicación para que los cambios surtan efecto. diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-et/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index da7249ec..f5cf3963 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index dbdd3fbf..43d88f4b 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-fil/strings.xml b/app/src/main/res/values-fil/strings.xml index dbdd3fbf..04cb116a 100644 --- a/app/src/main/res/values-fil/strings.xml +++ b/app/src/main/res/values-fil/strings.xml @@ -1,8 +1,9 @@ - + Mga Tanawin + Hanapin @@ -10,6 +11,7 @@ + Ayos diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5215249d..b039f5c3 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1,10 +1,11 @@ - Ouvrir le tiroir de navigation Fermer le tiroir de navigation Rafraîchir + Fermer + Annuler Paramètres Notifications @@ -198,4 +199,9 @@ Les bibliothèques suivantes sont utilisées : Nous avons pris des inspirations et du code de LeafPic. Allez voir, c\'est aussi un logiciel libre ! En savoir plus + Autoriser l\'ouverture des liens Youtube par une appli externe + Liens Youtube + Changer le thème de votre compte + Tirer vers le bas pour mettre à jour + Tirez depuis le haut de la page vers le bas pour l\'actualiser.\nVous devez redémarrer l\'application pour que ces changements prennent effet. diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index ca91f3e6..86bd9019 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -1,15 +1,16 @@ - Abrir cadro de navegación Pechar cadro de navegación - Refrescar + Actualizar + Pechar + Cancelar Axustes Notificacións - Conversa - Fío de comentarios + Conversas + Cronoloxía Perfil Aspecto Actividades @@ -28,10 +29,10 @@ Gústame Mencionado Compartido - Comezou a compartir + Xa compartes Problema: non se obtivo a lista de nodos! - Desculpe, precisa unha conexión a internet para esa tarefa + Desculpa, tes que ter conexión a internet para esto Confirmación Quere saír? @@ -54,7 +55,7 @@ Compartir… Etiquetas Persoas - Por favor, engada un nome + Por favor, engade un nome Compartir ligazón Gardar imaxe Compartir imaxe @@ -64,19 +65,19 @@ Non se cargou a imaxe - Debe permitir \"Permiso de acceso a almacenamento\" para gardar capturas. Pode - pechar a aplicación ou reiniciar o dispositivo. Se non permite acceder ao almacenamento pero que utilizar máis tarde a captura de pantalla, poderá permitir posteriormente o acceso na sección de permisos do dispositivo onde pode activar o \"permiso de acceso a almacenamento\" para dandelion*. - Ten que permitir \"Permiso de acceso a almacenamento\" para gardar/subir imaxes. Despois de iso debería - pechar a aplicación ou reiniciar o dispositivo. Se non permite acceder ao almacenamento, para poder gardar imaxes posteriormente, deberá abrir: preferencias do sistema - apps - dandelion* no dispositivo. - Na sección de permisos pode activar o \"permiso de escritura no almacenamento\". + Debes permitir \"Permiso de acceso a almacenamento\" para gardar capturas. Podes + pechar a aplicación ou reiniciar o dispositivo. Se non permites acceder ao almacenamento pero queres utilizar máis tarde a captura de pantalla, poderás permitir posteriormente o acceso na sección de permisos do dispositivo onde podes activar o \"permiso de acceso a almacenamento\" para dandelion*. + Tes que permitir \"Permiso de acceso a almacenamento\" para gardar/subir imaxes. Despois de iso deberías + pechar a aplicación ou reiniciar o dispositivo. Se non permites acceder ao almacenamento, para poder gardar imaxes posteriormente, deberás abrir: preferencias do sistema - apps - dandelion* no dispositivo. + Na sección de permisos podes activar o \"permiso de escritura no almacenamento\". Permiso denegado. - Permiso concedido. Inténteo de novo. + Permiso concedido. Inténtao de novo. Nodo personalizado Nome do nodo Protocolo Enderezo do nodo Faltan datos - Ir a última paxina lida na conversa? + Ir a última páxina lida na conversa? Agochar a barra de estado na vista principal Agochar barra de estado Mostrar título na vista principal @@ -84,7 +85,7 @@ Atallo do lanzador A barra superior carga a conversa - Pulse nun espazo baldeiro na barra superior para abrir a conversa + Preme nun espazo baleiro na barra superior para abrir a conversa Aparencia Rede @@ -93,13 +94,13 @@ Cadro de navegación - Controle a visibiidade das entradas no cadro de navegación + Controla a visibiidade das entradas no cadro de navegación Usuaria Xeral Admin Decorado e cores - Estableza qué cores se utilizan na aplicación + Escolle qué cores se utilizan na aplicación Cor primaria Cor das barras de ferramentas Cor de énfase @@ -109,7 +110,7 @@ Notificacións extendidas Extender a icona da campá de notificación con un menú desplegable que mostre a categoría das notificacións - Cambiar o idioma de esta aplicación. Reinicie para que se aplique o troco + Cambiar o idioma de esta aplicación. Reinicia para que se aplique o troco Idioma Idioma do sistema @@ -133,7 +134,7 @@ Cargar axustes proxy para Tor (Orbot) HTTP Proxy Proxy Habilitar Proxy - Proxy para o tráfico de dandelion* para saltar cortalumes.\nPodería precisar reinicio. Esto podería non funcionar en algúns móbiles. + Proxy para o tráfico de dandelion* para saltar cortalumes.\nPodería precisar reinicio. Esto podería non funcionar nalgúns móbiles. Servidor Porto Precisa reiniciar a app para desactivar o uso do proxy @@ -143,12 +144,12 @@ Axustes personais Abrir os axustes da conta diaspora* - Xestione a súa lista de contactos + Xestiona a lista de contactos Xestionar etiquetas - Deixar de seguir etiquetas que segue + Deixar de seguir etiquetas que segues Mudar de conta Eliminar os datos locais da sesión e cambiar a outro nodo/conta de diaspora* - Esto eliminará todas as cookies e datos de sesión. Seguro que quere mudar de conta? + Esto eliminará todas as cookies e datos de sesión. Seguro que queres mudar de conta? Limpar cache Limpar a cache da VistaWeb Agochar automáticamente as barras superior e inferior mentras desplaza @@ -158,8 +159,8 @@ Varios Restablecer completamente - Eliminar todas os axustes locais do app e desconectar todas as contas - Esto restablecerá todos os axustes da aplicación ao valor por omisión e desconectarao de todos os nodos. As súas imaxes descargadas permanecerán. Seguro que quere proceder? + Eliminar todolos axustes locais da app e desconectar todas as contas + Esto restablecerá todos os axustes da aplicación ao valor por omisión e desconectarate de todolos nodos. As imaxes descargadas permanecerán. Seguro que queres proceder? Activar un AdBlocker básico. Poderían verse anuncios por exemplo en vistas incrustadas Bloquear publicidade Sobre @@ -177,19 +178,19 @@ Nome do perfil do nodo: %1$s Dominio do nodo: %1$s Ficheiro de depuración copiado ao portapapeis - dandelion* é a súa aplicación para a rede social diaspora*. Engade características como barras de ferramentas e soporte para servidores proxy como a rede Tor para a súa experiencia social. + dandelion* é a túa aplicación para a rede social diaspora*. Engade características como barras de ferramentas e soporte para servidores proxy como a rede Tor. Contribúa ao código! - dandelion* é desenvolto libre, libre de Liberdade, e segue o espíritu que marca o proxecto diaspora*. Se quere contribuír, adiante! Por agora somos un equipo pequeno, así que agradecemos calquer tipo de axuda! - Obteña as fontes - Traduza a app! - Non está a aplicación no seu idioma? Pode cambiar eso! Por qué non nos axuda traducíndoa? Utilizamos a plataforma Crowdin para que calquera poida traducir a app. + dandelion* é desenvolta libre, libre de Liberdade, e segue o espíritu que marca o proxecto diaspora*. Se queres contribuír, adiante! Por agora somos un equipo pequeno, así que agradecemos calquer tipo de axuda! + Aquí as fontes + Traduce a app! + Non está a aplicación no teu idioma? Podes cambiar eso! Por qué non nos axudas traducíndoa? Utilizamos a plataforma Crowdin para que calquera poida traducir a app. Deixame traducir - Qué lle parece! - dandelion* aínda está en desenvolvemento, asi que si ten suxerencias de calquer tipo o valoración, por favor utilice o noso xestor de erros para facérnolo saber! + Danos a túa opinión! + dandelion* aínda está en desenvolvemento, asi que se tes suxestións de calquer tipo ou valoración, por favor usa o noso xestor de errros para facérnolo saber! Reporte erros - Difunda! - Dígalle aos seus amigos e familiares que utiliza diaspora* e #dandelion! Por qué no escribir sobre a experiencia? Encantaríanos saber de vostede! - Comparta a aplicación + Difunde! + Dille aos teus amigos e familiares que utilizas diaspora* e #dandelion! Por qué non escribir sobre a experiencia? Encantaríanos saber de ti! + Comparte a aplicación Ei!! Olla #dandelion! %1$s Mantedores @@ -201,6 +202,9 @@ Utilízase o seguinte código: Inspirámonos e collemos código de LeafPic. Bótalle un ollo, tamén é software libre! Cóntame máis - Activar para abrir vídeos YouTube nunha app externa - Ligazóns YouTube + Activar para abrir vídeos YouTube nunha app externa + Ligazóns YouTube + Cambiar o decorado da túa conta + Tira para actualizar + Tirar hacia abaixo na parte superior da páxina.\nDebes reiniciar a app para que os cambios se apliquen. diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 7ac5fed3..07facc0c 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -1,5 +1,4 @@ - नेविगेशन ड्रॉवर खोलें diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-hr/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index eab450c1..36ef8efa 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -1,5 +1,4 @@ - Újratölt diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-in/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 12aac244..8271dda5 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -1,10 +1,11 @@ - Apri barra di navigazione Chiudi barra di navigazione Ricarica + Chiudi + Annulla Impostazioni Notifiche @@ -159,7 +160,7 @@ Aggiungi avviso dell\'app Aggiungere un riferimento a questa applicazione ai testi condivisi: [via #dandelion] - Vario + Altro Reset completo Elimina localmente tutte le impostazioni relative all\'app e disconnette da tutti gli account Questo cancellerà tutte le impostazioni dell\'app che sono state cambiate ai loro valori predefiniti e ti disconnetterà da tutti i pod. Le immagini scaricate non verranno toccate. Sei sicuro di voler procedere? @@ -204,4 +205,9 @@ Sono utilizzate le seguenti librerie: Abbiamo preso ispirazione e parte del codice da LeafPic. Dagli un\'occhiata, anch\'esso è software libero! Dimmi di più + Abilita l\'apertura dei link Youtube su app esterna + Links Youtube + Cambia il tema del tuo account + Trascina per aggiornare + Trascina dall\'alto al basso per aggiornare la pagina.\nDevi riavviare l\'app affinchè le modifiche abbiano effetto. diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index dbdd3fbf..9626eba5 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -1,25 +1,37 @@ - + הגדרות + חפש + רשימת שינויים + עוד + הסתר שורת מצב + מראה + כללי + שנה את שפת האפליקציה. אתחל את האפליקציה בכדי שהשינויים יכנסו לתוקף + שפה + ברירת מחדל + שונות + אודות + תורמים diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index a3b6c284..5c8c52ea 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1,10 +1,11 @@ - ナビゲーションドロワーを開く ナビゲーションドロワーを閉じる 再読み込み + 閉じる + キャンセル 設定 通知 @@ -198,6 +199,9 @@ 以下のライブラリーが使用されます: LeafPic からいくつかのインスピレーションとコードを得ました。チェックしてみてください。同様のフリーソフトウェアです! さらに詳しく - 外部アプリで Youtube のリンクを開くことができます - Youtube のリンク + 外部アプリで Youtube のリンクを開くことができます + Youtube のリンク + アカウントのテーマを変更 + 引き下げて更新 + ページの上から下に引き下げて更新します。\n変更を反映するため、アプリを再起動する必要があります。 diff --git a/app/src/main/res/values-jw/strings.xml b/app/src/main/res/values-jw/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-jw/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-kab/strings.xml b/app/src/main/res/values-kab/strings.xml index 923b84c1..5d824099 100644 --- a/app/src/main/res/values-kab/strings.xml +++ b/app/src/main/res/values-kab/strings.xml @@ -1,5 +1,4 @@ - Ldi umuɣ n tunigin diff --git a/app/src/main/res/values-kmr/strings.xml b/app/src/main/res/values-kmr/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-kmr/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index ea637348..a7989702 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1,5 +1,4 @@ - 사이드 메뉴 열기 diff --git a/app/src/main/res/values-mk/strings.xml b/app/src/main/res/values-mk/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-mk/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index 45434b62..2f9811b6 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -1,8 +1,8 @@ - വീണ്ടും ലോഡ് ചെയ്യുക + റദ്ദാക്കുക ക്രമീകരണങ്ങൾ അറിയിപ്പുകൾ diff --git a/app/src/main/res/values-mr/strings.xml b/app/src/main/res/values-mr/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-mr/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 2c6f6282..19084ead 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -1,5 +1,4 @@ - Åpne navigasjonsskuff diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 31cbf9d2..41ef2f93 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1,8 +1,11 @@ - + Open navigatiemenu + Sluit navigatiemenu Herladen + Sluit + Annuleren Instellingen Meldingen @@ -72,7 +75,11 @@ Pod adres Ontbrekende waarde Ga naar laatste bezochte pagina in de stream? + Verberg statusbalk op hoofdweergave Verberg statusbalk + Toon titel in de hoofdweergave + Toon titel + Launcher snelkoppeling Bovenste werkbalk laadt stream Klik op een lege ruimte in de bovenste werkbalk om de stream te openen @@ -192,4 +199,9 @@ De volgende bibliotheken worden gebruikt: We zijn geïnspireerd door LeafPic en lenen er code van. Ga kijken, deze vrije software is het proberen waard! Vertel me meer + Inschakelen om Youtube links te openen op externe app + Youtube links + Wijzig het thema van uw account + Trek om te vernieuwen + Trek omlaag op de bovenkant van de pagina om te vernieuwen.\nU moet de app opnieuw opstarten om wijzigingen door te voeren. diff --git a/app/src/main/res/values-no/strings.xml b/app/src/main/res/values-no/strings.xml index 2ef280f0..e56fc1d8 100644 --- a/app/src/main/res/values-no/strings.xml +++ b/app/src/main/res/values-no/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-or/strings.xml b/app/src/main/res/values-or/strings.xml new file mode 100644 index 00000000..91176dc2 --- /dev/null +++ b/app/src/main/res/values-or/strings.xml @@ -0,0 +1,118 @@ + + + + ନେଭିଗେସନ୍ ଡ୍ରୟର୍ ଖୋଲନ୍ତୁ + ନେଭିଗେସନ୍ ଡ୍ରୟର୍ ବନ୍ଦ କରନ୍ତୁ + ପୁନଃଲୋଡ୍ କରନ୍ତୁ + ବନ୍ଦ କରନ୍ତୁ + ବାତିଲ୍ କର + + ସେଟିଂସମୂହ + ବିଜ୍ଞପ୍ତି + ବାର୍ତ୍ତାଳାପ + ପ୍ରୋଫାଇଲ୍ + ସନ୍ଧାନ କରନ୍ତୁ + ପରିବର୍ତ୍ତନ ଲଗ୍ + ପରିସଂଖ୍ୟାନ + + ସବୁ ବିଜ୍ଞପ୍ତି + + ନିଶ୍ଚିତକରଣ + + ଅଧିକ + ବିଷୟରେ | ସହାୟତା + ପାଠ୍ୟ ଭାବରେ ଲିଙ୍କ୍ ଅଂଶୀଦାର କରନ୍ତୁ + ୱେବପୃଷ୍ଠାର ସ୍କ୍ରିନସଟ୍ ଅଂଶୀଦାର କରନ୍ତୁ + ୱେବପୃଷ୍ଠାର ସ୍କ୍ରିନସଟ୍ ନିଅନ୍ତୁ + ଏଥିରେ ପ୍ରତିଛବି ସଞ୍ଚୟ କରୁଛି + ଲିଙ୍କ୍ ଠିକଣା କପି ହୋଇଛି … + ଶୀର୍ଷକୁ ଯାଆନ୍ତୁ + ଆପ୍ ବାହାରକୁ ଯାଆନ୍ତୁ + ମୋବାଇଲ୍/ଡେସ୍କଟପ୍ ଦର୍ଶନ ଟୋଗଲ୍ କରନ୍ତୁ + ଅଂଶୀଦାର… + ଦୟାକରି ଏକ ନାମ ଯୋଡ଼ନ୍ତୁ + ଲିଙ୍କ୍ ଠିକଣା ଅଂଶୀଦାର କରନ୍ତୁ + ପ୍ରତିଛବି ସଞ୍ଚୟ କରନ୍ତୁ + ପ୍ରତିଛବି ଅଂଶୀଦାର କରନ୍ତୁ + + ପ୍ରତିଛବି ଲୋଡ୍ କରିବାରେ ଅସମର୍ଥ + + ପ୍ରୋଟୋକଲ୍ + ମୁଖ୍ୟ ଦର୍ଶନରେ ସ୍ଥିତି ଦଣ୍ଡିକା ଲୁଚାନ୍ତୁ + ସ୍ଥିତି ଦଣ୍ଡିକା ଲୁଚାଅ + ମୁଖ୍ୟ ଦର୍ଶନରେ ଆଖ୍ୟା ଦେଖାନ୍ତୁ + ଆଖ୍ୟା ଦେଖାନ୍ତୁ + ଉନ୍ମୋଚକ ସର୍ଟକଟ୍ + + + ରୂପ + ନେଟୱର୍କ + + + ଉପଭୋକ୍ତା + ସାଧାରଣ + ବ୍ୟବସ୍ଥାପକ + + ଥିମ୍ ଏବଂ ରଙ୍ଗ + + ଏହି ଆପ୍ ର ଭାଷା ବଦଳାନ୍ତୁ। ପରିବର୍ତ୍ତନଗୁଡ଼ିକ କାର୍ଯ୍ୟକାରୀ ହେବା ପାଇଁ ଆପ୍ ପୁନଃଆରମ୍ଭ କରନ୍ତୁ + ଭାଷା + ସିଷ୍ଟମ୍ ଭାଷା + + ଫଣ୍ଟ ଆକାର + ସାଧାରଣ + ବଡ଼ + ବିରାଟ + + ପ୍ରତିଛବିଗୁଡ଼ିକୁ ଧାରଣ କରନ୍ତୁ + + ସ୍କ୍ରିନ୍ ଘୂର୍ଣ୍ଣନ + ଡିଫଲ୍ଟ + ପୋର୍ଟ୍ରେଟ୍ + ଲ୍ୟାଣ୍ଡସ୍କେପ୍ + + ପ୍ରକ୍ସି + ପ୍ରକ୍ସି ସକ୍ଷମ କରନ୍ତୁ + + + ଆକାଉଣ୍ଟ୍ ବଦଳାନ୍ତୁ + ଏହା ସମସ୍ତ କୁକୀ ଏବଂ ଅଧିବେଶନ ଡାଟା ଲିଭାଇଦେବ। ଆପଣ ପ୍ରକୃତରେ ଆପଣଙ୍କ ଆକାଉଣ୍ଟ୍ ପରିବର୍ତ୍ତନ କରିବାକୁ ଚାହାଁନ୍ତି କି? + + ଵିଵିଧ + ପୂର୍ଣ୍ଣ ପୁନଃସେଟ୍ + ମୌଳିକ AdBlocker ସକ୍ଷମ କରନ୍ତୁ। ବିଜ୍ଞାପନଗୁଡ଼ିକ ଗ୍ରଥିତ ଦର୍ଶନରେ ଅନ୍ତର୍ଭୁକ୍ତ ହୋଇପାରେ + ବିଜ୍ଞାପନଗୁଡ଼ିକୁ ଅବରୋଧ କରନ୍ତୁ + ବିଷୟରେ + ଲାଇସେନ୍ସ + ଆପ୍ଲିକେସନ୍ + ଡିଭାଇସ୍ + ଆପ୍ ସଂସ୍କରଣ: %1$s + ଆଣ୍ଡ୍ରଏଡ୍ ସଂସ୍କରଣ: %1$s + ଡିଭାଇସ୍ ନାମ: %1$s + କୋଡ୍ ନାମ: %1$s + ଉତ୍ସ ପ୍ରାପ୍ତ କରନ୍ତୁ + ଆପ୍ ଅନୁବାଦ କରନ୍ତୁ! + ଆପ୍ ଆପଣଙ୍କ ଭାଷାରେ ଉପଲବ୍ଧ ନାହିଁ କି? ଆପଣ ଏହା ବଦଳାଇପାରିବେ! ଆପଣ ଏହାକୁ ଅନୁବାଦ କରି ଆମକୁ କାହିଁକି ସାହାଯ୍ୟ କରୁନାହାଁନ୍ତି? ଆପ୍ ଅନୁବାଦ କରିବାରେ ଯେକୌଣସି ବ୍ୟକ୍ତିଙ୍କୁ ସକ୍ଷମ କରିବା ପାଇଁ ଆମେ Crowdin ବ୍ୟବହାର କରୁ। + ମୋତେ ଅନୁବାଦ କରିବାକୁ ଦିଅ + ମତାମତ ଦିଅନ୍ତୁ! + dandelion* ଏପର୍ଯ୍ୟନ୍ତ ବିକାଶରେ ଅଛି, ତେଣୁ ଯଦି ଆପଣଙ୍କର ପରାମର୍ଶ କିମ୍ୱା କୌଣସି ପ୍ରକାରର ମତାମତ ରହିଛି, ତେବେ ଦୟାକରି ଆମକୁ ଜଣାଇବା ପାଇଁ ଆମର ବଗ୍ ଟ୍ରାକର୍ ବ୍ୟବହାର କରନ୍ତୁ! + ବଗ୍‌ ରିପୋର୍ଟ୍‌ କରନ୍ତୁ + ଶବ୍ଦ ବିସ୍ତାର କରନ୍ତୁ! + diaspora* ଏବଂ #dandelion ବିଷୟରେ ଆପଣଙ୍କ ବନ୍ଧୁ ଏବଂ ପରିବାରକୁ କୁହନ୍ତୁ! ଆପଣ ଆପଣଙ୍କର ଅନୁଭୂତି ବିଷୟରେ କାହିଁକି ବ୍ଲଗ୍ କରୁନାହଁ? ଆମେ ଆପଣଙ୍କଠାରୁ ଶୁଣିବାକୁ ପସନ୍ଦ କରିବୁ! + ଆପ୍ ଅଂଶୀଦାର କରନ୍ତୁ + ଆଜ୍ଞା! #dandelion କୁ ଥରେ ଦେଖିଯାଆନ୍ତୁ! %1$s + + ରକ୍ଷଣାବେକ୍ଷଣକାରୀ + ଏହି ଆପ୍ ବର୍ତ୍ତମାନ <br><br>%1$sଙ୍କ ଦ୍ୱାରା ବିକାଶ ଓ ରକ୍ଷଣାବେକ୍ଷଣ କରାଯାଉଛି + ଯୋଗଦାନକାରୀ + %1$s<br><br>ଧନ୍ୟବାଦ! + GNU GPLv3+ ଲାଇସେନ୍ସ + ତୃତୀୟ-ପକ୍ଷ ଲାଇବ୍ରେରୀ + ନିମ୍ନଲିଖିତ ଲାଇବ୍ରେରୀଗୁଡ଼ିକ ବ୍ୟବହାର ହୋଇଛି: + ଆମେ LeafPic ରୁ କିଛି ପ୍ରେରଣା ଏବଂ କୋଡ୍ ନେଇଛୁ। ଯାଆନ୍ତୁ ଏହାକୁ ଥରେ ଦେଖି ଆସନ୍ତୁ, ଏହା ବି ଏକ ମାଗଣା ସଫ୍ଟୱେର୍! + ମୋତେ ଆହୁରି କୁହନ୍ତୁ + ବାହ୍ୟ ଆପରେ YouTube ଲିଙ୍କ୍ ଖୋଲିବା ପାଇଁ ସକ୍ଷମ କରନ୍ତୁ + YouTube ଲିଙ୍କଗୁଡ଼ିକ + ଆପଣଙ୍କ ଆକାଉଣ୍ଟର ଥିମ୍ ପରିବର୍ତ୍ତନ କରନ୍ତୁ + ସତେଜ କରିବାକୁ ଟାଣନ୍ତୁ + diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-pa/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ef7ccada..520b2632 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -1,10 +1,11 @@ - Otwórz panel nawigacyjny Zamknij panel nawigacyjny Przeładuj + Zamknij + Anuluj Ustawienia Powiadomienia @@ -198,4 +199,8 @@ Zostały użyte następujące biblioteki zewnętrzne: Zaczerpnęliśmy kilka pomysłów oraz trochę kodu z aplikacji LeafPic. Wypróbuj ją, to także wolne oprogramowanie! Chcę wiedzieć więcej + Włącz aby otwierać linki do YouTube w zewnętrznej aplikacji + Linki YouTube + Zmień motyw konta + Pociągnij aby odświeżyć diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 64cb73a3..682ddefd 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1,10 +1,11 @@ - Abra o painel de navegação Fechar painel de navegação Atualizar + Fechar + Cancelar Configurações Notificações diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 0baf4751..a0b80c09 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -1,10 +1,11 @@ - Abrir menu de navegação Fechar menu de navegação Recarregar + Fechar + Cancelar Definições Notificações @@ -66,17 +67,25 @@ Permissão recusada. Permissão concedida. Tente novamente. + Pod personalizado + Nome do Pod Protocolo + Endereço do Pod Valor em falta + Ir para a última página visitada no fluxo? Ocultar barra de estado na vista principal Ocultar barra de estado Mostrar título na vista principal Mostrar título Atalho para o lançador + Barra de ferramentas superior carrega o fluxo + Clique num espaço vazio da barra de ferramentas superior para abrir o fluxo Aparência Rede + Definições do Pod + Operacionalidade Controlo de navegação @@ -92,18 +101,22 @@ Cor secundária Cor da barra de progresso Modo AMOLED + Substitua as cores com o AMOLED exibe preto amigável em muitas partes do aplicativo. Você precisa reiniciar para alternar esta configuração. Para navegar em diaspora* no escuro, você também precisa ativar o tema escuro, que pode ser encontrado nas configurações da sua conta pessoal diaspora*. Notificações expandidas + Estenda o sinal de notificações com um menu suspenso que mostra as categorias de notificação Altera o idioma da aplicação. Tem que reiniciar a aplicação para aplicar as alterações Idioma Idioma do sistema + Controlar tamanho do texto na WebView Tamanho do tipo de letra Normal Grande Enorme Carregar imagens + Alternar carregamento de imagens para poupar dados móveis Rotação do ecrã Controlar automaticamente a rotação do ecrã @@ -112,19 +125,38 @@ Vertical Horizontal + Carregar predefinição Tor + Carregar definições de proxy para Tor (Orbot) Proxy HTTP Proxy Ativar proxy + Proxy dandelion*\'s para contornar firewalls.\nPode ser necessário reiniciar e pode não funcionar em alguns telefones. Servidor Porta Tem que reiniciar a aplicação para aplicar a alteração + Predefinição de proxy Orbot carregada + Abra links externos com abas personalizadas do Chrome. Chromium, Firefox ou Google Chrome precisa ser instalado para usar este recurso. \nNOTA IMPORTANTE: Guias personalizadas do Chrome não usam servidores proxy configurados! Definições pessoais + Abra suas definições da sua conta diaspora* Gerir lista de contactos + Gerir \'hashtags\' + Não seguir hashtags já seguidas Mudar de conta + Apagar dados de sessão local e mudar para outro pod/conta diaspora* + Isto irá apagar todos os dados de cookies e da sessão. Tem a certeza de que deseja alterar sua conta? Limpar cache + Limpar cache WebView + Ocultar automaticamente as barras de ferramentas superior e inferior durante a rolagem + Barra Intellihide + Anexar compartilhado-por-aviso + Acrescentar uma referência a este aplicativo a textos compartilhados: [via #dandelion] Diversos + Resetar tudo + Localmente limpar todas as configurações relacionadas ao aplicativo e sair de todas as contas + Isto irá redefinir todas as configurações alteradas do aplicativo para seus valores padrão e sair de todos os servidores. Suas imagens baixadas permanecerão intactas. Tem certeza que deseja continuar? + Habilitar o AdBlocker básico. Anúncios podem ser incluídos, por exemplo, em visualizações incorporadas Bloquear anúncios Acerca Licença @@ -141,12 +173,20 @@ Nome do perfil Pod: %1$s Domínio Pod: %1$s Dados copiados para a área de transferência + dandelion* é seu aplicativo companheiro para navegar pela diaspora*. Ele adiciona recursos como barras de ferramentas úteis e suporte para servidores de proxy como a Tor Network para sua experiência social. + Contribua com código! + dandelion* é desenvolvido gratuitamente como na Liberdade e segue as ideias do projeto diaspora*. Se você quiser contribuir, vá em frente! Atualmente somos uma equipe muito pequena, então nós apreciamos muito qualquer tipo de ajuda! Obter o código fonte Traduzir a aplicação! + O aplicativo não está disponível em seu idioma? Você pode alterar isso! Por que você não nos ajuda traduzindo-lo? Nós usamos Stringlate para permitir que alguém traduza o aplicativo. Quero participar + Dar Feedback! + dandelion* ainda está em desenvolvimento, então se você tiver sugestões ou algum tipo de feedback, por favor, use nosso bug tracker para nos informar! Reportar erros Passe a palavra! + Conte aos seus amigos e familiares sobre diaspora* e #dandelion! Por que você não blog sobre suas experiências? Nós adoraríamos ouvir de você! Partilhar plicação + Ei! Confira #dandelion! %1$s Desenvolvimento Esta aplicação está a ser desenvolvida e mantida por <br><br>%1$s @@ -155,7 +195,11 @@ Licença GNU GPLv3+ Bibliotecas de terceiros Utilizamos as seguintes bibliotecas: + Demos alguma inspiração e código do LeafPic. Vá conferir, é também software livre! Saber mais - Ative para abrir as ligações YouTube na aplicação externa - Ligações YouTube + Ative para abrir as ligações YouTube na aplicação externa + Ligações YouTube + Altera o tema da sua conta + Puxar para atualizar + Deslize de cima para baixo para recarregar.\nTem que reiniciar a aplicação para aplicar as alterações. diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index cd05a96c..b14cad56 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -1,5 +1,4 @@ - Reîncarcă diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 0a184397..4aa33db5 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -1,10 +1,11 @@ - Открыть панель навигации Закрыть панель навигации Обновить + Закрыть + Отмена Настройки Уведомления @@ -45,7 +46,7 @@ Сделать скриншот страницы Сохранение изображения в Сохранение скриншота как: - Адрес ссылки скопирован… + Адрес ссылки скопирован … Новый пост В начало Искать по тегам и людям @@ -198,6 +199,9 @@ Используются следующие библиотеки: Мы вдохновлялись и взяли немного кода из LeafPic. Попробуйте это приложение, оно тоже является свободным ПО! Расскажите мне больше - Открывать ссылки на Youtube во внешних приложениях - Ссылки на Youtube + Открывать ссылки на Youtube во внешних приложениях + Ссылки на Youtube + Изменить тему вашей учётной записи + Потяните для обновления + Потяните вниз, чтобы обновить страницу.\nВам нужно перезапустить приложение, чтобы изменения вступили в силу. diff --git a/app/src/main/res/values-sc/strings.xml b/app/src/main/res/values-sc/strings.xml index 72288008..d16b663e 100644 --- a/app/src/main/res/values-sc/strings.xml +++ b/app/src/main/res/values-sc/strings.xml @@ -1,10 +1,11 @@ - Aberi su pannellu de nàvigu Serra su pannellu de nàvigu Torra a carrigare + Serra + Annulla Impostatziones Notìficas @@ -201,6 +202,9 @@ Sunt impreadas custas librerias: Amus pigadu ispiratzione e parte de su còdighe dae LeafPic. Abbistade·bos·lu, est fintzas cussu unu programma lìberu! Àteras informatziones - Abìlita pro abèrrere sos ligàmenes de Youtube in un\'aplicatzione esterna - Ligàmenes de Youtube + Abìlita pro abèrrere sos ligàmenes de Youtube in un\'aplicatzione esterna + Ligàmenes de Youtube + Muda su tema de su contu tuo + Tira cara a bassu pro annoare + Tira cara a bassu pro annoare sa pàgina.\nDepes torrare a allùghere s\'aplicatzione pro fàghere in modu chi sas modìficas tèngiant efetu. diff --git a/app/src/main/res/values-si/strings.xml b/app/src/main/res/values-si/strings.xml new file mode 100644 index 00000000..45159998 --- /dev/null +++ b/app/src/main/res/values-si/strings.xml @@ -0,0 +1,81 @@ + + + + නැවත පූරණය + වසන්න + අවලංගු + + සැකසුම් + දැනුම්දීම් + සංවාද + පැතිකඩ + ක්‍රියාකාරකම් + අදහස් දැක්විණි + සැඳහුම් + ප්‍රසිද්ධ + සොයන්න + සබඳතා + සංඛ්‍යාලේඛන + + සියළුම දැනුම්දීම් + එවගේම අදහස් දැක්විණි + + ඔබට පිටවීමට ඇවැසිද? + + තව + පිළිබඳව | උපකාර + ප්‍රසිද්ධ ක්‍රියාකාරකම් + වාර්තා + වියමන පිටුවෙහි තිරසේයාවක් බෙදාගන්න + වියමන පිටුවෙහි තිර සේයාවක් අරගන්න + ලෙස තිරසේයාව සුරකින්න: + සබැඳියේ ලිපිනය පිටපත් විය… + යෙදුමෙන් පිටවන්න + බෙදාගන්න… + නමක් එකතු කරන්න + සබැඳියේ ලිපිනය බෙදාගන්න + බාහිර අතිරික්සුවකින් විවෘත කරන්න… + සබැඳිය පසුරුපුවරුවට පිටපත් කරන්න + + + කෙටුම්පත + සිරැසිය පෙන්වන්න + + + ජාලය + + + පරිශීලක + පරිපාලක + + තේමාව සහ වර්ණ + + භාෂාව + පද්ධතියේ භාෂාව + + මුද්‍රණඅකුරේ ප්‍රමාණය + සාමාන්‍ය + + + පෙරනිමි + + පෙරකලාසිය + පෙරකලාසිය සබල කරන්න + + + ගිණුම වෙනස් කරන්න + + පිලිබඳව + බලපත්‍රය + යෙදුම + උපාංගය + ඇන්ඩ්‍රොයිඩ් අනුවාදය: %1$s + උපාංගයේ නම: %1$s + කේතනාමය: %1$s + මූලාශ්‍රය ගන්න + යෙදුම පරිවර්තනය කරන්න! + යෙදුම බෙදාගන්න + + ජීඑන්යූ ජීපීඑල්v3+ බලපත්‍රය + යූටියුබ් සබැඳිය + diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-sk/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-sq/strings.xml b/app/src/main/res/values-sq/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-sq/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-sr-rRS/strings.xml b/app/src/main/res/values-sr-rRS/strings.xml index 6cca4e74..422fd22e 100644 --- a/app/src/main/res/values-sr-rRS/strings.xml +++ b/app/src/main/res/values-sr-rRS/strings.xml @@ -1,5 +1,4 @@ - Otvori navigacioni panel diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 1bbf84ec..543f0196 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index fba5005a..7c42e701 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -1,10 +1,11 @@ - - Stäng navigeringsmenyn - Stäng navigeringsmenyn + Öppna navigeringslådan + Stäng navigeringslådan Ladda om + Avsluta + Avbryt Inställningar Notiser @@ -45,7 +46,7 @@ Ta skärmdump av en webbsida Sparar bild som Sparar skärmdump som: - Länkadress kopierad… + Länkadressen kopierades ... Nytt inlägg Till toppen Sök på taggar eller personer @@ -58,7 +59,7 @@ Dela länkadress Spara bild Dela bild - Öppna i en extern webbläsare… + Öppna i en extern webbläsare... Kopiera länkadress Kopiera bildadressen @@ -204,4 +205,9 @@ Följande bibliotek används: Vi hämtade inspiration och kod från LeafPic. Kika på det, det är också fri programvara! Berätta mer + Aktivera för att öppna Youtube-länkar i en extern app + Youtube-länkar + Ändra temat för ditt konto + Dra för att uppdatera + Dra ner på toppen av sidan för att uppdatera.\nDu måste starta om appen för att ändringarna ska träda i kraft. diff --git a/app/src/main/res/values-ta/strings.xml b/app/src/main/res/values-ta/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-ta/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-te/strings.xml b/app/src/main/res/values-te/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-te/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-th/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index ca2a50d3..6c40a2c3 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1,10 +1,11 @@ - Gezinme çekmecesini aç Gezinme çekmecesini kapat Yeniden Yükle + Kapat + İptal Ayarlar Bildirimler @@ -26,7 +27,9 @@ Ayrıca Yorumlar Gönderine Yorumlar Beğeniler + Bahsedilen Yeniden paylaşılan + Paylaşım Başlatıldı Hata: Pod listesi alınamadı! Üzgünüm, devam etmek için internete bağlı olmalısın. @@ -71,6 +74,7 @@ Protokol Pod adresi Eksik değer + Akışta son ziyaret edilen sayfaya git? Durum çubuğunu ana görünümde gizle Durum çubuğunu gizle Başlığı ana görünümde göster @@ -87,6 +91,7 @@ Menü Kaydırıcı + Gezinme çekmecesindeki girişlerin görünürlüğünü kontrol et Kullanıcı Genel Yönetici @@ -132,6 +137,7 @@ Sunucu Port Proxy kullanımını devre dışı bırakmak için uygulamanın yeniden başlatılması gerekiyor + Orbot proxy hazır ayarı yüklendi Chrome Özel Sekmeler ile harici bağlantılar açın. Bu özelliği kullanabilmek için Chromium, Firefox veya Google Chrome\'un yüklü olması gerekir.\n ÖNEMLİ NOT: Chrome Özel Sekmeler, yapılandırılmış proxy sunucuları kullanmaz! @@ -140,15 +146,19 @@ diaspora* hesap ayarlarını aç Kişi listenizi yönetin Etiketleri yönetin + Mevcut takip edilen etiketleri takipten vazgeç Hesabı Değiştir Yerel oturum verilerini silin ve başka bir diaspora * pod(a)/hesab(a) geçin Bu, tüm çerezleri ve oturum verilerini siler. Gerçekten hesabını değiştirmek istiyor musun? Önbelleği temizle WebView önbelleğini temizle Kaydırma yaparken üst ve alt araç çubuklarını otomatik olarak gizle + Araç Çubuklarını Otomatik Gizle + shared-by-notice ekle Bu uygulamaya, paylaşılan metinlere bir referans ekleyin: [örn #dandelion] Çeşitli + Tamamen Sıfırlama Uygulama ile ilgili tüm ayarları yerel olarak sil ve tüm hesaplardan çıkış yap Bu, uygulamanın tüm değiştirilen ayarlarını varsayılan değerlerine sıfırlar ve tüm podlardan çıkar. İndirdiğiniz görüntülere donulmaz. Devam etmek istediğine emin misin? Temel reklam engelleyiciyi etkinleştirin. Reklamlar yerleşik görünümlere dahil edilebilir @@ -184,6 +194,7 @@ Hey %1$s ! #dandelion’a bir göz at! Yardımcılar + Bu uygulamayı şu anda geliştiren ve devam ettiren <br><br>%1$s Katkıda bulunanlar %1$s<br><br>Teşekkürler! GNU GPLv3+ License @@ -191,4 +202,9 @@ Şu kütüphaneler kullanıldı: LeafPic\'ten biraz ilham ve kod aldık. Göz atabilirsiniz, özgür bir yazılım! Daha fazla göster + YouTube linklerini harici uygulamada açmak için etkinleştir + YouTube linkleri + Hesabınızın temasını değiştirin + Yenilemek için çek + Yenilemek için sayfanın üst kısmından çekin\nDeğişikliklerin geçerli olması için uygulamayı yeniden başlat. diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 3ef60848..19fb0794 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -1,10 +1,11 @@ - Відкрити панель навігації Закрити панель навігації Перезавантажити + Закрити + Скасувати Налаштування Сповіщення @@ -58,7 +59,7 @@ Поширити посилання Зберегти зображення Поділитися зображенням - Відкрити у зовнішньому браузері… + Відкрити у зовнішньому браузері… Копіювати адресу посилання у буфер обміну Копіювати зображення у буфер обміну @@ -204,4 +205,9 @@ Використовуються такі бібліотеки: Ми взяли трохи натхнення і коду з LeafPic. Це також вільне програмне забезпечення, тож користуйтеся! Хочу знати більше + Увімкнути для відкриття посилань Youtube у зовнішньому застосунку + Youtube посилання + Змінити тему вашого облікового запису + Потягніть, щоб оновити + Потягніть сторінку згори вниз, щоб оновити.\nВам потрібно перезавантажити застосунок, щоб зміни набрали сили. diff --git a/app/src/main/res/values-ur/strings.xml b/app/src/main/res/values-ur/strings.xml new file mode 100644 index 00000000..43d88f4b --- /dev/null +++ b/app/src/main/res/values-ur/strings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index e575411b..c38cc780 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 45f47267..d1b2cd37 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1,44 +1,213 @@ - 打开导航栏 隐藏导航栏 + 刷新 + 关闭 + 取消 设置 + 通知 + 对话 + 串流 + 资料 + 方面 + 活动 + 已赞 + 已评论 + 提及 + 公共 搜索 + 联系人 更新日志 + 统计 + 全部通知 + 也评论了 + 评论此文 + 已赞 + 已提及 + 已转发 + 已开始分享 + 错误:无法检索播客列表! + 抱歉,您必须连接到互联网 + 确认 + 您是否想要退出? 更多 + 关于 | 帮助 + 关注的标签 + 公共活动 + 反馈 + 以文本形式共享链接 + 分享网页截图 + 网页截图 + 保存图像至 + 保存截图为: + 已复制链接地址 + 新文章 + 返回顶部 + 按标签或人物搜索 + 退出应用 + 切换移动版/桌面版视图 共享。。。 + 按标签搜索 + 按人物搜索 + 请添加姓名 + 分享链接地址 + 保存图像 + 分享图像 + 在外部浏览器中打开 + 复制链接地址至剪切板 + 复制图像地址至剪切板 + 无法载入图像 + 您必须授予“访问存储权限”以保存屏幕截图。 + 完全关闭应用程序或重启设备。如果您不允许存储访问,但希望稍后使用 + 屏幕截图功能,您可以稍后批准权限。请打开:系统设置 - 应用 - + dandelion*。 + 您必须允许“访问存储权限”保存/上传图像。 + 在完全关闭应用程序或重启设备之后。如果您不允许存储访问,但希望稍后保存图像 + 您可以稍后授权。请打开:系统设置 - 应用 - + dandelion。 + 权限被拒绝。 + 已授予权限。请重试。 + 自定义 Pod + Pod 名称 + 协议 + Pod 地址 + 缺失值 + 跳转到上一个访问过的页面? + 在主视图中隐藏状态栏 隐藏状态栏 + 在主视图中显示标题 显示标题 + 启动器快捷方式 + 顶级工具栏负载流 + 点击顶部工具栏的空间打开流流 外观 + 网络 + 播客设置 + 可操作性 + 导航滑块 + 在导航抽屉中控制条目的可见性 + 用户 通用 + 管理员 + 主题及颜色 + 控制应用所使用的颜色 + 主颜色 + 工具栏颜色 + 强调色 + 进度条颜色 + AMOLED 模式 + 在 AMOLED 中显示友好的黑色。您需要重启切换此设置。在暗中浏览散居地* 也需要激活暗色主题,您可以在您的个人散居地* 帐户设置中找到。 + 扩展通知 + 通过显示通知类别的辍学菜单扩展通知铃声 更改语言(重启应用后生效) 语言 + 系统语言 + 控制WebView文本大小 + 字体大小 + 正常 + + 巨大 + 加载图像 + 切换图像加载到例如保存移动数据 + 屏幕旋转 + 控制自动旋转屏幕 默认 + 传感器\n(忽略系统设置) + 肖像 + 横向 + 加载 Tor 预设 + 为 Tor (Orbot) HTTP 代理加载代理设置 + 代理 + 启用代理 + 代理 dandelion*,来规避防火墙。\n可能需要重启。这可能无法在某些手机上运行。 + 主机 + 端口 + 应用需要重新启动以禁用代理使用 + 加载轨道代理预设 + 使用 Chrome 自定义标签打开外部链接。Chromium、Firefox 或 Google Chrome 需要安装才能使用此功能。 \nImportant:Chrome 自定义标签不使用配置的代理服务器! + 个人设置 + 打开 Diaspora* 帐户设置 + 管理您的联系人列表 + 管理哈希标签 + 取消关注已经跟随哈希 + 更改帐户 + 擦除本地会话数据并切换到另一个 Diaspora* pod/帐户 + 这将删除所有 cookie 和会话数据。您真的想要更改您的帐户吗? 清除缓存 + 清除WebView缓存 + 滚动时自动隐藏顶部和底部工具栏 + 智能隐藏工具栏 + 附加共享通知 + 将此应用添加到共享文本:[通过 #dandelion] 杂项 + 完全重置 + 本地擦除应用程序的所有设置,注销所有账户 + 这将重置应用程序的所有更改设置为默认值,并从所有讲台上注销。您下载的图像将保持不变。您确定要继续吗? + 启用基本的 AdBlocker。广告可能包括在内部的视图中 + 屏蔽广告 关于 许可 + 调试 + 适用范围 + 设备 + 散居者*播客 + 调试日志 + 调试日志(Verbose) + 应用版本: %1$s + Android 版本: %1$s + 设备名称: %1$s + 代码名: %1$s + 播客资料名称: %1$s + 播客域: %1$s + 调试日志已复制到剪贴板 + dandelion* 是您浏览社交网络 diaspora* 的配套应用。它添加了一些功能,例如有用的工具栏和支持Tor网络等代理服务器。 + 贡献代码! + dandelion* 像自由一样自由发展,遵循 diaspora* 项目的想法。如果你想作出贡献,继续前进!目前我们是一个非常小的团队,因此我们非常感谢任何帮助! + 获取源 + 翻译应用! + 应用程序不可用您的语言?您可以更改它!为什么你没有帮助我们翻译它?我们使用Stringlate来让任何人能够翻译这个应用。 + 让我翻译 + 提供反馈! + dandelion* 仍在开发中,所以如果您有任何建议或任何反馈,请使用我们的错误追踪器让我们知道! + 报告错误 + 传播单词! + 告诉你的朋友和家人关于 Diaspora* 和 #dandelion! 为什么你没有关于你的经历的博客? 我们很喜欢听到你的声音! + 分享应用 + 嘿!看看 #dandelion! %1$s + 维护者 + 此应用目前正在开发和维持 <br><br>%1$s 贡献者 + %1$s<br><br>谢谢! + GNU GPLv3+ 授权 + 第三方图书馆 + 使用下列图书馆: + 我们从LeafPic获得了一些灵感和代码。去检查它,也是免费的软件! + 告诉我更多 + 启用在外部应用打开 Youtube 链接 + YouTube链接 + 更改您的帐户的主题 + 下拉刷新 + 在页面顶部下拉刷新。\n您需要重新启动应用程序以使更改生效。 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index e88fea5d..22866bc8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1,10 +1,11 @@ - 開啟側邊導覽選單 關閉側邊導覽選單 重新下載 + 關閉 + 取消 設定 通知 @@ -199,6 +200,9 @@ 我們使用了下列程式庫: 我們從 LeafPic 應用程式得到一些啟發以及程式碼。去看看吧,它也是自由軟體喔! 再多說一些 - 使用其他應用程式來開啟 Youtube 連結 - Youtube 連結 + 使用其他應用程式來開啟 Youtube 連結 + Youtube 連結 + 修改帳號的佈景主題 + 下拉可更新 + 從頁面的上方下拉一下可以更新內容。\n這個設定修改後需要重啟應用程式才會生效。 diff --git a/app/src/main/res/values/strings-not_translatable.xml b/app/src/main/res/values/strings-not_translatable.xml index c66a18d4..7f67ac27 100644 --- a/app/src/main/res/values/strings-not_translatable.xml +++ b/app/src/main/res/values/strings-not_translatable.xml @@ -37,10 +37,6 @@ not_implemented - @string/not_implemented - @string/not_implemented - @string/not_implemented - @string/not_implemented auto @@ -149,4 +145,6 @@ PDF gsantner pref_key__open_youtube_external_enabled + pref_key_manage_theme + pref_key__swipe_refresh_enabled diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c542f21..78bac4bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,6 +4,8 @@ Open navigation drawer Close navigation drawer Reload + Close + Cancel Settings @@ -253,7 +255,10 @@ The following libraries are used: We took some inspiration and code from LeafPic. Go check it out, it\'s free software as well! Tell me more - Enable to open Youtube links on external app - Youtube links + Enable to open Youtube links on external app + Youtube links + Change the theme of your account + Pull to refresh + Pulling down on top of page to refresh.\nYou need to restart the app for changes to take effect. diff --git a/app/src/main/res/xml/preferences__master.xml b/app/src/main/res/xml/preferences__master.xml index c1ab7939..c6afd55f 100644 --- a/app/src/main/res/xml/preferences__master.xml +++ b/app/src/main/res/xml/preferences__master.xml @@ -77,8 +77,8 @@ android:defaultValue="true" android:icon="@drawable/ic_open_yt_external_black_24px" android:key="@string/pref_key__open_youtube_external_enabled" - android:summary="@string/open_youtube_external_tabs_description" - android:title="@string/pref_title__open_youtube_external"/> + android:summary="@string/enable_to_open_youtube_links_on_external_app" + android:title="@string/youtube_links"/> + + diff --git a/app/src/main/res/xml/preferences__sub_themes.xml b/app/src/main/res/xml/preferences__sub_themes.xml index ec5a5e00..aa4bde15 100644 --- a/app/src/main/res/xml/preferences__sub_themes.xml +++ b/app/src/main/res/xml/preferences__sub_themes.xml @@ -21,5 +21,12 @@ android:summary="@string/amoled_mode_description__app_specific" android:title="@string/amoled_mode" android:icon="@drawable/ic_color_lens_black_24px" /> + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 25e4f2b8..75a6ed58 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,7 @@ /*####################################################### * - * Maintained by Gregor Santner, 2017- - * https://gsantner.net/ - * - * License of this file: Apache 2.0 (Commercial upon request) - * https://www.apache.org/licenses/LICENSE-2.0 + * SPDX-FileCopyrightText: 2017-2023 Gregor Santner + * SPDX-License-Identifier: Unlicense OR CC0-1.0 * #########################################################*/ // Top-level build file where you can add configuration options common to all sub-projects/modules. @@ -13,12 +10,12 @@ import java.text.SimpleDateFormat buildscript { ext { - version_gradle_tools = "3.2.1" - version_plugin_kotlin = "1.3.11" + version_gradle_tools = "3.6.3" + version_plugin_kotlin = "1.3.72" enable_plugin_kotlin = false - version_compileSdk = 28 - version_buildTools = "28.0.3" + version_compileSdk = 29 + version_buildTools = "29.0.3" version_minSdk = 17 // https://developer.android.com/topic/libraries/support-library/ @@ -59,6 +56,13 @@ allprojects { tasks.matching { task -> task.name.matches('.*generate.*Resources') }.all { task -> task.dependsOn copyRepoFiles } + + tasks.matching {it instanceof Test}.all { // Enable unit test output, html+xml output + testLogging.events "passed", "skipped", "failed", "standardOut", "standardError" + testLogging.showStandardStreams = true + reports.junitXml.enabled = true + reports.html.enabled = true + } } task clean(type: Delete) { @@ -79,7 +83,7 @@ static String findUsedAndroidLocales() { Set langs = new HashSet<>() new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) { final foldername = it.name - if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates")) { + if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates") && !it.canonicalPath.contains("gradle" + File.separator + "daemon")) { new File(it.toString()).eachFileRecurse(groovy.io.FileType.FILES) { if (it.name.toLowerCase().endsWith(".xml") && it.getCanonicalFile().getText('UTF-8').contains("diaspora.fediverse.observer. + +🍻 Mehrere Accounts: Nutze dandelion* und dandelior* um zwei Accounts auf dem gleichen Gerät zu nutzen. Die Apps besitzen eigene Icons und unterschiedliche Vorgabefarben. + +🌍 Hinweis: Die App nutzt Androids WebView Komponente um Inhalte von diaspora* Pods in der mobilen Ansicht anzuzeigen. Für fehlende Features frage bitte auf dem diaspora* Bug Tracker. + +Weitere Informationen: +Project site | diaspora* FAQ + diff --git a/metadata/de/short_description.txt b/metadata/de/short_description.txt new file mode 100644 index 00000000..71a3004f --- /dev/null +++ b/metadata/de/short_description.txt @@ -0,0 +1 @@ +Client für das Soziale Netzwerk diaspora* diff --git a/metadata/en b/metadata/en deleted file mode 120000 index f2b0341f..00000000 --- a/metadata/en +++ /dev/null @@ -1 +0,0 @@ -en-US \ No newline at end of file diff --git a/metadata/en-US/changelogs/1.txt b/metadata/en-US/changelogs/1.txt new file mode 100644 index 00000000..d60031cb --- /dev/null +++ b/metadata/en-US/changelogs/1.txt @@ -0,0 +1 @@ +Added to F-Droid diff --git a/metadata/en-US/featureGraphic.png b/metadata/en-US/featureGraphic.png index 39038c2f..92105097 100644 Binary files a/metadata/en-US/featureGraphic.png and b/metadata/en-US/featureGraphic.png differ diff --git a/metadata/en-US/full_description.txt b/metadata/en-US/full_description.txt index cb8fdf60..e1c445bd 100644 --- a/metadata/en-US/full_description.txt +++ b/metadata/en-US/full_description.txt @@ -12,14 +12,11 @@ It adds useful features to your networking experience: 🈯 Use in any language that the app is translated in - for example in German but have English as system language. -🔐 Looking for a pod to register? The app lists many pods with more being listed at podupti.me. +🔐 Looking for a pod to register? The app lists many pods with more being listed at diaspora.fediverse.observer. 🍻 Multiple accounts: You can use dandelion* and dandelior* to use two accounts at the same time on one device. They use a different icon and other default colors. 🌍 Notice: The app uses the Android WebView component to display contents of diaspora* pods in the mobile view. For missing features and bugs in mobile view, ask at diaspora* bugtracker. More information: -Project Blog | diaspora* FAQ - -Support the project: -Translate using Stringlate | Join discussion on Matrix | Contribution information | Android Contribution Guide | Support main developer +Project site | diaspora* FAQ diff --git a/metadata/en-US/promoGraphic.png b/metadata/en-US/promoGraphic.png index a750adc9..186cec0f 100644 Binary files a/metadata/en-US/promoGraphic.png and b/metadata/en-US/promoGraphic.png differ diff --git a/metadata/zz/full_description.txt b/metadata/zz/full_description.txt new file mode 100644 index 00000000..8e27be7d --- /dev/null +++ b/metadata/zz/full_description.txt @@ -0,0 +1 @@ +text diff --git a/metadata/zz/short_description.txt b/metadata/zz/short_description.txt new file mode 100644 index 00000000..8e27be7d --- /dev/null +++ b/metadata/zz/short_description.txt @@ -0,0 +1 @@ +text diff --git a/metadata/zz/title.txt b/metadata/zz/title.txt new file mode 100644 index 00000000..8e27be7d --- /dev/null +++ b/metadata/zz/title.txt @@ -0,0 +1 @@ +text