... | ... |
@@ -8,7 +8,7 @@ android { |
8 | 8 |
minSdkVersion 16 |
9 | 9 |
targetSdkVersion 26 |
10 | 10 |
versionCode 1 |
11 |
- versionName "1.0" |
|
11 |
+ versionName "1.1" |
|
12 | 12 |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
13 | 13 |
vectorDrawables.useSupportLibrary = true |
14 | 14 |
} |
... | ... |
@@ -19,7 +19,7 @@ |
19 | 19 |
<category android:name="android.intent.category.LAUNCHER" /> |
20 | 20 |
</intent-filter> |
21 | 21 |
</activity> |
22 |
- |
|
22 |
+ <fragment android:name=".views.SettingsActivityFragment" /> |
|
23 | 23 |
<receiver |
24 | 24 |
android:name=".controllers.SyncManager$RefreshBroadcastReceiver" |
25 | 25 |
android:exported="true"> |
... | ... |
@@ -8,6 +8,7 @@ import android.content.SharedPreferences; |
8 | 8 |
import android.graphics.Color; |
9 | 9 |
import android.net.Uri; |
10 | 10 |
import android.os.Build; |
11 |
+import android.os.Handler; |
|
11 | 12 |
import android.preference.PreferenceManager; |
12 | 13 |
import android.support.v4.app.NotificationCompat; |
13 | 14 |
import android.widget.Toast; |
... | ... |
@@ -141,13 +142,18 @@ public class FlashManager { |
141 | 142 |
|
142 | 143 |
int min = 0; |
143 | 144 |
int max = sorted.length - 1; |
144 |
- if(max < 0){ |
|
145 |
- max = 0; |
|
146 |
- } |
|
145 |
+ |
|
147 | 146 |
if (max > flashesToStoreInDatabase) { |
148 | 147 |
min = max - flashesToStoreInDatabase; |
149 | 148 |
} |
150 | 149 |
JSONArray output = new JSONArray(); |
150 |
+ if(min < 0 || max >= sorted.length){ |
|
151 |
+ min = 0; |
|
152 |
+ max = sorted.length - 1; |
|
153 |
+ } |
|
154 |
+ if(max < 0){ |
|
155 |
+ max = 0; |
|
156 |
+ } |
|
151 | 157 |
for (int i = min; i <= max; i++) { |
152 | 158 |
output.put(sorted[i].serialize()); |
153 | 159 |
} |
... | ... |
@@ -246,9 +252,17 @@ public class FlashManager { |
246 | 252 |
DebugManager.sendDebugNotification("Error occurred while trying push notifications: " + exception.getLocalizedMessage(), context); |
247 | 253 |
} |
248 | 254 |
} |
249 |
- if(MainFlashActivity.activeInstance != null){ |
|
250 |
- MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
251 |
- } |
|
255 |
+ Handler mainHandler = new Handler(context.getMainLooper()); |
|
256 |
+ Runnable myRunnable = new Runnable() { |
|
257 |
+ @Override |
|
258 |
+ public void run() { |
|
259 |
+ if(MainFlashActivity.activeInstance != null){ |
|
260 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
261 |
+ } |
|
262 |
+ } |
|
263 |
+ }; |
|
264 |
+ mainHandler.post(myRunnable); |
|
265 |
+ |
|
252 | 266 |
} |
253 | 267 |
|
254 | 268 |
@Override |
... | ... |
@@ -256,9 +270,16 @@ public class FlashManager { |
256 | 270 |
lastContactSuccessful = ConnectionStatus.INVALID; |
257 | 271 |
exception.printStackTrace(); |
258 | 272 |
DebugManager.sendDebugNotification("An error occurred while trying to receive flashes: " + exception.getLocalizedMessage(), context); |
259 |
- if(MainFlashActivity.activeInstance != null){ |
|
260 |
- MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
261 |
- } |
|
273 |
+ Handler mainHandler = new Handler(context.getMainLooper()); |
|
274 |
+ Runnable myRunnable = new Runnable() { |
|
275 |
+ @Override |
|
276 |
+ public void run() { |
|
277 |
+ if(MainFlashActivity.activeInstance != null){ |
|
278 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
279 |
+ } |
|
280 |
+ } |
|
281 |
+ }; |
|
282 |
+ mainHandler.post(myRunnable); |
|
262 | 283 |
} |
263 | 284 |
}, context); |
264 | 285 |
} catch (MalformedURLException exception) { |
... | ... |
@@ -267,8 +288,15 @@ public class FlashManager { |
267 | 288 |
} catch (Exception exception) { |
268 | 289 |
exception.printStackTrace(); |
269 | 290 |
} |
270 |
- if(MainFlashActivity.activeInstance != null){ |
|
271 |
- MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
272 |
- } |
|
291 |
+ Handler mainHandler = new Handler(context.getMainLooper()); |
|
292 |
+ Runnable myRunnable = new Runnable() { |
|
293 |
+ @Override |
|
294 |
+ public void run() { |
|
295 |
+ if(MainFlashActivity.activeInstance != null){ |
|
296 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
297 |
+ } |
|
298 |
+ } |
|
299 |
+ }; |
|
300 |
+ mainHandler.post(myRunnable); |
|
273 | 301 |
} |
274 | 302 |
} |
... | ... |
@@ -11,6 +11,7 @@ import android.widget.TextView; |
11 | 11 |
|
12 | 12 |
import app.librenews.io.librenews.R; |
13 | 13 |
import app.librenews.io.librenews.controllers.FlashManager; |
14 |
+import app.librenews.io.librenews.controllers.SyncManager; |
|
14 | 15 |
|
15 | 16 |
public class MainFlashActivity extends AppCompatActivity { |
16 | 17 |
public static MainFlashActivity activeInstance; |
... | ... |
@@ -66,7 +67,6 @@ public class MainFlashActivity extends AppCompatActivity { |
66 | 67 |
manager.refresh(); |
67 | 68 |
} |
68 | 69 |
}); |
69 |
- regenerateToolbarStatus(); |
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
@Override |
... | ... |
@@ -9,25 +9,24 @@ import app.librenews.io.librenews.R; |
9 | 9 |
import app.librenews.io.librenews.controllers.FlashManager; |
10 | 10 |
import app.librenews.io.librenews.controllers.SyncManager; |
11 | 11 |
|
12 |
-public class SettingsActivityFragment extends PreferenceFragment { |
|
12 |
+public class SettingsActivityFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{ |
|
13 | 13 |
@Override |
14 |
- public void onCreate(final Bundle savedInstanceState) { |
|
14 |
+ public void onCreate(Bundle savedInstanceState) { |
|
15 | 15 |
super.onCreate(savedInstanceState); |
16 | 16 |
// Load the preferences from an XML resource |
17 | 17 |
addPreferencesFromResource(R.xml.preferences); |
18 |
- SharedPreferences.OnSharedPreferenceChangeListener spChanged = new |
|
19 |
- SharedPreferences.OnSharedPreferenceChangeListener() { |
|
20 |
- @Override |
|
21 |
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, |
|
22 |
- String key) { |
|
23 |
- if(key.equals("refresh_preference") || key.equals("automatically_refresh")){ |
|
24 |
- new SyncManager(getView().getContext(), new FlashManager(getView().getContext())).startSyncService(); |
|
25 |
- } |
|
26 |
- if(MainFlashActivity.activeInstance != null){ |
|
27 |
- MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
28 |
- } |
|
29 |
- } |
|
30 |
- }; |
|
31 |
- PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(spChanged); |
|
18 |
+ PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ @Override |
|
22 |
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, |
|
23 |
+ String key) { |
|
24 |
+ System.out.println(key + " changed!"); |
|
25 |
+ if(key.equals("refresh_preference") || key.equals("automatically_refresh")){ |
|
26 |
+ new SyncManager(getView().getContext(), new FlashManager(getView().getContext())).startSyncService(); |
|
27 |
+ } |
|
28 |
+ if (getActivity() instanceof MainFlashActivity) { |
|
29 |
+ ((MainFlashActivity)getActivity()).regenerateToolbarStatus(); |
|
30 |
+ } |
|
32 | 31 |
} |
33 | 32 |
} |
... | ... |
@@ -34,5 +34,10 @@ |
34 | 34 |
Les notifications d\'actualités sont parmi les canaux les plus importants par lesquels nous recevons des informations. LibreNews vise à démocratiser ce processus en fournissant un service de notification d\'actualités minimaliste, libre, open source, rapide, sécurisé et décentralisé qui fonctionnera sur presque n\'importe quel smartphone.</p> |
35 | 35 |
]]> |
36 | 36 |
</string> |
37 |
+ <string name="title_activity_welcome">Welcome to LibreNews</string> |
|
38 |
+ <string name="short_description_of_app">LibreNews provides ad-free, decentralized, and secure breaking news notifications.</string> |
|
39 |
+ <string name="how_to_use">You\'ll mostly interact with LibreNews through its notifications, as the app itself is just settings. \n\nYou\'ll probably get around 3 breaking news notifications per day, if you stick with the default settings.</string> |
|
40 |
+ <string name="final_notes_welcome_screen">LibreNews doesn\'t track you in any way, and doesn\'t have ads. It\'s completely open source, making the code free for anyone to see.</string> |
|
41 |
+ <string name="start_app">START LIBRENEWS</string> |
|
37 | 42 |
|
38 | 43 |
</resources> |
... | ... |
@@ -34,5 +34,11 @@ |
34 | 34 |
最新ニュースの通知は、情報を受け取るために最も重要なチャネルの 1 つです。LibreNews はほぼすべての携帯で動作して、 <i>ミニマリスト、フリー、オープンソース、ファースト、セキュア、 そして 分散 ニュース通知サービス を提供することで、このプロセスを民主化することを目指しています。 |
35 | 35 |
]]> |
36 | 36 |
</string> |
37 |
+ <string name="title_activity_welcome">Welcome to LibreNews</string> |
|
38 |
+ <string name="short_description_of_app">LibreNews provides ad-free, decentralized, and secure breaking news notifications.</string> |
|
39 |
+ <string name="how_to_use">You\'ll mostly interact with LibreNews through its notifications, as the app itself is just settings. \n\nYou\'ll probably get around 3 breaking news notifications per day, if you stick with the default settings.</string> |
|
40 |
+ <string name="final_notes_welcome_screen">LibreNews doesn\'t track you in any way, and doesn\'t have ads. It\'s completely open source, making the code free for anyone to see.</string> |
|
41 |
+ <string name="start_app">START LIBRENEWS</string> |
|
42 |
+ <string name="status_text" formatted="false">syncing every {rate}</string> |
|
37 | 43 |
|
38 | 44 |
</resources> |
... | ... |
@@ -36,8 +36,6 @@ |
36 | 36 |
</string> |
37 | 37 |
|
38 | 38 |
<string name="title_activity_welcome">Welcome to LibreNews</string> |
39 |
- <string name="dummy_button">Dummy Button</string> |
|
40 |
- <string name="dummy_content">DUMMY\nCONTENT</string> |
|
41 | 39 |
<string name="short_description_of_app">LibreNews provides ad-free, decentralized, and secure breaking news notifications.</string> |
42 | 40 |
<string name="how_to_use">You\'ll mostly interact with LibreNews through its notifications, as the app itself is just settings. \n\nYou\'ll probably get around 3 breaking news notifications per day, if you stick with the default settings.</string> |
43 | 41 |
<string name="final_notes_welcome_screen">LibreNews doesn\'t track you in any way, and doesn\'t have ads. It\'s completely open source, making the code free for anyone to see.</string> |