Commit e6ba823d authored by kirk's avatar kirk

version 200

parent 45962dae
......@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="us.rader.wyfy"
android:versionCode="22"
android:versionName="1.22" >
android:versionCode="200"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="10"
......@@ -63,7 +63,7 @@
</provider>
<activity
android:name="us.rader.wyfy.DeleteRowsActivity"
android:name="us.rader.wyfy.SavedRowsActivity"
android:label="@string/title_activity_delete_rows"
android:parentActivityName="us.rader.wyfy.MainActivity" >
<meta-data
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/delete_rows_activity"
android:id="@+id/saved_rows_activity"
android:layout_width="match_parent"
android:layout_height="match_parent" >
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:id="@+id/saved_rows_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/qr_code_padding" >
......
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/delete_rows_item" android:title="@string/delete_rows_label" android:showAsAction="never"></item><item android:id="@+id/scan_qr_item" android:showAsAction="never" android:title="@string/scan_qr_label"></item>
<item android:id="@+id/show_saved_rows_item" android:title="@string/saved_label" android:showAsAction="never"></item><item android:id="@+id/scan_qr_item" android:showAsAction="never" android:title="@string/scan_qr_label"></item>
<item android:id="@+id/share_qr_item" android:title="@string/share_label" android:showAsAction="never"></item><item android:id="@+id/write_tag_item" android:title="@string/write_tag_label" android:showAsAction="never"></item>
......
......@@ -36,9 +36,7 @@
<string name="scan_qr_label">Scan QR&#8230;</string>
<string name="error_scanning_qr_code">Error scanning QR code</string>
<string name="unsupported_qr_code">Unsupported QR code %1$s</string>
<string name="delete_label">Delete</string>
<string name="delete_selected_label">Delete Selected</string>
<string name="delete_rows_label">Database</string>
<string name="saved_label">Saved</string>
<string name="title_activity_delete_rows">Database</string>
<string name="delete_ssid_prompt">Delete %1$s?</string>
......
......@@ -15,6 +15,7 @@
*/
package us.rader.wyfy;
import us.rader.wyfy.db.WiFiSettingsContract;
import us.rader.wyfy.model.WifiSettings;
import us.rader.wyfy.model.WifiSettings.ConnectionOutcome;
import us.rader.wyfy.nfc.ForegroundDispatchActivity;
......@@ -193,11 +194,17 @@ public final class MainActivity extends FragmentActivity implements
}
/**
* {@link Activity#startActivityForResult(Intent, int)} request code when
* launching {@link SavedRowsActivity}
*/
public static final int REQUEST_SHOWS_SAVED_DATA = 2;
/**
* {@link Activity#startActivityForResult(Intent, int)} request code when
* launching {@link WriteTagActivity}
*/
public static final int REQUEST_WRITE_TAG = 1;
public static final int REQUEST_WRITE_TAG = 1;
/**
* Cached singleton instance of {@link WifiSettings}
......@@ -260,9 +267,9 @@ public final class MainActivity extends FragmentActivity implements
switch (item.getItemId()) {
case R.id.delete_rows_item:
case R.id.show_saved_rows_item:
return deleteRows();
return showSavedRows();
case R.id.write_tag_item:
......@@ -335,6 +342,11 @@ public final class MainActivity extends FragmentActivity implements
onQrCodeScanned(requestCode, resultCode, resultData);
break;
case REQUEST_SHOWS_SAVED_DATA:
onLoadSavedData(resultCode, resultData);
break;
default:
alert(getString(R.string.unrecognized_request));
......@@ -398,16 +410,63 @@ public final class MainActivity extends FragmentActivity implements
}
/**
* Handle "Database" menu item
* Load the UI with the result of returned by {@link SavedRowsActivity}
*
* @return <code>true</code>
* @param resultCode
* result code
*
* @param resultData
* {@link Intent} containing result data
*/
private boolean deleteRows() {
private void onLoadSavedData(int resultCode, Intent resultData) {
Intent intent = new Intent(this, DeleteRowsActivity.class);
startActivity(intent);
return true;
if (resultCode != RESULT_OK) {
return;
}
if (resultData == null) {
return;
}
Uri uri = resultData.getData();
if (uri == null) {
return;
}
String ssid = uri
.getQueryParameter(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SSID);
if (ssid == null) {
return;
}
String password = uri
.getQueryParameter(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_PASSWORD);
String hidden = uri
.getQueryParameter(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_HIDDEN);
String security = uri
.getQueryParameter(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SECURITY);
wifiSettings.setSsid(ssid);
wifiSettings.setPassword(password);
wifiSettings.setSecurity(Enum.valueOf(WifiSettings.Security.class,
security));
wifiSettings.setHidden(Boolean.valueOf(hidden));
if (wifiSettingsFragment != null) {
wifiSettingsFragment.onModelChanged(false);
}
}
/**
......@@ -765,6 +824,19 @@ public final class MainActivity extends FragmentActivity implements
}
}
/**
* Handle "Database" menu item
*
* @return <code>true</code>
*/
private boolean showSavedRows() {
Intent intent = new Intent(this, SavedRowsActivity.class);
startActivityForResult(intent, REQUEST_SHOWS_SAVED_DATA);
return true;
}
/**
* Start {@Link WriteTagActivity}
*
......
......@@ -260,6 +260,13 @@ public final class QrCodeFragment extends Fragment {
private int getQrCodeSize() {
View view = getView();
if (view == null) {
return 0;
}
View qrView = view.findViewById(R.id.qr_code_layout);
int size = Math.min(qrView.getWidth(), qrView.getHeight());
return size;
......
......@@ -21,16 +21,16 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
/**
* {@link FragmentActivity} to display {@link DeleteRowsFragment}
* {@link FragmentActivity} to display {@link SavedRowsFragment}
*
* @author Kirk
*/
public class DeleteRowsActivity extends FragmentActivity {
public class SavedRowsActivity extends FragmentActivity {
/**
* {@link DeleteRowsFragment}
* {@link SavedRowsFragment}
*/
private DeleteRowsFragment deleteRowsFragment;
private SavedRowsFragment deleteRowsFragment;
/**
* @param savedInstanceState
......@@ -42,11 +42,11 @@ public class DeleteRowsActivity extends FragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.delete_rows_activity);
setContentView(R.layout.saved_rows_activity);
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
deleteRowsFragment = new DeleteRowsFragment();
transaction.add(R.id.delete_rows_activity, deleteRowsFragment);
deleteRowsFragment = new SavedRowsFragment();
transaction.add(R.id.saved_rows_activity, deleteRowsFragment);
transaction.commit();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment