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

Skip to content
Snippets Groups Projects
Commit 3327ed72 authored by str4d's avatar str4d
Browse files

I2PTunnel: Ask to install app for tunnel, if none are installed when opening

parent 40afd69a
No related branches found
No related tags found
No related merge requests found
0.9.17.1
* Fixed crashes in addressbook and netDb status page
* Fixed crash when opening an IRC client tunnel
* Updated translations
0.9.17 / 2014-12-01 / bcf947f433876f643e0f6dff81aac88848b797d3
......
......@@ -4,6 +4,7 @@ import java.util.List;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.Toast;
import net.i2p.android.i2ptunnel.util.TunnelConfig;
import net.i2p.android.i2ptunnel.util.TunnelUtil;
......@@ -233,6 +234,17 @@ public class TunnelEntry {
else return getServerLink(linkify);
}
public Uri getRecommendedAppForTunnel() {
int resId = 0;
if ("ircclient".equals(mController.getType()))
resId = R.string.market_irc;
if (resId > 0)
return Uri.parse(mContext.getString(resId));
else
return null;
}
public String getDetails() {
String details;
if (isClient())
......
package net.i2p.android.i2ptunnel;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
......@@ -61,7 +64,27 @@ public class TunnelEntryAdapter extends ArrayAdapter<TunnelEntry> {
public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(tunnel.getTunnelLink(true)));
getContext().startActivity(i);
try {
getContext().startActivity(i);
} catch (ActivityNotFoundException e) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.install_recommended_app)
.setMessage(R.string.app_needed_for_this_tunnel_type)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
Uri uri = tunnel.getRecommendedAppForTunnel();
if (uri != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
getContext().startActivity(intent);
}
}
})
.setNegativeButton(net.i2p.android.lib.client.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
}
}
});
}
......
......@@ -167,6 +167,10 @@
<string name="i2ptunnel_type_streamrserver">Streamr server</string>
<string name="i2ptunnel_type_httpbidirserver">HTTP bidir</string>
<string name="market_irc" translatable="false">market://search?q=pname:com.androirc</string>
<string name="install_recommended_app">Install recommended app?</string>
<string name="app_needed_for_this_tunnel_type">You need to install an app to use this tunnel. Would you like to install the recommended app?</string>
<string name="i2ptunnel_not_initialized">Tunnels are not initialized yet, please reload in two minutes.</string>
<string name="i2ptunnel_new_tunnel">New Tunnel</string>
<string name="i2ptunnel_msg_config_saved">Configuration changes saved</string>
......
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