Skip to content

Commit

Permalink
add checkForUpdate setting, store open state of the manual settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerInk committed Mar 7, 2021
1 parent 4715b92 commit 99024e4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import freed.renderscript.RenderScriptManager;
import freed.settings.SettingKeys;
import freed.settings.SettingsManager;
import freed.update.ReleaseChecker;
import freed.utils.Log;

public class CameraFeatureDetector {
Expand Down Expand Up @@ -60,6 +61,10 @@ private void setGlobalDefaultSettings()

SettingsManager.getGlobal(SettingKeys.GuideList).setValues(FreedApplication.getContext().getResources().getStringArray(R.array.guidelist));
SettingsManager.getGlobal(SettingKeys.GuideList).set(SettingsManager.getGlobal(SettingKeys.GuideList).getValues()[0]);
if (ReleaseChecker.isGithubRelease)
SettingsManager.getGlobal(SettingKeys.CHECKFORUPDATES).set(true);

SettingsManager.getGlobal(SettingKeys.SHOWMANUALSETTINGS).set(true);

SettingsManager.getGlobal(SettingKeys.LOCATION_MODE).setIsSupported(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public class CameraUiFragment extends AbstractFragment implements SettingsChildA
private SampleInfoOverlayHandler infoOverlayHandler;
//holds guide
private GuideHandler guideHandler;
private final String KEY_MANUALMENUOPEN = "key_manualmenuopen";
private SharedPreferences sharedPref;

private UiSettingsChild aelock;

Expand Down Expand Up @@ -265,7 +263,7 @@ public void setCameraToUi(CameraWrapperInterface wrapper) {


//restore view state for the manuals
if (manualsettingsIsOpen)
if (SettingsManager.getGlobal(SettingKeys.SHOWMANUALSETTINGS).get())
showManualSettings();
//remove the values fragment from ui when a new api gets loaded and it was open.
if (horizontalValuesFragment != null && horizontalValuesFragment.isAdded())
Expand All @@ -288,8 +286,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
Log.d(TAG, "####################ONCREATEDVIEW####################");
fragment_activityInterface = (ActivityInterface)getActivity();
touchHandler = new SwipeMenuListner(this);
sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
manualsettingsIsOpen = sharedPref.getBoolean(KEY_MANUALMENUOPEN, false);
manualsettingsIsOpen = SettingsManager.getGlobal(SettingKeys.SHOWMANUALSETTINGS).get();
return inflater.inflate(layout.cameraui_fragment, container, false);
}

Expand Down Expand Up @@ -361,7 +358,11 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
transaction.commit();
}
setCameraToUi(cameraUiWrapper);
if (ReleaseChecker.isGithubRelease)
checkForUpdate();
}

private void checkForUpdate() {
if (ReleaseChecker.isGithubRelease && SettingsManager.getGlobal(SettingKeys.CHECKFORUPDATES).get()) {
new ReleaseChecker(new ReleaseChecker.UpdateEvent() {
@Override
public void onUpdateAvailable() {
Expand All @@ -371,7 +372,7 @@ public void run() {
versionView.addView(new VersionView(getContext(), new VersionView.ButtonEvents() {
@Override
public void onDownloadClick() {
getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/KillerInk/FreeDcam/releases/latest")));
startActivity(Intent.createChooser(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/KillerInk/FreeDcam/releases/latest")), "Choose browser"));
versionView.removeAllViews();
}

Expand All @@ -384,6 +385,7 @@ public void onCloseClick() {
});
}
}).isUpdateAvailable();
}
}

@Override
Expand All @@ -402,10 +404,7 @@ public void onResume() {
public void onPause()
{
infoOverlayHandler.StopUpdating();
sharedPref.edit().putBoolean(KEY_MANUALMENUOPEN, manualsettingsIsOpen).commit();
boolean settingsOpen = false;
String KEY_SETTINGSOPEN = "key_settingsopen";
sharedPref.edit().putBoolean(KEY_SETTINGSOPEN, settingsOpen).commit();
SettingsManager.getGlobal(SettingKeys.SHOWMANUALSETTINGS).set(manualsettingsIsOpen);
super.onPause();

}
Expand All @@ -415,7 +414,6 @@ private void hide_ManualSettings()
manualsettingsIsOpen = false;
Log.d(TAG, "HideSettings");
manualModes_holder.animate().translationY(manualModes_holder.getHeight()).setDuration(300);
//manualModes_holder.setVisibility(View.GONE);
}

private void showManualSettings()
Expand All @@ -430,7 +428,6 @@ private void showManualSettings()
@Override
public void onSettingsChildClick(UiSettingsChild item, boolean fromLeftFragment)
{

if (currentOpendChild == item)
{
removeHorizontalFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import freed.settings.SettingKeys;
import freed.settings.SettingsManager;
import freed.settings.mode.BooleanSettingModeInterface;
import freed.update.ReleaseChecker;
import freed.utils.Log;

public class SettingsMenuItemFactory
Expand Down Expand Up @@ -262,6 +263,11 @@ public void fillLeftSettingsMenu(CameraWrapperInterface cameraUiWrapper, Context
}
}

if (ReleaseChecker.isGithubRelease) {
SettingsChild_BooleanSetting booleanSetting = new SettingsChild_BooleanSetting(context, SettingsManager.getGlobal(SettingKeys.CHECKFORUPDATES), R.string.setting_checkforupdate_header, R.string.setting_checkforupdate_description);
globalSettingGroup.addView(booleanSetting);
}

settingsChildHolder.addView(globalSettingGroup);
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/freed/settings/SettingKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public class SettingKeys{


public final static Key<GlobalBooleanSettingMode> useCustomMatrixOnCamera2 = new Key(GlobalBooleanSettingMode.class, R.string.aps_usecustom_matrix_oncamera2);
public final static Key<GlobalBooleanSettingMode> CHECKFORUPDATES = new Key(GlobalBooleanSettingMode.class, R.string.aps_checkforupdates);
public final static Key<GlobalBooleanSettingMode> SHOWMANUALSETTINGS = new Key(GlobalBooleanSettingMode.class, R.string.aps_showmanualsettings);

public final static Key<ApiBooleanSettingMode> ENABLE_VIDEO_OPMODE = new Key(ApiBooleanSettingMode.class, R.string.aps_enable_video_opmode);
public final static Key<SettingMode> Focuspeak = new Key(SettingMode.class, R.string.aps_focuspeak);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/appsettings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<string name="aps_xiaomi_pro_video_log" translatable="false">xiaomiProVideoLog</string>
<string name="aps_qcom_video_hdr" translatable="false">qcomVideoHDR</string>
<string name="aps_usecustom_matrix_oncamera2" translatable="false">useCustomMatrixOnCamera2</string>
<string name="aps_checkforupdates" translatable="false">checkforupdates</string>
<string name="aps_showmanualsettings" translatable="false">showmanualsettings</string>
<string name="aps_api" translatable="false">activeapi</string>
<string name="aps_app_version" translatable="false">app_version</string>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,8 @@
<string name="setting_yuvsize_description">Size of the Yuv</string>
<string name="update_available">A new Version is available to download</string>

<string name="setting_checkforupdate_description">When enabled it checks if a new version is available on Github</string>
<string name="setting_checkforupdate_header">Check for new updates</string>


</resources>

0 comments on commit 99024e4

Please sign in to comment.