Browse Source

Add settings, Minor drawer bug fix

pull/27/head
Apostolos Fanakis 7 years ago
parent
commit
7433d9b2de
  1. 2
      app/build.gradle
  2. 9
      app/src/main/AndroidManifest.xml
  3. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  4. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java
  5. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  6. 44
      app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java
  7. 82
      app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java
  8. 25
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  9. 41
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  10. 46
      app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java
  11. 2
      app/src/main/res/layout/activity_bookmark.xml
  12. 33
      app/src/main/res/layout/activity_settings.xml
  13. 1
      app/src/main/res/values-v21/styles.xml
  14. 21
      app/src/main/res/values/strings.xml
  15. 1
      app/src/main/res/values/styles.xml
  16. 35
      app/src/main/res/xml/app_preferences.xml

2
app/build.gradle

@ -31,6 +31,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.android.support:preference-v14:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'

9
app/src/main/AndroidManifest.xml

@ -105,6 +105,15 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" />
</activity>
<activity
android:name=".activities.settings.SettingsActivity"
android:parentActivityName=".activities.main.MainActivity"
android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" />
</activity>
<provider
android:name="android.support.v4.content.FileProvider"

3
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -3,6 +3,7 @@ package gr.thmmy.mthmmy.activities;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@ -42,6 +43,8 @@ public class LoginActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
PreferenceManager.setDefaultValues(this, R.xml.app_preferences, false);
//Variables initialization
inputUsername = findViewById(R.id.username);
inputPassword = findViewById(R.id.password);

9
app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java

