Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

Commit 6dba15f

Browse files
committed
remove startDownload button, start download automatically
1 parent 92e243d commit 6dba15f

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/main/java/de/storchp/opentracks/osmplugin/download/DownloadActivity.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,24 @@ protected void onCreate(Bundle savedInstanceState) {
119119
Log.i(TAG, "downloadUri=" + downloadUri + ", downloadType=" + downloadType);
120120

121121
binding.downloadInfo.setText(downloadUri.toString());
122-
binding.startDownloadButton.setOnClickListener((view) -> {
123-
if (downloadId == null) {
124-
startDownload();
125-
}
126-
});
122+
123+
downloadBroadcastReceiver = new DownloadBroadcastReceiver();
124+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
125+
registerReceiver(downloadBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
126+
} else {
127+
registerReceiver(downloadBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
128+
}
129+
130+
startDownload();
127131
} else {
128132
binding.downloadInfo.setText(R.string.no_download_uri_found);
129-
binding.startDownloadButton.setEnabled(false);
130133
}
131134

132135
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
133136
public void handleOnBackPressed() {
134137
navigateUp();
135138
}
136139
});
137-
138-
downloadBroadcastReceiver = new DownloadBroadcastReceiver();
139-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
140-
registerReceiver(downloadBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
141-
} else {
142-
registerReceiver(downloadBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
143-
}
144140
}
145141

146142
protected final ActivityResultLauncher<Intent> directoryIntentLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),

src/main/res/layout/activity_download.xml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
android:layout_width="match_parent"
44
android:layout_height="match_parent">
55

6-
<include layout="@layout/toolbar" android:id="@+id/toolbar"/>
6+
<include
7+
layout="@layout/toolbar"
8+
android:id="@+id/toolbar" />
79

810
<ProgressBar
911
android:id="@+id/progressBar"
@@ -13,24 +15,14 @@
1315
android:layout_height="wrap_content"
1416
android:visibility="gone"
1517
android:layout_below="@id/toolbar"
16-
style="?android:attr/progressBarStyleHorizontal"/>
18+
style="?android:attr/progressBarStyleHorizontal" />
1719

1820
<TextView
1921
android:id="@+id/download_info"
2022
android:layout_width="match_parent"
2123
android:layout_height="wrap_content"
2224
android:textSize="18sp"
2325
android:padding="20sp"
24-
android:layout_below="@id/progressBar"
25-
/>
26-
27-
<com.google.android.material.button.MaterialButton
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:layout_below="@id/download_info"
31-
android:layout_centerHorizontal="true"
32-
android:id="@+id/startDownloadButton"
33-
android:text="@string/startDownload"
34-
/>
26+
android:layout_below="@id/progressBar" />
3527

3628
</RelativeLayout>

0 commit comments

Comments
 (0)