diff --git a/build.gradle b/build.gradle index f553e375d..b9a2d19d2 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ repositories { dependencies { compile 'com.android.support:appcompat-v7:24.1.0' + compile 'com.android.support:support-v13:24.1.0' compile 'com.android.support:support-v4:24.1.0' compile 'com.android.support:design:24.1.0' compile 'com.android.support:cardview-v7:21.0.+' diff --git a/src/org/kiwix/kiwixmobile/LibraryFragment.java b/src/org/kiwix/kiwixmobile/LibraryFragment.java index ba5779fb3..5494c5e35 100644 --- a/src/org/kiwix/kiwixmobile/LibraryFragment.java +++ b/src/org/kiwix/kiwixmobile/LibraryFragment.java @@ -1,5 +1,6 @@ package org.kiwix.kiwixmobile; +import android.app.FragmentManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -7,6 +8,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.SharedPreferences; +import android.graphics.Color; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; @@ -14,7 +17,9 @@ import android.os.Bundle; import android.os.Environment; import android.os.IBinder; import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; +import android.support.design.widget.Snackbar; +import android.app.Fragment; +import android.support.v4.view.GravityCompat; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; @@ -45,11 +50,13 @@ import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.network.KiwixService; import org.kiwix.kiwixmobile.utils.StorageUtils; +import eu.mhutti1.utils.storage.StorageDevice; +import eu.mhutti1.utils.storage.StorageSelectDialog; import rx.android.schedulers.AndroidSchedulers; import static org.kiwix.kiwixmobile.downloader.DownloadService.KIWIX_ROOT; -public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener { +public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener, StorageSelectDialog.OnSelectListener { public @BindView(R.id.library_list) ListView libraryList; @BindView(R.id.progressBar) ProgressBar progressBar; @@ -99,7 +106,7 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick noNetworkConnection(); } - this.getContext().registerReceiver(new BroadcastReceiver() { + faActivity.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { NetworkInfo network = conMan.getActiveNetworkInfo(); diff --git a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java index 7893e0442..05ca9bf9c 100644 --- a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java +++ b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java @@ -27,7 +27,7 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.support.v4.app.Fragment; +import android.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.util.Log; @@ -334,7 +334,7 @@ public class ZimFileSelectFragment extends Fragment ViewHolder holder; LibraryNetworkEntity.Book book = getItem(position); if (convertView == null) { - convertView = View.inflate(getContext(), R.layout.library_item, null); + convertView = View.inflate(context, R.layout.library_item, null); holder = new ViewHolder(); holder.title = (TextView) convertView.findViewById(R.id.title); holder.description = (TextView) convertView.findViewById(R.id.description); diff --git a/src/org/kiwix/kiwixmobile/ZimManageActivity.java b/src/org/kiwix/kiwixmobile/ZimManageActivity.java index fcd46b558..bc9ff587c 100644 --- a/src/org/kiwix/kiwixmobile/ZimManageActivity.java +++ b/src/org/kiwix/kiwixmobile/ZimManageActivity.java @@ -5,9 +5,9 @@ import android.content.Intent; import android.os.Bundle; import android.provider.Settings; import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; +import android.app.Fragment; +import android.app.FragmentManager; +import android.support.v13.app.FragmentPagerAdapter; import android.support.v4.view.MenuItemCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; @@ -66,7 +66,7 @@ public class ZimManageActivity extends AppCompatActivity { setUpToolbar(); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. - mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); diff --git a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java index 588223c17..4e59c62b8 100644 --- a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java +++ b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java @@ -1,6 +1,7 @@ package org.kiwix.kiwixmobile.downloader; +import android.app.Activity; import android.app.AlertDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -8,8 +9,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; +import android.app.Fragment; import android.support.v4.content.ContextCompat; import android.util.Base64; import android.view.LayoutInflater; @@ -42,7 +42,7 @@ public class DownloadFragment extends Fragment { public static DownloadAdapter downloadAdapter; private ZimManageActivity zimManageActivity; CoordinatorLayout mainLayout; - private FragmentActivity faActivity; + private Activity faActivity; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -141,7 +141,7 @@ public class DownloadFragment extends Fragment { // Get the data item for this position // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { - convertView = LayoutInflater.from(getContext()).inflate(R.layout.download_item, parent, false); + convertView = LayoutInflater.from(faActivity).inflate(R.layout.download_item, parent, false); } mKeys = mData.keySet().toArray(new Integer[mData.size()]); // Lookup view for data population @@ -180,7 +180,7 @@ public class DownloadFragment extends Fragment { ImageView stop = (ImageView) convertView.findViewById(R.id.stop); stop.setOnClickListener(v -> { - new AlertDialog.Builder(getContext()) + new AlertDialog.Builder(faActivity) .setTitle(R.string.confirm_stop_download_title) .setMessage(R.string.confirm_stop_download_msg) .setPositiveButton(R.string.yes, (dialog, i) -> {