@ -64,7 +64,8 @@ public class BookmarkActivity extends BaseActivity {
}
public boolean onTopicInteractionListener(String interactionType, Bookmark bookmarkedTopic) {
if (interactionType.equals(TopicBookmarksFragment.INTERACTION_CLICK_TOPIC_BOOKMARK)){
switch (interactionType) {
case TopicBookmarksFragment.INTERACTION_CLICK_TOPIC_BOOKMARK:
Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class);
Bundle extras = new Bundle();
extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic="
@ -73,11 +74,13 @@ public class BookmarkActivity extends BaseActivity {
intent.putExtras(extras);
startActivity(intent);
finish();
} else if (interactionType.equals(TopicBookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION)) {
break;
case TopicBookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION:
return toggleNotification(bookmarkedTopic);
} else if (interactionType.equals(TopicBookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK)){
case TopicBookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK:
removeBookmark(bookmarkedTopic);
Toast.makeText(BookmarkActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show();
break;
}
return true;
}

3
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -8,6 +8,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.preference.PreferenceManager;
import android.widget.Toast;
import java.util.ArrayList;
@ -53,6 +54,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
redirectToActivityFromIntent(intentFilter);
setContentView(R.layout.activity_main);
PreferenceManager.setDefaultValues(this, R.xml.app_preferences, false);
if (sessionManager.isLoginScreenDefault()) {
//Go to login
Intent intent = new Intent(MainActivity.this, LoginActivity.class);

44
app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java

@ -0,0 +1,44 @@
package gr.thmmy.mthmmy.activities.settings;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseActivity;
public class SettingsActivity extends BaseActivity {
public static final String NOTIFICATION_VIBRATION_KEY = "pref_notification_vibration_enable_key";
public static final String APP_SIGNATURE_ENABLE_KEY = "pref_posting_app_signature_enable_key";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
//Initialize toolbar
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Settings");
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
createDrawer();
drawer.setSelection(SETTINGS_ID);
if (savedInstanceState == null) {
Fragment preferenceFragment = new SettingsFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.pref_container, preferenceFragment);
fragmentTransaction.commit();
}
}
@Override
protected void onResume() {
drawer.setSelection(SETTINGS_ID);
super.onResume();
}
}

82
app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java

@ -0,0 +1,82 @@
package gr.thmmy.mthmmy.activities.settings;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.util.Log;
import gr.thmmy.mthmmy.R;
public class SettingsFragment extends PreferenceFragmentCompat {
private static final int REQUEST_CODE_ALERT_RINGTONE = 2;
public static final String SETTINGS_SHARED_PREFS = "settingsSharedPrefs";
public static final String SELECTED_RINGTONE = "selectedRingtoneKey";
private static final String SELECTED_NOTIFICATIONS_SOUND = "pref_notifications_select_sound_key";
private static final String SILENT_SELECTED = "STFU";
private SharedPreferences settingsFile;
@Override
public void onCreatePreferences(Bundle bundle, String s) {
// Load the Preferences from the XML file
addPreferencesFromResource(R.xml.app_preferences);
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(SELECTED_NOTIFICATIONS_SOUND)) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
Activity activity = this.getActivity();
settingsFile = activity != null
? activity.getSharedPreferences(SETTINGS_SHARED_PREFS, Context.MODE_PRIVATE)
: null;
String existingValue = settingsFile != null
? settingsFile.getString(SELECTED_RINGTONE, null)
: null;
if (existingValue != null) {
if (existingValue.equals(SILENT_SELECTED)) {
//Selects "Silent"
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
} else {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(existingValue));
}
} else {
//No ringtone has been selected, set to the default
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
}
startActivityForResult(intent, REQUEST_CODE_ALERT_RINGTONE);
return true;
} else {
return super.onPreferenceTreeClick(preference);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_ALERT_RINGTONE && data != null) {
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
SharedPreferences.Editor editor = settingsFile.edit();
if (ringtone != null) {
editor.putString(SELECTED_RINGTONE, ringtone.toString()).apply();
} else {
// "Silent" was selected
editor.putString(SELECTED_RINGTONE, SILENT_SELECTED).apply();
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}

25
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
@ -12,6 +13,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.SpannableStringBuilder;
@ -44,6 +46,7 @@ import java.util.Objects;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.board.BoardActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Bookmark;
import gr.thmmy.mthmmy.model.Post;
@ -184,6 +187,7 @@ public class TopicActivity extends BaseActivity {
* navigation bar occurs
*/
private Integer pageRequestValue;
//Bottom navigation bar graphics related
private LinearLayout bottomNavBar;
private ImageButton firstPage;
@ -191,10 +195,12 @@ public class TopicActivity extends BaseActivity {
private TextView pageIndicator;
private ImageButton nextPage;
private ImageButton lastPage;
//Topic's info related
private SpannableStringBuilder topicTreeAndMods = new SpannableStringBuilder("Loading..."),
topicViewers = new SpannableStringBuilder("Loading...");
boolean includeAppSignaturePreference = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -214,6 +220,11 @@ public class TopicActivity extends BaseActivity {
topicPageUrl = ThmmyPage.sanitizeTopicUrl(topicPageUrl);
if (sessionManager.isLoggedIn()) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
includeAppSignaturePreference = sharedPrefs.getBoolean(SettingsActivity.APP_SIGNATURE_ENABLE_KEY, true);
}
thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl), true);
//Initializes graphics
@ -336,9 +347,7 @@ public class TopicActivity extends BaseActivity {
if (drawer.isDrawerOpen()) {
drawer.closeDrawer();
return;
}
else if(postsList!=null && postsList.size()>0 && postsList.get(postsList.size()-1)==null)
{
} else if (postsList != null && postsList.size() > 0 && postsList.get(postsList.size() - 1) == null) {
postsList.remove(postsList.size() - 1);
topicAdapter.notifyItemRemoved(postsList.size());
topicAdapter.setBackButtonHidden();
@ -356,6 +365,11 @@ public class TopicActivity extends BaseActivity {
super.onResume();
refreshTopicBookmark();
drawer.setSelection(-1);
if (sessionManager.isLoggedIn()) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
includeAppSignaturePreference = sharedPrefs.getBoolean(SettingsActivity.APP_SIGNATURE_ENABLE_KEY, true);
}
}
@Override
@ -548,6 +562,7 @@ public class TopicActivity extends BaseActivity {
}
}
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
private enum ResultCode {
SUCCESS, NETWORK_ERROR, PARSING_ERROR, OTHER_ERROR, SAME_PAGE, UNAUTHORIZED
@ -898,7 +913,9 @@ public class TopicActivity extends BaseActivity {
@Override
protected Boolean doInBackground(String... args) {
final String sentFrommTHMMY = "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url] [/i][/size][/right]";
final String sentFrommTHMMY = includeAppSignaturePreference
? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY [/url][/i][/size][/right]"
: "";
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("message", args[1] + sentFrommTHMMY)

41
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -47,6 +47,7 @@ import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.downloads.DownloadsActivity;
import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
import gr.thmmy.mthmmy.model.Bookmark;
import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.services.DownloadHelper;
@ -147,10 +148,11 @@ public abstract class BaseActivity extends AppCompatActivity {
protected static final int BOOKMARKS_ID = 2;
protected static final int LOG_ID = 3;
protected static final int ABOUT_ID = 4;
protected static final int SETTINGS_ID = 5;
private AccountHeader accountHeader;
private ProfileDrawerItem profileDrawerItem;
private PrimaryDrawerItem downloadsItem, loginLogoutItem;
private PrimaryDrawerItem downloadsItem, settingsItem, loginLogoutItem;
private IconicsDrawable loginIcon, logoutIcon;
/**
@ -162,9 +164,8 @@ public abstract class BaseActivity extends AppCompatActivity {
final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent);
PrimaryDrawerItem homeItem, bookmarksItem, aboutItem;
IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected,
bookmarksIcon, bookmarksIconSelected, aboutIcon,
aboutIconSelected;
IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, settingsIcon,
settingsIconSelected, bookmarksIcon, bookmarksIconSelected, aboutIcon, aboutIconSelected;
//Drawer Icons
homeIcon = new IconicsDrawable(this)
@ -188,6 +189,14 @@ public abstract class BaseActivity extends AppCompatActivity {
.color(primaryColor);
downloadsIconSelected = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_settings)
.color(selectedSecondaryColor);
settingsIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_settings)
.color(primaryColor);
settingsIconSelected = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_file_download)
.color(selectedSecondaryColor);
@ -243,6 +252,15 @@ public abstract class BaseActivity extends AppCompatActivity {
.withIcon(loginIcon)
.withSelectable(false);
settingsItem = new PrimaryDrawerItem()
.withTextColor(primaryColor)
.withSelectedColor(selectedPrimaryColor)
.withSelectedTextColor(selectedSecondaryColor)
.withIdentifier(SETTINGS_ID)
.withName(R.string.settings)
.withIcon(settingsIcon)
.withSelectedIcon(settingsIconSelected);
bookmarksItem = new PrimaryDrawerItem()
.withTextColor(primaryColor)
.withSelectedColor(selectedPrimaryColor)
@ -337,7 +355,11 @@ public abstract class BaseActivity extends AppCompatActivity {
Intent i = new Intent(BaseActivity.this, AboutActivity.class);
startActivity(i);
}
} else if (drawerItem.equals(SETTINGS_ID)) {
if (!(BaseActivity.this instanceof SettingsActivity)) {
Intent intent = new Intent(BaseActivity.this, SettingsActivity.class);
startActivity(intent);
}
}
drawer.closeDrawer();
@ -346,7 +368,7 @@ public abstract class BaseActivity extends AppCompatActivity {
});
if (sessionManager.isLoggedIn())
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, loginLogoutItem, aboutItem);
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem);
else
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, loginLogoutItem, aboutItem);
@ -369,10 +391,17 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
{
drawer.removeItem(DOWNLOADS_ID);
drawer.removeItem(SETTINGS_ID);
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
profileDrawerItem.withName(sessionManager.getUsername());
setDefaultAvatar();
} else {
if (!drawer.getDrawerItems().contains(downloadsItem)){
drawer.addItemAtPosition(settingsItem, 2);
}
if (!drawer.getDrawerItems().contains(settingsItem)){
drawer.addItemAtPosition(settingsItem, 3);
}
loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout
profileDrawerItem.withName(sessionManager.getUsername());
if (sessionManager.hasAvatar())

46
app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java

@ -6,11 +6,14 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import android.support.v7.preference.PreferenceManager;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
@ -25,6 +28,9 @@ import gr.thmmy.mthmmy.model.PostNotification;
import timber.log.Timber;
import static android.support.v4.app.NotificationCompat.PRIORITY_MAX;
import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_VIBRATION_KEY;
import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SELECTED_RINGTONE;
import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SETTINGS_SHARED_PREFS;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
@ -40,15 +46,13 @@ public class NotificationService extends FirebaseMessagingService {
try {
int userId = BaseApplication.getInstance().getSessionManager().getUserId();
//Don't notify me if the sender is me!
if(Integer.parseInt(json.getString("posterId"))!= userId)
{
if (Integer.parseInt(json.getString("posterId")) != userId) {
int topicId = Integer.parseInt(json.getString("topicId"));
int postId = Integer.parseInt(json.getString("postId"));
String topicTitle = json.getString("topicTitle");
String poster = json.getString("poster");
sendNotification(new PostNotification(postId, topicId, topicTitle, poster));
}
else
} else
Timber.v("Notification suppressed (own userID).");
} catch (JSONException e) {
Timber.e(e, "JSON Exception");
@ -70,6 +74,20 @@ public class NotificationService extends FirebaseMessagingService {
*/
private void sendNotification(PostNotification postNotification) {
Timber.i("Creating a notification...");
SharedPreferences settingsFile = getSharedPreferences(SETTINGS_SHARED_PREFS, Context.MODE_PRIVATE);
Uri notificationSoundUri = Uri.parse(settingsFile.getString(SELECTED_RINGTONE, null));
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean notificationsVibrateEnabled = sharedPrefs.getBoolean(NOTIFICATION_VIBRATION_KEY, true);
int notificationDefaultValues = Notification.DEFAULT_LIGHTS;
if (notificationsVibrateEnabled) {
notificationDefaultValues |= Notification.DEFAULT_VIBRATE;
}
if (notificationSoundUri == null) {
notificationDefaultValues |= Notification.DEFAULT_SOUND;
}
String topicUrl = "https://www.thmmy.gr/smf/index.php?topic=" + postNotification.getTopicId() + "." + postNotification.getPostId();
Intent intent = new Intent(this, TopicActivity.class);
Bundle extras = new Bundle();
@ -86,8 +104,7 @@ public class NotificationService extends FirebaseMessagingService {
if (buildVersion >= Build.VERSION_CODES.M) {
Notification existingNotification = getActiveNotification(topicId);
if(existingNotification!=null)
{
if (existingNotification != null) {
newPostsCount = existingNotification.extras.getInt(NEW_POSTS_COUNT) + 1;
contentText = newPostsCount + " new posts";
}
@ -103,9 +120,16 @@ public class NotificationService extends FirebaseMessagingService {
.setContentText(contentText)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setDefaults(notificationDefaultValues)
.setGroup(GROUP_KEY)
.addExtras(notificationExtras);
//Checks for values other than defaults and applies them
if (notificationSoundUri != null) {
notificationBuilder.setSound(notificationSoundUri);
}
if (!notificationsVibrateEnabled) {
notificationBuilder.setVibrate(new long[]{0L});
}
if (buildVersion < Build.VERSION_CODES.O)
notificationBuilder.setPriority(PRIORITY_MAX);
@ -116,8 +140,7 @@ public class NotificationService extends FirebaseMessagingService {
NotificationCompat.Builder summaryNotificationBuilder = null;
if(createSummaryNotification)
{
if (createSummaryNotification) {
summaryNotificationBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
@ -130,8 +153,6 @@ public class NotificationService extends FirebaseMessagingService {
}
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Since Android Oreo notification channel is needed.
@ -147,8 +168,7 @@ public class NotificationService extends FirebaseMessagingService {
@RequiresApi(api = Build.VERSION_CODES.M)
private Notification getActiveNotification(int notificationId) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if(notificationManager!=null)
{
if (notificationManager != null) {
StatusBarNotification[] barNotifications = notificationManager.getActiveNotifications();
for (StatusBarNotification notification : barNotifications) {
if (notification.getId() == notificationId)

2
app/src/main/res/layout/activity_bookmark.xml

@ -55,5 +55,3 @@
app:mpb_indeterminateTint="@color/accent"
app:mpb_progressStyle="horizontal"/>
</android.support.design.widget.CoordinatorLayout>

33
app/src/main/res/layout/activity_settings.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.settings.SettingsActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolbarTheme">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:gravity="center"
app:popupTheme="@style/ToolbarTheme" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/pref_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>

1
app/src/main/res/values-v21/styles.xml

@ -24,5 +24,6 @@
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
</resources>

21
app/src/main/res/values/strings.xml

@ -6,6 +6,7 @@
<string name="login_spinner">Authenticating&#8230;</string>
<string name="logout">Logout</string>
<string name="downloads">Downloads</string>
<string name="settings">Settings</string>
<string name="about">About</string>
<string name="home">Home</string>
<string name="bookmark">Bookmarks</string>
@ -74,6 +75,7 @@
<string name="remove_bookmark">Remove</string>
<string name="empty_board_bookmarks">You have no bookmarked boards</string>
<string name="empty_topic_bookmarks">You have no bookmarked topics</string>
<string name="toggle_notification">Toggle Notification</string>
<!--FontAwesome-->
<string name="fa_icon_star">&#xf005;</string>
@ -91,13 +93,26 @@
<string name="fa_folder">&#xf07b;</string>
<string name="fa_circle">&#xf111;</string>
<!--Notifications-->
<string name="toggle_notification">Toggle Notification</string>
<!--Download Prompt-->
<string name="downloadPromptText">File \"%1$s\" already exists. Download again?"</string>
<string name="download_symbol">Download Symbol</string>
<string name="cancel">Cancel</string>
<string name="open">Open</string>
<string name="download">Download</string>
<!--Settings Activity-->
<string name="action_settings">Settings</string>
<string name="title_activity_settings">Settings</string>
<string name="pref_category_notifications">Notifications</string>
<!--<string name="pref_title_notifications_enable">New posts notification</string>
<string name="pref_summary_notifications_enable">Toggle notifications state</string>-->
<string name="pref_title_notification_vibration_enable">Vibration</string>
<string name="pref_summary_notification_vibration_enable">Summary</string>
<string name="pref_title_notifications_sound">Notifications sound</string>
<string name="pref_summary_notifications_sound">Select your preferred notification sound</string>
<string name="pref_category_posting">Posting</string>
<string name="pref_title_posting_app_signature_enable">App signature</string>
<string name="pref_summary_posting_app_signature_enable">If enabled, a \"Posted from mThmmy\" message will be inserted at the end of your posts</string>
</resources>

1
app/src/main/res/values/styles.xml

@ -23,6 +23,7 @@
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">

35
app/src/main/res/xml/app_preferences.xml

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory android:title="@string/pref_category_notifications">
<!--<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_notifications_enable_key"
android:summary="@string/pref_summary_notifications_enable"
android:title="@string/pref_title_notifications_enable" />-->
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_notification_vibration_enable_key"
android:summary="@string/pref_summary_notification_vibration_enable"
android:title="@string/pref_title_notification_vibration_enable" />
<Preference
android:key="pref_notifications_select_sound_key"
android:summary="@string/pref_summary_notifications_sound"
android:title="@string/pref_title_notifications_sound" />
</android.support.v7.preference.PreferenceCategory>
<android.support.v7.preference.PreferenceCategory android:title="@string/pref_category_posting">
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_posting_app_signature_enable_key"
android:summary="@string/pref_summary_posting_app_signature_enable"
android:title="@string/pref_title_posting_app_signature_enable" />
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
Loading…
Cancel
Save