mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2025-07-04 22:16:26 +00:00
First commit: Just a collection of library sources from Github. Compiles, but doesn't work.
This commit is contained in:
60
temp/droidkit-actors-0.2.48/actors-sample/build.gradle
Normal file
60
temp/droidkit-actors-0.2.48/actors-sample/build.gradle
Normal file
@ -0,0 +1,60 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.9.+'
|
||||
}
|
||||
}
|
||||
apply plugin: 'android'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://oss.sonatype.org/content/groups/public/" }
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "20.0.0"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 19
|
||||
versionCode apkVersionCode
|
||||
versionName apkVersionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('androidStore') &&
|
||||
project.hasProperty('androidStorePass') &&
|
||||
project.hasProperty('androidAliasPass')&&
|
||||
project.hasProperty('androidAlias')) {
|
||||
android.signingConfigs.release.storeFile = file(androidStore)
|
||||
android.signingConfigs.release.storePassword = androidStorePass
|
||||
android.signingConfigs.release.keyAlias = androidAlias
|
||||
android.signingConfigs.release.keyPassword = androidAliasPass
|
||||
} else {
|
||||
buildTypes.release.signingConfig = null
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:19.+'
|
||||
// compile project(":actors-android")
|
||||
compile project(":actors")
|
||||
compile project(":actors-android")
|
||||
}
|
17
temp/droidkit-actors-0.2.48/actors-sample/proguard-rules.txt
Normal file
17
temp/droidkit-actors-0.2.48/actors-sample/proguard-rules.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/ex3ndr/Documents/android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# 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 *;
|
||||
#}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.droidkit.actors.sample">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="com.droidkit.actors.sample.MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,21 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import com.droidkit.actors.Actor;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 27.08.14.
|
||||
*/
|
||||
public class CounterActor extends Actor {
|
||||
int last = -1;
|
||||
|
||||
@Override
|
||||
public void onReceive(Object message) {
|
||||
if (message instanceof Integer) {
|
||||
int val = (Integer) message;
|
||||
if (last != val - 1) {
|
||||
Log.d("Error! Wrong order expected #" + (last + 1) + " got #" + val);
|
||||
}
|
||||
last++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import com.droidkit.actors.ReflectedActor;
|
||||
import com.droidkit.actors.tasks.AskCallback;
|
||||
import com.droidkit.actors.tasks.AskFuture;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 18.08.14.
|
||||
*/
|
||||
public class DownloadFile extends ReflectedActor {
|
||||
|
||||
public void onReceive(String[] url) {
|
||||
ask(HttpDownloader.download(url[0]));
|
||||
ask(HttpDownloader.download(url[1]));
|
||||
AskFuture future = ask(HttpDownloader.download(url[2]));
|
||||
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
future.cancel();
|
||||
|
||||
// combine("downloaded", byte[].class,
|
||||
// ask(HttpDownloader.download(url[0])),
|
||||
// ask(HttpDownloader.download(url[1])));
|
||||
}
|
||||
|
||||
public void onDownloadedReceive(byte[][] data) {
|
||||
Log.d("DownloadFile:onDownloadedReceive:" + data);
|
||||
Log.d("downloaded " + data[0].length + " bytes and " + data[1].length + " bytes");
|
||||
}
|
||||
|
||||
public void onDownloadedReceive(Throwable throwable) {
|
||||
Log.d("DownloadFile:onDownloadedReceiveError:" + throwable);
|
||||
}
|
||||
|
||||
public void onReceive(String url) {
|
||||
Log.d("DownloadFile:onReceiveUrl:" + url);
|
||||
ask(HttpDownloader.download(url), new AskCallback() {
|
||||
@Override
|
||||
public void onResult(Object result) {
|
||||
self().send(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onReceive(byte[] data) {
|
||||
Log.d("DownloadFile:receiveData:" + data);
|
||||
Log.d("downloaded " + data.length + " bytes");
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 17.08.14.
|
||||
*/
|
||||
public class HashUtil {
|
||||
public static String md5(String s) {
|
||||
try {
|
||||
byte[] bytesOfMessage = s.getBytes("UTF-8");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] thedigest = md.digest(bytesOfMessage);
|
||||
return hex(thedigest);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String hex(byte[] data) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
res.append(Integer.toHexString(data[i] & 0xFF).toLowerCase());
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import com.droidkit.actors.*;
|
||||
import com.droidkit.actors.dispatch.RunnableDispatcher;
|
||||
import com.droidkit.actors.tasks.TaskActor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 18.08.14.
|
||||
*/
|
||||
public class HttpDownloader extends TaskActor<byte[]> {
|
||||
|
||||
private static final RunnableDispatcher dispatcher = new RunnableDispatcher(2);
|
||||
|
||||
public static String path(String url) {
|
||||
return "/http_" + HashUtil.md5(url);
|
||||
}
|
||||
|
||||
public static Props<HttpDownloader> prop(final String url) {
|
||||
return Props.create(HttpDownloader.class, new ActorCreator<HttpDownloader>() {
|
||||
@Override
|
||||
public HttpDownloader create() {
|
||||
return new HttpDownloader(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ActorSelection download(String url) {
|
||||
return new ActorSelection(prop(url), path(url));
|
||||
}
|
||||
|
||||
private String url;
|
||||
private Runnable runnable;
|
||||
|
||||
public HttpDownloader(final String url) {
|
||||
this.url = url;
|
||||
runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Log.d("HttpDownloader:startDownload:" + url);
|
||||
URL urlSpec = new URL(url);
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) urlSpec.openConnection();
|
||||
urlConnection.setConnectTimeout(15000);
|
||||
urlConnection.setReadTimeout(15000);
|
||||
InputStream in = urlConnection.getInputStream();
|
||||
byte[] data = IOUtils.readAll(in);
|
||||
complete(data);
|
||||
Log.d("HttpDownloader:complete:" + url);
|
||||
} catch (IOException e) {
|
||||
error(e);
|
||||
Log.d("HttpDownloader:error:" + url);
|
||||
}
|
||||
}
|
||||
};
|
||||
setTimeOut(500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTask() {
|
||||
Log.d("HttpDownloader:startTask:" + url);
|
||||
dispatcher.postAction(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskObsolete() {
|
||||
Log.d("HttpDownloader:onTaskObsolete:" + url);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 20.08.14.
|
||||
*/
|
||||
public class IOUtils {
|
||||
public static byte[] readAll(InputStream in) throws IOException {
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(in);
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream(4096);
|
||||
byte[] buffer = new byte[4 * 1024];
|
||||
int len;
|
||||
int readed = 0;
|
||||
try {
|
||||
while ((len = bufferedInputStream.read(buffer)) >= 0) {
|
||||
Thread.yield();
|
||||
os.write(buffer, 0, len);
|
||||
readed += len;
|
||||
}
|
||||
} catch (java.io.IOException e) {
|
||||
|
||||
}
|
||||
return os.toByteArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import com.droidkit.actors.ActorRef;
|
||||
import com.droidkit.actors.ActorSystem;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 18.08.14.
|
||||
*/
|
||||
public class Log {
|
||||
private static final ActorRef log = ActorSystem.system().actorOf(LogActor.class, "log");
|
||||
|
||||
public static void d(String s) {
|
||||
log.send(s);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import android.util.Log;
|
||||
import com.droidkit.actors.Actor;
|
||||
|
||||
/**
|
||||
* Created by ex3ndr on 14.08.14.
|
||||
*/
|
||||
public class LogActor extends Actor {
|
||||
|
||||
@Override
|
||||
public void preStart() {
|
||||
Log.d("LOGACTOR#" + hashCode(), "preStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Object message) {
|
||||
Log.d("LOGACTOR#" + hashCode(), message + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postStop() {
|
||||
Log.d("LOGACTOR#" + hashCode(), "postStop");
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.droidkit.actors.sample;
|
||||
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.droidkit.actors.ActorRef;
|
||||
import com.droidkit.actors.android.UiActor;
|
||||
import com.droidkit.actors.android.UiActorDispatcher;
|
||||
|
||||
import static com.droidkit.actors.ActorSystem.system;
|
||||
|
||||
public class MainActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
system().addDispatcher("ui", new UiActorDispatcher(system()));
|
||||
|
||||
// ActorRef log = system().actorOf(LogActor.class, "log");
|
||||
|
||||
// ActorRef downloader = system().actorOf(DownloadFile.class, "dow");
|
||||
// downloader.send("http://flirtyfleurs.com/wp-content/uploads/2012/10/pwg-sample-11_photo.jpg");
|
||||
// downloader.send("http://flirtyfleurs.com/wp-content/uploads/2012/10/pwg-sample-11_photo.jpg", 600);
|
||||
// downloader.send("http://flirtyfleurs.com/wp-content/uploads/2012/10/pwg-sample-11_photo.jpg", 3000);
|
||||
|
||||
// ActorRef dow2 = system().actorOf(DownloadFile.class, "dow2");
|
||||
// dow2.send(new String[]{
|
||||
// "http://flirtyfleurs.com/wp-content/uploads/2012/10/pwg-sample-11_photo.jpg",
|
||||
// "http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg",
|
||||
// "http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg"});
|
||||
|
||||
final TextView view = (TextView) findViewById(R.id.demo);
|
||||
final UiActor actor = new UiActor() {
|
||||
@Override
|
||||
public void onReceive(Object message) {
|
||||
view.setText(message.toString());
|
||||
}
|
||||
};
|
||||
|
||||
findViewById(R.id.demoButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
actor.getActorRef().send("message_" + i, i * 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
ActorRef ref = system().actorOf(CounterActor.class, "counter1");
|
||||
Log.d("Start");
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
ref.send((Integer) i);
|
||||
if (i % 1000 == 0) {
|
||||
Log.d("Progress " + i);
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d("End");
|
||||
}
|
||||
}.start();
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,26 @@
|
||||
<LinearLayout 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"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.droidkit.actors.sample.MainActivity">
|
||||
|
||||
<TextView
|
||||
android:text="@string/hello_world"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView android:id="@+id/demo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Demo counter"/>
|
||||
|
||||
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:text="doDemo"
|
||||
android:id="@+id/demoButton"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.droidkit.actors.sample.MainActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
@ -0,0 +1,6 @@
|
||||
<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>
|
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Actors</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
</resources>
|
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
Reference in New Issue
Block a user