App installation screen improvements#680
App installation screen improvements#680rosenpin wants to merge 9 commits intoFreeyourgadget:masterfrom rosenpin:master
Conversation
|
This is really interesting, thanks! Especially wrt the layout changes, this should be carefully tested also with firmware installation and for other devices as well. |
| <activity | ||
| android:name=".activities.FwAppInstallerActivity" | ||
| android:label="@string/title_activity_fw_app_insaller" | ||
| android:parentActivityName=".activities.ControlCenterv2"> |
There was a problem hiding this comment.
Removed the parent activity because we don't want the back button to re-open the main activity, we want it to finish the current activity
| @Override | ||
| protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| if (GBApplication.isDarkThemeEnabled()) { |
There was a problem hiding this comment.
the super.onCreate sets the theme to GadgetbridgeThemeDark with action bar, we don't want the action bar because we use a toolbar in the layout xml file
There was a problem hiding this comment.
Could you try directly extending the appcompat activity as it is done in ControlCenterv2? https://github.com/Freeyourgadget/Gadgetbridge/blob/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java#L63
It should allow you to avoid this check.
There was a problem hiding this comment.
Done, I also merged the toolbars by using a toolbar.xml file, I include that file both in the ControlCenterv2 activity and the FwAppInstallerActivity activity layouts
There was a problem hiding this comment.
I still need to check if the dark theme is enabled and change the theme if it is. But the else statement is redundant
| IntentFilter intentFilter = new IntentFilter(); | ||
| intentFilter.addAction("nodomain.freeyourgadget.gadgetbridge.INSTALLATION_FAILED"); | ||
| intentFilter.addAction("nodomain.freeyourgadget.gadgetbridge.INSTALLATION_SUCCESS"); | ||
| registerReceiver(installationResultReceiver, intentFilter); |
There was a problem hiding this comment.
Register the receiver to the failed/success installation intent, the receiver updates the views (progress bar/button)
|
|
||
| //Set up the toolbar | ||
| Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
| toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); |
There was a problem hiding this comment.
Set the text color to white
There was a problem hiding this comment.
See above about extending AppCompat activity: I believe you will not need this after changing.
Since it took some time to get the colors under control (and is not all done yet :-) ) I really would like to avoid using colors outside of the theme-inherited ones.
There was a problem hiding this comment.
I'll change it, BTW, I'm pretty sure we should no longer use the themes that include action bars, AFAIK toolbars are the way to go.
https://medium.com/@ZakTaccardi/goodbye-actionbar-apis-hello-toolbar-af6ae7b31e5d
There was a problem hiding this comment.
I agree, we didn't because of lack of time on our end, perhaps you can open a new PR after this one is merged to take care of the migration? It would be really great!
| //Set up the toolbar | ||
| Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
| toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); | ||
| toolbar.setTitle(getResources().getString(R.string.installation_d_d, currentAppIndex, appsCount)); |
There was a problem hiding this comment.
Set the title to installing ($index/$count)
| toolbar.setTitle(getResources().getString(R.string.installation_d_d, currentAppIndex, appsCount)); | ||
| toolbar.setNavigationIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_arrow_back, null)); | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) | ||
| toolbar.setElevation(16); |
There was a problem hiding this comment.
Set elevation only on lollipop+ devices (the fancy shadow)
There was a problem hiding this comment.
AppCompat should take care of this as well without explicit version checking.
| toolbar.setNavigationOnClickListener(new View.OnClickListener() { | ||
| @Override | ||
| public void onClick(View v) { | ||
| finish(); |
There was a problem hiding this comment.
Finish the current installation activity when the back button is clicked
| for (int i = 0; i < appsCount; i++) { | ||
| startIntent.setDataAndType(clipData.getItemAt(i).getUri(), null); | ||
| startIntent.putExtra("APPS_COUNT", appsCount); | ||
| startIntent.putExtra("APP_INDEX", Math.abs(i - appsCount)); |
There was a problem hiding this comment.
Because we want it to be (1/3) -> (2/3) -> (3/3), not (3/3) -> (2/3) -> (1/3)
Why not use for (int i = appsCount; i >=0 ; i--) you ask?
That would be a good question.
| resultIntent = new Intent("nodomain.freeyourgadget.gadgetbridge.INSTALLATION_FAILED"); | ||
| GB.updateInstallNotification(getContext().getString(R.string.installation_failed_), false, 0, getContext()); | ||
| } else { | ||
| resultIntent = new Intent("nodomain.freeyourgadget.gadgetbridge.INSTALLATION_SUCCESS"); |
There was a problem hiding this comment.
The installation was successful, set the intent action to success
| return; | ||
| } | ||
| if (hadError) { | ||
| resultIntent = new Intent("nodomain.freeyourgadget.gadgetbridge.INSTALLATION_FAILED"); |
There was a problem hiding this comment.
The installation was unsuccessful, set the intent action to failed
| } | ||
| } | ||
| } | ||
| getContext().sendBroadcast(resultIntent); |
| @@ -1,77 +1,69 @@ | |||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
There was a problem hiding this comment.
This layout is pretty much a list of views that goes from top to bottom, no reason to use RelativeLayout with so many rules when we can simply use a vertical LinearLayout
|
Also, if you think it's a good idea, I can easily make the selected file install automatically without the need to click the install button and then the back button every time |
|
Sweet! |
|
Oops, that makes sense, as I only made it so the PebbleIoThread sends a broadcast when the installation finishes/fails. |
|
@rosenpin I believe cf1451bde5f51678ff19b57fb9da5157a0668dcd should be reverted. As it is now the theme would remain dark until activity is destroyed / application is restarted. The rest of the theming is very well done, so +1 from my side (with the aforementioned observation). I'm wondering if the multiple file selection should be limited to pbw (apps), as it would not work (but could be dangerous if it worked) for firmwares. |
Removed theme changer commit
Good point, though it might be a bit confusing for users if the app won't explain the special behavior, maybe there should be different installations screen for apps/software? |
|
@danielegobbetti |
|
Yes there is a blacklist feature in settings |
|
Thanks! |
|
So how do we proceed with this? |
Improvements include: