├── .github
└── workflows
│ └── build.yaml
├── .gitignore
├── .idea
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── migrations.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── channel.css
│ ├── channel.html
│ ├── channel.js
│ └── channel.lass
│ ├── java
│ └── org
│ │ └── shirakumo
│ │ └── ocelot
│ │ ├── About.java
│ │ ├── Channel.java
│ │ ├── Chat.java
│ │ ├── Command.java
│ │ ├── DynamicListPreference.java
│ │ ├── EmoteList.java
│ │ ├── FirstTimeSetup.java
│ │ ├── PayloadView.java
│ │ ├── Service.java
│ │ ├── Settings.java
│ │ ├── Toolkit.java
│ │ └── UpdateHandler.java
│ └── res
│ ├── drawable
│ ├── channel_button.xml
│ ├── ic_add_circle_black_24dp.xml
│ ├── ic_attach_file_black_24dp.xml
│ ├── ic_close_black_24dp.xml
│ ├── ic_exit_to_app_black_24dp.xml
│ ├── ic_group_add_black_24dp.xml
│ ├── ic_info_outline_black_24dp.xml
│ ├── ic_input_black_24dp.xml
│ ├── ic_insert_emoticon_black_24dp.xml
│ ├── ic_looks_black_24dp.xml
│ ├── ic_menu.xml
│ ├── ic_notifications_black_24dp.xml
│ ├── ic_ocelot.xml
│ ├── ic_people_outline_black_24dp.xml
│ ├── ic_person_add_black_24dp.xml
│ ├── ic_person_outline_black_24dp.xml
│ ├── ic_remove_circle_black_24dp.xml
│ ├── ic_settings_black_24dp.xml
│ ├── ic_settings_ethernet_black_24dp.xml
│ └── white_circle.xml
│ ├── layout
│ ├── activity_chat.xml
│ ├── activity_first_time_setup.xml
│ ├── channel_button.xml
│ ├── dynamic_list_preference.xml
│ ├── dynamic_list_preference_entry.xml
│ ├── fragment_about.xml
│ ├── fragment_channel.xml
│ └── fragment_emote_list.xml
│ ├── menu
│ └── drawer.xml
│ ├── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ └── strings.xml
│ └── xml
│ ├── provider_paths.xml
│ ├── settings_connection.xml
│ ├── settings_headers.xml
│ ├── settings_looks.xml
│ └── settings_notification.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jLichat
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── consumer-rules.pro
├── pom.xml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── org
│ └── shirakumo
│ └── lichat
│ ├── Base64.java
│ ├── CL.java
│ ├── Client.java
│ ├── Condition.java
│ ├── Handler.java
│ ├── HandlerAdapter.java
│ ├── InputStream.java
│ ├── OutputStream.java
│ ├── Package.java
│ ├── Payload.java
│ ├── Printer.java
│ ├── Reader.java
│ ├── StandardObject.java
│ ├── Symbol.java
│ ├── Test.java
│ ├── conditions
│ ├── AlreadyConnected.java
│ ├── EncodingUnsupported.java
│ ├── EndOfStream.java
│ ├── InstantiationFailed.java
│ ├── InvalidClassDefinition.java
│ ├── InvalidUpdateReceived.java
│ ├── MalformedWireObject.java
│ ├── MissingArgument.java
│ ├── NoSuchClass.java
│ ├── NotConnected.java
│ ├── PackageAlreadyExists.java
│ ├── PingTimeout.java
│ ├── SlotMissing.java
│ ├── SlotValueFailed.java
│ ├── UnmatchedCloseParen.java
│ ├── UnprintableObject.java
│ └── WriteError.java
│ └── updates
│ ├── AlreadyInChannel.java
│ ├── Backfill.java
│ ├── BadContentType.java
│ ├── BadName.java
│ ├── Ban.java
│ ├── Capabilities.java
│ ├── ChannelInfo.java
│ ├── ChannelUpdate.java
│ ├── ChannelnameTaken.java
│ ├── Channels.java
│ ├── Connect.java
│ ├── ConnectionLost.java
│ ├── ConnectionUnstable.java
│ ├── Create.java
│ ├── Data.java
│ ├── Deny.java
│ ├── Destroy.java
│ ├── Disconnect.java
│ ├── Edit.java
│ ├── Emote.java
│ ├── Emotes.java
│ ├── Failure.java
│ ├── Grant.java
│ ├── IncompatibleVersion.java
│ ├── InsufficientPermissions.java
│ ├── InvalidPassword.java
│ ├── InvalidPermissions.java
│ ├── InvalidUpdate.java
│ ├── IpBan.java
│ ├── IpUnban.java
│ ├── Join.java
│ ├── Kick.java
│ ├── Kill.java
│ ├── Leave.java
│ ├── MalformedUpdate.java
│ ├── Message.java
│ ├── NoSuchChannel.java
│ ├── NoSuchChannelInfo.java
│ ├── NoSuchProfile.java
│ ├── NoSuchUser.java
│ ├── NoSuchUserInfo.java
│ ├── NotInChannel.java
│ ├── Pause.java
│ ├── Permissions.java
│ ├── Ping.java
│ ├── Pong.java
│ ├── Pull.java
│ ├── Quiet.java
│ ├── Register.java
│ ├── ServerInfo.java
│ ├── SetChannelInfo.java
│ ├── SetUserInfo.java
│ ├── TargetUpdate.java
│ ├── TextUpdate.java
│ ├── TooManyConnections.java
│ ├── TooManyUpdates.java
│ ├── Unban.java
│ ├── Unquiet.java
│ ├── Update.java
│ ├── UpdateFailure.java
│ ├── UpdateTooLong.java
│ ├── UserInfo.java
│ ├── UsernameMismatch.java
│ ├── UsernameTaken.java
│ └── Users.java
├── metadata
└── en-US
│ ├── changelogs
│ └── 3.txt
│ ├── full_description.txt
│ ├── images
│ ├── icon.png
│ └── phoneScreenshots
│ │ ├── 1.png
│ │ ├── 2.png
│ │ └── 3.png
│ ├── short_description.txt
│ └── title.txt
├── settings.gradle
└── shirakumo.jks.gpg
/.github/workflows/build.yaml:
--------------------------------------------------------------------------------
1 | name: Build APK
2 | on: [create, workflow_dispatch]
3 |
4 | jobs:
5 | build:
6 | runs-on: ubuntu-latest
7 | steps:
8 | - name: Checkout the code
9 | uses: actions/checkout@v2
10 | - name: Setup Java
11 | uses: actions/setup-java@v4
12 | with:
13 | distribution: 'temurin'
14 | java-version: '21'
15 | - name: Prepare keys
16 | run: |
17 | gpg --quiet --batch --yes --decrypt --passphrase "$RELEASE_PASSWORD" --output $HOME/shirakumo.jks shirakumo.jks.gpg
18 | mkdir -p $HOME/.gradle
19 | echo "RELEASE_STORE_FILE=$HOME/shirakumo.jks" >> $HOME/.gradle/gradle.properties
20 | echo "RELEASE_STORE_PASSWORD=$RELEASE_PASSWORD" >> $HOME/.gradle/gradle.properties
21 | echo "RELEASE_KEY_ALIAS=shirakumo" >> $HOME/.gradle/gradle.properties
22 | echo "RELEASE_KEY_PASSWORD=$RELEASE_PASSWORD" >> $HOME/.gradle/gradle.properties
23 | env:
24 | RELEASE_PASSWORD: ${{ secrets.RELEASE_PASSWORD }}
25 | - name: Build the app
26 | run: ./gradlew build
27 | - name: Assemble
28 | run: ./gradlew assembleRelease
29 | - name: Upload artifact
30 | uses: actions/upload-artifact@v1
31 | with:
32 | name: app
33 | path: app/build/outputs/apk/release/app-release.apk
34 | - name: Create release
35 | id: create_release
36 | uses: actions/create-release@v1
37 | env:
38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 | with:
40 | tag_name: rel-${{ github.ref }}
41 | release_name: Release ${{ github.ref }}
42 | draft: false
43 | prerelease: false
44 | - name: Upload release
45 | uses: actions/upload-release-asset@v1
46 | env:
47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 | with:
49 | upload_url: ${{ steps.create_release.outputs.upload_url }}
50 | asset_path: app/build/outputs/apk/release/app-release.apk
51 | asset_name: ocelot.apk
52 | asset_content_type: application/vnd.android.package-archive
53 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | jLichat/build
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Yukari Hafner
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 | 2. Altered source versions must be plainly marked as such, and must not be
16 | misrepresented as being the original software.
17 | 3. This notice may not be removed or altered from any source distribution.
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Ocelot
2 | ======
3 |
4 | A chat client for the Lichat protocol.
5 |
6 | This supports the full Lichat 2.0 protocol, including most extensions.
7 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 34
5 | defaultConfig {
6 | applicationId "org.shirakumo.ocelot"
7 | minSdkVersion 21
8 | targetSdkVersion 34
9 | versionCode 6
10 | versionName '0.6'
11 | }
12 | signingConfigs{
13 | release {
14 | storeFile file(RELEASE_STORE_FILE)
15 | storePassword RELEASE_STORE_PASSWORD
16 | keyAlias RELEASE_KEY_ALIAS
17 | keyPassword RELEASE_KEY_PASSWORD
18 | v1SigningEnabled true
19 | v2SigningEnabled true
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | signingConfig signingConfigs.release
27 | }
28 | }
29 | productFlavors {
30 | }
31 | compileOptions {
32 | targetCompatibility 1.8
33 | sourceCompatibility 1.8
34 | }
35 | buildFeatures {
36 | buildConfig true
37 | }
38 | namespace 'org.shirakumo.ocelot'
39 | lint {
40 | abortOnError false
41 | }
42 | }
43 |
44 | dependencies {
45 | implementation project(':jLichat')
46 | implementation 'androidx.preference:preference:1.2.1'
47 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
48 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
49 | implementation 'com.google.android.material:material:1.11.0'
50 | implementation 'com.rarepebble:colorpicker:2.2.0'
51 | }
52 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
48 |
49 |
54 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/assets/channel.css:
--------------------------------------------------------------------------------
1 | #channel{font-family:monospace;}#channel .update{margin-top:0.2em;}#channel .update >*{display:flex;align-items:flex-start;}#channel .update .content .clock{color:gray;}#channel .update .clock{text-align:center;margin-right:0.5em;}#channel .update .from{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.5em;min-width:100px;}#channel .update .text{word-wrap:break-word;white-space:pre-wrap;min-width:0px;flex-grow:1;}#channel .update .text a{text-decoration:none;}#channel .update .text .payload{max-width:100%;max-height:50vh;}
--------------------------------------------------------------------------------
/app/src/main/assets/channel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/assets/channel.js:
--------------------------------------------------------------------------------
1 | var channel = document.getElementById("channel");
2 |
3 | var constructElement = function(options){
4 | var el = document.createElement(options.tag);
5 | el.setAttribute("class", (options.classes||[]).join(" "));
6 | if(options.text) el.innerText = options.text;
7 | if(options.html) el.innerHTML = options.html;
8 | for(var attr in (options.attributes||{})){
9 | el.setAttribute(attr, options.attributes[attr]);
10 | }
11 | for(var i in (options.elements||[])){
12 | el.appendChild(constructElement(options.elements[i]));
13 | }
14 | return el;
15 | };
16 |
17 | var objectColor = function(object){
18 | var str = object.toString();
19 | var hash = 0;
20 | for(var i=0; i>8)-1;
25 | var g = 16*(1+(encoded&0x0F0)>>4)-1;
26 | var b = 16*(1+(encoded&0x00F)>>0)-1;
27 |
28 | return "rgb("+Math.min(200, Math.max(50, r))
29 | +","+Math.min(180, Math.max(80, g))
30 | +","+Math.min(180, Math.max(80, b))+")";
31 | };
32 |
33 | var formatTime = function(time){
34 | var date = new Date(time*1000);
35 | var pd = function(a){return (a<10)?"0"+a:""+a;}
36 | return pd(date.getHours())+":"+pd(date.getMinutes())+":"+pd(date.getSeconds());
37 | };
38 |
39 | var reloadCSS = function(){
40 | var links = document.getElementsByTagName("link");
41 | for(var i in links){
42 | var link = links[i];
43 | if(link.rel === "stylesheet"){
44 | var h = link.href.replace(/(&|\?)forceReload=\d /,"");
45 | link.href=h+(h.indexOf('?')>=0?'&':'?')+"forceReload="+(new Date().valueOf());
46 | }
47 | }
48 | };
49 |
50 | var clear = function(){
51 | while(channel.firstChild){
52 | channel.removeChild(channel.firstChild);
53 | }
54 | };
55 |
56 | var matchesFrom = function(node, from){
57 | return node.children[0].children[1].innerText === from;
58 | };
59 |
60 | var isAtBottom = function(){
61 | return (window.innerHeight + window.scrollY) >= document.body.offsetHeight;
62 | };
63 |
64 | var lastInserted = null;
65 | var addScrollHandler = function(element){
66 | if(!isAtBottom()) return element;
67 | lastInserted = element;
68 | var elements = element.querySelectorAll("img,audio,video");
69 | for(var i=0; i* :display flex
6 | :align-items flex-start)
7 | ((.content .clock) :color gray)
8 | (.clock :text-align center
9 | :margin-right 0.5em)
10 | (.from :overflow hidden
11 | :white-space nowrap
12 | :text-overflow ellipsis
13 | :margin-left 0.5em
14 | :min-width 100px)
15 | (.text :word-wrap break-word
16 | :white-space pre-wrap
17 | :min-width 0px
18 | :flex-grow 1
19 | (a :text-decoration none)
20 | (.payload
21 | :max-width 100%
22 | :max-height 50vh))))
23 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/About.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.app.DialogFragment;
4 | import android.os.Bundle;
5 | import android.text.Html;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | public class About extends DialogFragment {
12 | public About() {
13 | // Required empty public constructor
14 | }
15 |
16 | public static About newInstance() {
17 | return new About();
18 | }
19 |
20 | public void onResume(){
21 | super.onResume();
22 | setStyle(DialogFragment.STYLE_NORMAL, R.style.Theme_AppCompat_Light_Dialog_Alert);
23 | }
24 |
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
27 | Bundle savedInstanceState) {
28 | View view = inflater.inflate(R.layout.fragment_about, container, false);
29 | ((TextView)view.findViewById(R.id.about_version)).setText(BuildConfig.VERSION_NAME);
30 |
31 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
32 | ((TextView) view.findViewById(R.id.about_text)).setText(Html.fromHtml(getString(R.string.app_description), Html.FROM_HTML_MODE_COMPACT));
33 | }else{
34 | ((TextView) view.findViewById(R.id.about_text)).setText(Html.fromHtml(getString(R.string.app_description)));
35 | }
36 | return view;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/Command.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | @FunctionalInterface
4 | public interface Command {
5 | public void execute(Channel channel, String[] args);
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/DynamicListPreference.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.content.res.TypedArray;
6 | import android.preference.DialogPreference;
7 | import android.util.AttributeSet;
8 | import android.view.KeyEvent;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.inputmethod.EditorInfo;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 | import android.widget.ImageButton;
15 | import android.widget.LinearLayout;
16 | import android.widget.TextView;
17 |
18 | import java.util.Arrays;
19 | import java.util.Set;
20 | import java.util.TreeSet;
21 |
22 | public class DynamicListPreference extends DialogPreference {
23 | private Set entries = new TreeSet<>();
24 |
25 | public DynamicListPreference(Context context, AttributeSet attrs){
26 | this(context, attrs, 0);
27 | }
28 |
29 | public DynamicListPreference(Context context, AttributeSet attrs, int defStyleAttr){
30 | super(context, attrs, defStyleAttr);
31 |
32 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DynamicListPreference);
33 | int entriesId = ta.getResourceId(R.styleable.DynamicListPreference_entries, -1);
34 | if(entriesId != -1){
35 | entries.addAll(Arrays.asList(context.getResources().getStringArray(entriesId)));
36 | }
37 | ta.recycle();
38 |
39 | setDialogLayoutResource(R.layout.dynamic_list_preference);
40 | }
41 |
42 | private void addEntry(LinearLayout view, String entry){
43 | LayoutInflater li = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
44 | View entryView = li.inflate(R.layout.dynamic_list_preference_entry, null);
45 |
46 | ((TextView)entryView.findViewById(R.id.entry)).setText(entry);
47 | entryView.findViewById(R.id.remove_entry).setOnClickListener((vw)->{
48 | entries.remove(entry);
49 | view.removeView(entryView);
50 | });
51 | view.addView(entryView);
52 | }
53 |
54 | @Override
55 | protected void onBindDialogView(View view) {
56 | super.onBindDialogView(view);
57 | ImageButton add_entry = view.findViewById(R.id.add_entry);
58 | EditText entry_name = view.findViewById(R.id.new_entry);
59 | LinearLayout entries = view.findViewById(R.id.entries);
60 |
61 | entry_name.setOnEditorActionListener((TextView vw, int actionId, KeyEvent event)->{
62 | if (actionId == EditorInfo.IME_ACTION_DONE ||
63 | (event != null && !event.isShiftPressed() && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)){
64 | add_entry.callOnClick();
65 | return true;
66 | }
67 | return false;
68 | });
69 |
70 | add_entry.setOnClickListener((vw)->{
71 | String channel = entry_name.getText().toString();
72 | if(!channel.isEmpty()){
73 | entry_name.setText("");
74 | if(this.entries.add(channel))
75 | addEntry(entries, channel);
76 | }
77 | });
78 |
79 | for(String entry : this.entries){
80 | addEntry(entries, entry);
81 | }
82 | }
83 |
84 | @Override
85 | protected void onDialogClosed(boolean positiveResult) {
86 | SharedPreferences.Editor edit = getSharedPreferences().edit();
87 | edit.putStringSet(getKey(), entries);
88 | edit.apply();
89 | }
90 |
91 | @Override
92 | protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
93 | entries.clear();
94 | if (restorePersistedValue) {
95 | entries.addAll(getSharedPreferences().getStringSet(getKey(), new TreeSet<>()));
96 | } else {
97 | entries.addAll((Set)defaultValue);
98 | }
99 | }
100 |
101 | @Override
102 | protected Object onGetDefaultValue(TypedArray a, int index) {
103 | return a.getTextArray(index);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/EmoteList.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.Context;
6 | import android.os.Bundle;
7 | import android.app.DialogFragment;
8 | import android.util.DisplayMetrics;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.BaseAdapter;
14 | import android.widget.GridView;
15 |
16 | import org.shirakumo.lichat.Payload;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | public class EmoteList extends DialogFragment {
24 |
25 | EmoteListListener listener;
26 | View view;
27 | List images = new ArrayList<>();
28 |
29 | public EmoteList() {
30 | // Required empty public constructor
31 | }
32 |
33 | public static EmoteList newInstance() {
34 | return new EmoteList();
35 | }
36 |
37 | public void onResume(){
38 | super.onResume();
39 | setStyle(DialogFragment.STYLE_NORMAL, R.style.Theme_AppCompat_Light_Dialog_Alert);
40 | }
41 |
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
44 | Bundle savedInstanceState) {
45 | view = inflater.inflate(R.layout.fragment_emote_list, container, false);
46 | GridView grid = view.findViewById(R.id.emotes);
47 | grid.setAdapter(new GridViewAdapter());
48 |
49 | if(listener != null) showEmotes(listener.getEmotes());
50 | return view;
51 | }
52 |
53 | public void showEmotes(Map emotes){
54 | String[] names = new String[emotes.size()];
55 | names = emotes.keySet().toArray(names);
56 | Arrays.sort(names);
57 | for(String name : names){
58 | // FIXME: cache views
59 | PayloadView emote = new PayloadView(view.getContext(), emotes.get(name));
60 | emote.setOnClickListener((v)->{
61 | listener.onEmoteChosen(name);
62 | dismiss();
63 | });
64 | images.add(emote);
65 | }
66 | }
67 |
68 | @Override
69 | public void onAttach(Activity context) {
70 | super.onAttach(context);
71 | try {
72 | listener = (EmoteListListener) context;
73 | if(view != null) showEmotes(listener.getEmotes());
74 | } catch (ClassCastException e) {
75 | throw new ClassCastException(context.toString()+" must implement EmoteListListener");
76 | }
77 | }
78 |
79 | @Override
80 | public void onAttach(Context context) {
81 | super.onAttach(context);
82 | try {
83 | listener = (EmoteListListener) context;
84 | if(view != null) showEmotes(listener.getEmotes());
85 | } catch (ClassCastException e) {
86 | throw new ClassCastException(context.toString()+" must implement EmoteListListener");
87 | }
88 | }
89 |
90 | @Override
91 | public void onDetach() {
92 | super.onDetach();
93 | listener = null;
94 | }
95 |
96 | public interface EmoteListListener{
97 | public void onEmoteChosen(String emote);
98 | public Map getEmotes();
99 | }
100 |
101 | private class GridViewAdapter extends BaseAdapter{
102 | @Override
103 | public int getCount() {
104 | return images.size();
105 | }
106 |
107 | @Override
108 | public Object getItem(int position) {
109 | return null;
110 | }
111 |
112 | @Override
113 | public long getItemId(int position) {
114 | return 0;
115 | }
116 |
117 | @Override
118 | public View getView(int position, View convertView, ViewGroup parent) {
119 | return images.get(position);
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/FirstTimeSetup.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.preference.PreferenceManager;
7 | import android.view.View;
8 | import android.widget.CheckBox;
9 | import android.widget.EditText;
10 | import android.widget.Switch;
11 |
12 | public class FirstTimeSetup extends Activity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_first_time_setup);
18 | EditText username = ((EditText)findViewById(R.id.setup_username));
19 | EditText password = ((EditText)findViewById(R.id.setup_password));
20 | EditText hostname = ((EditText)findViewById(R.id.setup_hostname));
21 | EditText port = ((EditText)findViewById(R.id.setup_port));
22 | CheckBox registered = ((CheckBox)findViewById(R.id.setup_registered));
23 |
24 | registered.setOnCheckedChangeListener((vw, ticked)->{
25 | password.setVisibility(ticked? View.VISIBLE : View.GONE);
26 | });
27 |
28 | findViewById(R.id.setup_complete).setOnClickListener((vw)->{
29 | boolean error = false;
30 |
31 | if(32 < username.getText().length()){
32 | username.setError("The username must be less than 32 characters long.");
33 | error = true;
34 | }
35 |
36 | if(password.getText().length() < 6 && registered.isChecked()){
37 | password.setError("Registered accounts need a password with 6 to 32 characters.");
38 | error = true;
39 | }
40 |
41 | if(65535 < Integer.parseInt(port.getText().toString())){
42 | port.setError("There are not ports above 65535.");
43 | error = true;
44 | }
45 |
46 | if(!error) {
47 | PreferenceManager.getDefaultSharedPreferences(this).edit()
48 | .putBoolean("setup", true)
49 | .putString("username", username.getText().toString())
50 | .putString("password", password.getText().toString())
51 | .putString("hostname", hostname.getText().toString())
52 | .putString("port", port.getText().toString())
53 | .putBoolean("autoconnect", ((Switch) findViewById(R.id.setup_autoconnect)).isChecked())
54 | .apply();
55 |
56 | Intent intent = new Intent();
57 | intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
58 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
59 | intent.putExtra("app_package", getBaseContext().getPackageName());
60 | intent.putExtra("app_uid", getBaseContext().getApplicationInfo().uid);
61 | intent.putExtra("android.provider.extra.APP_PACKAGE", getBaseContext().getPackageName());
62 | getBaseContext().startActivity(intent);
63 |
64 | finish();
65 | }
66 | });
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/PayloadView.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.Movie;
8 | import android.view.View;
9 |
10 | import org.shirakumo.lichat.Payload;
11 |
12 | public class PayloadView extends View {
13 | Bitmap image;
14 | Movie movie;
15 | long start = 0;
16 |
17 | public PayloadView(Context context, Payload payload){
18 | super(context);
19 | if(payload.contentType.equals("image/gif")){
20 | movie = Movie.decodeByteArray(payload.data, 0, payload.data.length);
21 | }else{
22 | image = BitmapFactory.decodeByteArray(payload.data, 0, payload.data.length, null);
23 | }
24 | }
25 |
26 | @Override
27 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
28 | if(movie != null)
29 | setMeasuredDimension(movie.width()*2, movie.height()*2);
30 | else if(image != null)
31 | setMeasuredDimension(image.getWidth()*2, image.getHeight()*2);
32 | else
33 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
34 | }
35 |
36 | @Override
37 | protected void onDraw(Canvas canvas) {
38 | drawContent(canvas);
39 | }
40 |
41 | private void drawContent(Canvas canvas){
42 | canvas.scale(2f, 2f);
43 | if (movie != null) {
44 | long now = android.os.SystemClock.uptimeMillis();
45 | if (start == 0) { start = now; }
46 |
47 | int dur = movie.duration();
48 | if (dur <= 0) {
49 | dur = 1000;
50 | }
51 |
52 | movie.setTime((int)((now - start) % dur));
53 |
54 | movie.draw(canvas, 0, 0);
55 | invalidate();
56 | }else if(image != null){
57 | canvas.drawBitmap(image, 0, 0, null);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/Settings.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.preference.Preference;
8 | import android.preference.PreferenceActivity;
9 | import android.preference.PreferenceFragment;
10 | import android.preference.PreferenceManager;
11 |
12 | import java.io.File;
13 | import java.util.List;
14 |
15 | public class Settings extends PreferenceActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | }
21 |
22 | @Override
23 | public void onBuildHeaders(List target) {
24 | loadHeadersFromResource(R.xml.settings_headers, target);
25 | }
26 |
27 | @Override
28 | protected boolean isValidFragment (String fragmentName) {
29 | return true;
30 | }
31 |
32 |
33 |
34 | private abstract static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
35 | @Override
36 | public void onResume() {
37 | super.onResume();
38 | getPreferenceScreen()
39 | .getSharedPreferences()
40 | .registerOnSharedPreferenceChangeListener(this);
41 | }
42 |
43 | @Override
44 | public void onPause() {
45 | super.onPause();
46 | getPreferenceScreen()
47 | .getSharedPreferences()
48 | .unregisterOnSharedPreferenceChangeListener(this);
49 | }
50 | }
51 |
52 | public static class Connection extends SettingsFragment{
53 | @Override
54 | public void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | addPreferencesFromResource(R.xml.settings_connection);
57 | }
58 |
59 | @Override
60 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
61 | if (key.equals("username")) {
62 | Preference pref = findPreference(key);
63 | pref.setSummary(sharedPreferences.getString(key, ""));
64 | }
65 | }
66 | }
67 |
68 | public static class Notification extends SettingsFragment {
69 | @Override
70 | public void onCreate(Bundle savedInstanceState) {
71 | super.onCreate(savedInstanceState);
72 | addPreferencesFromResource(R.xml.settings_notification);
73 |
74 | Preference systemNotifs = findPreference("system_notifications");
75 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
76 | systemNotifs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
77 | @Override
78 | public boolean onPreferenceClick(Preference preference) {
79 | Intent intent = new Intent();
80 | intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
81 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
82 | intent.putExtra("app_package", getContext().getPackageName());
83 | intent.putExtra("app_uid", getContext().getApplicationInfo().uid);
84 | intent.putExtra("android.provider.extra.APP_PACKAGE", getContext().getPackageName());
85 | getContext().startActivity(intent);
86 | return true;
87 | }
88 | });
89 | } else {
90 | systemNotifs.setEnabled(false);
91 | }
92 | }
93 |
94 | @Override
95 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
96 | }
97 | }
98 |
99 | public static class Looks extends SettingsFragment {
100 | @Override
101 | public void onCreate(Bundle savedInstanceState) {
102 | super.onCreate(savedInstanceState);
103 | addPreferencesFromResource(R.xml.settings_looks);
104 | }
105 |
106 | @Override
107 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
108 | if (key.equals("username")) {
109 | Preference pref = findPreference(key);
110 | pref.setSummary(sharedPreferences.getString(key, ""));
111 | }
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/org/shirakumo/ocelot/UpdateHandler.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.ocelot;
2 |
3 | import org.shirakumo.lichat.HandlerAdapter;
4 | import org.shirakumo.lichat.Payload;
5 | import org.shirakumo.lichat.conditions.InvalidUpdateReceived;
6 | import org.shirakumo.lichat.updates.*;
7 |
8 | public class UpdateHandler extends HandlerAdapter {
9 |
10 | private Chat chat;
11 |
12 | public UpdateHandler(Chat chat){
13 | this.chat = chat;
14 | }
15 |
16 | public void handle(Failure update){
17 | chat.getChannel().showText(update.clock, update.from, " ** Failure: "+update.text);
18 | }
19 |
20 | public void handle(Join update){
21 | chat.ensureChannel(update.channel);
22 | chat.getChannel(update.channel).showText(update.clock, update.from, " ** Joined "+update.channel);
23 | }
24 |
25 | public void handle(Leave update){
26 | chat.getChannel(update.channel).showText(update.clock, update.from, " ** Left "+update.channel);
27 | }
28 |
29 | public void handle(Message update){
30 | chat.getChannel(update.channel).showText(update.clock, update.from, update.text);
31 | }
32 |
33 | public void handle(Data update){
34 | chat.getChannel(update.channel).showData(update.clock, update.from, update);
35 | }
36 |
37 | public void handle(Channels update){
38 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(update.clock, update.from, "Channels: "+
39 | Toolkit.join(update.channels, ", "));
40 | }
41 |
42 | public void handle(Users update){
43 | chat.getChannel(update.from).showText(update.clock, update.from, "Users: "+
44 | Toolkit.join(update.users, ", "));
45 | }
46 |
47 | public void handle(Connect update){
48 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(" ** Connection established");
49 | }
50 |
51 | public void handle(Disconnect update){
52 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(" ** Connection closed");
53 | }
54 |
55 | public void handle(ConnectionLost update){
56 | if(update.exception instanceof InvalidUpdateReceived){
57 | Object real = ((InvalidUpdateReceived)update.exception).object;
58 | if(real instanceof Failure){
59 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(" ** "+((Failure)real).text);
60 | }else{
61 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(" ** Received unexpected response of type "+real.getClass().getSimpleName());
62 | }
63 | }else{
64 | chat.getChannel(Chat.SYSTEM_CHANNEL).showText(" ** Connection lost");
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/channel_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
11 |
12 |
13 | -
14 |
15 |
16 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_circle_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_attach_file_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_exit_to_app_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_group_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_input_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_insert_emoticon_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_looks_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_people_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_remove_circle_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings_ethernet_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/white_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
42 |
43 |
59 |
60 |
61 |
62 |
63 |
71 |
72 |
73 |
74 |
90 |
91 |
104 |
105 |
118 |
119 |
120 |
126 |
127 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_first_time_setup.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
32 |
33 |
47 |
48 |
59 |
60 |
75 |
76 |
85 |
86 |
99 |
100 |
114 |
115 |
126 |
127 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/channel_button.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dynamic_list_preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
25 |
26 |
39 |
40 |
49 |
50 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dynamic_list_preference_entry.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
37 |
38 |
52 |
53 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_channel.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_emote_list.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #FFFFFF
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 12sp
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Ocelot
3 | OcelotClient
4 | Ocelot is an open source Android client for the Lichat chat protocol.
6 | You can obtain the source code for Ocelot on GitHub.
7 | Ocelot and Lichat are © 2017 Shirakumo, www.shirakumo.org
8 | ]]>
9 | Ok
10 | Send file
11 | Open emote drawer
12 | Enter your chat message
13 | Channel name
14 | User name
15 | Password
16 | Server hostname
17 | Server port
18 | Ocelot
19 | Ocelot is connected.
20 | Ocelot Notifications
21 | Ocelot Service
22 | Channel for the background service notification
23 | Ocelot Updates
24 | Notifications about messages and updates from the Ocelot chat
25 | Connection
26 | Account and Server connection settings
27 | Username
28 | Your username to connect with
29 | Password
30 | The password to use if you registered your account
31 | Server Hostname
32 | The hostname or IP address of the Lichat server
33 | Server Port
34 | The TCP port to connect to the server with
35 | Connect on start
36 | Connect immediately when Ocelot starts
37 | Channels to join
38 | Which channels to join after connecting
39 | Notification
40 | How and when to display notifications
41 | Show Notifications
42 |
43 | System Notifications
44 | Go to system notification settings
45 | Notify on message
46 | Show a notification on every message
47 | Notify on mention
48 | Show a notification when you are mentioned
49 | Notification sound
50 | The sound to play on a notification
51 | Vibration
52 | Vibrate when a notification arrives
53 | Notification Light
54 | Make the phone show its light when a notification arrives
55 | Light Colour
56 | The colour of the notification light
57 | Looks
58 | Change the look of the chat
59 | Font size
60 | The default font size of the chat in pt
61 | Own username color
62 | The colour of your own username
63 | Background color
64 | The background colour of the chat
65 | Foreground color
66 | The text colour of the chat
67 | Link color
68 | The colour of links
69 | Mention highlight
70 | The colour to highlight mentions with
71 | Show emotes
72 | Will turn :emotes: into images
73 | Show data
74 | Will show images, videos, etc. in-line
75 | Channels
76 | Manage
77 | Join Channel
78 | Leave Channel
79 | Create Channel
80 | Pull User to Channel
81 | Kick User from Channel
82 | Connect
83 | Disconnect
84 | System
85 | Settings
86 | Quit
87 | About
88 | Welcome to Ocelot
89 | User information
90 | Server information
91 | Automatically connect on start
92 | Finish
93 | Registered
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_connection.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
20 |
27 |
35 |
40 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_headers.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_looks.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
13 |
18 |
23 |
28 |
33 |
38 |
43 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
13 |
19 |
25 |
31 |
37 |
43 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:8.2.0'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/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 | android.enableJetifier=false
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 | RELEASE_STORE_FILE=shirakumo.jks.gpg
21 | RELEASE_STORE_PASSWORD=
22 | RELEASE_KEY_ALIAS=
23 | RELEASE_KEY_PASSWORD=
24 | android.nonTransitiveRClass=false
25 | android.nonFinalResIds=false
26 | org.gradle.configuration-cache=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shirakumo/Ocelot/3dc014388c61ac0fba2912cd0bfac09d04dadb76/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/jLichat/.gitignore:
--------------------------------------------------------------------------------
1 | target/
--------------------------------------------------------------------------------
/jLichat/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Yukari Hafner
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 | 2. Altered source versions must be plainly marked as such, and must not be
16 | misrepresented as being the original software.
17 | 3. This notice may not be removed or altered from any source distribution.
18 |
--------------------------------------------------------------------------------
/jLichat/README.md:
--------------------------------------------------------------------------------
1 | ## About jLichat
2 | This is a Java library implementing the client protocol for the [Lichat](https://shirakumo.github.io/lichat-protocol) protocol.
3 |
4 | ## How To
5 | The `Client` class gives you a functioning TCP client using the standard Sockets API. In order to process events as they arrive, extend the `HandlerAdapter` or do your own dispatching with the `Handler` interface. You can add as many handlers as you want to the client through the `addHandler` class.
6 |
7 | The rest should be pretty self-explanatory by the source and Lichat documentation.
8 |
--------------------------------------------------------------------------------
/jLichat/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | }
4 |
5 | android {
6 | compileSdkVersion 34
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 34
11 |
12 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
13 | consumerProguardFiles "consumer-rules.pro"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | compileOptions {
23 | sourceCompatibility JavaVersion.VERSION_1_8
24 | targetCompatibility JavaVersion.VERSION_1_8
25 | }
26 | namespace 'org.shirakumo.jLichat'
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/jLichat/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shirakumo/Ocelot/3dc014388c61ac0fba2912cd0bfac09d04dadb76/jLichat/consumer-rules.pro
--------------------------------------------------------------------------------
/jLichat/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | org.shirakumo
6 | jLichat
7 | jar
8 | 1.0.0
9 |
10 |
11 |
12 |
13 | UTF-8
14 | org.shirakumo.lichat.Test
15 |
16 |
17 |
18 |
19 | org.apache.maven.plugins
20 | maven-compiler-plugin
21 | 3.6.1
22 |
23 | 1.8
24 | 1.8
25 |
26 |
27 |
28 | org.codehaus.mojo
29 | exec-maven-plugin
30 | 1.2.1
31 |
32 |
33 |
34 | java
35 |
36 |
37 |
38 |
39 | org.shirakumo.lichat.Test
40 |
41 |
42 |
43 |
44 |
45 | org.apache.maven.plugins
46 | maven-jar-plugin
47 | 3.0.2
48 |
49 |
50 |
51 | org.shirakumo.lichat.Test
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.apache.maven.plugins
62 | maven-javadoc-plugin
63 | 3.0.0-M1
64 |
65 | Shirakumo.]]>
66 | public
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/jLichat/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/jLichat/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/jLichat/src/main/java/org/shirakumo/lichat/Base64.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.lichat;
2 |
3 | // We need this because java.util.Base64 is a Java8 thing
4 | // and thus not available in older Android SDKs. Sigh.
5 | //
6 | // From https://stackoverflow.com/a/10736154/743237
7 | public class Base64 {
8 | private static final char[] map1 = new char[64];
9 | static {
10 | int i=0;
11 | for (char c='A'; c<='Z'; c++) map1[i++] = c;
12 | for (char c='a'; c<='z'; c++) map1[i++] = c;
13 | for (char c='0'; c<='9'; c++) map1[i++] = c;
14 | map1[i++] = '+'; map1[i++] = '/';
15 | }
16 |
17 | private static final byte[] map2 = new byte[128];
18 | static {
19 | for (int i=0; i>> 2;
44 | int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
45 | int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
46 | int o3 = i2 & 0x3F;
47 | out[op++] = map1[o0];
48 | out[op++] = map1[o1];
49 | out[op] = op < oDataLen ? map1[o2] : '='; op++;
50 | out[op] = op < oDataLen ? map1[o3] : '='; op++; }
51 | return out;
52 | }
53 |
54 | public static byte[] decode (String s) {
55 | return decode(s.toCharArray());
56 | }
57 |
58 | public static byte[] decode (char[] in) {
59 | return decode(in, 0, in.length);
60 | }
61 |
62 | public static byte[] decode (char[] in, int iOff, int iLen) {
63 | if (iLen%4 != 0) throw new IllegalArgumentException ("Length of Base64 encoded input string is not a multiple of 4.");
64 | while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--;
65 | int oLen = (iLen*3) / 4;
66 | byte[] out = new byte[oLen];
67 | int ip = iOff;
68 | int iEnd = iOff + iLen;
69 | int op = 0;
70 | while (ip < iEnd) {
71 | int i0 = in[ip++];
72 | int i1 = in[ip++];
73 | int i2 = ip < iEnd ? in[ip++] : 'A';
74 | int i3 = ip < iEnd ? in[ip++] : 'A';
75 | if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
76 | throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
77 | int b0 = map2[i0];
78 | int b1 = map2[i1];
79 | int b2 = map2[i2];
80 | int b3 = map2[i3];
81 | if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
82 | throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
83 | int o0 = ( b0 <<2) | (b1>>>4);
84 | int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
85 | int o2 = ((b2 & 3)<<6) | b3;
86 | out[op++] = (byte)o0;
87 | if (op symbols;
7 |
8 | Package(String name){
9 | this.name = name;
10 | symbols = new HashMap();
11 | }
12 |
13 | public Symbol findSymbol(String name){
14 | return symbols.get(name);
15 | }
16 |
17 | public Symbol intern(String name){
18 | Symbol symbol = symbols.get(name);
19 | if(symbol == null){
20 | symbol = new Symbol(this, name);
21 | symbols.put(name, symbol);
22 | }
23 | return symbol;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/jLichat/src/main/java/org/shirakumo/lichat/Payload.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.lichat;
2 | import org.shirakumo.lichat.updates.*;
3 |
4 | import java.net.URLConnection;
5 | import java.util.*;
6 | import java.io.*;
7 |
8 | public class Payload{
9 | public final String name;
10 | public final String contentType;
11 | public final byte[] data;
12 |
13 | public Payload(Emote update){
14 | this(update.name, update.contentType, update.payload);
15 | }
16 |
17 | public Payload(Data update){
18 | this(update.filename, update.contentType, update.payload);
19 | }
20 |
21 | public Payload(String path) throws IOException{
22 | this(new File(path));
23 | }
24 |
25 | public Payload(File path) throws IOException{
26 | this(path.getName(), URLConnection.guessContentTypeFromName(path.getName()), new FileInputStream(path));
27 | }
28 |
29 | public Payload(String name, String contentType, String data){
30 | this(name, contentType, Base64.decode(data));
31 | }
32 |
33 | public Payload(String name, String contentType, byte[] data){
34 | this.name = name;
35 | this.contentType = contentType;
36 | this.data = data;
37 | }
38 |
39 | public Payload(String name, String contentType, java.io.InputStream stream) throws IOException{
40 | this.name = name;
41 | this.contentType = contentType;
42 | this.data = CL.readOctetStream(stream);
43 | }
44 |
45 | public void save(String path) throws IOException{
46 | save(new File(path));
47 | }
48 |
49 | public void save(File path) throws IOException{
50 | FileOutputStream out = new FileOutputStream(path);
51 | out.write(data);
52 | out.close();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/jLichat/src/main/java/org/shirakumo/lichat/Printer.java:
--------------------------------------------------------------------------------
1 | package org.shirakumo.lichat;
2 | import org.shirakumo.lichat.conditions.*;
3 | import java.util.*;
4 |
5 | public class Printer{
6 | public final OutputStream stream;
7 |
8 | public Printer(OutputStream stream){
9 | this.stream = stream;
10 | }
11 |
12 | public Printer(java.io.OutputStream stream){
13 | this.stream = new OutputStream(stream);
14 | }
15 |
16 | private void printSexprList(List