Delete PreferenceActivityGingerbread

This commit is contained in:
Martin Fietz 2018-01-09 20:19:38 +01:00
parent b1c212c2fc
commit 1694432560
7 changed files with 9 additions and 137 deletions

View File

@ -15,6 +15,7 @@ import java.util.List;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.activity.OnlineFeedViewActivity; import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.storage.PodDBAdapter;
@ -22,7 +23,6 @@ import de.danoeh.antennapod.fragment.DownloadsFragment;
import de.danoeh.antennapod.fragment.EpisodesFragment; import de.danoeh.antennapod.fragment.EpisodesFragment;
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment; import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment; import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.preferences.PreferenceController;
/** /**
* User interface tests for MainActivity * User interface tests for MainActivity
@ -155,7 +155,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
public void testGoToPreferences() { public void testGoToPreferences() {
openNavDrawer(); openNavDrawer();
solo.clickOnText(solo.getString(R.string.settings_label)); solo.clickOnText(solo.getString(R.string.settings_label));
solo.waitForActivity(PreferenceController.getPreferenceActivity()); solo.waitForActivity(PreferenceActivity.class);
} }
public void testDrawerPreferencesHideSomeElements() { public void testDrawerPreferencesHideSomeElements() {

View File

@ -96,15 +96,6 @@
android:name=".activity.DownloadAuthenticationActivity" android:name=".activity.DownloadAuthenticationActivity"
android:launchMode="singleInstance"/> android:launchMode="singleInstance"/>
<activity
android:name=".activity.PreferenceActivityGingerbread"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/settings_label">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="de.danoeh.antennapod.activity.MainActivity"/>
</activity>
<activity <activity
android:name=".activity.PreferenceActivity" android:name=".activity.PreferenceActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"

View File

@ -18,7 +18,6 @@ import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils; import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import de.danoeh.antennapod.preferences.PreferenceController;
/** Guides the user through the authentication process */ /** Guides the user through the authentication process */
@ -104,7 +103,7 @@ public class FlattrAuthActivity extends ActionBarActivity {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
if (authSuccessful) { if (authSuccessful) {
Intent intent = new Intent(this, PreferenceController.getPreferenceActivity()); Intent intent = new Intent(this, PreferenceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); startActivity(intent);
} else { } else {

View File

@ -64,7 +64,6 @@ import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment; import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment; import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity; import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.preferences.PreferenceController;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
import rx.Observable; import rx.Observable;
import rx.Subscription; import rx.Subscription;
@ -173,7 +172,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
findViewById(R.id.nav_settings).setOnClickListener(v -> { findViewById(R.id.nav_settings).setOnClickListener(v -> {
drawerLayout.closeDrawer(navDrawer); drawerLayout.closeDrawer(navDrawer);
startActivity(new Intent(MainActivity.this, PreferenceController.getPreferenceActivity())); startActivity(new Intent(MainActivity.this, PreferenceActivity.class));
}); });
FragmentTransaction transaction = fm.beginTransaction(); FragmentTransaction transaction = fm.beginTransaction();

View File

@ -61,7 +61,6 @@ import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment; import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment; import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity; import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.preferences.PreferenceController;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
import rx.Observable; import rx.Observable;
import rx.Subscription; import rx.Subscription;
@ -270,7 +269,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
findViewById(R.id.nav_settings).setOnClickListener(v -> { findViewById(R.id.nav_settings).setOnClickListener(v -> {
drawerLayout.closeDrawer(navDrawer); drawerLayout.closeDrawer(navDrawer);
startActivity(new Intent(MediaplayerInfoActivity.this, PreferenceController.getPreferenceActivity())); startActivity(new Intent(MediaplayerInfoActivity.this, PreferenceActivity.class));
}); });
butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed); butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed);

View File

@ -1,97 +0,0 @@
package de.danoeh.antennapod.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources.Theme;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.preferences.PreferenceController;
/**
* PreferenceActivity for API 10. In order to change the behavior of the preference UI, see
* PreferenceController.
*/
public class PreferenceActivityGingerbread extends android.preference.PreferenceActivity {
private static final String TAG = "PreferenceActivity";
private final PreferenceController.PreferenceUI preferenceUI = new PreferenceController.PreferenceUI() {
@SuppressWarnings("deprecation")
@Override
public Preference findPreference(CharSequence key) {
return PreferenceActivityGingerbread.this.findPreference(key);
}
@Override
public Activity getActivity() {
return PreferenceActivityGingerbread.this;
}
};
private PreferenceController preferenceController;
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
preferenceController = new PreferenceController(preferenceUI);
preferenceController.onCreate();
}
@Override
protected void onResume() {
super.onResume();
preferenceController.onResume();
}
@Override
protected void onPause() {
preferenceController.onPause();
super.onPause();
}
@Override
protected void onStop() {
preferenceController.onStop();
super.onStop();
}
@Override
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
theme.applyStyle(UserPreferences.getTheme(), true);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
preferenceController.onActivityResult(requestCode, resultCode, data);
}
@SuppressWarnings("deprecation")
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
super.onPreferenceTreeClick(preferenceScreen, preference);
if (preference != null)
if (preference instanceof PreferenceScreen)
if (((PreferenceScreen) preference).getDialog() != null)
((PreferenceScreen) preference)
.getDialog()
.getWindow()
.getDecorView()
.setBackgroundDrawable(
this.getWindow().getDecorView()
.getBackground().getConstantState()
.newDrawable()
);
return false;
}
}

View File

@ -56,8 +56,6 @@ import de.danoeh.antennapod.activity.AboutActivity;
import de.danoeh.antennapod.activity.DirectoryChooserActivity; import de.danoeh.antennapod.activity.DirectoryChooserActivity;
import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.activity.MediaplayerActivity; import de.danoeh.antennapod.activity.MediaplayerActivity;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.activity.PreferenceActivityGingerbread;
import de.danoeh.antennapod.activity.StatisticsActivity; import de.danoeh.antennapod.activity.StatisticsActivity;
import de.danoeh.antennapod.asynctask.ExportWorker; import de.danoeh.antennapod.asynctask.ExportWorker;
import de.danoeh.antennapod.core.export.ExportWriter; import de.danoeh.antennapod.core.export.ExportWriter;
@ -97,8 +95,8 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir"; private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir";
private static final String AUTO_DL_PREF_SCREEN = "prefAutoDownloadSettings"; private static final String AUTO_DL_PREF_SCREEN = "prefAutoDownloadSettings";
private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher"; private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher";
public static final String PREF_PLAYBACK_REWIND_DELTA_LAUNCHER = "prefPlaybackRewindDeltaLauncher"; private static final String PREF_PLAYBACK_REWIND_DELTA_LAUNCHER = "prefPlaybackRewindDeltaLauncher";
public static final String PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER = "prefPlaybackFastForwardDeltaLauncher"; private static final String PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER = "prefPlaybackFastForwardDeltaLauncher";
private static final String PREF_GPODNET_LOGIN = "pref_gpodnet_authenticate"; private static final String PREF_GPODNET_LOGIN = "pref_gpodnet_authenticate";
private static final String PREF_GPODNET_SETLOGIN_INFORMATION = "pref_gpodnet_setlogin_information"; private static final String PREF_GPODNET_SETLOGIN_INFORMATION = "pref_gpodnet_setlogin_information";
private static final String PREF_GPODNET_SYNC = "pref_gpodnet_sync"; private static final String PREF_GPODNET_SYNC = "pref_gpodnet_sync";
@ -132,19 +130,6 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
.registerOnSharedPreferenceChangeListener(this); .registerOnSharedPreferenceChangeListener(this);
} }
/**
* Returns the preference activity that should be used on this device.
*
* @return PreferenceActivity if the API level is greater than 10, PreferenceActivityGingerbread otherwise.
*/
public static Class<? extends Activity> getPreferenceActivity() {
if (Build.VERSION.SDK_INT > 10) {
return PreferenceActivity.class;
} else {
return PreferenceActivityGingerbread.class;
}
}
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals(UserPreferences.PREF_SONIC)) { if(key.equals(UserPreferences.PREF_SONIC)) {
@ -230,12 +215,8 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
.setOnPreferenceChangeListener( .setOnPreferenceChangeListener(
(preference, newValue) -> { (preference, newValue) -> {
Intent i = new Intent(activity, MainActivity.class); Intent i = new Intent(activity, MainActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
| Intent.FLAG_ACTIVITY_NEW_TASK);
} else {
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
activity.finish(); activity.finish();
activity.startActivity(i); activity.startActivity(i);
return true; return true;