1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Drop support for API 7-8 devices.

It's been a good time!
This commit is contained in:
Christophe Beyls 2017-05-21 19:55:32 +02:00
parent bd67dae36d
commit 66bb625955
8 changed files with 30 additions and 99 deletions

View file

@ -6,9 +6,9 @@ android {
defaultConfig {
applicationId "be.digitalia.fosdem"
minSdkVersion 7
minSdkVersion 9
targetSdkVersion 25
versionCode 700146
versionCode 900146
versionName "1.4.6"
// Supported languages
resConfigs "en"

View file

@ -25,7 +25,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.content.SharedPreferencesCompat;
import android.support.v4.os.AsyncTaskCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.MenuItemCompat;
@ -369,9 +368,9 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);
time = prefs.getLong(PREF_LAST_DOWNLOAD_REMINDER_TIME, -1L);
if ((time == -1L) || (time < (now - DOWNLOAD_REMINDER_SNOOZE_DURATION))) {
SharedPreferencesCompat.EditorCompat.getInstance().apply(
prefs.edit().putLong(PREF_LAST_DOWNLOAD_REMINDER_TIME, now)
);
prefs.edit()
.putLong(PREF_LAST_DOWNLOAD_REMINDER_TIME, now)
.apply();
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentByTag("download_reminder") == null) {
@ -405,17 +404,11 @@ public class MainActivity extends AppCompatActivity {
getMenuInflater().inflate(R.menu.main, menu);
MenuItem searchMenuItem = menu.findItem(R.id.search);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
this.searchMenuItem = searchMenuItem;
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
} else {
// Legacy search mode for Eclair
MenuItemCompat.setActionView(searchMenuItem, null);
MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
}
this.searchMenuItem = searchMenuItem;
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Animated refresh icon
@ -433,14 +426,6 @@ public class MainActivity extends AppCompatActivity {
}
switch (item.getItemId()) {
case R.id.search:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
return false;
} else {
// Legacy search mode for Eclair
onSearchRequested();
return true;
}
case R.id.refresh:
Drawable icon = item.getIcon();
if (icon instanceof Animatable) {

View file

@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
@ -71,11 +70,6 @@ public class SearchResultActivity extends AppCompatActivity {
setSearchViewQuery(query);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
// Legacy search mode for Eclair
getSupportActionBar().setSubtitle(query);
}
SearchResultListFragment f = SearchResultListFragment.newInstance(query);
getSupportFragmentManager().beginTransaction().replace(R.id.content, f).commit();
@ -96,18 +90,13 @@ public class SearchResultActivity extends AppCompatActivity {
getMenuInflater().inflate(R.menu.search, menu);
MenuItem searchMenuItem = menu.findItem(R.id.search);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Always show the search view
setSearchViewQuery(currentQuery);
} else {
// Legacy search mode for Eclair
MenuItemCompat.setActionView(searchMenuItem, null);
getSupportActionBar().setSubtitle(currentQuery);
}
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Always show the search view
setSearchViewQuery(currentQuery);
return true;
}
@ -125,14 +114,6 @@ public class SearchResultActivity extends AppCompatActivity {
case android.R.id.home:
finish();
return true;
case R.id.search:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
return false;
} else {
// Legacy search mode for Eclair
onSearchRequested();
return true;
}
}
return false;
}

View file

@ -12,7 +12,6 @@ import android.database.sqlite.SQLiteStatement;
import android.net.Uri;
import android.provider.BaseColumns;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.content.SharedPreferencesCompat;
import android.text.TextUtils;
import java.util.ArrayList;
@ -270,11 +269,10 @@ public class DatabaseManager {
cachedDays = null;
year = -1;
// Set last update time and server's last modified tag
SharedPreferencesCompat.EditorCompat.getInstance().apply(
getSharedPreferences().edit()
.putLong(LAST_UPDATE_TIME_PREF, System.currentTimeMillis())
.putString(LAST_MODIFIED_TAG_PREF, lastModifiedTag)
);
getSharedPreferences().edit()
.putLong(LAST_UPDATE_TIME_PREF, System.currentTimeMillis())
.putString(LAST_MODIFIED_TAG_PREF, lastModifiedTag)
.apply();
context.getContentResolver().notifyChange(URI_TRACKS, null);
context.getContentResolver().notifyChange(URI_EVENTS, null);
@ -293,9 +291,9 @@ public class DatabaseManager {
cachedDays = null;
year = -1;
SharedPreferencesCompat.EditorCompat.getInstance().apply(
getSharedPreferences().edit().remove(LAST_UPDATE_TIME_PREF)
);
getSharedPreferences().edit()
.remove(LAST_UPDATE_TIME_PREF)
.apply();
} finally {
db.endTransaction();

View file

@ -3,12 +3,10 @@ package be.digitalia.fosdem.fragments;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v4.content.SharedPreferencesCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
@ -89,9 +87,6 @@ public class BookmarksListFragment extends RecyclerViewFragment implements Loade
filterMenuItem = menu.findItem(R.id.filter);
upcomingOnlyMenuItem = menu.findItem(R.id.upcoming_only);
updateFilterMenuItem();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
menu.findItem(R.id.export_bookmarks).setEnabled(false).setVisible(false);
}
}
private void updateFilterMenuItem() {
@ -116,9 +111,9 @@ public class BookmarksListFragment extends RecyclerViewFragment implements Loade
case R.id.upcoming_only:
upcomingOnly = !upcomingOnly;
updateFilterMenuItem();
SharedPreferencesCompat.EditorCompat.getInstance().apply(
getActivity().getPreferences(Context.MODE_PRIVATE).edit().putBoolean(PREF_UPCOMING_ONLY, upcomingOnly)
);
getActivity().getPreferences(Context.MODE_PRIVATE).edit()
.putBoolean(PREF_UPCOMING_ONLY, upcomingOnly)
.apply();
getLoaderManager().restartLoader(BOOKMARKS_LOADER_ID, null, this);
return true;
case R.id.export_bookmarks:

View file

@ -12,7 +12,6 @@ import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.content.SharedPreferencesCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@ -89,9 +88,9 @@ public class TracksFragment extends Fragment implements RecycledViewPoolProvider
final int page = holder.pager.getCurrentItem();
SharedPreferences prefs = getActivity().getPreferences(Context.MODE_PRIVATE);
if (prefs.getInt(PREF_CURRENT_PAGE, -1) != page) {
SharedPreferencesCompat.EditorCompat.getInstance().apply(
prefs.edit().putInt(PREF_CURRENT_PAGE, page)
);
prefs.edit()
.putInt(PREF_CURRENT_PAGE, page)
.apply();
}
}

View file

@ -1,6 +1,5 @@
package be.digitalia.fosdem.providers;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ContentProvider;
import android.content.ContentValues;
@ -120,14 +119,9 @@ public class BookmarksExportProvider extends ContentProvider {
return cursor;
}
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Nullable
@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
throw new FileNotFoundException("Bookmarks export is not supported for this Android version");
}
try {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
new DownloadThread(new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1])).start();

View file

@ -2,7 +2,6 @@ package be.digitalia.fosdem.utils;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v4.content.LocalBroadcastManager;
import java.io.BufferedInputStream;
@ -12,10 +11,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
/**
* Utility class to perform HTTP requests.
*
@ -26,22 +21,6 @@ public class HttpUtils {
private static final int DEFAULT_TIMEOUT = 10000;
private static final int BUFFER_SIZE = 8192;
static {
// HTTP connection reuse was buggy pre-froyo
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
System.setProperty("http.keepAlive", "false");
}
// Bypass hostname verification on older devices
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
}
}
public static class HttpResult {
// Will be null when the local content is up-to-date
public InputStream inputStream;