Style adjustments

This commit is contained in:
stefan-niedermann 2020-01-19 10:21:03 +01:00
parent 6e45e2339e
commit 71458afd8f
6 changed files with 49 additions and 44 deletions

View file

@ -198,7 +198,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
setContentView(R.layout.drawer_layout); setContentView(R.layout.drawer_layout);
ButterKnife.bind(this); ButterKnife.bind(this);
String categoryAdapterSelectedItem = ADAPTER_KEY_RECENT; String categoryAdapterSelectedItem = ADAPTER_KEY_RECENT;
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (ACTION_RECENT.equals(getIntent().getAction())) { if (ACTION_RECENT.equals(getIntent().getAction())) {

View file

@ -32,8 +32,11 @@ import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundExce
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException;
import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.nextcloud.android.sso.helper.SingleAccountHelper;
import java.util.Objects;
import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.android.activity.EditNoteActivity;
import it.niedermann.owncloud.notes.android.fragment.CategoryDialogFragment.CategoryDialogListener;
import it.niedermann.owncloud.notes.model.CloudNote; import it.niedermann.owncloud.notes.model.CloudNote;
import it.niedermann.owncloud.notes.model.DBNote; import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.LocalAccount; import it.niedermann.owncloud.notes.model.LocalAccount;
@ -44,7 +47,7 @@ import it.niedermann.owncloud.notes.util.ICallback;
import static androidx.core.content.pm.ShortcutManagerCompat.isRequestPinShortcutSupported; import static androidx.core.content.pm.ShortcutManagerCompat.isRequestPinShortcutSupported;
import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.ACTION_SHORTCUT; import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.ACTION_SHORTCUT;
public abstract class BaseNoteFragment extends Fragment implements CategoryDialogFragment.CategoryDialogListener { public abstract class BaseNoteFragment extends Fragment implements CategoryDialogListener {
private static final String TAG = BaseNoteFragment.class.getSimpleName(); private static final String TAG = BaseNoteFragment.class.getSimpleName();
@ -273,7 +276,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
showCategorySelector(); showCategorySelector();
return true; return true;
case R.id.menu_move: case R.id.menu_move:
AccountChooserDialogFragment.newInstance().show(getFragmentManager(), BaseNoteFragment.class.getCanonicalName()); AccountChooserDialogFragment.newInstance().show(Objects.requireNonNull(getFragmentManager()), BaseNoteFragment.class.getCanonicalName());
return true; return true;
case R.id.menu_share: case R.id.menu_share:
Intent shareIntent = new Intent(); Intent shareIntent = new Intent();
@ -293,7 +296,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
return false; return false;
case MENU_ID_PIN: case MENU_ID_PIN:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ShortcutManager shortcutManager = getActivity().getSystemService(ShortcutManager.class); ShortcutManager shortcutManager = Objects.requireNonNull(getActivity()).getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) { if (shortcutManager.isRequestPinShortcutSupported()) {
Intent intent = new Intent(getActivity(), EditNoteActivity.class); Intent intent = new Intent(getActivity(), EditNoteActivity.class);
@ -349,7 +352,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
} }
} }
protected float getFontSizeFromPreferences(SharedPreferences sp) { float getFontSizeFromPreferences(SharedPreferences sp) {
final String prefValueSmall = getString(R.string.pref_value_font_size_small); final String prefValueSmall = getString(R.string.pref_value_font_size_small);
final String prefValueMedium = getString(R.string.pref_value_font_size_medium); final String prefValueMedium = getString(R.string.pref_value_font_size_medium);
// final String prefValueLarge = getString(R.string.pref_value_font_size_large); // final String prefValueLarge = getString(R.string.pref_value_font_size_large);
@ -372,7 +375,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
*/ */
private void showCategorySelector() { private void showCategorySelector() {
final String fragmentId = "fragment_category"; final String fragmentId = "fragment_category";
FragmentManager manager = getFragmentManager(); FragmentManager manager = Objects.requireNonNull(getFragmentManager());
Fragment frag = manager.findFragmentByTag(fragmentId); Fragment frag = manager.findFragmentByTag(fragmentId);
if (frag != null) { if (frag != null) {
manager.beginTransaction().remove(frag).commit(); manager.beginTransaction().remove(frag).commit();

View file

@ -17,6 +17,7 @@ import androidx.fragment.app.Fragment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -46,8 +47,8 @@ public class CategoryDialogFragment extends DialogFragment {
void onCategoryChosen(String category); void onCategoryChosen(String category);
} }
public static final String PARAM_ACCOUNT_ID = "account_id"; static final String PARAM_ACCOUNT_ID = "account_id";
public static final String PARAM_CATEGORY = "category"; static final String PARAM_CATEGORY = "category";
private long accountId; private long accountId;
@ -56,13 +57,25 @@ public class CategoryDialogFragment extends DialogFragment {
private FolderArrayAdapter adapter; private FolderArrayAdapter adapter;
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if(getArguments() != null && getArguments().containsKey(PARAM_ACCOUNT_ID)) {
accountId = getArguments().getLong(PARAM_ACCOUNT_ID);
} else {
throw new IllegalArgumentException("Provide at least \"" + PARAM_ACCOUNT_ID + "\"");
}
}
@NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_change_category, null); View dialogView = Objects.requireNonNull(getActivity()).getLayoutInflater().inflate(R.layout.dialog_change_category, null);
ButterKnife.bind(this, dialogView); ButterKnife.bind(this, dialogView);
if (savedInstanceState == null) { if (savedInstanceState == null) {
textCategory.setText(getArguments().getString(PARAM_CATEGORY)); if(getArguments() != null && getArguments().containsKey(PARAM_CATEGORY)) {
accountId = getArguments().getLong(PARAM_ACCOUNT_ID); textCategory.setText(getArguments().getString(PARAM_CATEGORY));
}
} }
adapter = new FolderArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item); adapter = new FolderArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item);
textCategory.setAdapter(adapter); textCategory.setAdapter(adapter);

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -28,11 +27,15 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginBottom="@dimen/activity_margin" android:layout_marginBottom="@dimen/activity_margin"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/bg_highlighted"
android:padding="8dp"
android:scrollbars="horizontal|vertical" android:scrollbars="horizontal|vertical"
android:textIsSelectable="true" android:textIsSelectable="true"
app:fontFamily="monospace" /> android:typeface="monospace"
tools:text="@string/android_get_accounts_permission_not_granted_exception_message" />
<LinearLayout <LinearLayout
style="?android:buttonBarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
@ -41,17 +44,25 @@
<Button <Button
android:id="@+id/close" android:id="@+id/close"
style="?android:buttonBarButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight=".5" android:layout_weight=".5"
android:text="@string/simple_close" /> android:text="@string/simple_close" />
<Button <Button
android:id="@+id/copy" android:id="@+id/copy"
style="?android:buttonBarButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_weight=".5" android:layout_weight=".5"
android:text="@string/simple_copy" /> android:background="@color/primary"
android:foreground="?attr/selectableItemBackground"
android:text="@string/simple_copy"
android:textColor="@color/fg_contrast"
tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -5,12 +5,11 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="?dialogPreferredPadding"> android:padding="?dialogPreferredPadding">
<it.niedermann.owncloud.notes.android.AlwaysAutoCompleteTextView <it.niedermann.owncloud.notes.android.AlwaysAutoCompleteTextView
android:id="@+id/editCategory" android:id="@+id/editCategory"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:completionThreshold="1" android:completionThreshold="1"
android:inputType="text" android:inputType="text"
android:textColor="@color/fg_default" android:textColor="@color/fg_default" />
/>
</LinearLayout> </LinearLayout>

View file

@ -2,15 +2,10 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="@style/Theme.AppCompat.DayNight.DarkActionBar"> <style name="AppTheme" parent="@style/Theme.AppCompat.DayNight.DarkActionBar">
<!-- Main theme colors -->
<!-- App Bar -->
<item name="colorPrimary">@color/primary</item> <item name="colorPrimary">@color/primary</item>
<!-- Status Bar and contextual Status Bars -->
<item name="colorPrimaryDark">@color/primary</item> <item name="colorPrimaryDark">@color/primary</item>
<!-- Snackbar Action Link -->
<item name="colorAccent">@color/primary</item> <item name="colorAccent">@color/primary</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="android:buttonStyle">@style/cloudbutton</item>
<item name="android:windowBackground">@color/bg_normal</item> <item name="android:windowBackground">@color/bg_normal</item>
</style> </style>
@ -24,19 +19,11 @@
<item name="android:textColorSecondary">@color/fg_default_low</item> <item name="android:textColorSecondary">@color/fg_default_low</item>
</style> </style>
<!--
cert4android is using these styles and we want the same button style in the trust activity
-->
<style name="Widget.AppCompat.Button.Borderless" parent="cloudbutton">
<item name="android:layout_margin">2dp</item>
</style>
<style name="ncAlertDialog" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert"> <style name="ncAlertDialog" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@color/primary</item> <item name="colorAccent">@color/primary</item>
<item name="colorPrimary">@color/primary</item> <item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary</item> <item name="colorPrimaryDark">@color/primary</item>
<item name="android:textColorPrimary">@color/fg_default</item> <item name="android:textColorPrimary">@color/fg_default</item>
<item name="android:alertDialogTheme">@style/cloudbutton</item>
<item name="android:windowBackground">@color/bg_normal</item> <item name="android:windowBackground">@color/bg_normal</item>
</style> </style>
@ -49,13 +36,6 @@
<item name="android:layout_alignParentRight">true</item> <item name="android:layout_alignParentRight">true</item>
</style> </style>
<style name="cloudbutton" parent="android:style/Widget.Button">
<item name="android:background">@color/primary</item>
<item name="android:textColor">@drawable/button_selector</item>
<item name="android:padding">@dimen/button_padding</item>
<item name="android:elevation">@dimen/button_elevation</item>
</style>
<style name="SplashTheme" parent="AppTheme"> <style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splashscreen</item> <item name="android:windowBackground">@drawable/splashscreen</item>
</style> </style>