Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wyfy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kirk
wyfy
Commits
e1acf811
Commit
e1acf811
authored
Jun 08, 2013
by
kirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
begin incorporating persistence
parent
6bb202e7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
471 additions
and
1 deletion
+471
-1
WiFiSettingsContract.java
WyFy/src/us/rader/wyfy/db/WiFiSettingsContract.java
+126
-0
WifiSettingsDatabaseHelper.java
WyFy/src/us/rader/wyfy/db/WifiSettingsDatabaseHelper.java
+322
-0
package-info.java
WyFy/src/us/rader/wyfy/db/package-info.java
+22
-0
WifiSettings.java
WyFy/src/us/rader/wyfy/model/WifiSettings.java
+1
-1
No files found.
WyFy/src/us/rader/wyfy/db/WiFiSettingsContract.java
0 → 100644
View file @
e1acf811
/*
* Copyright 2013 Kirk Rader
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
us
.
rader
.
wyfy
.
db
;
import
us.rader.wyfy.model.WifiSettings
;
import
android.content.ContentValues
;
import
android.provider.BaseColumns
;
/**
* SQLlite contract for persisting instances of {@link WifiSettings}
*
* @author Kirk
*/
public
final
class
WiFiSettingsContract
{
/**
* Table for storing instances of {@link WifiSettings}
*
* @author Kirk
*/
public
static
final
class
WifiSettingsEntry
implements
BaseColumns
{
/**
* "Hidden" state column name
*/
public
static
final
String
COLUMN_NAME_HIDDEN
=
"hidden"
;
//$NON-NLS-1$
/**
* Password column name
*/
public
static
final
String
COLUMN_NAME_PASSWORD
=
"password"
;
//$NON-NLS-1$
/**
* Security column name
*/
public
static
final
String
COLUMN_NAME_SECURITY
=
"security"
;
//$NON-NLS-1$
/**
* SSID column name
*/
public
static
final
String
COLUMN_NAME_SSID
=
"ssid"
;
//$NON-NLS-1$
/**
* {@link WifiSettings} table name
*/
public
static
final
String
TABLE_NAME
=
"wifi_settings"
;
//$NON-NLS-1$
/**
* Get a {@link ContentValues} to use to persist the current state of
* the {@link WifiSettings} singleton
*
* @return {@link ContentValues}
*
* @see #updateWifiSettings(ContentValues)
*/
public
static
ContentValues
getContentValues
()
{
WifiSettings
settings
=
WifiSettings
.
getInstance
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
COLUMN_NAME_HIDDEN
,
settings
.
isHidden
());
values
.
put
(
COLUMN_NAME_PASSWORD
,
settings
.
getPassword
());
values
.
put
(
COLUMN_NAME_SECURITY
,
settings
.
getSecurity
().
toString
());
values
.
put
(
COLUMN_NAME_SSID
,
settings
.
getSsid
());
return
values
;
}
/**
* Update the state of the singleton {@link WifiSettings} from the given
* {@link ContentValues}
*
* @param values
* {@link ContentValues}
*
* @see #getContentValues()
*/
public
static
void
updateWifiSettings
(
ContentValues
values
)
{
String
ssid
=
values
.
getAsString
(
COLUMN_NAME_SSID
);
String
password
=
values
.
getAsString
(
COLUMN_NAME_PASSWORD
);
WifiSettings
.
Security
security
=
Enum
.
valueOf
(
WifiSettings
.
Security
.
class
,
values
.
getAsString
(
COLUMN_NAME_SECURITY
));
boolean
hidden
=
values
.
getAsBoolean
(
COLUMN_NAME_HIDDEN
);
WifiSettings
settings
=
WifiSettings
.
getInstance
();
settings
.
setSsid
(
ssid
);
settings
.
setPassword
(
password
);
settings
.
setSecurity
(
security
);
settings
.
setHidden
(
hidden
);
}
/**
* Prevent casual instantiation of contract member
*/
private
WifiSettingsEntry
()
{
// nothing to do here
}
}
/**
* Prevent casual instantiation of contract class
*/
private
WiFiSettingsContract
()
{
// nothing to do here
}
}
WyFy/src/us/rader/wyfy/db/WifiSettingsDatabaseHelper.java
0 → 100644
View file @
e1acf811
This diff is collapsed.
Click to expand it.
WyFy/src/us/rader/wyfy/db/package-info.java
0 → 100644
View file @
e1acf811
/*
* Copyright 2013 Kirk Rader
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Persistence using the SQLite database built into Android
*
* @author Kirk
*/
package
us
.
rader
.
wyfy
.
db
;
\ No newline at end of file
WyFy/src/us/rader/wyfy/model/WifiSettings.java
View file @
e1acf811
...
...
@@ -339,7 +339,7 @@ public final class WifiSettings implements Serializable {
/**
* Initialize to default state
*/
pr
otected
WifiSettings
()
{
pr
ivate
WifiSettings
()
{
ssid
=
""
;
//$NON-NLS-1$
password
=
""
;
//$NON-NLS-1$
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment