├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── shaarli_icon.png │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_action_new.png │ │ │ │ └── ic_action_accept.png │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_action_new.png │ │ │ │ └── ic_action_accept.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_action_new.png │ │ │ │ └── ic_action_accept.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_action_new.png │ │ │ │ └── ic_action_accept.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ ├── menu_add.xml │ │ │ │ ├── menu_accounts_management.xml │ │ │ │ ├── menu_main.xml │ │ │ │ └── menu_add_account.xml │ │ │ ├── layout │ │ │ │ ├── tags_list.xml │ │ │ │ ├── activity_accounts_management.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── share_dialog.xml │ │ │ │ └── activity_add_account.xml │ │ │ └── values-fr │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── dimtion │ │ │ │ └── shaarlier │ │ │ │ ├── HttpSchemeHandlerActivity.java │ │ │ │ ├── Tag.java │ │ │ │ ├── SpaceTokenizer.java │ │ │ │ ├── DebugHelper.java │ │ │ │ ├── ShaarliAccount.java │ │ │ │ ├── AccountsManagementActivity.java │ │ │ │ ├── TagsSource.java │ │ │ │ ├── EncryptionHelper.java │ │ │ │ ├── AutoCompleteWrapper.java │ │ │ │ ├── MySQLiteHelper.java │ │ │ │ ├── AccountsSource.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── NetworkService.java │ │ │ │ ├── NetworkManager.java │ │ │ │ ├── AddAccountActivity.java │ │ │ │ └── AddActivity.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── dimtion │ │ └── shaarlier │ │ └── ApplicationTest.java ├── build.gradle ├── proguard-rules.pro └── app.iml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── TODO.md ├── gradle.properties ├── Shaarlier.iml ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/shaarli_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable/shaarli_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-hdpi/ic_action_new.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-mdpi/ic_action_new.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-hdpi/ic_action_accept.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-mdpi/ic_action_accept.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xhdpi/ic_action_new.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xxhdpi/ic_action_new.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xhdpi/ic_action_accept.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarekJor/Shaarlier/master/app/src/main/res/drawable-xxhdpi/ic_action_accept.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | *.apk 9 | *.log 10 | *Thumbs.db 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jul 08 21:57:03 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_add.xml: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dimtion/shaarlier/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/tags_list.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_accounts_management.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_add_account.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | I know, a todo file is not always 2 | 3 | ## To do ASAP 4 | - Feature : Handle redirection (E.g : shaarli.fr) 5 | - Bug : autocomplete field for tags is hidden by keyboard when a description is too long (help needed!) 6 | 7 | ## Planned for future releases 8 | - Save link in a draft in case of an error 9 | - Nicer UI 10 | 11 | ## Q&A 12 | - Try app on as many apps as possible 13 | - Try more device screen sizes 14 | - Try in low network conditions 15 | - Try on slow devices 16 | 17 | ## Long term evolutions (if requested) 18 | - See online Shaarli links 19 | - Save link later 20 | - Try to stay KISS 21 | 22 | [Any idea ?](https://github.com/dimtion/Shaarlier/issues) 23 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion '25.0.1' 6 | 7 | defaultConfig { 8 | applicationId "com.dimtion.shaarlier" 9 | minSdkVersion 15 10 | targetSdkVersion 25 11 | versionCode 22 12 | versionName "1.4.0-alpha" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled true 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:25.3.1' 25 | compile 'org.jsoup:jsoup:1.9.2' 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\dimtion\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -keep public class org.jsoup.** { 19 | public *; 20 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_accounts_management.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /Shaarlier.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/HttpSchemeHandlerActivity.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.widget.Toast; 8 | 9 | public class HttpSchemeHandlerActivity extends Activity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | 15 | Uri data = getIntent().getData(); 16 | if(data != null) { 17 | String url = data.toString(); 18 | 19 | Intent addActivityIntent = new Intent(this, AddActivity.class); 20 | addActivityIntent.setAction(Intent.ACTION_SEND); 21 | addActivityIntent.setType("text/plain"); 22 | addActivityIntent.putExtra(Intent.EXTRA_TEXT, url); 23 | startActivity(addActivityIntent); 24 | } else { 25 | Toast.makeText(getApplicationContext(), R.string.add_not_handle, Toast.LENGTH_SHORT).show(); 26 | } 27 | 28 | finish(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/Tag.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | /** 4 | * Created by dimtion on 12/05/2015. 5 | * A tag from the SQLite db 6 | */ 7 | public class Tag { 8 | private long id; 9 | private ShaarliAccount masterAccount; 10 | private String value; 11 | private long masterAccountId; 12 | 13 | public long getId() { 14 | return id; 15 | } 16 | 17 | public void setId(long id) { 18 | this.id = id; 19 | } 20 | 21 | public ShaarliAccount getMasterAccount() { 22 | return masterAccount; 23 | } 24 | 25 | public void setMasterAccount(ShaarliAccount masterAccount) { 26 | this.masterAccount = masterAccount; 27 | this.masterAccountId = masterAccount.getId(); 28 | } 29 | 30 | public String getValue() { 31 | return value; 32 | } 33 | 34 | public void setValue(String value) { 35 | this.value = value; 36 | } 37 | 38 | public long getMasterAccountId() { 39 | return masterAccountId; 40 | } 41 | 42 | public void setMasterAccountId(long masterAccountId) { 43 | this.masterAccountId = masterAccountId; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getValue(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shaarlier 2 | 3 | [![Codacy Badge](https://api.codacy.com/project/badge/grade/6228d636f0e44708b2739a35e8b9a2b0)](https://www.codacy.com/app/zizou-xena/Shaarlier) 4 | 5 | A simple app for sharing links on your Shaarli. 6 | 7 | ## Features 8 | - Publish links on your Shaarli 9 | - Automatically add a title and a description to your links (as Shaarli does) 10 | - Optional dialog box for editing title, description or tags 11 | - Multiple Shaarlis 12 | 13 | ## Planned features 14 | See [TODO file](https://github.com/dimtion/Shaarlier/blob/master/TODO.md) for a detailed roadmap. 15 | 16 | ## Downloads 17 | - From the [Play Store](https://play.google.com/store/apps/details?id=com.dimtion.shaarlier) 18 | - From the [release tab](https://github.com/dimtion/Shaarlier/releases) 19 | - From the [Aptoide Store](http://dimtion.store.aptoide.com/app/market/com.dimtion.shaarlier/8/8917968/Shaarlier) 20 | - From [F-Droid](https://f-droid.org/repository/browse/?fdfilter=shaarlier&fdid=com.dimtion.shaarlier) 21 | 22 | ## Why ? 23 | I made this app because the official one doesn't feels right to me, in some cases you just need to save a link for reading it later. So launching the browser for that only task is quite too long (you know, I like when things are fast and easy). 24 | 25 | ## Links 26 | - Main (and best) fork of the project : https://github.com/shaarli/Shaarli/ 27 | - Thanks Jonathan Hedley for [jsoup](http://jsoup.org/) under [MIT Licence](http://jsoup.org/license) 28 | - My own personnal [shaarli](https://shaarli.dimtion.fr) 29 | 30 | -------- 31 | 32 | Software under [GPLv3](https://www.gnu.org/licenses/gpl.html) 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/SpaceTokenizer.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.text.SpannableString; 4 | import android.text.Spanned; 5 | import android.text.TextUtils; 6 | import android.widget.MultiAutoCompleteTextView; 7 | 8 | /** 9 | * Created by dimtion on 22/02/2015. 10 | * Custom tokenizer, found on : http://stackoverflow.com/a/4596652/1582589 by vsm * 11 | */ 12 | 13 | 14 | class SpaceTokenizer implements MultiAutoCompleteTextView.Tokenizer { 15 | 16 | public int findTokenStart(CharSequence text, int cursor) { 17 | int i = cursor; 18 | 19 | while (i > 0 && text.charAt(i - 1) != ' ') { 20 | i--; 21 | } 22 | while (i < cursor && text.charAt(i) == ' ') { 23 | i++; 24 | } 25 | 26 | return i; 27 | } 28 | 29 | public int findTokenEnd(CharSequence text, int cursor) { 30 | int i = cursor; 31 | int len = text.length(); 32 | 33 | while (i < len) { 34 | if (text.charAt(i) == ' ') { 35 | return i; 36 | } else { 37 | i++; 38 | } 39 | } 40 | 41 | return len; 42 | } 43 | 44 | public CharSequence terminateToken(CharSequence text) { 45 | int i = text.length(); 46 | 47 | while (i > 0 && text.charAt(i - 1) == ' ') { 48 | i--; 49 | } 50 | 51 | if (i > 0 && text.charAt(i - 1) == ' ') { 52 | return text; 53 | } else { 54 | if (text instanceof Spanned) { 55 | SpannableString sp = new SpannableString(text + " "); 56 | TextUtils.copySpansFrom((Spanned) text, 0, text.length(), 57 | Object.class, sp, 0); 58 | return sp; 59 | } else { 60 | return text + " "; 61 | } 62 | } 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/DebugHelper.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | 9 | import java.text.DateFormat; 10 | import java.text.SimpleDateFormat; 11 | import java.util.Date; 12 | import java.util.TimeZone; 13 | 14 | 15 | /** 16 | * Created by dimtion on 16/05/2015. 17 | * A class to help debugging, should not be in production 18 | */ 19 | class DebugHelper { 20 | 21 | public static void sendMailDev(Activity context, String subject, String content) { 22 | Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( 23 | "mailto", context.getString(R.string.developer_mail), null)); 24 | intent.putExtra(Intent.EXTRA_SUBJECT, subject); 25 | intent.putExtra(Intent.EXTRA_TEXT, content); 26 | 27 | context.startActivity(Intent.createChooser(intent, "Debug report...")); 28 | } 29 | 30 | public static String generateReport(Exception e, Activity activity, String extra) { 31 | String[] errorMessage = {e.getMessage(), e.toString()}; 32 | 33 | return generateReport(errorMessage, activity, extra); 34 | } 35 | 36 | public static String generateReport(String[] errorMessage, Activity activity, String extra){ 37 | String message = "Feel free to add a little message : \n\n"; 38 | 39 | message += "-----BEGIN REPORT-----\n"; 40 | message += "Report type: DEBUG \n"; 41 | message += "Android version: " + " " + Build.VERSION.RELEASE + "\n"; 42 | try { 43 | message += "App version: " + activity.getPackageManager() 44 | .getPackageInfo(activity.getPackageName(), 0).versionName + "\n"; 45 | } catch (PackageManager.NameNotFoundException e1) { 46 | e1.printStackTrace(); 47 | } 48 | message += "Activity: " + activity.toString(); 49 | 50 | TimeZone tz = TimeZone.getTimeZone("UTC"); 51 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); 52 | df.setTimeZone(tz); 53 | 54 | message += df.format(new Date()) + "\n\n"; 55 | 56 | for (String m : errorMessage) { 57 | message += m + "\n\n"; 58 | } 59 | 60 | message += "-----EXTRA-----\n" + extra + "\n"; 61 | 62 | message += "-----END REPORT-----\n\n"; 63 | message += "Thanks for the report, I'll try to answer as soon as possible !\n"; 64 | 65 | return message; 66 | } 67 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/ShaarliAccount.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by dimtion on 11/05/2015. 7 | * A Shaarli Account 8 | */ 9 | 10 | public class ShaarliAccount implements Serializable { 11 | private long id; 12 | private String urlShaarli; 13 | private String username; 14 | private String password; 15 | private String basicAuthUsername; 16 | private String basicAuthPassword; 17 | private String shortName; 18 | private byte[] initialVector; 19 | private boolean validateCert; 20 | 21 | @Override 22 | public String toString() { 23 | if (this.shortName.equals("")) 24 | return username; 25 | return shortName; 26 | } 27 | 28 | public long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(long id) { 33 | this.id = id; 34 | } 35 | 36 | public String getUrlShaarli() { 37 | return urlShaarli; 38 | } 39 | 40 | public void setUrlShaarli(String urlShaarli) { 41 | this.urlShaarli = urlShaarli; 42 | } 43 | 44 | public String getUsername() { 45 | return username; 46 | } 47 | 48 | public void setUsername(String username) { 49 | this.username = username; 50 | } 51 | 52 | public String getPassword() { 53 | return password; 54 | } 55 | 56 | public void setPassword(String password) { 57 | this.password = password; 58 | } 59 | 60 | public String getBasicAuthUsername() { 61 | return basicAuthUsername; 62 | } 63 | 64 | public void setBasicAuthUsername(String basicAuthUsername) { 65 | this.basicAuthUsername = basicAuthUsername; 66 | } 67 | 68 | public String getBasicAuthPassword() { 69 | return basicAuthPassword; 70 | } 71 | 72 | public void setBasicAuthPassword(String basicAuthPassword) { 73 | this.basicAuthPassword = basicAuthPassword; 74 | } 75 | 76 | public String getShortName() { 77 | return shortName; 78 | } 79 | 80 | public void setShortName(String shortName) { 81 | this.shortName = shortName; 82 | } 83 | 84 | public byte[] getInitialVector() { 85 | return initialVector; 86 | } 87 | 88 | public void setInitialVector(byte[] initialVector) { 89 | this.initialVector = initialVector; 90 | } 91 | 92 | public boolean isValidateCert() { 93 | return validateCert; 94 | } 95 | 96 | public void setValidateCert(boolean validateCert) { 97 | this.validateCert = validateCert; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/AccountsManagementActivity.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.content.Intent; 4 | import android.database.SQLException; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | import android.widget.AdapterView; 12 | import android.widget.ArrayAdapter; 13 | import android.widget.ListView; 14 | 15 | import java.util.List; 16 | 17 | 18 | public class AccountsManagementActivity extends AppCompatActivity { 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_accounts_management); 24 | } 25 | 26 | @Override 27 | protected void onResume() { 28 | super.onResume(); 29 | final ListView accountsListView = (ListView) findViewById(R.id.accountListView); 30 | AccountsSource accountsSource = new AccountsSource(getApplicationContext()); 31 | try { 32 | accountsSource.rOpen(); 33 | List accountsList = accountsSource.getAllAccounts(); 34 | ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, accountsList); 35 | 36 | accountsListView.setAdapter(adapter); 37 | 38 | if (accountsList.isEmpty()) 39 | findViewById(R.id.noAccountToShow).setVisibility(View.VISIBLE); 40 | else 41 | findViewById(R.id.noAccountToShow).setVisibility(View.GONE); 42 | 43 | 44 | } catch (SQLException e) { 45 | Log.e("DB_ERROR", e.toString()); 46 | } finally { 47 | accountsSource.close(); 48 | } 49 | accountsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 50 | @Override 51 | public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) { 52 | ShaarliAccount clickedAccount = (ShaarliAccount) accountsListView.getItemAtPosition(position); 53 | 54 | addOrEditAccount(clickedAccount); 55 | } 56 | }); 57 | } 58 | 59 | private void addOrEditAccount(ShaarliAccount account) { 60 | Intent intent = new Intent(this, AddAccountActivity.class); 61 | if (account != null) { 62 | intent.putExtra("_id", account.getId()); 63 | Log.w("EDIT ACCOUNT", account.getShortName()); 64 | } 65 | startActivity(intent); 66 | } 67 | @Override 68 | public boolean onCreateOptionsMenu(Menu menu) { 69 | // Inflate the menu; this adds items to the action bar if it is present. 70 | getMenuInflater().inflate(R.menu.menu_accounts_management, menu); 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean onOptionsItemSelected(MenuItem item) { 76 | // Handle action bar item clicks here. The action bar will 77 | // automatically handle clicks on the Home/Up button, so long 78 | // as you specify a parent activity in AndroidManifest.xml. 79 | int id = item.getItemId(); 80 | 81 | //noinspection SimplifiableIfStatement 82 | if (id == R.id.action_add) { 83 | addOrEditAccount(null); 84 | } 85 | 86 | return super.onOptionsItemSelected(item); 87 | } 88 | } -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/TagsSource.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.SQLException; 7 | import android.database.sqlite.SQLiteDatabase; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by dimtion on 12/05/2015. 14 | * Interface between the table TAGS and the JAVA objects 15 | */ 16 | class TagsSource { 17 | private final String[] allColumns = {MySQLiteHelper.TAGS_COLUMN_ID, 18 | MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT, 19 | MySQLiteHelper.TAGS_COLUMN_TAG}; 20 | private final MySQLiteHelper dbHelper; 21 | private SQLiteDatabase db; 22 | 23 | public TagsSource(Context context) { 24 | dbHelper = new MySQLiteHelper(context); 25 | } 26 | 27 | public void rOpen() throws SQLException { 28 | db = dbHelper.getReadableDatabase(); 29 | } 30 | 31 | public void wOpen() throws SQLException { 32 | db = dbHelper.getWritableDatabase(); 33 | } 34 | 35 | public void close() { 36 | dbHelper.close(); 37 | } 38 | 39 | public List getAllTags() { 40 | List tags = new ArrayList<>(); 41 | 42 | Cursor cursor = db.query(MySQLiteHelper.TABLE_TAGS, allColumns, null, null, null, null, null); 43 | cursor.moveToFirst(); 44 | while (!cursor.isAfterLast()) { 45 | Tag account = cursorToTag(cursor); 46 | tags.add(account); 47 | cursor.moveToNext(); 48 | } 49 | 50 | cursor.close(); 51 | return tags; 52 | } 53 | 54 | public Tag createTag(ShaarliAccount masterAccount, String value) { 55 | Tag tag = new Tag(); 56 | tag.setMasterAccount(masterAccount); 57 | tag.setValue(value.trim()); 58 | 59 | ContentValues values = new ContentValues(); 60 | values.put(MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT, masterAccount.getId()); 61 | values.put(MySQLiteHelper.TAGS_COLUMN_TAG, tag.getValue()); 62 | 63 | // If existing, do nothing : 64 | String[] getTagArgs = {String.valueOf(tag.getMasterAccountId()), tag.getValue()}; 65 | 66 | Cursor cursor = db.query(MySQLiteHelper.TABLE_TAGS, allColumns, 67 | MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT + " = ? AND " + 68 | MySQLiteHelper.TAGS_COLUMN_TAG + " = ?", 69 | getTagArgs, null, null, null); 70 | try { 71 | cursor.moveToFirst(); 72 | if (cursor.isAfterLast()) { 73 | long insertId = db.insert(MySQLiteHelper.TABLE_TAGS, null, values); 74 | tag.setId(insertId); 75 | return tag; 76 | } else { 77 | tag = cursorToTag(cursor); 78 | } 79 | } catch (Exception e){ 80 | tag = null; 81 | } finally { 82 | cursor.close(); 83 | } 84 | return tag; 85 | } 86 | 87 | private Tag cursorToTag(Cursor cursor) { // If necessary (later), load the full account in the tag 88 | Tag tag = new Tag(); 89 | tag.setId(cursor.getLong(0)); 90 | tag.setMasterAccountId(cursor.getLong(1)); 91 | tag.setValue(cursor.getString(2)); 92 | return tag; 93 | } 94 | 95 | private void deleteAllTags() { 96 | db.delete(MySQLiteHelper.TABLE_TAGS, null, null); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/dimtion/shaarlier/EncryptionHelper.java: -------------------------------------------------------------------------------- 1 | package com.dimtion.shaarlier; 2 | 3 | import android.util.Base64; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | import java.security.InvalidAlgorithmParameterException; 7 | import java.security.InvalidKeyException; 8 | import java.security.NoSuchAlgorithmException; 9 | import java.security.SecureRandom; 10 | 11 | import javax.crypto.BadPaddingException; 12 | import javax.crypto.Cipher; 13 | import javax.crypto.IllegalBlockSizeException; 14 | import javax.crypto.KeyGenerator; 15 | import javax.crypto.NoSuchPaddingException; 16 | import javax.crypto.SecretKey; 17 | import javax.crypto.spec.IvParameterSpec; 18 | import javax.crypto.spec.SecretKeySpec; 19 | 20 | /** 21 | * Created by dimtion on 13/05/2015. 22 | * A simple class to encrypt and decrypt simple data 23 | * (Probably needs review) 24 | */ 25 | class EncryptionHelper { 26 | public final static int KEY_LENGTH = 256; 27 | public final static int IV_LENGTH = 16; 28 | 29 | public static SecretKey generateKey() throws NoSuchAlgorithmException { 30 | 31 | SecureRandom secureRandom = new SecureRandom(); 32 | // Do *not* seed secureRandom! Automatically seeded from system entropy. 33 | KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); 34 | keyGenerator.init(KEY_LENGTH, secureRandom); 35 | return keyGenerator.generateKey(); 36 | } 37 | 38 | public static byte[] generateInitialVector() { 39 | SecureRandom random = new SecureRandom(); 40 | return random.generateSeed(IV_LENGTH); 41 | } 42 | 43 | public static String secretKeyToString(SecretKey secretKey) { 44 | return Base64.encodeToString(secretKey.getEncoded(), Base64.DEFAULT); 45 | } 46 | 47 | public static SecretKey stringToSecretKey(String stringKey) { 48 | byte[] encodedKey = Base64.decode(stringKey, Base64.DEFAULT); 49 | return new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); 50 | } 51 | 52 | private static byte[] encryptDecrypt(int mode, byte[] clear, SecretKey key, byte[] initialVector) 53 | throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException { 54 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); 55 | IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector); 56 | 57 | cipher.init(mode, key, ivParameterSpec); 58 | return cipher.doFinal(clear); 59 | } 60 | 61 | public static byte[] encrypt(byte[] clear, SecretKey key, byte[] initialVector) 62 | throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException { 63 | return encryptDecrypt(Cipher.ENCRYPT_MODE, clear, key, initialVector); 64 | } 65 | 66 | public static byte[] decrypt(byte[] encrypted, SecretKey key, byte[] initialVector) 67 | throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException { 68 | return encryptDecrypt(Cipher.DECRYPT_MODE, encrypted, key, initialVector); 69 | } 70 | 71 | public static byte[] stringToBase64(String clear) throws UnsupportedEncodingException { 72 | return Base64.encode(clear.getBytes(), Base64.DEFAULT); 73 | } 74 | 75 | public static String base64ToString(byte[] data) throws UnsupportedEncodingException { 76 | return new String(Base64.decode(data, Base64.DEFAULT)); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 73 | 76 | 77 | 82 | 85 | 86 | 87 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /app/src/main/res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Shaarlier 4 | Réglages 5 | Une erreur s\'est produite lors du partage 6 | Contenu non géré 7 | Votre lien a bien été partagé 8 | Liens privés par défaut 9 | 10 | L\'url donnée ne semble pas fonctionner 11 | Vous n\'êtes pas connecté à internet 12 | Le pseudo ou le mot de passe est incorrect 13 | L\'url donné n\'est pas un Shaarli compatible 14 | L\'url donnée n\'est pas valide 15 | Logo de Shaarli 16 | Plus à venir… 17 | Privé 18 | Partager sur Shaarli 19 | Les paramètres sont corrects 20 | tags (séparés par des espaces) 21 | Tester puis enregistrer 22 | À propos 23 | Comportement 24 | Afficher une boite de dialogue lors du partage 25 | Ajouter à Shaarli 26 | 27 | Pseudo : 28 | Mot de passe : 29 | Url de votre Shaarli : 30 | Pour utiliser cette application vous avez besoin d\'un Shaarli, un clone minimaliste de delicious. 31 | Cette application est fièrement développée par dimtion, vous pouvez me trouver sur GitHub (et d\'autres recoins d\'internet). 32 | Chargement du title… 33 | Erreur chargement titre 34 | Charger automatiquement le titre de la page 35 | shaarli.monserveur.fr 36 | Aller à mon Shaarli 37 | Partager un lien 38 | Version inconnue 39 | (vide pour une nouvelle note) 40 | Lien à partager : 41 | (laisser vide pour une nouvelle note) 42 | Titre : 43 | Description : 44 | Add 45 | Gérer les comptes 46 | Compte par défaut 47 | Nom du compte : 48 | Il n\'y a aucun compte à afficher 49 | Valider 50 | Comptes 51 | Nouveau compte 52 | Êtes-vous sûr de vouloir supprimer ce compte ? 53 | Erreur lors du chargement des tags 54 | Désactiver la validation du certificat (non sécurisé) 55 | Ajouter un compte 56 | Vous pensez que c\'est un bug ? 57 | Voulez-vous signaler ce bug ? 58 | Charger automatiquement la description 59 | Afficher Shaarlier dans la liste des navigateurs web 60 | Authentification HTTP 61 | Aucune description n\'a été trouvé 62 | Une erreur inconnue s\'est produite 63 | Chargement… 64 | Effacer le compte 65 | "Version %1$s" 66 | Avancé 67 | Tweeter 68 | Twitter (nécessite shaarli2twitter) 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 18 | 19 | 28 | 29 | 30 |