add: module http
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 206
|
||||
versionName "3.0.0 Alpha7"
|
||||
versionCode 208
|
||||
versionName "3.0.0 Alpha9"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
@@ -7,6 +7,16 @@ import android.content.ContextWrapper;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okio.BufferedSink;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/8/4.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ public class FloatyWindowManger {
|
||||
|
||||
public static void addWindow(Context context, FloatyWindow window) {
|
||||
context.startService(new Intent(context, FloatyService.class));
|
||||
if (SettingsCompat.canDrawOverlays(context)) {
|
||||
if (!SettingsCompat.canDrawOverlays(context)) {
|
||||
Toast.makeText(context, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
manageDrawOverlays(context);
|
||||
return;
|
||||
|
||||
@@ -184,6 +184,9 @@ public class StorageFileProvider {
|
||||
@Override
|
||||
public ObservableSource<ScriptFile> apply(@NonNull ScriptFile dir) throws Exception {
|
||||
ScriptFile[] scriptFiles = dir.listFiles();
|
||||
if (scriptFiles == null) {
|
||||
return Observable.empty();
|
||||
}
|
||||
mScriptFileCache.put(dir.getPath(), new ArrayList<>(Arrays.asList(scriptFiles)));
|
||||
return Observable.fromArray(scriptFiles);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.stardust.scriptdroid.sublime;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.stardust.enhancedfloaty.FloatyWindow;
|
||||
import com.stardust.enhancedfloaty.ResizableFloaty;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.reactivestreams.Publisher;
|
||||
@@ -62,24 +66,19 @@ public class SublimePluginClient {
|
||||
}
|
||||
|
||||
private void listenInternal(final Subscriber<? super Void> s) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mSocket = new Socket(host, port);
|
||||
mConnectionState.onNext(true);
|
||||
mSocket.setTcpNoDelay(true);
|
||||
mOutputStream = mSocket.getOutputStream();
|
||||
s.onComplete();
|
||||
readLoop(mSocket.getInputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
s.onError(e);
|
||||
} finally {
|
||||
tryClose();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
try {
|
||||
mSocket = new Socket(host, port);
|
||||
mConnectionState.onNext(true);
|
||||
mSocket.setTcpNoDelay(true);
|
||||
mOutputStream = mSocket.getOutputStream();
|
||||
s.onComplete();
|
||||
readLoop(mSocket.getInputStream());
|
||||
} catch (IOException e) {
|
||||
s.onError(e);
|
||||
} finally {
|
||||
tryClose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PublishSubject<Boolean> getConnectionState() {
|
||||
|
||||
@@ -163,11 +163,9 @@ public class CodeMirrorEditor extends FrameLayout {
|
||||
|
||||
private void setupWebSettings() {
|
||||
WebSettings settings = mWebView.getSettings();
|
||||
settings.setUseWideViewPort(true);
|
||||
settings.setBuiltInZoomControls(true);
|
||||
//settings.setLoadWithOverviewMode(true);
|
||||
settings.setJavaScriptEnabled(true);
|
||||
//settings.setUseWideViewPort(true);
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setNeedInitialFocus(true);
|
||||
|
||||
@@ -102,11 +102,6 @@ public class EditorView extends FrameLayout {
|
||||
}
|
||||
};
|
||||
|
||||
private void setMenuItemStatus(int id, boolean enabled) {
|
||||
findViewById(id).setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
public EditorView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -159,10 +154,17 @@ public class EditorView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setMenuItemStatus(int id, boolean enabled) {
|
||||
findViewById(id).setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
@AfterViews
|
||||
void init() {
|
||||
setUpEditor();
|
||||
setUpInputMethodEnhancedBar();
|
||||
setMenuItemStatus(R.id.save, false);
|
||||
}
|
||||
|
||||
private void setUpInputMethodEnhancedBar() {
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -46,6 +47,11 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
|
||||
|
||||
/**
|
||||
@@ -244,7 +250,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||
if(isHidden()){
|
||||
if (isHidden()) {
|
||||
return;
|
||||
}
|
||||
Toast.makeText(App.getApp(), e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -34,6 +34,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/13.
|
||||
@@ -57,8 +58,8 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
||||
mScriptFileList.setOnScriptFileClickListener(new ScriptListView.OnScriptFileClickListener() {
|
||||
@Override
|
||||
public void onScriptFileClick(View view, ScriptFile file) {
|
||||
//Scripts.edit(file);
|
||||
EditorFloaty.floatingEdit(getContext(), file);
|
||||
Scripts.edit(file);
|
||||
//EditorFloaty.floatingEdit(getContext(), file);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
||||
mFloatingActionMenu.collapse();
|
||||
return true;
|
||||
}
|
||||
if(mScriptFileList.canGoBack()){
|
||||
if (mScriptFileList.canGoBack()) {
|
||||
mScriptFileList.goBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
void onDirectoryChange(StorageFileProvider.DirectoryChangeEvent event) {
|
||||
public void onDirectoryChange(StorageFileProvider.DirectoryChangeEvent event) {
|
||||
if (!event.getDir().equals(mCurrentDirectory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
android:id="@+id/save"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:enabled="false"
|
||||
app:icon="@drawable/ic_save_white_48dp"
|
||||
app:text="@string/text_save"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user