mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2024-12-18 03:28:55 +01:00
moved gist extension to separate repo https://github.com/TwidereProject/Twidere-Android-Extension-Gist
This commit is contained in:
parent
e3065ff34b
commit
dffa6b3b3f
@ -4,5 +4,4 @@ include ':twidere.library.extension'
|
||||
include ':twidere.wear'
|
||||
include ':twidere.donate.nyanwp'
|
||||
include ':twidere.donate.nyanwp.wear'
|
||||
include ':twidere.component.nyan'
|
||||
include ':twidere.extension.shortener.gist'
|
||||
include ':twidere.component.nyan'
|
1
twidere.extension.shortener.gist/.gitignore
vendored
1
twidere.extension.shortener.gist/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build
|
1
twidere.extension.shortener.gist/README.md
Normal file
1
twidere.extension.shortener.gist/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Moved to [Twidere-Android-Extension-Gist](https://github.com/TwidereProject/Twidere-Android-Extension-Gist) #
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.mariotaku.twidere.extension.shortener.gist"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "0.9"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apt 'com.bluelinelabs:logansquare-compiler:1.3.7'
|
||||
compile 'com.github.mariotaku.RestFu:urlconnection:0.9.25'
|
||||
compile project(':twidere.library.extension')
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/mariotaku/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<manifest
|
||||
package="org.mariotaku.twidere.extension.shortener.gist"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.DeviceDefault"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<meta-data
|
||||
android:name="org.mariotaku.twidere.extension"
|
||||
android:value="true"/>
|
||||
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Dialog">
|
||||
<intent-filter>
|
||||
<action android:name="org.mariotaku.twidere.EXTENSION_SETTINGS"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".GistStatusShortenerService"
|
||||
android:permission="org.mariotaku.twidere.permission.SHORTEN_STATUS">
|
||||
|
||||
<meta-data
|
||||
android:name="org.mariotaku.twidere.extension.version.status_shortener"
|
||||
android:value="@string/status_shortener_service_interface_version"/>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="org.mariotaku.twidere.EXTENSION_SHORTEN_STATUS"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/6/4.
|
||||
*/
|
||||
@JsonObject
|
||||
public class Gist {
|
||||
|
||||
@JsonField(name = "html_url")
|
||||
String htmlUrl;
|
||||
|
||||
@JsonField(name = "id")
|
||||
String id;
|
||||
|
||||
public String getHtmlUrl() {
|
||||
return htmlUrl;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/2/20.
|
||||
*/
|
||||
@JsonObject
|
||||
public class GistFile {
|
||||
@JsonField(name = "content")
|
||||
String content;
|
||||
|
||||
GistFile() {
|
||||
}
|
||||
|
||||
public GistFile(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.ParcelableStatusUpdate;
|
||||
import org.mariotaku.twidere.model.StatusShortenResult;
|
||||
import org.mariotaku.twidere.service.StatusShortenerService;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/6/4.
|
||||
*/
|
||||
public class GistStatusShortenerService extends StatusShortenerService {
|
||||
|
||||
@Override
|
||||
protected StatusShortenResult shorten(ParcelableStatusUpdate status, UserKey currentAccountKey, String overrideStatusText) {
|
||||
final Github github = GithubFactory.getInstance(getApiKey());
|
||||
final NewGist newGist = new NewGist();
|
||||
newGist.setDescription("long tweet");
|
||||
newGist.setIsPublic(false);
|
||||
final String content = overrideStatusText != null ? overrideStatusText : status.text;
|
||||
newGist.putFile("long_tweet.txt", new GistFile(content));
|
||||
try {
|
||||
Gist gist = github.createGist(newGist);
|
||||
final StatusShortenResult shortened = StatusShortenResult.shortened(getShortenedStatus(content, gist.getHtmlUrl()));
|
||||
shortened.extra = gist.getId();
|
||||
return shortened;
|
||||
} catch (GithubException e) {
|
||||
return StatusShortenResult.error(-1, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean callback(StatusShortenResult result, ParcelableStatus status) {
|
||||
final String apiKey = getApiKey();
|
||||
if (apiKey == null) return false;
|
||||
final Github github = GithubFactory.getInstance(apiKey);
|
||||
final NewGist newGist = new NewGist();
|
||||
newGist.setDescription("https://twitter.com/" + status.user_screen_name + "/status/" + status.id);
|
||||
try {
|
||||
github.updateGist(result.extra, newGist);
|
||||
} catch (GithubException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getApiKey() {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
return preferences.getString("api_key", null);
|
||||
}
|
||||
|
||||
private String getShortenedStatus(String content, String htmlUrl) {
|
||||
final int codePointCount = content.codePointCount(0, content.length());
|
||||
final int offset = content.offsetByCodePoints(0, Math.min(99, codePointCount));
|
||||
return content.substring(0, offset) + " " + htmlUrl;
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import org.mariotaku.restfu.annotation.method.PATCH;
|
||||
import org.mariotaku.restfu.annotation.method.POST;
|
||||
import org.mariotaku.restfu.annotation.param.Headers;
|
||||
import org.mariotaku.restfu.annotation.param.KeyValue;
|
||||
import org.mariotaku.restfu.annotation.param.Path;
|
||||
import org.mariotaku.restfu.annotation.param.Raw;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/6/4.
|
||||
*/
|
||||
@Headers(@KeyValue(key = "Accept", value = "application/vnd.github.v3+json"))
|
||||
public interface Github {
|
||||
|
||||
@POST("/gists")
|
||||
Gist createGist(@Raw NewGist newGist) throws GithubException;
|
||||
|
||||
@PATCH("/gists/{id}")
|
||||
Gist updateGist(@Path("id") String id, @Raw NewGist newGist) throws GithubException;
|
||||
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.bluelinelabs.logansquare.JsonMapper;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
|
||||
import org.mariotaku.restfu.RestConverter;
|
||||
import org.mariotaku.restfu.http.ContentType;
|
||||
import org.mariotaku.restfu.http.HttpResponse;
|
||||
import org.mariotaku.restfu.http.mime.Body;
|
||||
import org.mariotaku.restfu.http.mime.StringBody;
|
||||
import org.mariotaku.twidere.util.LoganSquareMapperFinder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/5.
|
||||
*/
|
||||
public class GithubConverterFactory extends RestConverter.SimpleFactory<GithubException> {
|
||||
|
||||
private static Map<Type, RestConverter<HttpResponse, ?, GithubException>> sResponseConverters = new HashMap<>();
|
||||
private static Map<Type, RestConverter<?, Body, GithubException>> sBodyConverters = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
sBodyConverters.put(NewGist.class, new LoganSquareRequestConverter<>(NewGist.class));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static Object parseOrThrow(Body body, JsonMapper<?> mapper)
|
||||
throws IOException, GithubException, RestConverter.ConvertException {
|
||||
try {
|
||||
final Object parsed = mapper.parse(body.stream());
|
||||
if (parsed == null) {
|
||||
throw new GithubException("Empty data");
|
||||
}
|
||||
return parsed;
|
||||
} catch (JsonParseException e) {
|
||||
throw new RestConverter.ConvertException("Malformed JSON Data");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestConverter<HttpResponse, ?, GithubException> forResponse(Type type) throws RestConverter.ConvertException {
|
||||
RestConverter<HttpResponse, ?, GithubException> converter = sResponseConverters.get(type);
|
||||
if (converter != null) {
|
||||
return converter;
|
||||
}
|
||||
final JsonMapper<?> mapper;
|
||||
try {
|
||||
mapper = LoganSquareMapperFinder.mapperFor(type);
|
||||
} catch (LoganSquareMapperFinder.ClassLoaderDeadLockException e) {
|
||||
throw new RestConverter.ConvertException(e);
|
||||
}
|
||||
return new LoganSquareResponseConverter(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestConverter<?, Body, GithubException> forRequest(Type type) throws RestConverter.ConvertException {
|
||||
final RestConverter<?, Body, GithubException> converter = sBodyConverters.get(type);
|
||||
if (converter != null) {
|
||||
return converter;
|
||||
}
|
||||
return super.forRequest(type);
|
||||
}
|
||||
|
||||
public static class UnsupportedTypeException extends UnsupportedOperationException {
|
||||
public UnsupportedTypeException(Type type) {
|
||||
super("Unsupported type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoganSquareResponseConverter implements RestConverter<HttpResponse, Object, GithubException> {
|
||||
private final JsonMapper<?> mapper;
|
||||
|
||||
public LoganSquareResponseConverter(JsonMapper<?> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(HttpResponse httpResponse) throws IOException, ConvertException, GithubException {
|
||||
final Body body = httpResponse.getBody();
|
||||
return parseOrThrow(body, mapper);
|
||||
}
|
||||
}
|
||||
|
||||
private static class LoganSquareRequestConverter<T> implements RestConverter<T, Body, GithubException> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
LoganSquareRequestConverter(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Body convert(T from) throws ConvertException, IOException, GithubException {
|
||||
final JsonMapper<Object> mapper;
|
||||
try {
|
||||
mapper = LoganSquareMapperFinder.mapperFor(type);
|
||||
} catch (LoganSquareMapperFinder.ClassLoaderDeadLockException e) {
|
||||
throw new RestConverter.ConvertException(e);
|
||||
}
|
||||
return new StringBody(mapper.serialize(from), ContentType.parse("application/json"));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import org.mariotaku.restfu.http.HttpRequest;
|
||||
import org.mariotaku.restfu.http.HttpResponse;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/6/4.
|
||||
*/
|
||||
public class GithubException extends Exception {
|
||||
private HttpRequest request;
|
||||
private HttpResponse response;
|
||||
|
||||
public GithubException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GithubException(String detailMessage) {
|
||||
super(detailMessage);
|
||||
}
|
||||
|
||||
public GithubException(String detailMessage, Throwable throwable) {
|
||||
super(detailMessage, throwable);
|
||||
}
|
||||
|
||||
public GithubException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public void setRequest(HttpRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public HttpRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setResponse(HttpResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public HttpResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import org.mariotaku.restfu.ExceptionFactory;
|
||||
import org.mariotaku.restfu.RestAPIFactory;
|
||||
import org.mariotaku.restfu.RestRequest;
|
||||
import org.mariotaku.restfu.http.Authorization;
|
||||
import org.mariotaku.restfu.http.Endpoint;
|
||||
import org.mariotaku.restfu.http.HttpRequest;
|
||||
import org.mariotaku.restfu.http.HttpResponse;
|
||||
import org.mariotaku.restfu.urlconnection.URLConnectionRestClient;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/2/20.
|
||||
*/
|
||||
public class GithubFactory {
|
||||
|
||||
public static Github getInstance(final String apiKey) {
|
||||
final RestAPIFactory<GithubException> factory = new RestAPIFactory<>();
|
||||
factory.setEndpoint(new Endpoint("https://api.github.com/"));
|
||||
factory.setHttpClient(new URLConnectionRestClient());
|
||||
factory.setAuthorization(new Authorization() {
|
||||
@Override
|
||||
public String getHeader(Endpoint endpoint, RestRequest restRequest) {
|
||||
return "token " + apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAuthorization() {
|
||||
return apiKey != null;
|
||||
}
|
||||
});
|
||||
factory.setExceptionFactory(new GithubExceptionFactory());
|
||||
factory.setRestConverterFactory(new GithubConverterFactory());
|
||||
return factory.build(Github.class);
|
||||
}
|
||||
|
||||
private static class GithubExceptionFactory implements ExceptionFactory<GithubException> {
|
||||
@Override
|
||||
public GithubException newException(Throwable throwable, HttpRequest httpRequest, HttpResponse httpResponse) {
|
||||
GithubException exception;
|
||||
if (throwable != null) {
|
||||
exception = new GithubException(throwable);
|
||||
} else {
|
||||
exception = new GithubException();
|
||||
}
|
||||
exception.setRequest(httpRequest);
|
||||
exception.setResponse(httpResponse);
|
||||
return exception;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/6/4.
|
||||
*/
|
||||
@JsonObject
|
||||
public class NewGist {
|
||||
@JsonField(name = "description")
|
||||
String description;
|
||||
@JsonField(name = "public")
|
||||
boolean isPublic;
|
||||
@JsonField(name = "files")
|
||||
Map<String, GistFile> files;
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setIsPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
public void putFile(String key, GistFile file) {
|
||||
if (files == null) {
|
||||
files = new HashMap<>();
|
||||
}
|
||||
files.put(key, file);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.shortener.gist;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.settings);
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".SettingsActivity">
|
||||
|
||||
<TextView
|
||||
android:text="@string/hello_world"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</RelativeLayout>
|
@ -1,28 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".SettingsActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
</menu>
|
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.5 KiB |
@ -1,25 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
@ -1,24 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
@ -1,26 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Twidere Gist Shortener Extension</string>
|
||||
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="github_api_key">GitHub API key</string>
|
||||
</resources>
|
@ -1,23 +0,0 @@
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
|
||||
</resources>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<EditTextPreference
|
||||
android:key="api_key"
|
||||
android:title="@string/github_api_key"/>
|
||||
</PreferenceScreen>
|
1
twidere.extension.shortener.twitlonger/README.md
Normal file
1
twidere.extension.shortener.twitlonger/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Moved to [Twidere-Android-Extension-TwitLonger](https://github.com/TwidereProject/Twidere-Android-Extension-TwitLonger) #
|
Loading…
Reference in New Issue
Block a user