I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 57d81fb1 authored by str4d's avatar str4d
Browse files

Migrated home buttons to use Fragment transactions

parent ee97af6e
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
......@@ -69,8 +68,11 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), NewsFragment.class);
startActivity(intent);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, new NewsFragment())
.addToBackStack(null)
.commit();
}
});
......@@ -78,9 +80,15 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), TextResourceFragment.class);
intent.putExtra(TextResourceFragment.TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
startActivity(intent);
TextResourceFragment f = new TextResourceFragment();
Bundle args = new Bundle();
args.putInt(TextResourceFragment.TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
f.setArguments(args);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, f)
.addToBackStack(null)
.commit();
}
});
......@@ -99,10 +107,16 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), WebFragment.class);
//intent.setData((new Uri.Builder()).scheme("http").authority("www.i2p2.de").path("/").build());
intent.setData(Uri.parse("http://www.i2p2.de/"));
startActivity(intent);
WebFragment f = new WebFragment();
Bundle args = new Bundle();
args.putString(WebFragment.HTML_URI, "http://www.i2p2.de/");
f.setArguments(args);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, f)
.addToBackStack(null)
.commit();
}
});
......@@ -110,10 +124,16 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), WebFragment.class);
//intent.setData((new Uri.Builder()).scheme("http").authority("www.i2p2.de").path("/faq").build());
intent.setData(Uri.parse("http://www.i2p2.de/faq"));
startActivity(intent);
WebFragment f = new WebFragment();
Bundle args = new Bundle();
args.putString(WebFragment.HTML_URI, "http://www.i2p2.de/faq");
f.setArguments(args);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, f)
.addToBackStack(null)
.commit();
}
});
......@@ -121,9 +141,15 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), WebFragment.class);
intent.putExtra(WebFragment.HTML_RESOURCE_ID, R.raw.welcome_html);
startActivity(intent);
WebFragment f = new WebFragment();
Bundle args = new Bundle();
args.putInt(WebFragment.HTML_RESOURCE_ID, R.raw.welcome_html);
f.setArguments(args);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, f)
.addToBackStack(null)
.commit();
}
});
......@@ -159,8 +185,11 @@ public class MainFragment extends I2PFragmentBase {
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), PeersFragment.class);
startActivity(intent);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_content, new PeersFragment())
.addToBackStack(null)
.commit();
}
});
......
package net.i2p.android.router.fragment;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
......@@ -30,8 +29,7 @@ public class TextResourceFragment extends I2PFragmentBase {
View v = inflater.inflate(R.layout.text_resource, container, false);
TextView tv = (TextView) v.findViewById(R.id.text_resource_text);
tv.setMovementMethod(ScrollingMovementMethod.getInstance());
Intent intent = getActivity().getIntent();
int id = intent.getIntExtra(TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
int id = getArguments().getInt(TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
if (id == R.raw.releasenotes_txt)
tv.setText("Release Notes for Release " + Util.getOurVersion(getActivity()) + "\n\n" +
getResourceAsString(id));
......
package net.i2p.android.router.fragment;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
......@@ -21,6 +19,7 @@ public class WebFragment extends I2PFragmentBase {
private I2PWebViewClient _wvClient;
final static String HTML_URI = "html_url";
final static String HTML_RESOURCE_ID = "html_resource_id";
private static final String WARNING = "Warning - " +
"any non-I2P links visited in this window are fetched over the regular internet and are " +
......@@ -39,16 +38,16 @@ public class WebFragment extends I2PFragmentBase {
wv.getSettings().setBuiltInZoomControls(true);
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
wv.getSettings().setUseWideViewPort(true);
Intent intent = getActivity().getIntent();
Uri uri = intent.getData();
if (uri != null) {
String uriStr = getArguments().getString(HTML_URI);
if (uriStr != null) {
Uri uri = Uri.parse(uriStr);
//wv.getSettings().setLoadsImagesAutomatically(true);
//wv.loadUrl(uri.toString());
// go thru the client so .i2p will work too
_wvClient.shouldOverrideUrlLoading(wv, uri.toString());
} else {
wv.getSettings().setLoadsImagesAutomatically(false);
int id = intent.getIntExtra(HTML_RESOURCE_ID, 0);
int id = getArguments().getInt(HTML_RESOURCE_ID, 0);
// no default, so restart should keep previous view
if (id != 0)
loadResource(wv, id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment