65 Commits

Author SHA1 Message Date
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
Hans-Christoph Steiner
1571e28f68 support swapping with removable storage on android-21+
This uses the new Storage Access Framework, which was required for
accessing files on the SD Card starting in android-19.  But the API
was really limited until android-21, and not really complete until
android-23 or even android-26.  So the levels of usability will vary a
lot based on how new the version of Android is.
2018-12-21 00:03:39 +01:00
Hans-Christoph Steiner
0e6b4acabf
rename RepoUpdater to IndexUpdater 2018-12-17 17:17:28 +01:00
Hans-Christoph Steiner
6db0fa6387 add clickable list of APKs to the swap HTML index page
This allows for rapid, direct download of APKs.  It is sometimes useful, as
long as it doesn't get in the way.
2018-08-17 15:05:00 +02:00
Hans-Christoph Steiner
ab8948eb5a fix "Send F-Droid via Bluetooth"
The 'com.mediatek.bluetooth' Bluetooth or android-23 devices were not
being granted URI permissions.
2018-08-17 15:05:00 +02:00
Hans-Christoph Steiner
20c93c64d8 eliminate .views.fragments package used by a single class 2018-08-17 14:33:50 +02:00
Hans-Christoph Steiner
558dde5f77 run Deflator.end() to get rid of StrictMode errors:
java.lang.Throwable: Explicit termination method 'end' not called
	at dalvik.system.CloseGuard.open(CloseGuard.java:180)
	at java.util.zip.Deflater.<init>(Deflater.java:171)
	at kellinwood.zipio.ZioEntryOutputStream.<init>(ZioEntryOutputStream.java:35)
	at kellinwood.zipio.ZioEntry.getOutputStream(ZioEntry.java:482)
	at kellinwood.security.zipsigner.ZipSigner.signZip(ZipSigner.java:759)
	at kellinwood.security.zipsigner.ZipSigner.signZip(ZipSigner.java:664)
	at org.fdroid.fdroid.localrepo.LocalRepoKeyStore.signZip(LocalRepoKeyStore.java:213)
	at org.fdroid.fdroid.localrepo.LocalRepoManager.writeIndexJar(LocalRepoManager.java:492)
	at org.fdroid.fdroid.views.swap.SwapWorkflowActivity$PrepareSwapRepo.doInBackground(SwapWorkflowActivity.java:759)
	at org.fdroid.fdroid.views.swap.SwapWorkflowActivity$PrepareSwapRepo.doInBackground(SwapWorkflowActivity.java:709)
	at android.os.AsyncTask$2.call(AsyncTask.java:304)
	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	at java.lang.Thread.run(Thread.java:761)
E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
2018-08-17 12:03:31 +02:00
Hans-Christoph Steiner
4a684182ca enable lint "GetInstance" security check as error 2018-08-17 10:10:00 +02:00
Hans-Christoph Steiner
0e6e839ed7 fix lint "WifiManager Potential Leak" 2018-08-17 10:10:00 +02:00
Hans-Christoph Steiner
81b32120e9 fix UnusedResources errors left over from basic/full flavor split 2018-08-17 10:10:00 +02:00
Hans-Christoph Steiner
e3b26b76f6 make swap webserver never support HTTP Connection Keep-Alive
NanoHTTPD has issues with HTTP Keep-Alive, especially when other requests
are mixed in, like the /request-swap POST or perhaps the F-Droid HEAD to
fetch the ETag before the GET.

This disables gzip encoding and sets a Content Security Policy while I'm at
it.  APKs, PNGs, and JARs are already compressed, so gzip would only ever
cause problems.  And the index page is meant to be viewed by browsers, so
having a CSP will limit potential malicious swap activity.
2018-08-07 23:33:33 +02:00