125 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
779a0122fd fix ConcurrentModificationException crash in LocalRepoService
https://stackoverflow.com/a/602660

java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:851)
    at java.util.HashMap$ValueIterator.next(HashMap.java:879)
    at org.fdroid.fdroid.localrepo.LocalRepoManager.copyIconsToRepo(LocalRepoManager.java:296)
    at org.fdroid.fdroid.localrepo.LocalRepoService$1.run(LocalRepoService.java:131)
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
910f5da81a create download and install receivers per-app, not globally
Each individual app needs its own receivers for these things, just like in
AppListActivity and InstallManagerService.
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
d91fbe7b0e rework swap startup putting SwapService first
SwapService is the thing that needs to be always running, and the last
thing killed.  So it should start first, and stop last.  So now, the user
clicking the button starts SwapService, which starts SwapWorkflowActivity.
This also eliminatings the "Loading" screen in favor of just showing the
StartSwapView with various inline progress indicators.
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
035a89e5f6 move all current View tracking to SwapWorkflowActivity
This information is only ever used in SwapWorkflowActivity and nowhere else
so if it needs to be stored, it could be stored via saveInstanceState().
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
9dc9a23a41 fix all RtL lint errors in swap layouts 2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
89f5127f6d turn inline Install button into Cancel button during download 2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
bc14e62e46 receive Downloader error messages in swap 2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
f0158063fb show full error messages from UpdateService
The "cause" is the Exception that was caught and embedded into the
UpdateException, so it has more info on what happened.
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
ad3fd26756 immediately regenerate swap repo when user changes app selections
Instead of waiting for the user to make all the app selections, then click
next, this constantly regenerates the swap repo on each click of the app
list.  This means that the swap repo is more likely to be immediately ready
when the user clicks next.
2019-05-24 10:00:08 +02:00
Hans-Christoph Steiner
b5d94b7476 convert swap error "back" button to "Try again"
The Android back button provides a working back function, and the Swap
"close" button on the upper left already provides a reset function. So this
turns the "back" button to be a "try again" button which re-runs the
connection process.
2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
5851ea73e0 move ConnectingView to pure XML view, and remove Receiver superclass
The Receiver superclass is not reusing difficult code, but it is hiding the
simple list of UI configuration that it does.

This also eliminates the "error" TextView and just reuses the existing
TextView for error messages.
2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
5ddc287ab3 move NfcView to pure XML view 2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
a9aafa080d move JoinWifiView to pure XML view 2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
1e1ea03bc3 move ConfirmReceiveView to pure XML SwapView with logic in Presenter 2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
d5f2e26ea7 use one method everywhere for the "swap back" requests 2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
014fb0b99d move WifiQrView and SendFDroidView to pure XML views
This puts the logic in the "Presenter": SwapWorkflowActivity
2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
69ce8dbe8c move all WiFi/QR logic to Presenter (SwapWorkflowActivity) 2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
ea3b47f705 purge CacheSwapAppsService in favor of InstalledAppProvider
The most expensive part of this whole process is calculating the hash of the
whole APK.  InstalledAppProvider already caches that, and the rest is OK to
query.  If any particular part of the query is expensive, it could also be
moved to InstalledAppProviderService.
2019-05-24 10:00:07 +02:00
Hans-Christoph Steiner
85410504da LocalRepoService for setting up the local swap repo
This moves all logic for setting up the local fdroid repo to its own
IntentService.  That makes it much easier to interact with since things can
just use the static helper method to request it to update, and it'll do the
right thing.
2019-05-24 10:00:01 +02:00
Hans-Christoph Steiner
c5a6445239 fix bottom bar loading the wrong "Updates" string
closes #1785
2019-05-20 14:14:29 +02:00
Hans-Christoph Steiner
291e4c4c3c change 'fragment' name to avoid confusion, Swap doesn't use Fragments 2019-05-13 15:01:37 +02:00
Hans-Christoph Steiner
9d6c95d51d move menu handling to SwapView and SwapWorkflowActivity
The menus originate in the Activity, so avoid pushing it to the Views.
2019-05-13 15:01:37 +02:00
Hans-Christoph Steiner
fe59522666 SwapView base class so all swap views can just be XML
Almost all of the nearby/swap view classes could be condensed into a single
base class that is instantiated in the view XML.  This is the first step
towards making that happen.

It also lays the groundwork where "steps" are all SwapViews.  The
original concept of "steps" put all steps together, whether
F-Droid could control them or not.  For example, the Views were
mixed with the system Bluetooth prompts.  This is the first step
towards converting the steps to always be SwapViews, which are
always under control of this app.

When coming back to a SwapView/step, it does not seem feasible to handle
automatically restarting things like permissions and Bluetooth prompts. If
there is a way, it should be possible to first load the proper SwapView
instance, then trigger the system prompt.  The makes the SwapView a pure
View, without any Controller in it.
2019-05-13 15:01:32 +02:00
Hans-Christoph Steiner
6a8f5fb4a7 rename SwapAppsView things to "Swap Success" 2019-05-13 14:55:13 +02:00
Hans-Christoph Steiner
568abe9f3b rename swap_blank to swap_start_swap to match View name 2019-05-13 14:55:13 +02:00
Hans-Christoph Steiner
68cc241bc0 rename ConfirmReceive to ConfirmReceiveView to match standard 2019-05-13 14:55:13 +02:00
Hans-Christoph Steiner
9aa73b95e4 rename SwapConnecting to ConnectingView to match standard 2019-05-13 14:55:13 +02:00
Hans-Christoph Steiner
40c52821fa standardized code format for all swap layout XML 2019-05-13 14:55:13 +02:00
Hans-Christoph Steiner
a71489a102 set max width on places where the translations get too long
closes #1678
2019-05-10 14:13:23 +02:00
Hans-Christoph Steiner
307abc5706 Merge branch 'finalize-1.6' into 'master'
Finalize 1.6

Closes #1556

See merge request fdroid/fdroidclient!813
2019-04-09 22:16:00 +00:00
mueller-ma
1c881baa9c Color swipe to refresh indicator 2019-04-09 21:26:32 +00:00
Hans-Christoph Steiner
593ce5284c fix insane NPE
java.lang.NullPointerException: println needs a message
 at android.util.Log.println_native(Native Method)
 at android.util.Log.e(Log.java:232)
 at org.fdroid.fdroid.net.DownloaderService.handleIntent(DownloaderService.java:232)
 at org.fdroid.fdroid.net.DownloaderService.access$000(DownloaderService.java:88)
 at org.fdroid.fdroid.net.DownloaderService$ServiceHandler.handleMessage(DownloaderService.java:108)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:148)
 at android.os.HandlerThread.run(HandlerThread.java:61)
2019-04-09 14:39:45 +02:00
Hans-Christoph Steiner
934eb06ff1 SwapAppsView: don't crash on update if app is null
java.lang.NullPointerException: Attempt to read from field 'java.lang.String org.fdroid.fdroid.data.App.packageName' on a null object reference
at org.fdroid.fdroid.views.swap.SwapAppsView$AppListAdapter$ViewHolder$2.onChange(SwapAppsView.java:294)
at android.database.ContentObserver.onChange(ContentObserver.java:130)
at android.database.ContentObserver.onChange(ContentObserver.java:145)
at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:216)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
0322e87d18 purge debug message that causes NullPointerException
java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File java.io.File.getCanonicalFile()' on a null object reference
at android.os.storage.StorageManager.getStorageVolume(StorageManager.java:844)
at android.os.storage.StorageManager.getStorageVolume(StorageManager.java:838)
at android.os.Environment.isExternalStorageRemovable(Environment.java:725)
at org.fdroid.fdroid.views.main.NearbyViewBinder.<init>(NearbyViewBinder.java:85)
at org.fdroid.fdroid.views.main.MainViewController.bindSwapView(MainViewController.java:64)
at org.fdroid.fdroid.views.main.MainViewAdapter.onCreateViewHolder(MainViewAdapter.java:94)
at org.fdroid.fdroid.views.main.MainViewAdapter.onCreateViewHolder(MainViewAdapter.java:47)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
d201851784 fix crash when ExternalStorage fails to find something
java.lang.IllegalArgumentException: Failed to find storage device at null
at android.os.Environment.isExternalStorageRemovable(Environment.java:859)
at org.fdroid.fdroid.views.main.NearbyViewBinder.<init>(NearbyViewBinder.java:85)
at org.fdroid.fdroid.views.main.MainViewController.bindSwapView(MainViewController.java:64)
at org.fdroid.fdroid.views.main.MainViewAdapter.onCreateViewHolder(MainViewAdapter.java:94)
at org.fdroid.fdroid.views.main.MainViewAdapter.onCreateViewHolder(MainViewAdapter.java:47)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
3378c0a333 rename Canonical vs. Download URL in InstallManagerService process
AppUpdateStatusManager and InstallManagerService should be using only the
Canonical URL of the package since that is the global unique ID.  The actual
URL used to download it needs to be isolated in DownloaderService, which can
entirely manage the mirror selection process.  This is just a bunch of
renaming to make this all clearer.
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
a0b318c383 rename Apk.getUrl() to getCanonicalUrl() to highlight it is also an ID
This method returns the URL that points to the canonical download
source for this package.  This is also used as the unique ID for
tracking downloading, progress, and notifications throughout the
whole install process.  It is guaranteed to uniquely represent
this file since it points to a file on the file system of the
canonical webserver.
2019-03-26 21:46:38 +01:00
mueller-ma
05bbe94b47 Improve nearby swap splash layout
* Rename ids to something meaningful
* Remove inner layouts from constraint layout
* Use same text and button styles
* Make sure the background image doesn't overlap with the text
2019-03-17 00:04:40 +01:00
Hans-Christoph Steiner
9323ccdfd1 add HTTP Last-Modified header to nearby/swap webserver
This should support the new cache check scheme when using swap repos.
2019-02-19 11:17:09 +01:00
Hans-Christoph Steiner
9522012fe1 use built-in constants for HTTP status codes 2019-02-19 11:17:09 +01:00
Hans-Christoph Steiner
b5de4898b1 improve "try it" permissions prompt on Nearby screen
This should make all the translations fit on the screen properly.

