Settings
This commit is contained in:
parent
8cbc4c3d0e
commit
3f25556742
|
@ -126,6 +126,7 @@ import fr.gouv.etalab.mastodon.fragments.DisplayListsFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayMutedInstanceFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayMutedInstanceFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayNotificationsFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayNotificationsFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
||||||
|
import fr.gouv.etalab.mastodon.fragments.SettingsPeertubeFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.TabLayoutScheduleFragment;
|
import fr.gouv.etalab.mastodon.fragments.TabLayoutScheduleFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.TabLayoutSettingsFragment;
|
import fr.gouv.etalab.mastodon.fragments.TabLayoutSettingsFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.WhoToFollowFragment;
|
import fr.gouv.etalab.mastodon.fragments.WhoToFollowFragment;
|
||||||
|
@ -1666,6 +1667,11 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
navigationView.setCheckedItem(R.id.nav_settings);
|
navigationView.setCheckedItem(R.id.nav_settings);
|
||||||
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
||||||
toolbarTitle.setText(R.string.settings);
|
toolbarTitle.setText(R.string.settings);
|
||||||
|
}else if( extras.getInt(INTENT_ACTION) == BACK_TO_SETTINGS){
|
||||||
|
unCheckAllMenuItems(navigationView);
|
||||||
|
navigationView.setCheckedItem(R.id.nav_peertube_settings);
|
||||||
|
navigationView.getMenu().performIdentifierAction(R.id.nav_peertube_settings, 0);
|
||||||
|
toolbarTitle.setText(R.string.settings);
|
||||||
}else if (extras.getInt(INTENT_ACTION) == ADD_USER_INTENT){
|
}else if (extras.getInt(INTENT_ACTION) == ADD_USER_INTENT){
|
||||||
this.recreate();
|
this.recreate();
|
||||||
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
|
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
|
||||||
|
@ -2002,6 +2008,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit();
|
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit();
|
||||||
|
|
||||||
|
}else if (id == R.id.nav_peertube_settings) {
|
||||||
|
toot.hide();
|
||||||
|
SettingsPeertubeFragment settingsPeertubeFragment= new SettingsPeertubeFragment();
|
||||||
|
fragmentTag = "TABLAYOUT_PEERTUBE_SETTINGS";
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.main_app_container, settingsPeertubeFragment, fragmentTag).commit();
|
||||||
|
|
||||||
}else if (id == R.id.nav_favorites) {
|
}else if (id == R.id.nav_favorites) {
|
||||||
toot.hide();
|
toot.hide();
|
||||||
statusFragment = new DisplayStatusFragment();
|
statusFragment = new DisplayStatusFragment();
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
package fr.gouv.etalab.mastodon.fragments;
|
||||||
|
/* Copyright 2018 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Mastalab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.BACK_TO_SETTINGS;
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Thomas on 06/01/2019.
|
||||||
|
* Fragment for peertube settings
|
||||||
|
*/
|
||||||
|
public class SettingsPeertubeFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private int count1;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
final View rootView = inflater.inflate(R.layout.fragment_peertube_settings, container, false);
|
||||||
|
context = getContext();
|
||||||
|
assert context != null;
|
||||||
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
int videoMode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_TORRENT);
|
||||||
|
|
||||||
|
|
||||||
|
//Video mode
|
||||||
|
final Spinner video_mode_spinner = rootView.findViewById(R.id.set_video_mode);
|
||||||
|
ArrayAdapter<CharSequence> video_mode_spinnerAdapter = ArrayAdapter.createFromResource(getContext(),
|
||||||
|
R.array.settings_video_mode, android.R.layout.simple_spinner_item);
|
||||||
|
video_mode_spinner.setAdapter(video_mode_spinnerAdapter);
|
||||||
|
|
||||||
|
video_mode_spinner.setSelection(videoMode);
|
||||||
|
video_mode_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
if( count1 > 0 ) {
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_TORRENT);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_WEBVIEW);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_DIRECT);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( getActivity() != null)
|
||||||
|
getActivity().recreate();
|
||||||
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
|
intent.putExtra(INTENT_ACTION, BACK_TO_SETTINGS);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
count1++;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle saveInstance) {
|
||||||
|
super.onCreate(saveInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -298,6 +298,10 @@ public class Helper {
|
||||||
public static final int ATTACHMENT_ASK = 3;
|
public static final int ATTACHMENT_ASK = 3;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String SET_VIDEO_MODE = "set_video_mode";
|
||||||
|
public static final int VIDEO_MODE_TORRENT = 0;
|
||||||
|
public static final int VIDEO_MODE_WEBVIEW = 1;
|
||||||
|
public static final int VIDEO_MODE_DIRECT = 2;
|
||||||
|
|
||||||
public static final int BATTERY_PROFILE_NORMAL = 1;
|
public static final int BATTERY_PROFILE_NORMAL = 1;
|
||||||
public static final int BATTERY_PROFILE_MEDIUM = 2;
|
public static final int BATTERY_PROFILE_MEDIUM = 2;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2019 Thomas Schneider
|
||||||
|
|
||||||
|
This file is a part of Mastalab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
|
see <http://www.gnu.org/licenses>.
|
||||||
|
-->
|
||||||
|
<ScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/swipeContainer"
|
||||||
|
android:paddingLeft="@dimen/drawer_padding"
|
||||||
|
android:paddingRight="@dimen/drawer_padding"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Choose stream -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/set_video_mode"/>
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/set_video_mode"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
|
@ -21,8 +21,12 @@
|
||||||
android:id="@+id/swipeContainer"
|
android:id="@+id/swipeContainer"
|
||||||
android:paddingLeft="@dimen/drawer_padding"
|
android:paddingLeft="@dimen/drawer_padding"
|
||||||
android:paddingRight="@dimen/drawer_padding"
|
android:paddingRight="@dimen/drawer_padding"
|
||||||
|
android:layout_marginLeft="@dimen/fab_margin"
|
||||||
|
android:layout_marginRight="@dimen/fab_margin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="@dimen/fab_margin"
|
||||||
|
android:layout_marginEnd="@dimen/fab_margin">
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -60,6 +60,10 @@
|
||||||
android:id="@+id/nav_peertube_fav"
|
android:id="@+id/nav_peertube_fav"
|
||||||
android:icon="@drawable/ic_favorite_peertube_full"
|
android:icon="@drawable/ic_favorite_peertube_full"
|
||||||
android:title="@string/peertube_favorites" />
|
android:title="@string/peertube_favorites" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_peertube_settings"
|
||||||
|
android:icon="@drawable/ic_settings"
|
||||||
|
android:title="@string/settings" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_upload"
|
android:id="@+id/nav_upload"
|
||||||
android:icon="@drawable/ic_cloud_upload"
|
android:icon="@drawable/ic_cloud_upload"
|
||||||
|
|
|
@ -797,6 +797,14 @@
|
||||||
<string name="delete_comment">Delete a comment</string>
|
<string name="delete_comment">Delete a comment</string>
|
||||||
<string name="delete_comment_confirm">Are you sure to delete this comment?</string>
|
<string name="delete_comment_confirm">Are you sure to delete this comment?</string>
|
||||||
<string name="fullscreen">Full screen video</string>
|
<string name="fullscreen">Full screen video</string>
|
||||||
|
<string name="set_video_mode">Mode for videos</string>
|
||||||
<!-- end languages -->
|
<!-- end languages -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<string-array name="settings_video_mode">
|
||||||
|
<item>Torrent</item>
|
||||||
|
<item>Webview</item>
|
||||||
|
<item>Direct stream</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue