2016-06-12 18:46:19 +02:00
|
|
|
package net.foucry.pilldroid;
|
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Bundle;
|
2016-06-19 00:57:40 +02:00
|
|
|
import android.support.v4.content.res.ResourcesCompat;
|
2016-06-12 18:46:19 +02:00
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
import android.text.Html;
|
2016-06-14 23:41:05 +02:00
|
|
|
import android.text.Spanned;
|
2016-06-19 00:57:40 +02:00
|
|
|
import android.util.Log;
|
2016-06-14 23:41:05 +02:00
|
|
|
import android.webkit.WebView;
|
2016-06-19 00:57:40 +02:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
2016-06-12 18:46:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by jacques on 12/06/16.
|
|
|
|
*/
|
|
|
|
public class About extends AppCompatActivity{
|
|
|
|
|
2016-06-19 00:57:40 +02:00
|
|
|
private WebView aboutView;
|
2016-06-12 18:46:19 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.about);
|
|
|
|
|
2016-06-19 00:57:40 +02:00
|
|
|
String htmlString = null;
|
|
|
|
|
|
|
|
/* aboutView = (WebView) findViewById(R.id.aboutHtml);
|
|
|
|
|
|
|
|
aboutView.loadUrl("file:///android_asset/about.html");
|
|
|
|
aboutView.clearCache(true);
|
|
|
|
aboutView.clearHistory();
|
|
|
|
aboutView.getSettings().setJavaScriptEnabled(true);
|
|
|
|
aboutView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);*/
|
|
|
|
|
|
|
|
try {
|
|
|
|
InputStream is = getAssets().open("about.html");
|
|
|
|
int size = is.available();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[size];
|
|
|
|
|
|
|
|
is.read(buffer);
|
|
|
|
is.close();
|
|
|
|
|
|
|
|
htmlString = new String(buffer);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextView htmlTextView = (TextView)findViewById(R.id.aboutHtml);
|
|
|
|
htmlTextView.setText(Html.fromHtml(htmlString, new ImageGetter(), null));
|
2016-06-14 23:41:05 +02:00
|
|
|
|
2016-06-19 00:57:40 +02:00
|
|
|
Log.i("PillDroid", htmlTextView.getText().toString());
|
2016-06-12 18:46:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private class ImageGetter implements Html.ImageGetter {
|
|
|
|
|
|
|
|
public Drawable getDrawable(String source) {
|
|
|
|
int id;
|
|
|
|
if (source.equals("ic_launcher.png")) {
|
|
|
|
id = R.mipmap.ic_launcher;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawable d = getResources().getDrawable(id);
|
2016-06-19 00:57:40 +02:00
|
|
|
// Drawable d = ResourcesCompat.getDrawable(getResources(),id, null);
|
2016-06-12 18:46:19 +02:00
|
|
|
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|