summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-06 15:36:01 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-06 15:36:01 +0100
commit3f255567420b3dcc8c05f906beb8cace55a7ee8a (patch)
tree14fa7b1780455d73f27fb0d8001603a6448b14bf /app/src/main/java/fr/gouv/etalab/mastodon
parent8cbc4c3d0ed7f315dd7bce6a1e776f7ec243a018 (diff)
Settings
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java13
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsPeertubeFragment.java119
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java4
3 files changed, 136 insertions, 0 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
index 71a4b6ac0..c0bc31abc 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
@@ -126,6 +126,7 @@ import fr.gouv.etalab.mastodon.fragments.DisplayListsFragment;
import fr.gouv.etalab.mastodon.fragments.DisplayMutedInstanceFragment;
import fr.gouv.etalab.mastodon.fragments.DisplayNotificationsFragment;
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.TabLayoutSettingsFragment;
import fr.gouv.etalab.mastodon.fragments.WhoToFollowFragment;
@@ -1666,6 +1667,11 @@ public abstract class BaseMainActivity extends BaseActivity
navigationView.setCheckedItem(R.id.nav_settings);
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
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){
this.recreate();
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
@@ -2002,6 +2008,13 @@ public abstract class BaseMainActivity extends BaseActivity
fragmentManager.beginTransaction()
.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) {
toot.hide();
statusFragment = new DisplayStatusFragment();
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsPeertubeFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsPeertubeFragment.java
new file mode 100644
index 000000000..a5c0d82c7
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsPeertubeFragment.java
@@ -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;
+ }
+
+
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
index f8bdb1d5c..03ed49e62 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
@@ -298,6 +298,10 @@ public class Helper {
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_MEDIUM = 2;