... | ... |
@@ -0,0 +1,22 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<project version="4"> |
|
3 |
+ <component name="CompilerConfiguration"> |
|
4 |
+ <resourceExtensions /> |
|
5 |
+ <wildcardResourcePatterns> |
|
6 |
+ <entry name="!?*.java" /> |
|
7 |
+ <entry name="!?*.form" /> |
|
8 |
+ <entry name="!?*.class" /> |
|
9 |
+ <entry name="!?*.groovy" /> |
|
10 |
+ <entry name="!?*.scala" /> |
|
11 |
+ <entry name="!?*.flex" /> |
|
12 |
+ <entry name="!?*.kt" /> |
|
13 |
+ <entry name="!?*.clj" /> |
|
14 |
+ <entry name="!?*.aj" /> |
|
15 |
+ </wildcardResourcePatterns> |
|
16 |
+ <annotationProcessing> |
|
17 |
+ <profile default="true" name="Default" enabled="false"> |
|
18 |
+ <processorPath useClasspath="true" /> |
|
19 |
+ </profile> |
|
20 |
+ </annotationProcessing> |
|
21 |
+ </component> |
|
22 |
+</project> |
... | ... |
@@ -0,0 +1,3 @@ |
1 |
+<component name="CopyrightManager"> |
|
2 |
+ <settings default="" /> |
|
3 |
+</component> |
... | ... |
@@ -0,0 +1,41 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<project version="4"> |
|
3 |
+ <component name="EntryPointsManager"> |
|
4 |
+ <entry_points version="2.0" /> |
|
5 |
+ </component> |
|
6 |
+ <component name="NullableNotNullManager"> |
|
7 |
+ <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> |
|
8 |
+ <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> |
|
9 |
+ <option name="myNullables"> |
|
10 |
+ <value> |
|
11 |
+ <list size="4"> |
|
12 |
+ <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> |
|
13 |
+ <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> |
|
14 |
+ <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> |
|
15 |
+ <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> |
|
16 |
+ </list> |
|
17 |
+ </value> |
|
18 |
+ </option> |
|
19 |
+ <option name="myNotNulls"> |
|
20 |
+ <value> |
|
21 |
+ <list size="4"> |
|
22 |
+ <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> |
|
23 |
+ <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> |
|
24 |
+ <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> |
|
25 |
+ <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> |
|
26 |
+ </list> |
|
27 |
+ </value> |
|
28 |
+ </option> |
|
29 |
+ </component> |
|
30 |
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false"> |
|
31 |
+ <OptionsSetting value="true" id="Add" /> |
|
32 |
+ <OptionsSetting value="true" id="Remove" /> |
|
33 |
+ <OptionsSetting value="true" id="Checkout" /> |
|
34 |
+ <OptionsSetting value="true" id="Update" /> |
|
35 |
+ <OptionsSetting value="true" id="Status" /> |
|
36 |
+ <OptionsSetting value="true" id="Edit" /> |
|
37 |
+ <ConfirmationsSetting value="0" id="Add" /> |
|
38 |
+ <ConfirmationsSetting value="0" id="Remove" /> |
|
39 |
+ </component> |
|
40 |
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> |
|
41 |
+</project> |
... | ... |
@@ -0,0 +1,9 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<project version="4"> |
|
3 |
+ <component name="ProjectModuleManager"> |
|
4 |
+ <modules> |
|
5 |
+ <module fileurl="file://$PROJECT_DIR$/LibreNews-Android.iml" filepath="$PROJECT_DIR$/LibreNews-Android.iml" /> |
|
6 |
+ <module fileurl="file://$PROJECT_DIR$/LibreNews-App/LibreNews-App.iml" filepath="$PROJECT_DIR$/LibreNews-App/LibreNews-App.iml" /> |
|
7 |
+ </modules> |
|
8 |
+ </component> |
|
9 |
+</project> |
... | ... |
@@ -0,0 +1,12 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<project version="4"> |
|
3 |
+ <component name="RunConfigurationProducerService"> |
|
4 |
+ <option name="ignoredProducers"> |
|
5 |
+ <set> |
|
6 |
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> |
|
7 |
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> |
|
8 |
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> |
|
9 |
+ </set> |
|
10 |
+ </option> |
|
11 |
+ </component> |
|
12 |
+</project> |
... | ... |
@@ -0,0 +1,6 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<project version="4"> |
|
3 |
+ <component name="VcsDirectoryMappings"> |
|
4 |
+ <mapping directory="" vcs="Git" /> |
|
5 |
+ </component> |
|
6 |
+</project> |
... | ... |
@@ -11,7 +11,7 @@ |
11 | 11 |
android:roundIcon="@mipmap/ic_launcher_round" |
12 | 12 |
android:supportsRtl="true" |
13 | 13 |
android:theme="@style/AppTheme"> |
14 |
- <activity android:name=".views.FlashView"> |
|
14 |
+ <activity android:name=".views.MainFlashActivity"> |
|
15 | 15 |
<intent-filter> |
16 | 16 |
<action android:name="android.intent.action.MAIN" /> |
17 | 17 |
|
... | ... |
@@ -27,10 +27,6 @@ |
27 | 27 |
</intent-filter> |
28 | 28 |
</receiver> |
29 | 29 |
|
30 |
- <activity |
|
31 |
- android:name=".views.SettingsActivity" |
|
32 |
- android:label="@string/title_activity_settings" |
|
33 |
- android:theme="@style/AppTheme.NoActionBar"></activity> |
|
34 | 30 |
</application> |
35 | 31 |
|
36 | 32 |
</manifest> |
... | ... |
@@ -1,17 +1,14 @@ |
1 | 1 |
package app.librenews.io.librenews.controllers; |
2 | 2 |
|
3 |
-import android.app.Activity; |
|
4 |
-import android.app.AlarmManager; |
|
5 | 3 |
import android.app.NotificationManager; |
6 | 4 |
import android.app.PendingIntent; |
7 | 5 |
import android.content.Context; |
8 | 6 |
import android.content.Intent; |
9 | 7 |
import android.content.SharedPreferences; |
8 |
+import android.graphics.Color; |
|
10 | 9 |
import android.net.Uri; |
11 |
-import android.os.SystemClock; |
|
12 | 10 |
import android.preference.PreferenceManager; |
13 | 11 |
import android.support.v4.app.NotificationCompat; |
14 |
-import android.support.v4.widget.SwipeRefreshLayout; |
|
15 | 12 |
import android.widget.Toast; |
16 | 13 |
|
17 | 14 |
import org.json.JSONArray; |
... | ... |
@@ -30,10 +27,13 @@ import java.text.ParseException; |
30 | 27 |
import java.util.ArrayList; |
31 | 28 |
import java.util.Arrays; |
32 | 29 |
import java.util.Comparator; |
30 |
+import java.util.HashSet; |
|
33 | 31 |
import java.util.List; |
32 |
+import java.util.Set; |
|
34 | 33 |
|
35 | 34 |
import app.librenews.io.librenews.R; |
36 | 35 |
import app.librenews.io.librenews.models.Flash; |
36 |
+import app.librenews.io.librenews.views.MainFlashActivity; |
|
37 | 37 |
|
38 | 38 |
/** |
39 | 39 |
* Created by miles on 7/14/17. |
... | ... |
@@ -47,11 +47,32 @@ public class FlashManager { |
47 | 47 |
String serverUrl; |
48 | 48 |
String serverName; |
49 | 49 |
Context context; |
50 |
+ public static ConnectionStatus lastContactSuccessful = ConnectionStatus.NEUTRAL; |
|
51 |
+ |
|
52 |
+ public enum ConnectionStatus { |
|
53 |
+ VALID, |
|
54 |
+ INVALID, |
|
55 |
+ NEUTRAL; |
|
56 |
+ |
|
57 |
+ public int color(){ |
|
58 |
+ if(this.equals(VALID)){ |
|
59 |
+ return Color.parseColor("#3fee3f"); |
|
60 |
+ } |
|
61 |
+ if(this.equals(INVALID)){ |
|
62 |
+ return Color.parseColor("#ff3f3f"); |
|
63 |
+ } |
|
64 |
+ if(this.equals(INVALID)){ |
|
65 |
+ return Color.parseColor("#808080"); |
|
66 |
+ } |
|
67 |
+ return Color.parseColor("#808080"); |
|
68 |
+ } |
|
69 |
+ } |
|
50 | 70 |
|
51 | 71 |
public FlashManager(Context context) { |
52 | 72 |
this.context = context; |
53 | 73 |
this.prefs = PreferenceManager.getDefaultSharedPreferences(context); |
54 | 74 |
this.serverUrl = prefs.getString("server_url", "https://librenews.io/api"); |
75 |
+ lastContactSuccessful = ConnectionStatus.NEUTRAL; |
|
55 | 76 |
try { |
56 | 77 |
loadFlashesFromStorage(); |
57 | 78 |
} catch (FileNotFoundException exception) { |
... | ... |
@@ -174,6 +195,10 @@ public class FlashManager { |
174 | 195 |
|
175 | 196 |
public void refresh() { |
176 | 197 |
String newServerUrl = prefs.getString("server_url", "https://librenews.io/api"); |
198 |
+ Set<String> defaults = new HashSet<>(); |
|
199 |
+ defaults.add("Breaking News"); |
|
200 |
+ defaults.add("Announcements"); // mwahaha |
|
201 |
+ final Set<String> channels = prefs.getStringSet("channels", defaults); |
|
177 | 202 |
if (!newServerUrl.equals(serverUrl)) { |
178 | 203 |
// they changed their server preferences! |
179 | 204 |
try { |
... | ... |
@@ -191,7 +216,11 @@ public class FlashManager { |
191 | 216 |
retreiver.retrieveFlashes(new FlashRetreiver.FlashHandler() { |
192 | 217 |
@Override |
193 | 218 |
public void success(Flash[] flashes, String serverName) { |
219 |
+ lastContactSuccessful = ConnectionStatus.VALID; |
|
194 | 220 |
for (Flash f : flashes){ |
221 |
+ if(!channels.contains(f.getChannel())){ |
|
222 |
+ continue; |
|
223 |
+ } |
|
195 | 224 |
boolean pushed = false; |
196 | 225 |
for (Flash p : getLatestPushedFlashes()) { |
197 | 226 |
if (p.getId().equals(f.getId())) { |
... | ... |
@@ -210,12 +239,19 @@ public class FlashManager { |
210 | 239 |
DebugManager.sendDebugNotification("Error occurred while trying push notifications: " + exception.getLocalizedMessage(), context); |
211 | 240 |
} |
212 | 241 |
} |
242 |
+ if(MainFlashActivity.activeInstance != null){ |
|
243 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
244 |
+ } |
|
213 | 245 |
} |
214 | 246 |
|
215 | 247 |
@Override |
216 | 248 |
public void failure(Exception exception) { |
249 |
+ lastContactSuccessful = ConnectionStatus.INVALID; |
|
217 | 250 |
exception.printStackTrace(); |
218 | 251 |
DebugManager.sendDebugNotification("An error occurred while trying to receive flashes: " + exception.getLocalizedMessage(), context); |
252 |
+ if(MainFlashActivity.activeInstance != null){ |
|
253 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
254 |
+ } |
|
219 | 255 |
} |
220 | 256 |
}, context); |
221 | 257 |
} catch (MalformedURLException exception) { |
... | ... |
@@ -224,5 +260,8 @@ public class FlashManager { |
224 | 260 |
} catch (Exception exception) { |
225 | 261 |
exception.printStackTrace(); |
226 | 262 |
} |
263 |
+ if(MainFlashActivity.activeInstance != null){ |
|
264 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
265 |
+ } |
|
227 | 266 |
} |
228 | 267 |
} |
... | ... |
@@ -1,41 +0,0 @@ |
1 |
-package app.librenews.io.librenews.views; |
|
2 |
- |
|
3 |
-import android.content.Intent; |
|
4 |
-import android.preference.PreferenceActivity; |
|
5 |
-import android.preference.PreferenceManager; |
|
6 |
-import android.support.v4.widget.SwipeRefreshLayout; |
|
7 |
-import android.support.v7.app.AppCompatActivity; |
|
8 |
-import android.os.Bundle; |
|
9 |
-import android.view.View; |
|
10 |
- |
|
11 |
-import app.librenews.io.librenews.R; |
|
12 |
-import app.librenews.io.librenews.controllers.FlashManager; |
|
13 |
-import app.librenews.io.librenews.controllers.SyncManager; |
|
14 |
- |
|
15 |
-public class FlashView extends AppCompatActivity { |
|
16 |
- FlashManager manager; |
|
17 |
- |
|
18 |
- @Override |
|
19 |
- protected void onCreate(Bundle savedInstanceState) { |
|
20 |
- super.onCreate(savedInstanceState); |
|
21 |
- setContentView(R.layout.activity_flash_view); |
|
22 |
- manager = new FlashManager(this); |
|
23 |
- findViewById(R.id.settings_button).setOnClickListener( |
|
24 |
- new View.OnClickListener() { |
|
25 |
- @Override |
|
26 |
- public void onClick(View view) { |
|
27 |
- Intent intent = new Intent(FlashView.this, SettingsActivity.class); |
|
28 |
- startActivity(intent); |
|
29 |
- } |
|
30 |
- } |
|
31 |
- ); |
|
32 |
- final SwipeRefreshLayout srl = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); |
|
33 |
- srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
|
34 |
- @Override |
|
35 |
- public void onRefresh() { |
|
36 |
- new FlashManager(getApplicationContext()).refresh(); |
|
37 |
- srl.setRefreshing(false); |
|
38 |
- } |
|
39 |
- }); |
|
40 |
- } |
|
41 |
-} |
... | ... |
@@ -0,0 +1,78 @@ |
1 |
+package app.librenews.io.librenews.views; |
|
2 |
+ |
|
3 |
+import android.content.SharedPreferences; |
|
4 |
+import android.preference.PreferenceManager; |
|
5 |
+import android.support.v7.app.AppCompatActivity; |
|
6 |
+import android.os.Bundle; |
|
7 |
+import android.text.Html; |
|
8 |
+import android.view.View; |
|
9 |
+import android.widget.TextView; |
|
10 |
+ |
|
11 |
+import app.librenews.io.librenews.R; |
|
12 |
+import app.librenews.io.librenews.controllers.FlashManager; |
|
13 |
+ |
|
14 |
+public class MainFlashActivity extends AppCompatActivity { |
|
15 |
+ public static MainFlashActivity activeInstance; |
|
16 |
+ |
|
17 |
+ FlashManager manager; |
|
18 |
+ |
|
19 |
+ public void regenerateToolbarStatus(){ |
|
20 |
+ TextView connStatus = (TextView) findViewById(R.id.server_status); |
|
21 |
+ TextView statusTextView = (TextView) findViewById(R.id.status_text); |
|
22 |
+ connStatus.setTextColor(FlashManager.lastContactSuccessful.color()); |
|
23 |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); |
|
24 |
+ boolean syncing = prefs.getBoolean("automatically_refresh", true); |
|
25 |
+ boolean notifications = prefs.getBoolean("notifications_enabled", true); |
|
26 |
+ String host = prefs.getString("server_url", "https://librenews.io"); |
|
27 |
+ if(!(host.toLowerCase().startsWith("https://"))){ |
|
28 |
+ statusTextView.setText(getResources().getText(R.string.https_required)); |
|
29 |
+ return; |
|
30 |
+ } |
|
31 |
+ if(!syncing){ |
|
32 |
+ statusTextView.setText(getResources().getText(R.string.sync_disabled)); |
|
33 |
+ return; |
|
34 |
+ } |
|
35 |
+ if(!notifications){ |
|
36 |
+ statusTextView.setText(getResources().getText(R.string.notifications_disabled)); |
|
37 |
+ return; |
|
38 |
+ } |
|
39 |
+ int index = 0; |
|
40 |
+ String refreshValue = prefs.getString("refresh_preference", "1"); |
|
41 |
+ for(String s : getResources().getStringArray(R.array.refresh_values)){ |
|
42 |
+ if(s.equals(refreshValue)){ |
|
43 |
+ break; |
|
44 |
+ } |
|
45 |
+ index++; |
|
46 |
+ } |
|
47 |
+ String entry = getResources().getStringArray(R.array.refresh_rates)[index]; |
|
48 |
+ statusTextView.setText(getResources().getText(R.string.status_text).toString().replace("{rate}", entry)); |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ @Override |
|
52 |
+ protected void onCreate(Bundle savedInstanceState) { |
|
53 |
+ super.onCreate(savedInstanceState); |
|
54 |
+ activeInstance = this; |
|
55 |
+ setContentView(R.layout.activity_flash_view); |
|
56 |
+ manager = new FlashManager(this); |
|
57 |
+ findViewById(R.id.refresh_button).setOnClickListener(new View.OnClickListener() { |
|
58 |
+ @Override |
|
59 |
+ public void onClick(View view) { |
|
60 |
+ manager.refresh(); |
|
61 |
+ } |
|
62 |
+ }); |
|
63 |
+ regenerateToolbarStatus(); |
|
64 |
+ } |
|
65 |
+ |
|
66 |
+ @Override |
|
67 |
+ public void onResume(){ |
|
68 |
+ super.onResume(); |
|
69 |
+ regenerateToolbarStatus(); |
|
70 |
+ activeInstance = this; |
|
71 |
+ } |
|
72 |
+ |
|
73 |
+ @Override |
|
74 |
+ public void onDestroy(){ |
|
75 |
+ super.onDestroy(); |
|
76 |
+ activeInstance = null; |
|
77 |
+ } |
|
78 |
+} |
... | ... |
@@ -1,37 +0,0 @@ |
1 |
-package app.librenews.io.librenews.views; |
|
2 |
- |
|
3 |
-import android.content.SharedPreferences; |
|
4 |
-import android.os.Bundle; |
|
5 |
-import android.preference.PreferenceActivity; |
|
6 |
-import android.preference.PreferenceManager; |
|
7 |
-import android.support.design.widget.FloatingActionButton; |
|
8 |
-import android.support.design.widget.Snackbar; |
|
9 |
-import android.support.v7.app.AppCompatActivity; |
|
10 |
-import android.support.v7.widget.Toolbar; |
|
11 |
-import android.view.View; |
|
12 |
- |
|
13 |
-import app.librenews.io.librenews.R; |
|
14 |
-import app.librenews.io.librenews.controllers.FlashManager; |
|
15 |
-import app.librenews.io.librenews.controllers.SyncManager; |
|
16 |
- |
|
17 |
-public class SettingsActivity extends PreferenceActivity { |
|
18 |
- |
|
19 |
- @Override |
|
20 |
- protected void onCreate(Bundle savedInstanceState) { |
|
21 |
- super.onCreate(savedInstanceState); |
|
22 |
- addPreferencesFromResource(R.xml.preferences); |
|
23 |
- SharedPreferences.OnSharedPreferenceChangeListener spChanged = new |
|
24 |
- SharedPreferences.OnSharedPreferenceChangeListener() { |
|
25 |
- @Override |
|
26 |
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, |
|
27 |
- String key) { |
|
28 |
- if(key.equals("refresh_preference") || key.equals("automatically_refresh")){ |
|
29 |
- new SyncManager(getApplicationContext(), new FlashManager(getApplicationContext())).startSyncService(); |
|
30 |
- } |
|
31 |
- } |
|
32 |
- }; |
|
33 |
- |
|
34 |
- PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).registerOnSharedPreferenceChangeListener(spChanged); |
|
35 |
- } |
|
36 |
- |
|
37 |
-} |
... | ... |
@@ -1,9 +1,13 @@ |
1 | 1 |
package app.librenews.io.librenews.views; |
2 | 2 |
|
3 |
+import android.content.SharedPreferences; |
|
3 | 4 |
import android.preference.PreferenceFragment; |
4 | 5 |
import android.os.Bundle; |
6 |
+import android.preference.PreferenceManager; |
|
5 | 7 |
|
6 | 8 |
import app.librenews.io.librenews.R; |
9 |
+import app.librenews.io.librenews.controllers.FlashManager; |
|
10 |
+import app.librenews.io.librenews.controllers.SyncManager; |
|
7 | 11 |
|
8 | 12 |
public class SettingsActivityFragment extends PreferenceFragment { |
9 | 13 |
@Override |
... | ... |
@@ -12,5 +16,21 @@ public class SettingsActivityFragment extends PreferenceFragment { |
12 | 16 |
|
13 | 17 |
// Load the preferences from an XML resource |
14 | 18 |
addPreferencesFromResource(R.xml.preferences); |
19 |
+ |
|
20 |
+ SharedPreferences.OnSharedPreferenceChangeListener spChanged = new |
|
21 |
+ SharedPreferences.OnSharedPreferenceChangeListener() { |
|
22 |
+ @Override |
|
23 |
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, |
|
24 |
+ String key) { |
|
25 |
+ if(key.equals("refresh_preference") || key.equals("automatically_refresh")){ |
|
26 |
+ new SyncManager(getView().getContext(), new FlashManager(getView().getContext())).startSyncService(); |
|
27 |
+ } |
|
28 |
+ if(MainFlashActivity.activeInstance != null){ |
|
29 |
+ MainFlashActivity.activeInstance.regenerateToolbarStatus(); |
|
30 |
+ } |
|
31 |
+ } |
|
32 |
+ }; |
|
33 |
+ |
|
34 |
+ PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(spChanged); |
|
15 | 35 |
} |
16 | 36 |
} |
... | ... |
@@ -21,7 +21,7 @@ |
21 | 21 |
app:layout_constraintTop_toTopOf="parent" /> |
22 | 22 |
|
23 | 23 |
<Button |
24 |
- android:id="@+id/settings_button" |
|
24 |
+ android:id="@+id/refresh_button" |
|
25 | 25 |
style="@style/Widget.AppCompat.Button.Borderless.Colored" |
26 | 26 |
android:layout_width="wrap_content" |
27 | 27 |
android:layout_height="wrap_content" |
... | ... |
@@ -29,58 +29,57 @@ |
29 | 29 |
android:layout_marginEnd="8dp" |
30 | 30 |
android:layout_marginRight="8dp" |
31 | 31 |
android:layout_marginTop="8dp" |
32 |
- android:text="@string/action_settings" |
|
32 |
+ android:text="@string/refresh_label" |
|
33 | 33 |
android:textColor="@android:color/background_light" |
34 | 34 |
app:layout_constraintBottom_toBottomOf="@+id/toolbar" |
35 | 35 |
app:layout_constraintRight_toRightOf="@+id/toolbar" |
36 | 36 |
app:layout_constraintTop_toTopOf="@+id/toolbar" /> |
37 | 37 |
|
38 | 38 |
<TextView |
39 |
- android:id="@+id/server_name" |
|
39 |
+ android:id="@+id/server_status" |
|
40 | 40 |
android:layout_width="0dp" |
41 | 41 |
android:layout_height="wrap_content" |
42 | 42 |
android:layout_marginBottom="8dp" |
43 | 43 |
android:layout_marginLeft="16dp" |
44 | 44 |
android:layout_marginStart="16dp" |
45 | 45 |
android:layout_marginTop="8dp" |
46 |
- android:text="[server name]" |
|
46 |
+ android:text="•" |
|
47 |
+ android:textAllCaps="false" |
|
47 | 48 |
android:textAppearance="@style/TextAppearance.AppCompat.Medium.Inverse" |
49 |
+ android:textColor="@color/colorAccent" |
|
50 |
+ android:textSize="36sp" |
|
51 |
+ android:textStyle="bold" |
|
48 | 52 |
app:layout_constraintBottom_toBottomOf="@+id/toolbar" |
49 | 53 |
app:layout_constraintLeft_toLeftOf="@+id/toolbar" |
50 | 54 |
app:layout_constraintTop_toTopOf="@+id/toolbar" |
51 | 55 |
app:layout_constraintVertical_bias="0.444" /> |
52 | 56 |
|
53 |
- <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
54 |
- android:id="@+id/swiperefresh" |
|
55 |
- android:layout_width="360dp" |
|
57 |
+ <TextView |
|
58 |
+ android:id="@+id/status_text" |
|
59 |
+ android:layout_width="wrap_content" |
|
60 |
+ android:layout_height="wrap_content" |
|
61 |
+ android:text="[ERROR]" |
|
62 |
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium.Inverse" |
|
63 |
+ app:layout_constraintTop_toTopOf="@+id/server_status" |
|
64 |
+ android:layout_marginTop="8dp" |
|
65 |
+ app:layout_constraintBottom_toBottomOf="@+id/server_status" |
|
66 |
+ android:layout_marginBottom="8dp" |
|
67 |
+ app:layout_constraintLeft_toRightOf="@+id/server_status" |
|
68 |
+ android:layout_marginLeft="8dp" /> |
|
69 |
+ |
|
70 |
+ <fragment |
|
71 |
+ android:id="@+id/fragment" |
|
72 |
+ android:name="app.librenews.io.librenews.views.SettingsActivityFragment" |
|
73 |
+ android:layout_width="0dp" |
|
56 | 74 |
android:layout_height="0dp" |
75 |
+ android:layout_marginTop="0dp" |
|
57 | 76 |
app:layout_constraintTop_toBottomOf="@+id/toolbar" |
58 |
- android:layout_marginLeft="8dp" |
|
77 |
+ android:layout_marginLeft="0dp" |
|
59 | 78 |
app:layout_constraintLeft_toLeftOf="parent" |
60 | 79 |
app:layout_constraintBottom_toBottomOf="parent" |
61 |
- android:layout_marginStart="8dp" |
|
62 |
- app:layout_constraintVertical_bias="0.5"> |
|
63 |
- |
|
64 |
- <ScrollView |
|
65 |
- android:layout_width="match_parent" |
|
66 |
- android:layout_height="8dp" |
|
67 |
- tools:layout_editor_absoluteX="8dp" |
|
68 |
- tools:layout_editor_absoluteY="137dp"> |
|
69 |
- |
|
70 |
- <LinearLayout |
|
71 |
- android:layout_width="match_parent" |
|
72 |
- android:layout_height="wrap_content" |
|
73 |
- android:orientation="vertical"> |
|
74 |
- |
|
75 |
- <android.support.constraint.ConstraintLayout |
|
76 |
- android:layout_width="match_parent" |
|
77 |
- android:layout_height="match_parent"> |
|
78 |
- |
|
79 |
- </android.support.constraint.ConstraintLayout> |
|
80 |
- </LinearLayout> |
|
81 |
- </ScrollView> |
|
82 |
- |
|
83 |
- </android.support.v4.widget.SwipeRefreshLayout> |
|
80 |
+ android:layout_marginBottom="0dp" |
|
81 |
+ android:layout_marginRight="0dp" |
|
82 |
+ app:layout_constraintRight_toRightOf="parent" /> |
|
84 | 83 |
|
85 | 84 |
|
86 | 85 |
</android.support.constraint.ConstraintLayout> |
... | ... |
@@ -1,10 +0,0 @@ |
1 |
-<menu xmlns:android="http://schemas.android.com/apk/res/android" |
|
2 |
- xmlns:app="http://schemas.android.com/apk/res-auto" |
|
3 |
- xmlns:tools="http://schemas.android.com/tools" |
|
4 |
- tools:context="app.librenews.io.librenews.views.SettingsActivity"> |
|
5 |
- <item |
|
6 |
- android:id="@+id/action_settings" |
|
7 |
- android:orderInCategory="100" |
|
8 |
- android:title="@string/action_settings" |
|
9 |
- app:showAsAction="never" /> |
|
10 |
-</menu> |
... | ... |
@@ -28,4 +28,12 @@ |
28 | 28 |
<item>720</item> |
29 | 29 |
<item>1440</item> |
30 | 30 |
</string-array> |
31 |
+ <string-array name="channels"> |
|
32 |
+ <item>Announcements</item> |
|
33 |
+ <item>Breaking News</item> |
|
34 |
+ </string-array> |
|
35 |
+ <string-array name="default_channels"> |
|
36 |
+ <item>Announcements</item> |
|
37 |
+ <item>Breaking News</item> |
|
38 |
+ </string-array> |
|
31 | 39 |
</resources> |
... | ... |
@@ -2,6 +2,6 @@ |
2 | 2 |
<resources> |
3 | 3 |
<color name="colorPrimary">#3F51B5</color> |
4 | 4 |
<color name="colorPrimaryDark">#303F9F</color> |
5 |
- <color name="colorAccent">#FF4081</color> |
|
5 |
+ <color name="colorAccent">#ff4081</color> |
|
6 | 6 |
<color name="colorPrimarySub">#5b64c0</color> |
7 | 7 |
</resources> |
... | ... |
@@ -20,77 +20,19 @@ |
20 | 20 |
<string name="debug_mode_label">Debug mode</string> |
21 | 21 |
<string name="debug_mode_description">Whether LibreNews should send you lots of debug messages (via notifications)</string> |
22 | 22 |
<string name="title_activity_settings">Settings</string> |
23 |
- |
|
24 |
- <!-- Strings related to Settings --> |
|
25 |
- |
|
26 |
- <!-- Example General settings --> |
|
27 |
- <string name="pref_header_general">General</string> |
|
28 |
- |
|
29 |
- <string name="pref_title_social_recommendations">Enable social recommendations</string> |
|
30 |
- <string name="pref_description_social_recommendations">Recommendations for people to contact |
|
31 |
- based on your message history |
|
32 |
- </string> |
|
33 |
- |
|
34 |
- <string name="pref_title_display_name">Display name</string> |
|
35 |
- <string name="pref_default_display_name">John Smith</string> |
|
36 |
- |
|
37 |
- <string name="pref_title_add_friends_to_messages">Add friends to messages</string> |
|
38 |
- <string-array name="pref_example_list_titles"> |
|
39 |
- <item>Always</item> |
|
40 |
- <item>When possible</item> |
|
41 |
- <item>Never</item> |
|
42 |
- </string-array> |
|
43 |
- <string-array name="pref_example_list_values"> |
|
44 |
- <item>1</item> |
|
45 |
- <item>0</item> |
|
46 |
- <item>-1</item> |
|
47 |
- </string-array> |
|
48 |
- |
|
49 |
- <!-- Example settings for Data & Sync --> |
|
50 |
- <string name="pref_header_data_sync">Data & sync</string> |
|
51 |
- |
|
52 |
- <string name="pref_title_sync_frequency">Sync frequency</string> |
|
53 |
- <string-array name="pref_sync_frequency_titles"> |
|
54 |
- <item>15 minutes</item> |
|
55 |
- <item>30 minutes</item> |
|
56 |
- <item>1 hour</item> |
|
57 |
- <item>3 hours</item> |
|
58 |
- <item>6 hours</item> |
|
59 |
- <item>Never</item> |
|
60 |
- </string-array> |
|
61 |
- <string-array name="pref_sync_frequency_values"> |
|
62 |
- <item>15</item> |
|
63 |
- <item>30</item> |
|
64 |
- <item>60</item> |
|
65 |
- <item>180</item> |
|
66 |
- <item>360</item> |
|
67 |
- <item>-1</item> |
|
68 |
- </string-array> |
|
69 |
- |
|
70 |
- <string-array name="list_preference_entries"> |
|
71 |
- <item>Entry 1</item> |
|
72 |
- <item>Entry 2</item> |
|
73 |
- <item>Entry 3</item> |
|
74 |
- </string-array> |
|
75 |
- |
|
76 |
- <string-array name="list_preference_entry_values"> |
|
77 |
- <item>1</item> |
|
78 |
- <item>2</item> |
|
79 |
- <item>3</item> |
|
80 |
- </string-array> |
|
81 |
- |
|
82 |
- <string-array name="multi_select_list_preference_default_value" /> |
|
83 |
- |
|
84 |
- <string name="pref_title_system_sync_settings">System sync settings</string> |
|
85 |
- |
|
86 |
- <!-- Example settings for Notifications --> |
|
87 | 23 |
<string name="pref_header_notifications">Notifications</string> |
88 |
- |
|
89 |
- <string name="pref_title_new_message_notifications">New message notifications</string> |
|
90 |
- |
|
91 |
- <string name="pref_title_ringtone">Ringtone</string> |
|
92 |
- <string name="pref_ringtone_silent">Silent</string> |
|
93 |
- |
|
94 |
- <string name="pref_title_vibrate">Vibrate</string> |
|
95 | 24 |
<string name="action_settings">Settings</string> |
25 |
+ <string name="channels_label">Channels</string> |
|
26 |
+ <string name="channels_description">Select which channels will appear in notifications and your feed.</string> |
|
27 |
+ <string name="refresh_label">Refresh</string> |
|
28 |
+ <string name="https_required">server must be HTTPS</string> |
|
29 |
+ <string name="notifications_disabled">notifications disabled</string> |
|
30 |
+ <string name="sync_disabled">sync disabled</string> |
|
31 |
+ <string name="status_text" formatted="false">syncing every {rate}</string> |
|
32 |
+ <string name="short_description"> |
|
33 |
+ <![CDATA[ |
|
34 |
+ <p>Breaking news notifications are among the most important channels by which we receive information.</p><p><strong>LibreNews aims to democratize this process by providing a <i>minimalist, free, open source, fast, secure, </i>and <i>decentralized</i> news notification service</strong> that will run on almost any phone.</p> |
|
35 |
+ ]]> |
|
36 |
+ </string> |
|
37 |
+ |
|
96 | 38 |
</resources> |
... | ... |
@@ -24,6 +24,13 @@ |
24 | 24 |
android:key="refresh_preference" |
25 | 25 |
android:summary="@string/refresh_rate_description" |
26 | 26 |
android:title="@string/refresh_rate_label" /> |
27 |
+ <MultiSelectListPreference |
|
28 |
+ android:defaultValue="@array/default_channels" |
|
29 |
+ android:entries="@array/channels" |
|
30 |
+ android:entryValues="@array/channels" |
|
31 |
+ android:key="channels" |
|
32 |
+ android:summary="@string/channels_description" |
|
33 |
+ android:title="@string/channels_label" /> |
|
27 | 34 |
</PreferenceCategory> |
28 | 35 |
<PreferenceCategory android:title="@string/notification_preferences_label"> |
29 | 36 |
|