diff options
Diffstat (limited to 'app/src')
10 files changed, 93 insertions, 0 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ff325de8f..f39d20a13 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -44,6 +44,12 @@ android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity + android:name=".ui.SettingsActivity" + android:label="@string/edit" + android:theme="@style/AppTheme" + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> + + <activity android:name=".ui.AboutActivity" android:label="@string/about" android:theme="@style/AppTheme" diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/DrawerActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/DrawerActivity.java index 4fcc7e88f..90ef8866a 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/DrawerActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/DrawerActivity.java @@ -66,6 +66,7 @@ import it.niedermann.nextcloud.deck.util.ViewUtil; public abstract class DrawerActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { protected static final int MENU_ID_ABOUT = -1; protected static final int MENU_ID_ADD_BOARD = -2; + protected static final int MENU_ID_SETTINGS = -3; protected static final int MENU_ID_ADD_ACCOUNT = -2; protected static final int ACTIVITY_ABOUT = 1; protected static final long NO_ACCOUNTS = -1; @@ -290,6 +291,10 @@ public abstract class DrawerActivity extends AppCompatActivity implements Naviga Intent aboutIntent = new Intent(getApplicationContext(), AboutActivity.class); startActivityForResult(aboutIntent, ACTIVITY_ABOUT); break; + case MENU_ID_SETTINGS: + Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class); + startActivityForResult(settingsIntent, ACTIVITY_ABOUT); + break; case MENU_ID_ADD_BOARD: EditBoardDialogFragment.newInstance().show(getSupportFragmentManager(), getString(R.string.add_board)); break; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 9ee21b692..1961722e5 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -292,6 +292,7 @@ public class MainActivity extends DrawerActivity { } boardsMenu.add(Menu.NONE, MENU_ID_ADD_BOARD, Menu.NONE, getString(R.string.add_board)).setIcon(R.drawable.ic_add_grey_24dp); menu.add(Menu.NONE, MENU_ID_ABOUT, Menu.NONE, getString(R.string.about)).setIcon(R.drawable.ic_info_outline_grey_24dp); + menu.add(Menu.NONE, MENU_ID_SETTINGS, Menu.NONE, getString(R.string.simple_settings)).setIcon(R.drawable.ic_settings_grey600_24dp); if (currentBoardId == NO_BOARDS && boardsList.size() > 0) { Board currentBoard = boardsList.get(0); currentBoardId = currentBoard.getLocalId(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/SettingsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SettingsActivity.java new file mode 100644 index 000000000..d41147cc5 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SettingsActivity.java @@ -0,0 +1,29 @@ +package it.niedermann.nextcloud.deck.ui; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler; +import it.niedermann.nextcloud.deck.ui.settings.SettingsFragment; + +public class SettingsActivity extends AppCompatActivity { + private static final int RESULT_CANCELED = 1; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this)); + setResult(RESULT_CANCELED); + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new SettingsFragment()) + .commit(); + } + + @Override + public boolean onSupportNavigateUp() { + finish(); // close this activity as oppose to navigating up + return true; + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java new file mode 100644 index 000000000..30de63958 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java @@ -0,0 +1,26 @@ +package it.niedermann.nextcloud.deck.ui.settings; + +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.preference.SwitchPreference; + +import androidx.annotation.Nullable; + +import it.niedermann.nextcloud.deck.DeckLog; +import it.niedermann.nextcloud.deck.R; + +public class SettingsFragment extends PreferenceFragment { + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.settings); + + final SwitchPreference wifiOnlyPref = (SwitchPreference) findPreference(getString(R.string.pref_key_wifi_only)); + wifiOnlyPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> { + Boolean syncOnWifiOnly = (Boolean) newValue; + DeckLog.log("syncOnWifiOnly: " + syncOnWifiOnly); + return true; + }); + } +} diff --git a/app/src/main/res/drawable/ic_settings_grey600_24dp.xml b/app/src/main/res/drawable/ic_settings_grey600_24dp.xml new file mode 100644 index 000000000..b4207174c --- /dev/null +++ b/app/src/main/res/drawable/ic_settings_grey600_24dp.xml @@ -0,0 +1,5 @@ +<vector android:autoMirrored="true" android:height="24dp" + android:tint="#666666" 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> diff --git a/app/src/main/res/drawable/ic_sync_grey600_24dp.xml b/app/src/main/res/drawable/ic_sync_grey600_24dp.xml new file mode 100644 index 000000000..3628dedbf --- /dev/null +++ b/app/src/main/res/drawable/ic_sync_grey600_24dp.xml @@ -0,0 +1,5 @@ +<vector android:autoMirrored="true" android:height="24dp" + android:tint="#666666" 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="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/> +</vector> diff --git a/app/src/main/res/values/setup.xml b/app/src/main/res/values/setup.xml index 8e8a404ba..20ed7561c 100644 --- a/app/src/main/res/values/setup.xml +++ b/app/src/main/res/values/setup.xml @@ -2,6 +2,9 @@ <resources> <string name="shared_preference_last_sync" translatable="false">it.niedermann.nextcloud.deck.last_sync</string> <string name="shared_preference_last_account" translatable="false">it.niedermann.nextcloud.deck.last_account</string> + + <string name="pref_key_wifi_only" translatable="false">wifiOnly</string> + <!-- To be concatenated with the account id --> <string name="shared_preference_last_board_for_account_" translatable="false">it.niedermann.nextcloud.deck.last_board_for_account_</string> <string name="shared_preference_last_stack_for_account_and_board" translatable="false">it.niedermann.nextcloud.deck.last_stack_for_board_</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e7ec648a..928d4542a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,4 +130,7 @@ <string name="delete_board_message">This will permanently delete this board including all stacks and cards.</string> <string name="action_card_list_rename_column">Rename column</string> <string name="simple_rename">Rename</string> + <string name="simple_settings">Settings</string> + <string name="pref_value_wifi_and_mobile">Sync on Wi-Fi and mobile data</string> + <string name="pref_value_wifi_only">Sync only on Wi-Fi</string> </resources> diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml new file mode 100644 index 000000000..59ad3d4a6 --- /dev/null +++ b/app/src/main/res/xml/settings.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <SwitchPreference + android:defaultValue="@string/pref_value_wifi_and_mobile" + android:icon="@drawable/ic_sync_grey600_24dp" + android:key="@string/pref_key_wifi_only" + android:title="@string/pref_value_wifi_only" /> + +</PreferenceScreen> |