mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Removed custom styling of title divider of used dialogs (just too much code).
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package de.dennisguse.opentracks.fragments;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import de.dennisguse.opentracks.util.DialogUtils;
|
||||
|
||||
/**
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public abstract class AbstractDialogFragment extends DialogFragment {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Dialog dialog = createDialog();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
DialogUtils.setDialogTitleDivider(getActivity(), dialog);
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
||||
protected abstract Dialog createDialog();
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.util.DialogUtils;
|
||||
import de.dennisguse.opentracks.util.TrackIconUtils;
|
||||
|
||||
/**
|
||||
@@ -78,7 +77,6 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||
imageAdapter.setSelected(position);
|
||||
imageAdapter.notifyDataSetChanged();
|
||||
}
|
||||
DialogUtils.setDialogTitleDivider(context, alertDialog);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.util.DialogUtils;
|
||||
|
||||
@@ -29,7 +32,7 @@ import de.dennisguse.opentracks.util.DialogUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class ConfirmDeleteDialogFragment extends AbstractDialogFragment {
|
||||
public class ConfirmDeleteDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String CONFIRM_DELETE_DIALOG_TAG = "confirmDeleteDialog";
|
||||
private static final String KEY_TRACK_IDS = "trackIds";
|
||||
@@ -50,7 +53,7 @@ public class ConfirmDeleteDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
caller = (ConfirmDeleteCaller) context;
|
||||
@@ -59,8 +62,10 @@ public class ConfirmDeleteDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog() {
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
|
||||
int titleId;
|
||||
int messageId;
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -33,7 +35,7 @@ import de.dennisguse.opentracks.util.DialogUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class DeleteMarkerDialogFragment extends AbstractDialogFragment {
|
||||
public class DeleteMarkerDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String DELETE_MARKER_DIALOG_TAG = "deleteMarkerDialog";
|
||||
private static final String KEY_MARKER_IDS = "markerIds";
|
||||
@@ -49,7 +51,7 @@ public class DeleteMarkerDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
caller = (DeleteMarkerCaller) context;
|
||||
@@ -59,7 +61,8 @@ public class DeleteMarkerDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog() {
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final FragmentActivity fragmentActivity = getActivity();
|
||||
final long[] markerIds = getArguments().getLongArray(KEY_MARKER_IDS);
|
||||
int titleId;
|
||||
|
||||
@@ -23,6 +23,9 @@ import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -34,7 +37,7 @@ import de.dennisguse.opentracks.util.FileUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class FileTypeDialogFragment extends AbstractDialogFragment {
|
||||
public class FileTypeDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String FILE_TYPE_DIALOG_TAG = "fileType";
|
||||
private static final String KEY_TITLE_ID = "titleId";
|
||||
@@ -52,7 +55,7 @@ public class FileTypeDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
caller = (FileTypeCaller) context;
|
||||
@@ -62,7 +65,8 @@ public class FileTypeDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog() {
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
int optionId = getArguments().getInt(KEY_OPTION_ID);
|
||||
final int titleId = getArguments().getInt(KEY_TITLE_ID);
|
||||
final TrackFileFormat[] trackFileFormats = {TrackFileFormat.KML_WITH_TRACKDETAIL, TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA, TrackFileFormat.GPX};
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -32,7 +34,7 @@ import de.dennisguse.opentracks.util.StringUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class FrequencyDialogFragment extends AbstractDialogFragment {
|
||||
public class FrequencyDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String FREQUENCY_DIALOG_TAG = "frequencyDialog";
|
||||
|
||||
@@ -40,8 +42,7 @@ public class FrequencyDialogFragment extends AbstractDialogFragment {
|
||||
private static final String KEY_DEFAULT_VALUE = "defaultValue";
|
||||
private static final String KEY_TITLE_ID = "titleId";
|
||||
|
||||
public static FrequencyDialogFragment newInstance(
|
||||
int preferenceId, int defaultValue, int titleId) {
|
||||
public static FrequencyDialogFragment newInstance(int preferenceId, int defaultValue, int titleId) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(KEY_PREFERENCE_ID, preferenceId);
|
||||
bundle.putInt(KEY_DEFAULT_VALUE, defaultValue);
|
||||
@@ -53,7 +54,8 @@ public class FrequencyDialogFragment extends AbstractDialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog() {
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
FragmentActivity fragmentActivity = getActivity();
|
||||
|
||||
final int preferenceId = getArguments().getInt(KEY_PREFERENCE_ID);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.marker_detail, menu);
|
||||
|
||||
updateWaypoint(false);
|
||||
|
||||
@@ -169,15 +169,7 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
onDismissed();
|
||||
}
|
||||
}).setTitle(titleId);
|
||||
final Dialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
DialogUtils.setDialogTitleDivider(ExportActivity.this, dialog);
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
return builder.create();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class ImportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
message = getString(
|
||||
R.string.import_error, importedTrackCount, totalFiles, directoryDisplayName);
|
||||
}
|
||||
final Dialog dialog = new AlertDialog.Builder(this).setCancelable(true).setIcon(iconId)
|
||||
return new AlertDialog.Builder(this).setCancelable(true).setIcon(iconId)
|
||||
.setMessage(message).setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialogInterface) {
|
||||
@@ -173,14 +173,6 @@ public class ImportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
onDismissed();
|
||||
}
|
||||
}).setTitle(titleId).create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
DialogUtils.setDialogTitleDivider(ImportActivity.this, dialog);
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package de.dennisguse.opentracks.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.DialogPreference;
|
||||
import android.util.AttributeSet;
|
||||
@@ -30,7 +29,6 @@ import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.util.DialogUtils;
|
||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
import de.dennisguse.opentracks.util.TrackIconUtils;
|
||||
|
||||
@@ -106,12 +104,6 @@ public class ActivityTypePreference extends DialogPreference {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog(Bundle state) {
|
||||
super.showDialog(state);
|
||||
DialogUtils.setDialogTitleDivider(getContext(), getDialog());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
if (positiveResult) {
|
||||
|
||||
@@ -21,10 +21,6 @@ import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
|
||||
@@ -47,21 +43,13 @@ public class DialogUtils {
|
||||
* @param okListener the listener when OK is clicked
|
||||
*/
|
||||
public static Dialog createConfirmationDialog(final Context context, int titleId, String message, DialogInterface.OnClickListener okListener) {
|
||||
final AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||
return new AlertDialog.Builder(context)
|
||||
.setCancelable(true)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(R.string.generic_no, null)
|
||||
.setPositiveButton(R.string.generic_yes, okListener)
|
||||
.setTitle(titleId).create();
|
||||
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
setDialogTitleDivider(context, alertDialog);
|
||||
}
|
||||
});
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,51 +94,6 @@ public class DialogUtils {
|
||||
progressDialog.setOnCancelListener(onCancelListener);
|
||||
progressDialog.setProgressStyle(spinner ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL);
|
||||
progressDialog.setTitle(R.string.generic_progress_title);
|
||||
progressDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
setDialogTitleDivider(context, progressDialog);
|
||||
}
|
||||
});
|
||||
return progressDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dialog title divider.
|
||||
*
|
||||
* @param context the context
|
||||
* @param dialog the dialog
|
||||
*/
|
||||
public static void setDialogTitleDivider(Context context, Dialog dialog) {
|
||||
try {
|
||||
ViewGroup decorView = (ViewGroup) dialog.getWindow().getDecorView();
|
||||
if (decorView == null) {
|
||||
return;
|
||||
}
|
||||
FrameLayout windowContentView = (FrameLayout) decorView.getChildAt(0);
|
||||
if (windowContentView == null) {
|
||||
return;
|
||||
}
|
||||
FrameLayout contentView = (FrameLayout) windowContentView.getChildAt(0);
|
||||
if (contentView == null) {
|
||||
return;
|
||||
}
|
||||
LinearLayout parentPanel = (LinearLayout) contentView.getChildAt(0);
|
||||
if (parentPanel == null) {
|
||||
return;
|
||||
}
|
||||
LinearLayout topPanel = (LinearLayout) parentPanel.getChildAt(0);
|
||||
if (topPanel == null) {
|
||||
return;
|
||||
}
|
||||
View titleDivider = topPanel.getChildAt(2);
|
||||
if (titleDivider == null) {
|
||||
return;
|
||||
}
|
||||
titleDivider.setBackgroundColor(context.getResources().getColor(R.color.holo_orange_dark));
|
||||
} catch (Exception e) {
|
||||
// Can safely ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user