Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f4dd73de77
7 changed files with 70 additions and 215 deletions
|
@ -44,6 +44,7 @@
|
|||
\n\tHarry van der Wolf - contributor (contribute to country boundaries + configuration file + address files and else), active forum participant.
|
||||
</string>
|
||||
<string name="app_edition"></string>
|
||||
<string name="support_email">support@osmand.net</string>
|
||||
<string name="preferred_locale_no_translate">Display language</string>
|
||||
<string name="system_locale_no_translate">Device language</string>
|
||||
<string name="osmo">OsMo</string>
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.preference.PreferenceScreen;
|
|||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
|
@ -622,4 +621,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
|||
}
|
||||
return setFiles;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -24,48 +45,8 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
public class DashChooseAppDirFragment {
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class DashChooseAppDirFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_CHOOSE_APP_DIR_FRAGMENT";
|
||||
private ChooseAppDirFragment fragment;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
fragment = new ChooseAppDirFragment(activity, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return fragment.initView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
public static class ChooseAppDirFragment {
|
||||
public static final int VERSION_DEFAULTLOCATION_CHANGED = 19;
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
|
||||
/**
|
||||
* Created by Denis on
|
||||
* 26.03.2015.
|
||||
*/
|
||||
public class DashFirstTimeFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_FIRST_TIME_FRAGMENT";
|
||||
private static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION =
|
||||
new FirstTimeShouldShow();
|
||||
static final DashFragmentData FRAGMENT_DATA =
|
||||
new DashFragmentData(TAG, DashFirstTimeFragment.class, SHOULD_SHOW_FUNCTION, 110, null);
|
||||
|
||||
public static boolean interestedInFirstTime = true;
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_first_time, container, false);
|
||||
|
||||
view.findViewById(R.id.select_region).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final OsmandSettings.DrivingRegion[] drs = OsmandSettings.DrivingRegion.values();
|
||||
|
||||
final OsmandSettings.DrivingRegion currentRegion = getMyApplication().getSettings().DRIVING_REGION.get();
|
||||
|
||||
String[] entries = new String[drs.length];
|
||||
int currentIndex = 0;
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (currentRegion.equals(drs[i])){
|
||||
currentIndex = i;
|
||||
}
|
||||
entries[i] = getString(drs[i].name); // + " (" + drs[i].defMetrics.toHumanString(this) +")" ;
|
||||
}
|
||||
builder.setSingleChoiceItems(entries, currentIndex, null);
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int selectedPosition = ((AlertDialog)dialog).getListView().getCheckedItemPosition();
|
||||
getMyApplication().getSettings().DRIVING_REGION.set(drs[selectedPosition]);
|
||||
updateCurrentRegion(getView());
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
});
|
||||
|
||||
view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
interestedInFirstTime = false;
|
||||
dashboard.refreshDashboardFragments();
|
||||
}
|
||||
});
|
||||
|
||||
view.findViewById(R.id.download_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), DownloadActivity.class);
|
||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
updateCurrentRegion(view);
|
||||
((ImageView)view.findViewById(R.id.car_icon)).setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_car_dark));
|
||||
return view;
|
||||
}
|
||||
|
||||
private void updateCurrentRegion(View view) {
|
||||
((TextView) view.findViewById(R.id.region)).setText(getMyApplication().getSettings().DRIVING_REGION.get().name);
|
||||
}
|
||||
|
||||
private static class FirstTimeShouldShow extends DashFragmentData.ShouldShowFunction {
|
||||
@Override
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
return activity.getMyApplication().getAppInitializer().isFirstTime(activity)
|
||||
&& DashFirstTimeFragment.interestedInFirstTime;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,9 +21,6 @@ import java.util.Calendar;
|
|||
public class DashRateUsFragment extends DashBaseFragment {
|
||||
public static final String TAG = "DASH_RATE_US_FRAGMENT";
|
||||
|
||||
// TODO move to resources
|
||||
public static final String EMAIL = "support@osmand.net";
|
||||
|
||||
// Imported in shouldShow method
|
||||
private static OsmandSettings settings;
|
||||
private FragmentState state = FragmentState.INITIAL_STATE;
|
||||
|
@ -143,15 +140,16 @@ public class DashRateUsFragment extends DashBaseFragment {
|
|||
}
|
||||
dashboard.refreshDashboardFragments();
|
||||
return;
|
||||
case USER_HATES_APP:
|
||||
case USER_DISLIKES_APP:
|
||||
String email = getString(R.string.support_email);
|
||||
settings.RATE_US_STATE.set(RateUsState.DISLIKED_WITH_MESSAGE);
|
||||
settings.NUMBER_OF_APPLICATION_STARTS.set(0);
|
||||
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
|
||||
dashboard.refreshDashboardFragments();
|
||||
Intent sendEmail = new Intent(Intent.ACTION_SENDTO);
|
||||
sendEmail.setType("text/plain");
|
||||
sendEmail.setData(Uri.parse("mailto:" + EMAIL));
|
||||
sendEmail.putExtra(Intent.EXTRA_EMAIL, EMAIL);
|
||||
sendEmail.setData(Uri.parse("mailto:" + email));
|
||||
sendEmail.putExtra(Intent.EXTRA_EMAIL, email);
|
||||
startActivity(sendEmail);
|
||||
break;
|
||||
}
|
||||
|
@ -177,7 +175,7 @@ public class DashRateUsFragment extends DashBaseFragment {
|
|||
public void onClick(View v) {
|
||||
switch (state) {
|
||||
case INITIAL_STATE:
|
||||
state = FragmentState.USER_HATES_APP;
|
||||
state = FragmentState.USER_DISLIKES_APP;
|
||||
|
||||
header.setText(getResources().getString(R.string.user_hates_app_get_feedback));
|
||||
subheader.setText(getResources().getString(R.string.user_hates_app_get_feedback_long));
|
||||
|
@ -187,7 +185,7 @@ public class DashRateUsFragment extends DashBaseFragment {
|
|||
case USER_LIKES_APP:
|
||||
settings.RATE_US_STATE.set(RateUsState.IGNORED);
|
||||
break;
|
||||
case USER_HATES_APP:
|
||||
case USER_DISLIKES_APP:
|
||||
settings.RATE_US_STATE.set(RateUsState.DISLIKED_WITHOUT_MESSAGE);
|
||||
break;
|
||||
}
|
||||
|
@ -200,7 +198,7 @@ public class DashRateUsFragment extends DashBaseFragment {
|
|||
private enum FragmentState {
|
||||
INITIAL_STATE,
|
||||
USER_LIKES_APP,
|
||||
USER_HATES_APP
|
||||
USER_DISLIKES_APP
|
||||
}
|
||||
|
||||
public enum RateUsState {
|
||||
|
@ -211,7 +209,7 @@ public class DashRateUsFragment extends DashBaseFragment {
|
|||
DISLIKED_WITHOUT_MESSAGE
|
||||
}
|
||||
|
||||
public static class RateUsShouldShow extends DashboardOnMap.SettingsShouldShow {
|
||||
public static class RateUsShouldShow extends DashboardOnMap.DefaultShouldShow {
|
||||
@Override
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
return DashRateUsFragment.shouldShow(settings)
|
||||
|
|
|
@ -1,5 +1,34 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
||||
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -31,36 +60,6 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
|
|||
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollState;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
||||
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||
|
@ -73,14 +72,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
|
||||
private static final DashFragmentData.ShouldShowFunction rateUsShouldShow = new DashRateUsFragment.RateUsShouldShow();
|
||||
private static final DashFragmentData.ShouldShowFunction errorShouldShow = new ErrorShouldShow();
|
||||
private static final DashFragmentData.ShouldShowFunction chooseAppDirShouldShow = new ChooseAppDirShouldShow();
|
||||
|
||||
private final DashFragmentData[] fragmentsData = new DashFragmentData[]{
|
||||
new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class,
|
||||
rateUsShouldShow, 0, null),
|
||||
DashFirstTimeFragment.FRAGMENT_DATA,
|
||||
new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class,
|
||||
chooseAppDirShouldShow, 20, null),
|
||||
new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class,
|
||||
errorShouldShow, 30, null),
|
||||
new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class,
|
||||
|
@ -930,19 +925,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
return list;
|
||||
}
|
||||
|
||||
public static class SettingsShouldShow extends DashFragmentData.ShouldShowFunction {
|
||||
@Override
|
||||
public static class DefaultShouldShow extends DashFragmentData.ShouldShowFunction {
|
||||
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
return settings.registerBooleanPreference(SHOULD_SHOW + tag, true)
|
||||
.makeGlobal().get();
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultShouldShow extends SettingsShouldShow {
|
||||
@Override
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
return !activity.getMyApplication().getAppInitializer().isFirstTime(activity)
|
||||
&& super.shouldShow(settings, activity, tag);
|
||||
return settings.registerBooleanPreference(SHOULD_SHOW + tag, true).makeGlobal().get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -955,13 +941,5 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
}
|
||||
}
|
||||
|
||||
private static class ChooseAppDirShouldShow extends SettingsShouldShow {
|
||||
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return false;
|
||||
}
|
||||
return !settings.isExternalStorageDirectorySpecifiedV19()
|
||||
&& super.shouldShow(settings, activity, tag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ public final class DashFragmentData implements Comparable<DashFragmentData> {
|
|||
public final String rowNumberTag;
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
ShouldShowFunction shouldShowFunction,
|
||||
int position, String rowNumberTag) {
|
||||
ShouldShowFunction shouldShowFunction, int position, String rowNumberTag) {
|
||||
this.tag = tag;
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.shouldShowFunction = shouldShowFunction;
|
||||
|
@ -31,11 +30,14 @@ public final class DashFragmentData implements Comparable<DashFragmentData> {
|
|||
public boolean hasRows() {
|
||||
return rowNumberTag != null;
|
||||
}
|
||||
|
||||
public boolean canBeDisabled() {
|
||||
return shouldShowFunction.getTitleId() != -1;
|
||||
}
|
||||
|
||||
public static abstract class ShouldShowFunction {
|
||||
public abstract boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag);
|
||||
|
||||
public int getTitleId() {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue