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:
parent
0b160d2e04
commit
d672983a90
@ -25,7 +25,7 @@
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/error"
|
||||
android:textSize="20sp"
|
||||
|
@ -160,6 +160,13 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
.setOngoing(true)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.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());
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,9 @@ import java.util.TimerTask;
|
||||
* 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: Starting wifi after cancelling swap and beginning again doesn't work properly
|
||||
* TODO: Scan QR hangs when updating repoo
|
||||
*
|
||||
*/
|
||||
public class SwapService extends Service {
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class ConfirmReceive extends RelativeLayout implements SwapWorkflowActivi
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_blue);
|
||||
return R.color.swap_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,7 @@ public class InitialLoadingView extends RelativeLayout implements SwapWorkflowAc
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_blue);
|
||||
return R.color.swap_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,7 +132,7 @@ public class JoinWifiView extends RelativeLayout implements SwapWorkflowActivity
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_blue);
|
||||
return R.color.swap_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +80,7 @@ public class NfcView extends RelativeLayout implements SwapWorkflowActivity.Inne
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_blue);
|
||||
return R.color.swap_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,12 +124,13 @@ public class SelectAppsView extends ListView implements
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_bright_blue);
|
||||
return R.color.swap_bright_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -356,7 +356,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
|
||||
@Override
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_bright_blue);
|
||||
return R.color.swap_bright_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,7 +148,7 @@ public class SwapConnecting extends LinearLayout implements SwapWorkflowActivity
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_bright_blue);
|
||||
return R.color.swap_bright_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +284,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
service.setStep(currentView.getStep());
|
||||
}
|
||||
|
||||
toolbar.setBackgroundColor(currentView.getToolbarColour());
|
||||
toolbar.setBackgroundColor(getResources().getColor(currentView.getToolbarColour()));
|
||||
toolbar.setTitle(currentView.getToolbarTitle());
|
||||
toolbar.setNavigationIcon(R.drawable.ic_close_white);
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@ -604,6 +604,8 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
lrm.copyApksToRepo();
|
||||
publishProgress(getString(R.string.copying_icons));
|
||||
// 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>() {
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +111,7 @@ public class WifiQrView extends ScrollView implements SwapWorkflowActivity.Inner
|
||||
|
||||
@ColorRes
|
||||
public int getToolbarColour() {
|
||||
return getResources().getColor(R.color.swap_blue);
|
||||
return R.color.swap_blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user