Moved settings

Moved settings:
- Integrated server settings into global settings
- Moved settings out of article list options menu to bottom of drawer
- Moved add-feed item to end of feeds list
- Reorganized options in menu of article list. Now only article related settings are included

Removed wrong usage of id R.id.action_settings in SyncIntervalSelectorActivity.

Signed-off-by: emasty <emasty@gmail.com>
This commit is contained in:
emasty 2020-01-07 00:34:08 +01:00
parent 21b6a6d345
commit a65a813887
16 changed files with 191 additions and 61 deletions

View file

@ -766,8 +766,8 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
}
}
private static final int RESULT_SETTINGS = 15642;
private static final int RESULT_ADD_NEW_FEED = 15643;
public static final int RESULT_SETTINGS = 15642;
public static final int RESULT_ADD_NEW_FEED = 15643;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@ -781,28 +781,10 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
return true;
break;
case R.id.action_settings:
Intent intent = new Intent(this, SettingsActivity.class);
startActivityForResult(intent, RESULT_SETTINGS);
return true;
case R.id.menu_update:
startSync();
break;
case R.id.action_login:
startLoginActivity();
break;
case R.id.action_add_new_feed:
if(mApi.getAPI() != null) {
Intent newFeedIntent = new Intent(this, NewFeedActivity.class);
startActivityForResult(newFeedIntent, RESULT_ADD_NEW_FEED);
} else {
startLoginActivity();
}
break;
case R.id.menu_StartImageCaching:
final DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(this);
@ -944,20 +926,25 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
}
if(requestCode == RESULT_SETTINGS) {
//Update settings of image Loader
mApi.initApi(new NextcloudAPI.ApiConnectedListener() {
@Override
public void onConnected() {
ensureCorrectTheme(data);
}
// Extra is set if user entered/modified server settings
if (data.getBooleanExtra(SettingsActivity.PREF_SERVER_SETTINGS,false)) {
resetUiAndStartSync();
} else {
@Override
public void onError(Exception ex) {
ensureCorrectTheme(data);
ex.printStackTrace();
}
});
//Update settings of image Loader
mApi.initApi(new NextcloudAPI.ApiConnectedListener() {
@Override
public void onConnected() {
ensureCorrectTheme(data);
}
@Override
public void onError(Exception ex) {
ensureCorrectTheme(data);
ex.printStackTrace();
}
});
}
} else if(requestCode == RESULT_ADD_NEW_FEED) {
if(data != null) {
boolean val = data.getBooleanExtra(NewFeedActivity.ADD_NEW_SUCCESS, false);

View file

@ -22,6 +22,7 @@
package de.luhmer.owncloudnewsreader;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
@ -38,6 +39,10 @@ import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import com.google.android.material.navigation.NavigationView;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import java.io.ByteArrayInputStream;
@ -49,8 +54,6 @@ import java.io.Serializable;
import javax.inject.Inject;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
@ -59,7 +62,6 @@ import de.luhmer.owncloudnewsreader.di.ApiProvider;
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
import de.luhmer.owncloudnewsreader.model.AbstractItem;
import de.luhmer.owncloudnewsreader.model.ConcreteFeedItem;
import de.luhmer.owncloudnewsreader.model.FolderSubscribtionItem;
import de.luhmer.owncloudnewsreader.model.UserInfo;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -68,6 +70,8 @@ import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;
import static de.luhmer.owncloudnewsreader.LoginDialogActivity.RESULT_LOGIN;
/**
* A list fragment representing a list of NewsReader. This fragment also
* supports tablet devices by allowing list items to be given an 'activated'
@ -180,6 +184,8 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
lvAdapter.notifyDataSetChanged();
reloadAdapter();
bindNavigationMenu(view, inflater);
return view;
}
@ -210,6 +216,52 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
}
}
/**
* Cares about settings items in news list drawer.
* - Binds settings, shown at bottom of drawer
* - Inflates NavigationView which is set as footerview of ListView
* Currently used to show item "add newsfeed" at bottom of list.
*
* @param parent content view of drawer
* @param inflater inflater provided to fragment
*/
private void bindNavigationMenu(View parent, LayoutInflater inflater) {
// Bind settings menu at bottom of drawer
NavigationView navigationView = parent.findViewById(R.id.navigationMenu);
navigationView.setNavigationItemSelectedListener(item -> {
switch(item.getItemId()) {
case R.id.drawer_settings:
Intent intent = new Intent(getContext(), SettingsActivity.class);
getActivity().startActivityForResult(intent, NewsReaderListActivity.RESULT_SETTINGS);
return true;
default:
return false;
}
});
// Create NavigationView to show as footer of ListView
View footerView = inflater.inflate(R.layout.fragmet_newsreader_list_footer, null, false);
ExpandableListView list = parent.findViewById(R.id.expandableListView);
NavigationView footerNavigation = footerView.findViewById(R.id.listfooterMenu);
footerNavigation.setNavigationItemSelectedListener(item -> {
switch(item.getItemId()) {
case R.id.action_add_new_feed:
if(mApi.getAPI() != null) {
Intent newFeedIntent = new Intent(getContext(), NewFeedActivity.class);
getActivity().startActivityForResult(newFeedIntent, NewsReaderListActivity.RESULT_ADD_NEW_FEED);
} else {
Intent loginIntent = new Intent(getContext(), LoginDialogActivity.class);
getActivity().startActivityForResult(loginIntent, RESULT_LOGIN);
}
return true;
default:
return false;
}
});
list.addFooterView(footerView);
}
private ExpListTextClicked expListTextClickedListener = new ExpListTextClicked() {
@Override
@ -266,10 +318,6 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
};
public ExpandableListView getListView() {
return eListView;
}

View file

@ -27,6 +27,7 @@ import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.MenuItem;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@ -34,6 +35,8 @@ import javax.inject.Inject;
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
import static de.luhmer.owncloudnewsreader.LoginDialogActivity.RESULT_LOGIN;
/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
@ -75,6 +78,7 @@ public class SettingsActivity extends AppCompatActivity {
//public static final String CB_ENABLE_PODCASTS_STRING = "cb_enablePodcasts";
public static final String PREF_SERVER_SETTINGS = "pref_server_settings";
public static final String PREF_SYNC_SETTINGS = "pref_sync_settings";
public static final String SP_APP_THEME = "sp_app_theme";
@ -151,6 +155,28 @@ public class SettingsActivity extends AppCompatActivity {
setResult(RESULT_OK,intent);
}
/**
* Used to notify Activity, that server settings were touched by user.
*
* If server settings were touched, a result is provided by intent with corresponding request code.
* No notify the calling activity that server settings were touched, a new extra is put to
* response intent: PREF_SERVER_SETTINGS is set to true.
*
* Result has to be handled by receiving activity.
*
* @param requestCode
* @param resultCode
* @param data
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOGIN) {
Intent intent = getIntent().putExtra(PREF_SERVER_SETTINGS, true);
setResult(RESULT_OK, intent);
}
}
//@Override
public boolean onIsMultiPane() {

View file

@ -29,6 +29,7 @@ import de.luhmer.owncloudnewsreader.helper.NewsFileUtils;
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
import static android.app.Activity.RESULT_OK;
import static de.luhmer.owncloudnewsreader.LoginDialogActivity.RESULT_LOGIN;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_MARK_AS_READ_WHILE_SCROLLING_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_NAVIGATE_WITH_VOLUME_BUTTONS_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_OLED_MODE;
@ -40,6 +41,7 @@ import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_VERSION;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_CLEAR_CACHE;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_PASSWORD_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.LV_CACHE_IMAGES_OFFLINE_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.PREF_SERVER_SETTINGS;
import static de.luhmer.owncloudnewsreader.SettingsActivity.PREF_SYNC_SETTINGS;
import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_APP_THEME;
import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_DISPLAY_BROWSER;
@ -266,6 +268,13 @@ public class SettingsFragment extends PreferenceFragmentCompat {
checkForUnsycedChangesInDatabaseAndResetDatabase(prefFrag.getActivity());
return true;
});
Preference serverSettings = prefFrag.findPreference(PREF_SERVER_SETTINGS);
serverSettings.setOnPreferenceClickListener(preference -> {
Intent loginIntent = new Intent(getActivity(), LoginDialogActivity.class);
getActivity().startActivityForResult(loginIntent, RESULT_LOGIN);
return true;
});
}

View file

@ -75,9 +75,8 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
// automatically StartYoutubePlayer clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
} else if(id == R.id.action_save) {
if(id == R.id.action_save) {
int checkedPosition = mFragment.lvItems.getCheckedItemPosition();
Integer minutes = Integer.parseInt(items_values[checkedPosition]);

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#3A3A3A"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#3A3A3A"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/>
</vector>

View file

@ -0,0 +1,12 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/menuSeparator" />
</shape>
</item>
<item android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="@color/app_drawer_feed_list_background_color" />
</shape>
</item>
</layer-list>

View file

@ -1,4 +1,5 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
@ -69,6 +70,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:layout_below="@+id/header_view" />
android:layout_below="@+id/header_view"
android:layout_above="@id/navigationMenu"
/>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/navigationview_bg"
android:layout_alignParentBottom="true"
app:menu="@menu/drawer_menu" />
</RelativeLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.navigation.NavigationView
android:id="@+id/listfooterMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_drawer_feed_list_background_color"
app:menu="@menu/list_footer_menu" />
</LinearLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/drawer_settings"
android:icon="@drawable/ic_settings_black_24dp"
android:title="@string/action_settings" />
</menu>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_add_new_feed"
android:icon="@drawable/ic_add_black_24dp"
android:title="@string/action_add_new_feed"/>
</menu>

View file

@ -28,36 +28,23 @@
android:orderInCategory="95"
app:showAsAction="never" />
<item
android:id="@+id/menu_markAllAsRead"
app:showAsAction="never"
android:orderInCategory="96"
android:title="@string/menu_markAllAsRead"/>
<item
android:id="@+id/menu_downloadMoreItems"
app:showAsAction="never"
android:orderInCategory="97"
android:orderInCategory="96"
android:title="@string/menu_downloadMoreItems"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="98"
android:id="@+id/menu_markAllAsRead"
app:showAsAction="never"
android:title="@string/action_settings"/>
<item
android:id="@+id/action_login"
android:orderInCategory="100"
app:showAsAction="never"
android:title="@string/action_login"/>
android:orderInCategory="97"
android:title="@string/menu_markAllAsRead"/>
<item
android:id="@+id/action_add_new_feed"
android:orderInCategory="101"
app:showAsAction="never"
android:visible="false"
android:title="@string/action_add_new_feed"/>
<item

View file

@ -32,6 +32,7 @@
<color name="unstarredColor">#ffcccccc</color>
<color name="markasreadColor">@android:color/holo_green_light</color>
<color name="swipeBackground">#aaa</color>
<color name="menuSeparator">#555</color>
<color name="tintColor">@android:color/white</color>

View file

@ -33,6 +33,7 @@
<color name="unstarredColor">#ff888888</color>
<color name="markasreadColor">@android:color/holo_green_light</color>
<color name="swipeBackground">#aaa</color>
<color name="menuSeparator">#aaa</color>
<color name="tintColor">@android:color/black</color>

View file

@ -24,6 +24,13 @@
This preference simply launches an intent when selected. Use this UI sparingly, per
design guidelines.
-->
<Preference
android:key="pref_server_settings"
android:title="@string/action_login"
app:iconSpaceReserved="false">
</Preference>
<Preference
android:key="pref_sync_settings"