closes #1715
2019-02-18 23:52:41 +01:00
Hans-Christoph Steiner
cf5b9520fb fix lint "Implied locale in date format" 2019-01-02 15:40:38 +01:00
Hans-Christoph Steiner
945dbdbd3c prevent NPE in Bluetooth swap
ACRA  E  ACRA caught a IllegalStateException for org.fdroid.fdroid.debug
                         E  java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
                         E      at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
                         E      at android.os.Handler.handleCallback(Handler.java:751)
                         E      at android.os.Handler.dispatchMessage(Handler.java:95)
                         E      at android.os.Looper.loop(Looper.java:154)
                         E      at android.app.ActivityThread.main(ActivityThread.java:6128)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
                         E  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a
                            null object reference
                         E      at org.fdroid.fdroid.localrepo.peers.BonjourPeer.hashCode(BonjourPeer.java:41)
                         E      at sun.misc.Hashing.singleWordWangJenkinsHash(Hashing.java:48)
                         E      at java.util.HashMap.put(HashMap.java:423)
                         E      at java.util.HashSet.add(HashSet.java:217)
                         E      at rx.internal.operators.OperatorDistinct$1.onNext(OperatorDistinct.java:62)
                         E      at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:202)
                         E      at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:162)
                         E      at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                         E      ... 7 more
2018-12-26 00:29:19 +01:00
Hans-Christoph Steiner
c97424f054 show Toast when scanning an SDCard for repos 2018-12-21 23:06:04 +01:00
Hans-Christoph Steiner
43ee48ac2b only show "SDCards can be used to swap" if an SD Card is present 2018-12-21 23:05:24 +01:00
Hans-Christoph Steiner
38e0b8d29d update language to reflect "nearby" usage
closes #887
2018-12-21 17:07:40 +01:00
Hans-Christoph Steiner
90c3baf5af scanning WiFi/Bluetooth in android-23 requires location permission
This requires that admin#65 is fixed, otherwise every F-Droid update will
require Unknown Sources with Privileged Extension.

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id
https://stackoverflow.com/a/44200390

closes #656
2018-12-21 00:06:13 +01:00
Hans-Christoph Steiner
1d1f489d85 handle repo Intents for mirrors that are already enabled
This adds a new IntentService to pre-process Intents that request a
new repo is added.  Right now, this only handles Intents that come
from the new storage scanners.

This also adds a new case to the AddRepo UI logic to cover when an
incoming Intent is for a mirror that is already included in an enabled
repo.  In that case, the user is show the Repo Details screen for the
repo that includes that mirror.  This is done is a hacky way right now
since the only path through is to click the button.  So this clicks
the button in code.
2018-12-21 00:04:34 +01:00
Hans-Christoph Steiner
c4b0955c96 add preference to disable removable storage scanning 2018-12-21 00:04:34 +01:00
Hans-Christoph Steiner
f9bc219073 SDCardScannerService for using repos from SD Cards
Creates an IntentService subclass for scanning removable "external
storage" for F-Droid package repos, e.g. SD Cards. This is intented to
support sharable package repos, so it ignores non-removable storage,
like the fake emulated sdcard from devices with only built-in storage.
This method will only ever allow for reading repos, never writing.  It
also will not work for removeable storage devices plugged in via USB,
since do not show up as "External Storage"

* https://stackoverflow.com/a/40201333
* https://commonsware.com/blog/2017/11/14/storage-situation-external-storage.html

closes #1377
2018-12-21 00:04:34 +01:00