Skip to content

Commit

Permalink
Merge branch 'master' into release-0.16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestguice committed Aug 20, 2024
2 parents 6bf57a9 + 63ff807 commit 3f1645f
Show file tree
Hide file tree
Showing 47 changed files with 2,808 additions and 1,042 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies
implementation group: 'net.time4j', name: 'time4j-android', version: '4.8-2021a'

implementation 'com.github.forrestguice:colorpicker:0.0.13post1'
implementation 'android.arch.lifecycle:extensions:1.1.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.jraska:falcon:1.0.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@

package com.forrestguice.suntimeswidget.colors;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.util.TypedValue;
Expand Down Expand Up @@ -82,9 +85,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
{
//android.support.v7.view.ContextThemeWrapper contextWrapper = new android.support.v7.view.ContextThemeWrapper(getActivity(), getThemeResID()); // hack: contextWrapper required because base theme is not properly applied
View content = inflater.cloneInContext(getActivity()).inflate(R.layout.fragment_colorvalues, container, false);
if (savedState != null) {
onRestoreInstanceState(savedState);
}

ImageButton overflow = (ImageButton) content.findViewById(R.id.overflow);
if (overflow != null) {
Expand All @@ -105,6 +105,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
editID = (EditText) content.findViewById(R.id.editTextID);
setID(null);

if (savedState != null) {
onRestoreInstanceState(savedState);
}
updateViews();
return content;
}
Expand Down Expand Up @@ -196,11 +199,11 @@ public void onStop() {
@Override
public void onSaveInstanceState(@NonNull Bundle out)
{
super.onSaveInstanceState(out);
out.putParcelable("colorValues", colorValues);
out.putParcelable("defaultValues", defaultValues);
out.putStringArray("filterValues", filterValues.toArray(new String[0]));
out.putString("editID", editID.getText().toString());
super.onSaveInstanceState(out);
}
protected void onRestoreInstanceState(@NonNull Bundle savedState)
{
Expand Down Expand Up @@ -298,7 +301,8 @@ public void onClick(View v) {
}

protected ColorValues colorValues = null;
public void setColorValues(ColorValues v) {
public void setColorValues(ColorValues v)
{
colorValues = v;
setID(null);
updateViews();
Expand Down Expand Up @@ -367,9 +371,19 @@ public void pickColor(String key)

protected Intent pickColorIntent(String key, int requestCode)
{
Context context = getActivity();
int[] attr = { R.attr.timeCardBackground, R.attr.text_primaryColor };
TypedArray typedArray = context.obtainStyledAttributes(attr);
int colorUnder = ContextCompat.getColor(context, typedArray.getResourceId(0, R.color.card_bg));
@SuppressLint("ResourceType")
int colorOver = ContextCompat.getColor(context, typedArray.getResourceId(1, R.color.text_primary));
typedArray.recycle();

Intent intent = new Intent(getActivity(), ColorActivity.class);
intent.putExtra(ColorDialog.KEY_SHOWALPHA, true);
intent.setData(Uri.parse("color://" + String.format("#%08X", colorValues.getColor(key))));
intent.putExtra(ColorDialog.KEY_COLOR_UNDER, colorUnder);
intent.putExtra(ColorDialog.KEY_COLOR_OVER, colorOver);
intent.putExtra(ColorDialog.KEY_RECENT, new ArrayList<>(new LinkedHashSet<>(colorValues.getColors())));

if (defaultValues != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

public class ColorValuesSheetDialog extends BottomSheetDialogFragment
{
public static final String DIALOG_SHEET = "ColorValuesSheet";

public ColorValuesSheetDialog() {
setArguments(new Bundle());
}
Expand Down Expand Up @@ -163,12 +165,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup p

//ContextThemeWrapper contextWrapper = new ContextThemeWrapper(getActivity(), AppSettings.loadTheme(getContext())); // hack: contextWrapper required because base theme is not properly applied
View dialogContent = inflater.cloneInContext(getActivity()).inflate(R.layout.layout_dialog_colorsheet, parent, false);
initViews(dialogContent);

if (savedState != null) {
onRestoreInstanceState(savedState);
}

initViews(dialogContent);
return dialogContent;
}

Expand Down Expand Up @@ -212,19 +213,24 @@ public void initViews(View dialogView)
{
titleText = (TextView) dialogView.findViewById(R.id.dialog_title);

colorSheet = new ColorValuesSheetFragment();
colorSheet.setAppWidgetID(getAppWidgetID());
colorSheet.setColorTag(getColorTag());
colorSheet.setFilter(getFilter());
colorSheet.setApplyFilter(applyFilter());
colorSheet.setColorCollection(getColorCollection());
colorSheet.setMode(ColorValuesSheetFragment.MODE_SELECT);
colorSheet.setFragmentListener(fragmentListener);

FragmentManager fragments = getChildFragmentManager();
FragmentTransaction transaction = fragments.beginTransaction();
transaction.replace(R.id.fragmentContainer2, colorSheet, "ColorValuesSheet");
transaction.commit();
colorSheet = (ColorValuesSheetFragment) fragments.findFragmentByTag(DIALOG_SHEET);
if (colorSheet == null)
{
colorSheet = new ColorValuesSheetFragment();
colorSheet.setAppWidgetID(getAppWidgetID());
colorSheet.setColorTag(getColorTag());
colorSheet.setFilter(getFilter());
colorSheet.setApplyFilter(applyFilter());
colorSheet.setColorCollection(getColorCollection());
colorSheet.setMode(ColorValuesSheetFragment.MODE_SELECT);
colorSheet.setFragmentListener(fragmentListener);

FragmentTransaction transaction = fragments.beginTransaction();
transaction.replace(R.id.fragmentContainer2, colorSheet, DIALOG_SHEET);
transaction.commit();
fragments.executePendingTransactions();
}

check_filter = (CheckBox) dialogView.findViewById(R.id.check_filter);
if (check_filter != null)
Expand Down Expand Up @@ -269,6 +275,9 @@ public void onActivityCreated(Bundle savedInstanceState)
ViewUtils.disableTouchOutsideBehavior(getDialog());
}

/**
* FragmentListener
*/
private final ColorValuesSheetFragment.FragmentListener fragmentListener = new ColorValuesSheetFragment.FragmentListener()
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -39,6 +40,9 @@

public class ColorValuesSheetFragment extends ColorValuesFragment
{
public static final String DIALOG_LIST = "listDialog";
public static final String DIALOG_EDIT = "editDialog";

public static final int MODE_SELECT = 0;
public static final int MODE_EDIT = 1;

Expand All @@ -65,31 +69,51 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
{
//android.support.v7.view.ContextThemeWrapper contextWrapper = new android.support.v7.view.ContextThemeWrapper(getActivity(), getThemeResID()); // hack: contextWrapper required because base theme is not properly applied
View content = inflater.cloneInContext(getActivity()).inflate(R.layout.fragment_colorsheet, container, false);
if (savedState != null) {
onRestoreInstanceState(savedState);
}
initViews();
return content;
}

listDialog = new ColorValuesSelectFragment(); //(ColorValuesSelectFragment) fragments.findFragmentById(R.id.colorsCollectionFragment);
listDialog.setAppWidgetID(getAppWidgetID());
listDialog.setColorTag(getColorTag());
listDialog.setTheme(getThemeResID());
protected void initViews()
{
FragmentManager fragments = getChildFragmentManager();
listDialog = (ColorValuesSelectFragment) fragments.findFragmentByTag(DIALOG_LIST);
editDialog = (ColorValuesEditFragment) fragments.findFragmentByTag(DIALOG_EDIT);

editDialog = new ColorValuesEditFragment(); // (ClockColorValuesEditFragment) fragments.findFragmentById(R.id.colorsFragment);
editDialog.setTheme(getThemeResID());
editDialog.setFilter(getFilter());
editDialog.setApplyFilter(applyFilter());
if (listDialog == null)
{
listDialog = new ColorValuesSelectFragment(); //(ColorValuesSelectFragment) fragments.findFragmentById(R.id.colorsCollectionFragment);
listDialog.setAppWidgetID(getAppWidgetID());
listDialog.setColorTag(getColorTag());
listDialog.setTheme(getThemeResID());

getChildFragmentManager().beginTransaction().add(R.id.layout_color_sheet, listDialog).add(R.id.layout_color_sheet, editDialog).commit();
FragmentTransaction transaction = fragments.beginTransaction();
transaction.add(R.id.layout_color_sheet, listDialog, DIALOG_LIST);
transaction.addToBackStack(DIALOG_LIST);
transaction.commit();
}
if (editDialog == null)
{
editDialog = new ColorValuesEditFragment(); // (ClockColorValuesEditFragment) fragments.findFragmentById(R.id.colorsFragment);
editDialog.setTheme(getThemeResID());
editDialog.setFilter(getFilter());
editDialog.setApplyFilter(applyFilter());

if (savedState != null) {
onRestoreInstanceState(savedState);
FragmentTransaction transaction = fragments.beginTransaction();
transaction.add(R.id.layout_color_sheet, editDialog, DIALOG_EDIT);
transaction.addToBackStack(DIALOG_EDIT);
transaction.commit();
}
return content;
fragments.executePendingTransactions();
}

@Override
public void onResume()
{
super.onResume();

FragmentManager fragments = getChildFragmentManager();
//listDialog = (ColorValuesSelectFragment) fragments.findFragmentById(R.id.colorsCollectionFragment);
if (listDialog != null) {
listDialog.setColorCollection(colorCollection);
Expand Down Expand Up @@ -130,11 +154,13 @@ public void requestFocus()

protected void onRestoreInstanceState(@NonNull Bundle savedState) {
mode = savedState.getInt("mode");
colorCollection = savedState.getParcelable("colorCollection");
}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putInt("mode", mode);
outState.putParcelable("colorCollection", colorCollection);
super.onSaveInstanceState(outState);
}

Expand Down Expand Up @@ -444,8 +470,8 @@ public void clearFilter() {
}
}

protected ColorValuesCollection colorCollection = null;
public void setColorCollection(ColorValuesCollection collection) {
protected ColorValuesCollection<ColorValues> colorCollection = null;
public void setColorCollection(ColorValuesCollection<ColorValues> collection) {
colorCollection = collection;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@
import com.forrestguice.suntimeswidget.alarmclock.ui.AlarmOffsetDialog;
import com.forrestguice.suntimeswidget.settings.EditBottomSheetDialog;
import com.forrestguice.suntimeswidget.settings.WidgetSettings;
import com.forrestguice.suntimeswidget.settings.colors.ColorChangeListener;
import com.forrestguice.suntimeswidget.settings.colors.ColorChooser;
import com.forrestguice.suntimeswidget.settings.colors.ColorChooserView;
import com.forrestguice.suntimeswidget.settings.colors.ColorDialog;
import com.forrestguice.suntimeswidget.views.Toast;

import java.util.Locale;

import static com.forrestguice.suntimeswidget.alarmclock.AlarmEventContract.AUTHORITY;

public class EditEventDialog extends EditBottomSheetDialog
Expand Down Expand Up @@ -804,10 +802,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
};

private final ColorDialog.ColorChangeListener onColorChanged = new ColorDialog.ColorChangeListener() {
private final ColorChangeListener onColorChanged = new ColorChangeListener() {
@Override
public void onColorChanged(int color) {
super.onColorChanged(color);
setIsModified(true);
}
};
Expand Down
Loading

0 comments on commit 3f1645f

Please sign in to comment.