Refactor toolbar colours, fix notification for < 4.1 devices.

InnerView.getToolbarColour() was expecting a @ColorRes, except all views
were returning integers which were the colour value, not a pointer to
the resource as they should have been. Now only one place requires a
call to getResources().getColor() whereas before it was in each view.

Notifications on pre 4.1 devices require a pending intent to work. This
is so that when you touch the intent, it takes you somewhere meaningfull.
Without it, the update process crashes.
This commit is contained in:
Peter Serwylo 2015-08-16 08:34:04 +10:00
parent 0b160d2e04
commit d672983a90
12 changed files with 23 additions and 10 deletions

View File

@ -25,7 +25,7 @@
android:layout_gravity="center" /> android:layout_gravity="center" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/error" android:id="@+id/error"
android:textSize="20sp" android:textSize="20sp"

View File

@ -160,6 +160,13 @@ public class UpdateService extends IntentService implements ProgressListener {
.setOngoing(true) .setOngoing(true)
.setCategory(NotificationCompat.CATEGORY_SERVICE) .setCategory(NotificationCompat.CATEGORY_SERVICE)
.setContentTitle(getString(R.string.update_notification_title)); .setContentTitle(getString(R.string.update_notification_title));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
Intent intent = new Intent(this, FDroid.class);
// TODO: Is this the correct FLAG?
notificationBuilder.setContentIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
}
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
} }

View File

@ -68,6 +68,9 @@ import java.util.TimerTask;
* TODO: Turn off bluetooth after cancelling/timing out if we turned it on. * TODO: Turn off bluetooth after cancelling/timing out if we turned it on.
* TODO: Disable the Scan QR button unless visible via something. Could equally show relevant feedback. * TODO: Disable the Scan QR button unless visible via something. Could equally show relevant feedback.
* *
* TODO: Starting wifi after cancelling swap and beginning again doesn't work properly
* TODO: Scan QR hangs when updating repoo
*
*/ */
public class SwapService extends Service { public class SwapService extends Service {

View File

@ -77,7 +77,7 @@ public class ConfirmReceive extends RelativeLayout implements SwapWorkflowActivi
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_blue); return R.color.swap_blue;
} }
@Override @Override

View File

@ -58,7 +58,7 @@ public class InitialLoadingView extends RelativeLayout implements SwapWorkflowAc
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_blue); return R.color.swap_blue;
} }
@Override @Override

View File

@ -132,7 +132,7 @@ public class JoinWifiView extends RelativeLayout implements SwapWorkflowActivity
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_blue); return R.color.swap_blue;
} }
@Override @Override

View File

@ -80,7 +80,7 @@ public class NfcView extends RelativeLayout implements SwapWorkflowActivity.Inne
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_blue); return R.color.swap_blue;
} }
@Override @Override

View File

@ -124,12 +124,13 @@ public class SelectAppsView extends ListView implements
@Override @Override
public int getPreviousStep() { public int getPreviousStep() {
// TODO: The STEP_JOIN_WIFI step isn't shown first, need to make it so that it is, or so that this doesn't go back there.
return getState().isConnectingWithPeer() ? SwapService.STEP_INTRO : SwapService.STEP_JOIN_WIFI; return getState().isConnectingWithPeer() ? SwapService.STEP_INTRO : SwapService.STEP_JOIN_WIFI;
} }
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_bright_blue); return R.color.swap_bright_blue;
} }
@Override @Override

View File

@ -356,7 +356,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
@Override @Override
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_bright_blue); return R.color.swap_bright_blue;
} }
@Override @Override

View File

@ -148,7 +148,7 @@ public class SwapConnecting extends LinearLayout implements SwapWorkflowActivity
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_bright_blue); return R.color.swap_bright_blue;
} }
@Override @Override

View File

@ -284,7 +284,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
service.setStep(currentView.getStep()); service.setStep(currentView.getStep());
} }
toolbar.setBackgroundColor(currentView.getToolbarColour()); toolbar.setBackgroundColor(getResources().getColor(currentView.getToolbarColour()));
toolbar.setTitle(currentView.getToolbarTitle()); toolbar.setTitle(currentView.getToolbarTitle());
toolbar.setNavigationIcon(R.drawable.ic_close_white); toolbar.setNavigationIcon(R.drawable.ic_close_white);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@ -604,6 +604,8 @@ public class SwapWorkflowActivity extends AppCompatActivity {
lrm.copyApksToRepo(); lrm.copyApksToRepo();
publishProgress(getString(R.string.copying_icons)); publishProgress(getString(R.string.copying_icons));
// run the icon copy without progress, its not a blocker // run the icon copy without progress, its not a blocker
// TODO: Fix lint error about this being run from a worker thread, says it should be
// run on a main thread.
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override

View File

@ -111,7 +111,7 @@ public class WifiQrView extends ScrollView implements SwapWorkflowActivity.Inner
@ColorRes @ColorRes
public int getToolbarColour() { public int getToolbarColour() {
return getResources().getColor(R.color.swap_blue); return R.color.swap_blue;
} }
@Override @Override