-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advanced troubleshooting in settings
- Loading branch information
1 parent
cf87f3f
commit ddb338e
Showing
9 changed files
with
190 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
app/src/main/java/mobi/maptrek/fragments/preferences/Advanced.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright 2024 Andrey Novikov | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
package mobi.maptrek.fragments.preferences; | ||
|
||
import android.os.Bundle; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout; | ||
import androidx.preference.Preference; | ||
|
||
import com.google.android.material.snackbar.BaseTransientBottomBar; | ||
import com.google.android.material.snackbar.Snackbar; | ||
|
||
import mobi.maptrek.Configuration; | ||
import mobi.maptrek.MainActivity; | ||
import mobi.maptrek.MapTrek; | ||
import mobi.maptrek.R; | ||
|
||
public class Advanced extends BasePreferences { | ||
@Override | ||
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { | ||
addPreferencesFromResource(R.xml.preferences_advanced); | ||
|
||
Preference purgeMaps = findPreference("purge_maps"); | ||
if (purgeMaps != null) | ||
purgeMaps.setOnPreferenceClickListener(preference -> { | ||
CoordinatorLayout coordinatorLayout = ((MainActivity) requireActivity()).getCoordinatorLayout(); | ||
Snackbar snackbar = Snackbar.make(coordinatorLayout, R.string.msgPurgeMaps, Snackbar.LENGTH_LONG) | ||
.setAnchorView(getView()) | ||
.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() { | ||
public void onDismissed(Snackbar snackbar, @DismissEvent int event) { | ||
super.onDismissed(snackbar, event); | ||
if (event == DISMISS_EVENT_ACTION) | ||
return; | ||
requireActivity().finish(); | ||
MapTrek.getApplication().removeMapDatabase(); | ||
MapTrek.getApplication().restart(); | ||
} | ||
}) | ||
.setAction(R.string.actionUndo, view -> { | ||
// do nothing, we just do not precede with destructive operation | ||
}); | ||
TextView snackbarTextView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text); | ||
snackbarTextView.setMaxLines(99); | ||
snackbar.show(); | ||
return true; | ||
}); | ||
|
||
Preference resetMap = findPreference("reset_map"); | ||
if (resetMap != null) | ||
resetMap.setOnPreferenceClickListener(preference -> { | ||
CoordinatorLayout coordinatorLayout = ((MainActivity) requireActivity()).getCoordinatorLayout(); | ||
Snackbar snackbar = Snackbar.make(coordinatorLayout, R.string.msgMapReset, Snackbar.LENGTH_LONG) | ||
.setAnchorView(getView()) | ||
.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() { | ||
public void onDismissed(Snackbar snackbar, @DismissEvent int event) { | ||
super.onDismissed(snackbar, event); | ||
if (event == DISMISS_EVENT_ACTION) | ||
return; | ||
Configuration.resetMapState(); | ||
MapTrek.getApplication().restart(); | ||
} | ||
}) | ||
.setAction(R.string.actionUndo, view -> { | ||
// do nothing, we just do not precede with destructive operation | ||
}); | ||
TextView snackbarTextView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text); | ||
snackbarTextView.setMaxLines(99); | ||
snackbar.show(); | ||
return true; | ||
}); | ||
|
||
Preference resetAdvices = findPreference("reset_advices"); | ||
if (resetAdvices != null) | ||
resetAdvices.setOnPreferenceClickListener(preference -> { | ||
Configuration.resetAdviceState(); | ||
CoordinatorLayout coordinatorLayout = ((MainActivity) requireActivity()).getCoordinatorLayout(); | ||
Snackbar.make(coordinatorLayout, R.string.msgAdvicesReset, Snackbar.LENGTH_LONG) | ||
.setAnchorView(getView()) | ||
.show(); | ||
return true; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.