mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-06 01:37:46 +08:00
0.11.2: First Google Tango release
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Original Author: William J. Francis
|
||||
* http://www.techrepublic.com/blog/software-engineer/a-reusable-about-dialog-for-your-android-apps/
|
||||
*/
|
||||
package com.introlab.rtabmap;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.util.Linkify;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AboutDialog extends Dialog{
|
||||
|
||||
private static Context mContext = null;
|
||||
|
||||
public AboutDialog(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the standard Android on create method that gets called when the activity initialized.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setContentView(R.layout.about);
|
||||
TextView tv = (TextView)findViewById(R.id.info_text);
|
||||
tv.setText(Html.fromHtml(readRawTextFile(R.raw.info)));
|
||||
tv.setLinkTextColor(Color.WHITE);
|
||||
Linkify.addLinks(tv, Linkify.ALL);
|
||||
}
|
||||
|
||||
public static String readRawTextFile(int id) {
|
||||
InputStream inputStream = mContext.getResources().openRawResource(id);
|
||||
InputStreamReader in = new InputStreamReader(inputStream);
|
||||
BufferedReader buf = new BufferedReader(in);
|
||||
String line;
|
||||
StringBuilder text = new StringBuilder();
|
||||
try {
|
||||
while (( line = buf.readLine()) != null) text.append(line);
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user