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
deadc5fe
Commit
deadc5fe
authored
Jun 05, 2013
by
kirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
major refactoring as first stage in pass to finally address numerous UI refresh issues
parent
9972324e
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
555 additions
and
696 deletions
+555
-696
strings.xml
WyFy/res/values/strings.xml
+2
-0
MainActivity.java
WyFy/src/us/rader/wyfy/MainActivity.java
+205
-141
QrCodeFragment.java
WyFy/src/us/rader/wyfy/QrCodeFragment.java
+16
-148
WifiSettingsFragment.java
WyFy/src/us/rader/wyfy/WifiSettingsFragment.java
+87
-203
WifiSettings.java
WyFy/src/us/rader/wyfy/model/WifiSettings.java
+245
-204
No files found.
WyFy/res/values/strings.xml
View file @
deadc5fe
...
...
@@ -32,5 +32,7 @@
<string
name=
"null_message"
>
Status OK but message is null
</string>
<string
name=
"empty_message"
>
Empty message
</string>
<string
name=
"unparseable_payload"
>
Unparseable payload
</string>
<string
name=
"initialized_from_active_connection"
>
Initialized from active connection to %1%s
</string>
<string
name=
"no_active_connection"
>
No active connection
</string>
</resources>
WyFy/src/us/rader/wyfy/MainActivity.java
View file @
deadc5fe
This diff is collapsed.
Click to expand it.
WyFy/src/us/rader/wyfy/QrCodeFragment.java
View file @
deadc5fe
...
...
@@ -17,8 +17,6 @@ package us.rader.wyfy;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
us.rader.wyfy.model.WifiSettings
;
import
us.rader.wyfy.provider.FileProvider
;
...
...
@@ -52,30 +50,23 @@ public final class QrCodeFragment extends Fragment {
*
* @author Kirk
*/
private
class
UpdateQrCodeTask
extends
AsyncTask
<
WifiSettings
,
Void
,
Bitmap
>
{
private
class
UpdateQrCodeTask
extends
AsyncTask
<
Void
,
Void
,
Bitmap
>
{
/**
* Return the {@link Bitmap} for the QR code image representing
* <code>settings[0]</code>
*
* TODO: this will return <code>null</code> when invoked before the UI
* is actually ready to be rendered, which happens in
* {@link QrCodeFragment#onResume()} in single-pane mode; investigate
* ways to eliminate the resulting kludgery in
* {@link #onPostExecute(Bitmap)}
* @param params
* ignored
*
* @param settings
* Get QR code image from <code>settings[0]</code>
* @return {@link Bitmap} for QR code image or <code>null</code>
*
* @return {@link Bitmap} for QR code image
*
* @see android.os.AsyncTask#doInBackground(WifiSettings...)
* @see android.os.AsyncTask#doInBackground(Void...)
* @see WifiSettings#getQrCode(int)
* @see #onPostExecute(Bitmap)
*/
@Override
protected
Bitmap
doInBackground
(
WifiSettings
...
setting
s
)
{
protected
Bitmap
doInBackground
(
Void
...
param
s
)
{
try
{
...
...
@@ -83,13 +74,7 @@ public final class QrCodeFragment extends Fragment {
if
(
size
>
0
)
{
if
(
settings
[
0
]
==
null
)
{
return
createBlankBitmap
(
size
);
}
return
settings
[
0
].
getQrCode
(
size
);
return
WifiSettings
.
getInstance
().
getQrCode
(
size
);
}
...
...
@@ -110,31 +95,12 @@ public final class QrCodeFragment extends Fragment {
* the {@link Bitmap}
*
* @see android.os.AsyncTask#onPostExecute(java.lang.Object)
* @see #doInBackground(
WifiSettings
...)
* @see #doInBackground(
Void
...)
*/
@Override
protected
void
onPostExecute
(
Bitmap
bitmap
)
{
if
(
bitmap
==
null
)
{
// TODO: eliminate this kludge to force another refresh after
// giving the UI time to settle down
Timer
timer
=
new
Timer
();
TimerTask
timerTask
=
new
TimerTask
()
{
@Override
public
void
run
()
{
new
UpdateQrCodeTask
().
execute
(
settings
);
}
};
timer
.
schedule
(
timerTask
,
500
);
}
else
{
if
(
bitmap
!=
null
)
{
qrCode
.
setImageBitmap
(
bitmap
);
...
...
@@ -143,74 +109,10 @@ public final class QrCodeFragment extends Fragment {
}
/**
* {@link Bundle} key for {@link WifiSettings} argument
*/
private
static
final
String
WIFI_SETTINGS
=
"WIFI_SETTINGS"
;
//$NON-NLS-1$
/**
* Factory method for instances of this class
*
* @param settings
* {@link WifiSettings}
*
* @return {@link QrCodeFragment}
*/
public
static
QrCodeFragment
newInstance
(
WifiSettings
settings
)
{
QrCodeFragment
fragment
=
new
QrCodeFragment
();
Bundle
arguments
=
new
Bundle
();
if
(
settings
!=
null
)
{
arguments
.
putSerializable
(
WIFI_SETTINGS
,
settings
);
}
fragment
.
setArguments
(
arguments
);
return
fragment
;
}
/**
* QR code image
*/
private
ImageView
qrCode
;
/**
* Model
*/
private
WifiSettings
settings
;
/**
* Initialize {@link #settings} to <code>null</code>
*/
public
QrCodeFragment
()
{
settings
=
null
;
}
/**
* Process arguments
*
* @param savedInstanceState
* saved state or <code>null</code>
*
* @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
*/
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Bundle
arguments
=
getArguments
();
if
(
arguments
!=
null
)
{
settings
=
(
WifiSettings
)
arguments
.
getSerializable
(
WIFI_SETTINGS
);
}
}
private
ImageView
qrCode
;
/**
* Inflate the {@Link View}
...
...
@@ -254,21 +156,8 @@ public final class QrCodeFragment extends Fragment {
}
/**
* Update the QR code when resuming
*
* @see android.support.v4.app.Fragment#onResume()
*/
@Override
public
void
onResume
()
{
super
.
onResume
();
new
UpdateQrCodeTask
().
execute
(
settings
);
}
/**
* Save {@link #settings} QR code to a file and then send a sharing
* {@link Intent} wrapped in a chooser
* Save QR code to a file and then send a sharing {@link Intent} wrapped in
* a chooser
*
* @see Intent#ACTION_SEND
* @see Intent#createChooser(Intent, CharSequence)
...
...
@@ -279,7 +168,8 @@ public final class QrCodeFragment extends Fragment {
try
{
FragmentActivity
activity
=
getActivity
();
Bitmap
bitmap
=
settings
.
getQrCode
(
getQrCodeSize
());
Bitmap
bitmap
=
WifiSettings
.
getInstance
().
getQrCode
(
getQrCodeSize
());
File
file
=
activity
.
getFileStreamPath
(
"wyfy_qr.png"
);
//$NON-NLS-1$
FileOutputStream
stream
=
activity
.
openFileOutput
(
file
.
getName
(),
0
);
...
...
@@ -315,32 +205,10 @@ public final class QrCodeFragment extends Fragment {
/**
* Update the QR code to match the specified state
*
* @param settings
* {@link WifiSettings}
*/
public
void
updateQrCode
(
WifiSettings
settings
)
{
this
.
settings
=
settings
;
new
UpdateQrCodeTask
().
execute
(
settings
);
public
void
updateQrCode
()
{
}
/**
* Return a square {@link Bitmap} of the given size filled with
* {@link Color#WHITE}
*
* @param size
* the width and height of the {@link Bitmap}
*
* @return the {@link Bitmap}
*/
private
Bitmap
createBlankBitmap
(
int
size
)
{
Bitmap
bitmap
;
bitmap
=
Bitmap
.
createBitmap
(
size
,
size
,
Bitmap
.
Config
.
ARGB_8888
);
bitmap
.
eraseColor
(
Color
.
WHITE
);
return
bitmap
;
new
UpdateQrCodeTask
().
execute
();
}
...
...
WyFy/src/us/rader/wyfy/WifiSettingsFragment.java
View file @
deadc5fe
This diff is collapsed.
Click to expand it.
WyFy/src/us/rader/wyfy/model/WifiSettings.java
View file @
deadc5fe
This diff is collapsed.
Click to expand it.
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