|
| 1 | +package ca.pkay.rcloneexplorer; |
| 2 | + |
| 3 | +import android.app.ActivityManager; |
| 4 | +import android.content.Intent; |
| 5 | +import android.content.SharedPreferences; |
| 6 | +import android.graphics.Bitmap; |
| 7 | +import android.graphics.BitmapFactory; |
| 8 | +import android.net.Uri; |
| 9 | +import android.os.Bundle; |
| 10 | +import android.preference.PreferenceManager; |
| 11 | +import android.support.v7.app.ActionBar; |
| 12 | +import android.support.v7.app.AppCompatActivity; |
| 13 | +import android.support.v7.widget.LinearLayoutManager; |
| 14 | +import android.support.v7.widget.RecyclerView; |
| 15 | +import android.support.v7.widget.Toolbar; |
| 16 | + |
| 17 | +import java.util.ArrayList; |
| 18 | +import java.util.HashMap; |
| 19 | +import java.util.List; |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +import ca.pkay.rcloneexplorer.RecyclerViewAdapters.AboutLibrariesAdapter; |
| 23 | + |
| 24 | +public class AboutLibsActivity extends AppCompatActivity implements AboutLibrariesAdapter.OnClickListener { |
| 25 | + |
| 26 | + private List<String> libraryNames; |
| 27 | + private Map<String, String> libraryUrls; |
| 28 | + private Map<String, String> libraryLicences; |
| 29 | + private Map<String, String> libraryLicenceUrls; |
| 30 | + |
| 31 | + @Override |
| 32 | + protected void onCreate(Bundle savedInstanceState) { |
| 33 | + super.onCreate(savedInstanceState); |
| 34 | + applyTheme(); |
| 35 | + setContentView(R.layout.activity_about_libs); |
| 36 | + Toolbar toolbar = findViewById(R.id.toolbar); |
| 37 | + setSupportActionBar(toolbar); |
| 38 | + ActionBar actionBar = getSupportActionBar(); |
| 39 | + if (actionBar != null) { |
| 40 | + actionBar.setDisplayHomeAsUpEnabled(true); |
| 41 | + actionBar.setDisplayShowHomeEnabled(true); |
| 42 | + } |
| 43 | + |
| 44 | + createData(); |
| 45 | + RecyclerView recyclerView = findViewById(R.id.about_libs_list); |
| 46 | + recyclerView.setHasFixedSize(true); |
| 47 | + RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); |
| 48 | + recyclerView.setLayoutManager(layoutManager); |
| 49 | + AboutLibrariesAdapter aboutLibrariesAdapter = new AboutLibrariesAdapter(libraryNames, libraryUrls, libraryLicences, libraryLicenceUrls, this); |
| 50 | + recyclerView.setAdapter(aboutLibrariesAdapter); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public boolean onSupportNavigateUp() { |
| 55 | + onBackPressed(); |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + private void applyTheme() { |
| 60 | + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); |
| 61 | + int customPrimaryColor = sharedPreferences.getInt("pref_key_color_primary", -1); |
| 62 | + int customAccentColor = sharedPreferences.getInt("pref_key_color_accent", -1); |
| 63 | + getTheme().applyStyle(CustomColorHelper.getPrimaryColorTheme(this, customPrimaryColor), true); |
| 64 | + getTheme().applyStyle(CustomColorHelper.getAccentColorTheme(this, customAccentColor), true); |
| 65 | + |
| 66 | + // set recents app color to the primary color |
| 67 | + Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); |
| 68 | + ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, customPrimaryColor); |
| 69 | + setTaskDescription(taskDesc); |
| 70 | + } |
| 71 | + |
| 72 | + private void createData() { |
| 73 | + libraryNames = new ArrayList<>(); |
| 74 | + libraryUrls = new HashMap<>(); |
| 75 | + libraryLicences = new HashMap<>(); |
| 76 | + libraryLicenceUrls = new HashMap<>(); |
| 77 | + |
| 78 | + String androidSupportLibraries = "Android Support Libraries"; |
| 79 | + libraryNames.add(androidSupportLibraries); |
| 80 | + libraryUrls.put(androidSupportLibraries, "https://developer.android.com/topic/libraries/support-library/"); |
| 81 | + libraryLicences.put(androidSupportLibraries, "Licensed under Apache-2.0"); |
| 82 | + libraryLicenceUrls.put(androidSupportLibraries, "http://www.apache.org/licenses/LICENSE-2.0"); |
| 83 | + |
| 84 | + String colorPicker = "Color Picker"; |
| 85 | + libraryNames.add(colorPicker); |
| 86 | + libraryUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker"); |
| 87 | + libraryLicences.put(colorPicker, "Licensed under Apache-2.0"); |
| 88 | + libraryLicenceUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker/blob/master/LICENSE"); |
| 89 | + |
| 90 | + String exFilePicker = "ExFile Picker"; |
| 91 | + libraryNames.add(exFilePicker); |
| 92 | + libraryUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker"); |
| 93 | + libraryLicences.put(exFilePicker, "Licensed under MIT"); |
| 94 | + libraryLicenceUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker/blob/master/LICENSE"); |
| 95 | + |
| 96 | + String floatingActionButtonSpeedDial = "Floating Action Button Speed Dial"; |
| 97 | + libraryNames.add(floatingActionButtonSpeedDial); |
| 98 | + libraryUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial"); |
| 99 | + libraryLicences.put(floatingActionButtonSpeedDial, "Licensed under Apache-2.0"); |
| 100 | + libraryLicenceUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial/blob/master/LICENSE"); |
| 101 | + |
| 102 | + String fontAwesome = "Font Awesome"; |
| 103 | + libraryNames.add(fontAwesome); |
| 104 | + libraryUrls.put(fontAwesome, "https://fontawesome.com/"); |
| 105 | + libraryLicences.put(fontAwesome, "Licensed under CC BY 4.0"); |
| 106 | + libraryLicenceUrls.put(fontAwesome, "https://fontawesome.com/license"); |
| 107 | + |
| 108 | + String markDownView = "MarkDown View"; |
| 109 | + libraryNames.add(markDownView); |
| 110 | + libraryUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView"); |
| 111 | + libraryLicences.put(markDownView, "Licensed under Apache-2.0"); |
| 112 | + libraryLicenceUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView/blob/master/license.txt"); |
| 113 | + |
| 114 | + String materialDesignIcons = "Material Design"; |
| 115 | + libraryNames.add(materialDesignIcons); |
| 116 | + libraryUrls.put(materialDesignIcons, "https://github.com/Templarian/MaterialDesign"); |
| 117 | + libraryLicences.put(materialDesignIcons, "Licensed under SIL Open Font 1.1"); |
| 118 | + libraryLicenceUrls.put(materialDesignIcons, "http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web"); |
| 119 | + |
| 120 | + String rclone = "Rclone"; |
| 121 | + libraryNames.add(rclone); |
| 122 | + libraryUrls.put(rclone, "https://github.com/ncw/rclone"); |
| 123 | + libraryLicences.put(rclone, "Licensed under MIT"); |
| 124 | + libraryLicenceUrls.put(rclone, "https://github.com/ncw/rclone/blob/master/COPYING"); |
| 125 | + |
| 126 | + String toasty = "Toasty"; |
| 127 | + libraryNames.add(toasty); |
| 128 | + libraryUrls.put(toasty, "https://github.com/GrenderG/Toasty"); |
| 129 | + libraryLicences.put(toasty, "Licensed under LGPL-3.0"); |
| 130 | + libraryLicenceUrls.put(toasty, "https://github.com/GrenderG/Toasty/blob/master/LICENSE"); |
| 131 | + } |
| 132 | + |
| 133 | + @Override |
| 134 | + public void onLibraryClick(String url) { |
| 135 | + Uri uri = Uri.parse(url); |
| 136 | + Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| 137 | + if (intent.resolveActivity(getPackageManager()) != null) { |
| 138 | + startActivity(intent); |
| 139 | + } |
| 140 | + } |
| 141 | +} |
0 commit comments