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

Skip to content
Snippets Groups Projects
Commit 490148cb authored by str4d's avatar str4d
Browse files

Migrated old Dialog to DialogFragment

parent 430d56b6
No related branches found
No related tags found
No related merge requests found
......@@ -32,8 +32,6 @@ public class MainFragment extends I2PFragmentBase {
private boolean _startPressed = false;
protected static final String PROP_NEW_INSTALL = "i2p.newInstall";
protected static final String PROP_NEW_VERSION = "i2p.newVersion";
protected static final int DIALOG_NEW_INSTALL = 0;
protected static final int DIALOG_NEW_VERSION = 1;
/**
* Called when the fragment is first created.
......@@ -447,83 +445,21 @@ public class MainFragment extends I2PFragmentBase {
}
private void checkDialog() {
VersionDialog dialog = new VersionDialog();
String oldVersion = getPref(PREF_INSTALLED_VERSION, "??");
/*if(oldVersion.equals("??")) {
getActivity().showDialog(DIALOG_NEW_INSTALL);
if(oldVersion.equals("??")) {
Bundle args = new Bundle();
args.putInt(VersionDialog.DIALOG_TYPE, VersionDialog.DIALOG_NEW_INSTALL);
dialog.setArguments(args);
dialog.show(getActivity().getSupportFragmentManager(), "newinstall");
} else {
String currentVersion = Util.getOurVersion(getActivity());
if(!oldVersion.equals(currentVersion)) {
getActivity().showDialog(DIALOG_NEW_VERSION);
Bundle args = new Bundle();
args.putInt(VersionDialog.DIALOG_TYPE, VersionDialog.DIALOG_NEW_VERSION);
dialog.setArguments(args);
dialog.show(getActivity().getSupportFragmentManager(), "newversion");
}
}*/
}
/*@Override
protected Dialog onCreateDialog(int id) {
final String currentVersion = Util.getOurVersion(this);
Dialog rv = null;
AlertDialog.Builder b = new AlertDialog.Builder(this);
switch(id) {
case DIALOG_NEW_INSTALL:
b.setMessage(getResources().getText(R.string.welcome_new_install)).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPref(PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
MainActivity.this.removeDialog(id);
}
}).setNeutralButton("Release Notes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPref(PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
MainActivity.this.removeDialog(id);
Intent intent = new Intent(MainActivity.this, TextResourceActivity.class);
intent.putExtra(TextResourceActivity.TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
startActivity(intent);
}
}).setNegativeButton("Licenses", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPref(PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
MainActivity.this.removeDialog(id);
Intent intent = new Intent(MainActivity.this, LicenseActivity.class);
startActivity(intent);
}
});
rv = b.create();
break;
case DIALOG_NEW_VERSION:
b.setMessage(getResources().getText(R.string.welcome_new_version) + " " + currentVersion).setCancelable(true).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPref(PREF_INSTALLED_VERSION, currentVersion);
try {
dialog.dismiss();
} catch(Exception e) {
}
MainActivity.this.removeDialog(id);
}
}).setNegativeButton("Release Notes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPref(PREF_INSTALLED_VERSION, currentVersion);
try {
dialog.dismiss();
} catch(Exception e) {
}
MainActivity.this.removeDialog(id);
Intent intent = new Intent(MainActivity.this, TextResourceActivity.class);
intent.putExtra(TextResourceActivity.TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
startActivity(intent);
}
});
rv = b.create();
break;
}
return rv;
}*/
}
}
package net.i2p.android.router.fragment;
import net.i2p.android.router.R;
import net.i2p.android.router.activity.LicenseActivity;
import net.i2p.android.router.util.Util;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
public class VersionDialog extends DialogFragment {
protected static final String DIALOG_TYPE = "dialog_type";
protected static final int DIALOG_NEW_INSTALL = 0;
protected static final int DIALOG_NEW_VERSION = 1;
@Override
public Dialog onCreateDialog(Bundle SavedInstanceState) {
final String currentVersion = Util.getOurVersion(getActivity());
Dialog rv = null;
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
int id = getArguments().getInt(DIALOG_TYPE);
switch(id) {
case DIALOG_NEW_INSTALL:
b.setMessage(R.string.welcome_new_install)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PFragmentBase fb = (I2PFragmentBase) getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content);
fb.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
}
}).setNeutralButton(R.string.label_release_notes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PFragmentBase fb = (I2PFragmentBase) getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content);
fb.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
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();
}
}).setNegativeButton(R.string.label_licenses, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PFragmentBase fb = (I2PFragmentBase) getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content);
fb.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
Intent intent = new Intent(getActivity(), LicenseActivity.class);
startActivity(intent);
}
});
rv = b.create();
break;
case DIALOG_NEW_VERSION:
b.setMessage(R.string.welcome_new_version + " " + currentVersion)
.setCancelable(true)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PFragmentBase fb = (I2PFragmentBase) getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content);
fb.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
try {
dialog.dismiss();
} catch(Exception e) {
}
}
}).setNegativeButton(R.string.label_release_notes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PFragmentBase fb = (I2PFragmentBase) getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content);
fb.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
try {
dialog.dismiss();
} catch(Exception e) {
}
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();
}
});
rv = b.create();
break;
}
return rv;
}
}
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