Merge branch 'filter_notifications' into develop
This commit is contained in:
commit
8d7774da8f
|
@ -1,12 +1,12 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.3"
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.2"
|
||||
defaultConfig {
|
||||
applicationId "fr.gouv.etalab.mastodon"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 25
|
||||
targetSdkVersion 26
|
||||
versionCode 55
|
||||
versionName "1.4.9-beta-7"
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ allprojects {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
compile 'com.android.support:appcompat-v7:25.4.0'
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.android.support:support-v4:25.4.0'
|
||||
compile 'com.android.support:cardview-v7:25.4.0'
|
||||
compile 'com.android.support:appcompat-v7:26.0.2'
|
||||
compile 'com.android.support:design:26.0.2'
|
||||
compile 'com.android.support:support-v4:26.0.2'
|
||||
compile 'com.android.support:cardview-v7:26.0.2'
|
||||
compile 'com.loopj.android:android-async-http:1.4.9'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
compile 'com.evernote:android-job:1.1.11'
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.support.v7.widget.SwitchCompat;
|
|||
import android.util.Patterns;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
@ -139,6 +140,7 @@ public class MainActivity extends AppCompatActivity
|
|||
private String userIdService;
|
||||
private Intent streamingIntent;
|
||||
public static String lastHomeId = null, lastNotificationId = null;
|
||||
boolean notif_follow, notif_add, notif_mention, notif_share;
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
@ -224,6 +226,89 @@ public class MainActivity extends AppCompatActivity
|
|||
tabLayout.addTab(tabLocal);
|
||||
if( display_global)
|
||||
tabLayout.addTab(tabPublic);
|
||||
//Display filter for notification when long pressing the tab
|
||||
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||
tabStrip.getChildAt(1).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//Only shown if the tab has focus
|
||||
if( notificationsFragment != null && notificationsFragment.getUserVisibleHint()){
|
||||
PopupMenu popup = new PopupMenu(MainActivity.this, tabStrip.getChildAt(1));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_notifications, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemFavourite = menu.findItem(R.id.action_favorite);
|
||||
final MenuItem itemFollow = menu.findItem(R.id.action_follow);
|
||||
final MenuItem itemMention = menu.findItem(R.id.action_mention);
|
||||
final MenuItem itemBoost = menu.findItem(R.id.action_boost);
|
||||
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||
itemFavourite.setChecked(notif_add);
|
||||
itemFollow.setChecked(notif_follow);
|
||||
itemMention.setChecked(notif_mention);
|
||||
itemBoost.setChecked(notif_share);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
if( notificationsFragment != null)
|
||||
notificationsFragment.refreshAll();
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_favorite:
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
notif_add = !notif_add;
|
||||
editor.putBoolean(Helper.SET_NOTIF_ADD, notif_add);
|
||||
itemFavourite.setChecked(notif_add);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_follow:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_follow = !notif_follow;
|
||||
editor.putBoolean(Helper.SET_NOTIF_FOLLOW, notif_follow);
|
||||
itemFollow.setChecked(notif_follow);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_mention:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_mention = !notif_mention;
|
||||
editor.putBoolean(Helper.SET_NOTIF_MENTION, notif_mention);
|
||||
itemMention.setChecked(notif_mention);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_boost:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_share = !notif_share;
|
||||
editor.putBoolean(Helper.SET_NOTIF_SHARE, notif_share);
|
||||
itemBoost.setChecked(notif_share);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||
int countPage = 2;
|
||||
|
|
|
@ -195,10 +195,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
//Update the id of the last notification retrieved
|
||||
|
||||
MainActivity.lastNotificationId = notifications.get(0).getId();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
|
||||
editor.apply();
|
||||
lastReadNotifications = notifications.get(0).getId();
|
||||
updateNotificationLastId(sharedpreferences, this.userId, notifications.get(0).getId());
|
||||
}
|
||||
notificationsListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -225,11 +222,8 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
return;
|
||||
//Store last notification id to avoid to notify for those that have been already seen
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
if (visible && notifications != null && notifications.size() > 0) {
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
|
||||
editor.apply();
|
||||
lastReadNotifications = notifications.get(0).getId();
|
||||
updateNotificationLastId(sharedpreferences, this.userId, notifications.get(0).getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,14 +233,23 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
//Store last toot id for home timeline to avoid to notify for those that have been already seen
|
||||
//Store last notification id to avoid to notify for those that have been already seen
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
if (notifications != null && notifications.size() > 0) {
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
|
||||
editor.apply();
|
||||
lastReadNotifications = notifications.get(0).getId();
|
||||
updateNotificationLastId(sharedpreferences, this.userId, notifications.get(0).getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAll(){
|
||||
if( context == null)
|
||||
return;
|
||||
max_id = null;
|
||||
notifications = new ArrayList<>();
|
||||
firstLoad = true;
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
MainActivity.countNewNotifications = 0;
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
||||
public void refresh(Notification notification){
|
||||
if( context == null)
|
||||
|
@ -285,4 +288,20 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the id of the notification only if its greater than the previous one.
|
||||
* @param sharedPreferences SharedPreferences
|
||||
* @param userId String current logged user
|
||||
* @param notificationId String current notification id to check
|
||||
*/
|
||||
private void updateNotificationLastId(SharedPreferences sharedPreferences, String userId, String notificationId){
|
||||
String lastNotif = sharedPreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null);
|
||||
if( lastNotif != null && notificationId != null && Long.parseLong(notificationId) > Long.parseLong(lastNotif)){
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notificationId);
|
||||
editor.apply();
|
||||
lastReadNotifications = notificationId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
@ -69,6 +70,30 @@ public class SettingsNotificationsFragment extends Fragment {
|
|||
}else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||
final SwitchCompat switchCompatNotify = (SwitchCompat) rootView.findViewById(R.id.set_notify);
|
||||
switchCompatNotify.setChecked(notify);
|
||||
final LinearLayout notification_settings = (LinearLayout) rootView.findViewById(R.id.notification_settings);
|
||||
if( notify)
|
||||
notification_settings.setVisibility(View.VISIBLE);
|
||||
else
|
||||
notification_settings.setVisibility(View.GONE);
|
||||
switchCompatNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
// Save the state here
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_NOTIFY, isChecked);
|
||||
editor.apply();
|
||||
if( isChecked)
|
||||
notification_settings.setVisibility(View.VISIBLE);
|
||||
else
|
||||
notification_settings.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||
boolean notif_ask = sharedpreferences.getBoolean(Helper.SET_NOTIF_ASK, true);
|
||||
|
|
|
@ -223,6 +223,7 @@ public class Helper {
|
|||
public static final int TRANS_NONE = 2;
|
||||
|
||||
public static final String SET_TRANS_FORCED = "set_trans_forced";
|
||||
public static final String SET_NOTIFY = "set_notify";
|
||||
public static final String SET_NOTIF_FOLLOW = "set_notif_follow";
|
||||
public static final String SET_NOTIF_ADD = "set_notif_follow_add";
|
||||
public static final String SET_NOTIF_ASK = "set_notif_follow_ask";
|
||||
|
@ -1443,6 +1444,9 @@ public class Helper {
|
|||
*/
|
||||
public static boolean canNotify(Context context){
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||
if( !notify)
|
||||
return false;
|
||||
String dateIni = sharedpreferences.getString(Helper.SET_TIME_FROM, "07:00");
|
||||
String dateEnd = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00");
|
||||
Calendar now = Calendar.getInstance();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -33,108 +34,6 @@
|
|||
android:orientation="vertical"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<!-- NOTIFICATIONS SETTINGS -->
|
||||
<TextView
|
||||
android:text="@string/settings_title_notifications"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- Toots per page -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_add"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_ask"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_ask"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_mention"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_mention"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_share"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- END NOTIFICATIONS SETTINGS -->
|
||||
|
||||
<!-- NOTIFICATION CONTENT NEW -->
|
||||
<TextView
|
||||
android:text="@string/set_title_news"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- New hometimeline content -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_hometimeline"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notification_news"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/settings_title_hour"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
style="?attr/shapeBorder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="@string/settings_time_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:focusableInTouchMode="false"
|
||||
android:id="@+id/settings_time_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="@string/settings_time_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:focusableInTouchMode="false"
|
||||
android:id="@+id/settings_time_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<!-- MORE OPTIONS SETTINGS -->
|
||||
<TextView
|
||||
android:text="@string/settings_title_more_options"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -144,9 +43,9 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_wifi_only"/>
|
||||
android:text="@string/set_notify"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/set_wifi_only"
|
||||
android:id="@+id/set_notify"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
|
@ -154,43 +53,171 @@
|
|||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/notification_settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
<!-- NOTIFICATIONS SETTINGS -->
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/settings_title_notifications"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- Toots per page -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_notif_silent"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/set_silence"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:text="@string/set_notif_follow"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:text="@string/set_notif_follow_add"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_ask"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_ask"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_mention"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_mention"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_follow_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notif_follow_share"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- END NOTIFICATIONS SETTINGS -->
|
||||
|
||||
<!-- NOTIFICATION CONTENT NEW -->
|
||||
<TextView
|
||||
android:text="@string/set_title_news"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- New hometimeline content -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_notif_hometimeline"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_notification_news"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/set_led_colour_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/settings_title_hour"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
style="?attr/shapeBorder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="@string/set_led_colour"/>
|
||||
<Spinner
|
||||
android:id="@+id/led_colour_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="@string/settings_time_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:focusableInTouchMode="false"
|
||||
android:id="@+id/settings_time_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="@string/settings_time_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:focusableInTouchMode="false"
|
||||
android:id="@+id/settings_time_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<!-- MORE OPTIONS SETTINGS -->
|
||||
<TextView
|
||||
android:text="@string/settings_title_more_options"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/led_colours"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_wifi_only"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/set_wifi_only"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_notif_silent"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/set_silence"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/set_led_colour_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="@string/set_led_colour"/>
|
||||
<Spinner
|
||||
android:id="@+id/led_colour_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/led_colours"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_favorite"
|
||||
android:checkable="true"
|
||||
android:title="@string/favourite"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always"
|
||||
tools:ignore="AlwaysShowAction" />
|
||||
<item
|
||||
android:id="@+id/action_follow"
|
||||
android:checkable="true"
|
||||
android:title="@string/follow"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/action_mention"
|
||||
android:checkable="true"
|
||||
android:title="@string/mention"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/action_boost"
|
||||
android:checkable="true"
|
||||
android:title="@string/reblog"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
|
@ -59,6 +59,10 @@
|
|||
<string name="username">Benutzername</string>
|
||||
<string name="drafts">Entwürfe</string>
|
||||
<string name="new_data">Neue Beiträge sind verfügbar! Anzeigen?</string>
|
||||
<string name="favourite">Favorisierungen</string>
|
||||
<string name="follow">Neue Folgende</string>
|
||||
<string name="mention">Erwähnungen</string>
|
||||
<string name="reblog">Geteilte Beiträge</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Home</string>
|
||||
<string name="local_menu">Lokale Zeitleiste</string>
|
||||
|
@ -303,6 +307,7 @@
|
|||
<string name="set_share_validation_fav">Bestätigungsdialog vor dem favorisieren</string>
|
||||
<string name="settings_title_more_options">Erweiterte Einstellungen</string>
|
||||
<string name="set_wifi_only">Nur bei WLAN benachrichtigen</string>
|
||||
<string name="set_notify">Benachrichtigen?</string>
|
||||
<string name="set_notif_silent">Leise Benachrichtigungen</string>
|
||||
<string name="set_night_mode">Nachtmodus</string>
|
||||
<string name="set_nsfw_timeout">NSFW Anzeige Dauer (Sekunden, 0 bedeutet aus)</string>
|
||||
|
|
|
@ -60,6 +60,11 @@
|
|||
<string name="username">Nom d\'utilisateur</string>
|
||||
<string name="drafts">Brouillons</string>
|
||||
<string name="new_data">De nouvelles données sont disponibles ! Souhaitez-vous les afficher ?</string>
|
||||
<string name="favourite">Favoris</string>
|
||||
<string name="follow">Nouveaux⋅elles abonn⋅é⋅s</string>
|
||||
<string name="mention">Mentions</string>
|
||||
<string name="reblog">Partages</string>
|
||||
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Accueil</string>
|
||||
<string name="local_menu">Fil public local</string>
|
||||
|
@ -291,6 +296,7 @@
|
|||
<string name="set_share_validation_fav">Confirmer avant d\'ajouter aux favoris</string>
|
||||
<string name="settings_title_more_options">Options avancées</string>
|
||||
<string name="set_wifi_only">Notifier en WIFI seulement</string>
|
||||
<string name="set_notify">Notifier ?</string>
|
||||
<string name="set_notif_silent">Utiliser le vibreur</string>
|
||||
<string name="set_night_mode">Mode nuit</string>
|
||||
<string name="set_nsfw_timeout">Délai d\'affichage NSFW (en secondes, 0 signifie aucun délai)</string>
|
||||
|
|
|
@ -60,6 +60,11 @@
|
|||
<string name="username">User name</string>
|
||||
<string name="drafts">Drafts</string>
|
||||
<string name="new_data">New data are available! Do you want to display them?</string>
|
||||
<string name="favourite">Favourites</string>
|
||||
<string name="follow">New followers</string>
|
||||
<string name="mention">Mentions</string>
|
||||
<string name="reblog">Boosts</string>
|
||||
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Home</string>
|
||||
<string name="local_menu">Local timeline</string>
|
||||
|
@ -297,6 +302,7 @@
|
|||
<string name="set_share_validation_fav">Show confirmation dialog before adding to favourites</string>
|
||||
<string name="settings_title_more_options">Advanced settings</string>
|
||||
<string name="set_wifi_only">Notify in WIFI only</string>
|
||||
<string name="set_notify">Notify?</string>
|
||||
<string name="set_notif_silent">Silent Notifications</string>
|
||||
<string name="set_night_mode">Night mode</string>
|
||||
<string name="set_nsfw_timeout">NSFW view timeout (seconds, 0 means off)</string>
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.support.v7.widget.SwitchCompat;
|
|||
import android.util.Patterns;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
@ -142,6 +143,7 @@ public class MainActivity extends AppCompatActivity
|
|||
private String userIdService;
|
||||
private Intent streamingIntent;
|
||||
public static String lastHomeId = null, lastNotificationId = null;
|
||||
boolean notif_follow, notif_add, notif_mention, notif_share;
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
@ -227,6 +229,89 @@ public class MainActivity extends AppCompatActivity
|
|||
tabLayout.addTab(tabLocal);
|
||||
if( display_global)
|
||||
tabLayout.addTab(tabPublic);
|
||||
//Display filter for notification when long pressing the tab
|
||||
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||
tabStrip.getChildAt(1).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//Only shown if the tab has focus
|
||||
if( notificationsFragment != null && notificationsFragment.getUserVisibleHint()){
|
||||
PopupMenu popup = new PopupMenu(MainActivity.this, tabStrip.getChildAt(1));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_notifications, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemFavourite = menu.findItem(R.id.action_favorite);
|
||||
final MenuItem itemFollow = menu.findItem(R.id.action_follow);
|
||||
final MenuItem itemMention = menu.findItem(R.id.action_mention);
|
||||
final MenuItem itemBoost = menu.findItem(R.id.action_boost);
|
||||
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||
itemFavourite.setChecked(notif_add);
|
||||
itemFollow.setChecked(notif_follow);
|
||||
itemMention.setChecked(notif_mention);
|
||||
itemBoost.setChecked(notif_share);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
if( notificationsFragment != null)
|
||||
notificationsFragment.refreshAll();
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_favorite:
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
notif_add = !notif_add;
|
||||
editor.putBoolean(Helper.SET_NOTIF_ADD, notif_add);
|
||||
itemFavourite.setChecked(notif_add);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_follow:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_follow = !notif_follow;
|
||||
editor.putBoolean(Helper.SET_NOTIF_FOLLOW, notif_follow);
|
||||
itemFollow.setChecked(notif_follow);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_mention:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_mention = !notif_mention;
|
||||
editor.putBoolean(Helper.SET_NOTIF_MENTION, notif_mention);
|
||||
itemMention.setChecked(notif_mention);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_boost:
|
||||
editor = sharedpreferences.edit();
|
||||
notif_share = !notif_share;
|
||||
editor.putBoolean(Helper.SET_NOTIF_SHARE, notif_share);
|
||||
itemBoost.setChecked(notif_share);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||
int countPage = 2;
|
||||
|
|
Loading…
Reference in New Issue