import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
-import android.view.View.OnClickListener;
import android.widget.Button;
import com.hughes.util.StringUtil;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-public final class HtmlDisplayActivity extends ActionBarActivity {
+public final class HtmlDisplayActivity extends AppCompatActivity {
- static final String LOG = "QuickDic";
+ private static final String LOG = "QuickDic";
- static final String HTML_RES = "html_res";
- static final String HTML = "html";
- static final String TEXT_TO_HIGHLIGHT = "textToHighlight";
- static final String SHOW_OK_BUTTON = "showOKButton";
+ private static final String HTML_RES = "html_res";
+ private static final String HTML = "html";
+ private static final String TEXT_TO_HIGHLIGHT = "textToHighlight";
+ private static final String SHOW_OK_BUTTON = "showOKButton";
public static Intent getHelpLaunchIntent(Context c) {
final Intent intent = new Intent(c, HtmlDisplayActivity.class);
final boolean showOkButton) {
final Intent intent = new Intent(c, HtmlDisplayActivity.class);
intent.putExtra(HTML, html);
- intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight);
+ intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight == null ? "" : textToHighlight);
intent.putExtra(SHOW_OK_BUTTON, showOkButton);
return intent;
}
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
- setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);
+ DictionaryApplication.INSTANCE.init(getApplicationContext());
+ setTheme(DictionaryApplication.INSTANCE.getSelectedTheme().themeId);
super.onCreate(savedInstanceState);
setContentView(R.layout.html_display_activity);
html = StringUtil.readToString(res);
try {
res.close();
- } catch (IOException e) {
+ } catch (IOException ignored) {
}
} else {
html = getIntent().getStringExtra(HTML);
webView.getSettings().setDefaultFontSize(fontSizeSp);
try {
// No way to get pure UTF-8 data into WebView
+ // Cannot use StandardCharsets due to older Android.
html = Base64.encodeToString(html.getBytes("UTF-8"), Base64.DEFAULT);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Missing UTF-8 support?!", e);