├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── LICENSE ├── MinX.iml ├── README.md ├── app ├── .gitignore ├── app-release.apk ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── chdev │ │ └── ks │ │ └── minx │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── fonts │ │ ├── bitterregular.ttf │ │ └── gridnik.ttf │ └── saved_db.sqlite │ ├── java │ └── com │ │ └── chdev │ │ └── ks │ │ └── minx │ │ ├── AboutFragment.java │ │ ├── DatabaseManager │ │ ├── DataBaseAdapter.java │ │ ├── DataBaseHelper.java │ │ └── DataBaseOperations.java │ │ ├── ErrorActivity.java │ │ ├── FadeAnimation.java │ │ ├── HomeFragment.java │ │ ├── InitActivity.java │ │ ├── LibraryListAdapter.java │ │ ├── LoadWebData.java │ │ ├── MainActivity.java │ │ ├── MainFragment.java │ │ ├── SavedExtndActivity.java │ │ ├── SavedFragment.java │ │ ├── SavedListAdapter.java │ │ ├── SettingsFragment.java │ │ ├── SettingsPreferences.java │ │ ├── SplashActivity.java │ │ ├── SplashFragments │ │ ├── SplashIntroFragment.java │ │ ├── SplashPinFragment.java │ │ ├── SplashSettingsFragment.java │ │ └── SplashTutorialFragment.java │ │ └── SplashViewPagerAdapter.java │ └── res │ ├── drawable-hdpi │ ├── ic_action_action_delete.png │ ├── ic_action_action_search.png │ ├── ic_action_action_turned_in.png │ ├── ic_action_navigation_close.png │ └── ic_action_social_share.png │ ├── drawable-mdpi │ ├── ic_action_action_delete.png │ ├── ic_action_action_search.png │ ├── ic_action_action_turned_in.png │ ├── ic_action_navigation_close.png │ └── ic_action_social_share.png │ ├── drawable-xhdpi │ ├── ic_action_action_delete.png │ ├── ic_action_action_search.png │ ├── ic_action_action_turned_in.png │ ├── ic_action_navigation_close.png │ └── ic_action_social_share.png │ ├── drawable-xxhdpi │ ├── ic_action_action_delete.png │ ├── ic_action_action_search.png │ ├── ic_action_action_turned_in.png │ ├── ic_action_navigation_close.png │ └── ic_action_social_share.png │ ├── drawable-xxxhdpi │ ├── ic_action_action_delete.png │ ├── ic_action_action_search.png │ ├── ic_action_action_turned_in.png │ ├── ic_action_navigation_close.png │ └── ic_action_social_share.png │ ├── drawable │ ├── error_face.png │ ├── happy_face.png │ ├── ic_launcher.png │ ├── indicator_1.png │ ├── indicator_2.png │ ├── indicator_3.png │ ├── indicator_4.png │ ├── minx_small.png │ ├── sad_face.png │ ├── search_tutorial_small.png │ └── share_tutorial_small.png │ ├── layout │ ├── activity_error.xml │ ├── activity_init.xml │ ├── activity_main.xml │ ├── activity_saved_extnd.xml │ ├── activity_splash.xml │ ├── custom_list_single_item.xml │ ├── fragment_about.xml │ ├── fragment_home.xml │ ├── fragment_main.xml │ ├── fragment_saved.xml │ ├── fragment_settings.xml │ ├── fragment_splash_intro.xml │ ├── fragment_splash_pin.xml │ ├── fragment_splash_settings.xml │ ├── fragment_splash_tutorial.xml │ ├── new_pin_dialog.xml │ ├── reset_db_dialog.xml │ ├── reset_pin_dialog.xml │ └── save_dialog.xml │ ├── menu │ ├── menu_error.xml │ ├── menu_init.xml │ ├── menu_main.xml │ ├── menu_none.xml │ ├── menu_saved_extnd.xml │ └── menu_splash.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-ru │ └── strings.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | MinX -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 crazyhitty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MinX.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minx 2 | A minimalistic, text based web browser for android. 3 | 4 | 5 | Get it on Google Play 7 | 8 | 9 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Minx-brightgreen.svg?style=flat)](http://android-arsenal.com/details/3/2502) 10 | 11 | #Who is Minx for ? 12 | It is intended for those users who don’t like adverts on webpages or enjoy reading content from websites but unfortunately these websites don’t scale well on smartphone screens. Minx grabs textual data from websites and represents it to the user in a readable format. This app also removes any possibility of websites tracking user data as no cookies or user details are shared with the website. It uses jsoup to parse html data into string values which can further be displayed to the user. 13 | 14 | #Features 15 | * Ad free and no user information tracking. 16 | + Load any url into the app and it will load it as long as the url is valid. 17 | + Change font size according to your liking. 18 | + Save webpages offline. 19 | + Secure your archive with a PIN. 20 | 21 | #Screenshots 22 | ![](https://lh3.googleusercontent.com/Di5uZK0e9eWvWCzLVQ46DgqLrrniiAM-WKxHz1YnWw9oVggwHPf5BM7BSwnUu7nSmQ=h900-rw) 23 | ![](https://lh3.googleusercontent.com/Lj921COnloZt_JWOsCdBQlapvqIDE3UhheVE39FZ2lcBG1XLDFlNmB9HrXDT_Io7BA=h900-rw) 24 | ![](https://lh3.googleusercontent.com/7VYVwBPdIIA0kYYx7TBv1nYqQL0-Rmh4TywFHuBT5uhziMzUIKMcFicCGc83zn0_3g=h900-rw) 25 | ![](https://lh3.googleusercontent.com/Xknt4ot54VZ7WIcv7ETU0en-H5Ld7dOl8cOD-TPSiV8_yGHP5h68AFaGPQP0s09GHhk=h900-rw) 26 | ![](https://lh3.googleusercontent.com/PEr6BIJivSGP5Ae6FBIPIxnstjm1iIgGrq6AxvtHMeRh1NE5aoHY4X_Y5Yrekiz6QNU=h900-rw) 27 | ![](https://lh3.googleusercontent.com/x5nGu-cYQ9hBFJAYP1jgyvMovsYEmuKS8dfhzDd_ZNZpd3BY17Z9kOVG3yIP5duM18A=h900-rw) 28 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/app-release.apk -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "23.0.0 rc2" 6 | 7 | defaultConfig { 8 | applicationId "com.chdev.ks.minx" 9 | minSdkVersion 15 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "0.1" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:22.2.0' 25 | compile 'com.github.leonardoxh:custom-font:1.2' 26 | compile 'com.balysv:material-ripple:1.0.2' 27 | compile 'com.afollestad:material-dialogs:0.7.8.1' 28 | compile 'com.jakewharton:butterknife:7.0.1' 29 | compile 'org.jsoup:jsoup:1.8.3' 30 | compile 'com.pnikosis:materialish-progress:1.5' 31 | compile 'cat.ereza:customactivityoncrash:1.3.0' 32 | compile 'com.android.support:design:22.2.0' 33 | compile 'com.weiwangcn.betterspinner:library-material:1.1.0' 34 | compile('com.mikepenz:materialdrawer:3.1.2@aar') { 35 | transitive = true 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Kartik_ch\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/chdev/ks/minx/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 47 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/bitterregular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/assets/fonts/bitterregular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/gridnik.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/assets/fonts/gridnik.ttf -------------------------------------------------------------------------------- /app/src/main/assets/saved_db.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/assets/saved_db.sqlite -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/AboutFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.Menu; 11 | import android.view.MenuInflater; 12 | import android.view.MenuItem; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.Button; 16 | import android.widget.ListView; 17 | 18 | import com.balysv.materialripple.MaterialRippleLayout; 19 | 20 | /** 21 | * Created by Kartik_ch on 8/27/2015. 22 | */ 23 | public class AboutFragment extends Fragment { 24 | 25 | //MaterialRippleLayout rippleImgBtnMinx; 26 | Button btnGithub, btnGooglePlus, btnMail; 27 | ListView listViewLibrary; 28 | 29 | @Nullable 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 32 | //setHasOptionsMenu(true); 33 | return inflater.inflate(R.layout.fragment_about, container, false); 34 | } 35 | 36 | @Override 37 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 38 | super.onActivityCreated(savedInstanceState); 39 | 40 | btnGithub= (Button) getView().findViewById(R.id.btn_github); 41 | btnGooglePlus= (Button) getView().findViewById(R.id.btn_google_plus); 42 | btnMail= (Button) getView().findViewById(R.id.btn_mail); 43 | 44 | btnGithub.setOnClickListener(new View.OnClickListener() { 45 | @Override 46 | public void onClick(View v) { 47 | Intent intent=new Intent(Intent.ACTION_VIEW); 48 | intent.setData(Uri.parse(getResources().getString(R.string.github_website))); 49 | startActivity(intent); 50 | } 51 | }); 52 | 53 | btnGooglePlus.setOnClickListener(new View.OnClickListener() { 54 | @Override 55 | public void onClick(View v) { 56 | Intent intent=new Intent(Intent.ACTION_VIEW); 57 | intent.setData(Uri.parse(getResources().getString(R.string.google_plus_website))); 58 | startActivity(intent); 59 | } 60 | }); 61 | 62 | btnMail.setOnClickListener(new View.OnClickListener() { 63 | @Override 64 | public void onClick(View v) { 65 | //String mail_id=getResources().getString(R.string.mail_id); 66 | String mail_subject=getResources().getString(R.string.mail_subject); 67 | Intent intent=new Intent(Intent.ACTION_SEND); 68 | intent.putExtra(Intent.EXTRA_EMAIL,new String[]{"cr42yh17m4n@gmail.com"}); 69 | intent.putExtra(Intent.EXTRA_SUBJECT, mail_subject); 70 | intent.setType("message/rfc822"); 71 | startActivity(intent); 72 | } 73 | }); 74 | 75 | listViewLibrary= (ListView) getView().findViewById(R.id.libraries_list); 76 | listViewLibrary.setAdapter(new LibraryListAdapter(getActivity().getApplicationContext())); 77 | } 78 | 79 | /*@Override 80 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 81 | //super.onCreateOptionsMenu(menu, inflater); 82 | menu.clear(); 83 | //inflater.inflate(R.menu.menu_none, menu); 84 | } 85 | 86 | @Override 87 | public boolean onOptionsItemSelected(MenuItem item) { 88 | return super.onOptionsItemSelected(item); 89 | }*/ 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/DatabaseManager/DataBaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.DatabaseManager; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.database.SQLException; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.util.Log; 8 | 9 | import java.io.IOException; 10 | 11 | /** 12 | * Created by Kartik_ch on 8/29/2015. 13 | */ 14 | public class DataBaseAdapter { 15 | private final Context mContext; 16 | private SQLiteDatabase mDb; 17 | private DataBaseHelper mDbHelper; 18 | 19 | public DataBaseAdapter(Context context) { 20 | mContext = context; 21 | mDbHelper = new DataBaseHelper(mContext); 22 | } 23 | 24 | public DataBaseAdapter createDatabase() throws SQLException { 25 | try { 26 | mDbHelper.createDataBase(); 27 | } catch (IOException mIOException) { 28 | Log.e("Error", mIOException.toString() + " UnableToCreateDatabase"); 29 | throw new Error("UnableToCreateDatabase"); 30 | } 31 | return this; 32 | } 33 | 34 | public DataBaseAdapter open() throws SQLException { 35 | try { 36 | mDbHelper.openDataBase(); 37 | mDbHelper.close(); 38 | mDb = mDbHelper.getReadableDatabase(); 39 | } catch (SQLException mSQLException) { 40 | Log.e("OpenDb", "open >>" + mSQLException.toString()); 41 | throw mSQLException; 42 | } 43 | return this; 44 | } 45 | 46 | public void close() { 47 | mDbHelper.close(); 48 | } 49 | 50 | 51 | public Cursor selectQuery(String query) { 52 | Cursor c1 = null; 53 | try { 54 | 55 | if (mDb.isOpen()) { 56 | mDb.close(); 57 | 58 | } 59 | mDb = mDbHelper.getWritableDatabase(); 60 | c1 = mDb.rawQuery(query, null); 61 | 62 | } catch (Exception e) { 63 | 64 | System.out.println("DATABASE ERROR " + e); 65 | 66 | } 67 | return c1; 68 | 69 | } 70 | 71 | public void executeQuery(String query) { 72 | try { 73 | 74 | if (mDb.isOpen()) { 75 | mDb.close(); 76 | } 77 | 78 | mDb = mDbHelper.getWritableDatabase(); 79 | mDb.execSQL(query); 80 | 81 | } catch (Exception e) { 82 | 83 | System.out.println("DATABASE ERROR " + e); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/DatabaseManager/DataBaseHelper.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.DatabaseManager; 2 | 3 | import android.content.Context; 4 | import android.database.SQLException; 5 | import android.database.sqlite.SQLiteDatabase; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | 9 | import java.io.File; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.OutputStream; 14 | 15 | /** 16 | * Created by Kartik_ch on 8/29/2015. 17 | */ 18 | public class DataBaseHelper extends SQLiteOpenHelper { 19 | 20 | public static final String TABLE_NAME="webpage"; 21 | public static final String DB_NAME="saved_db.sqlite"; 22 | private static String DB_PATH; 23 | private Context mContext; 24 | private SQLiteDatabase mDataBase; 25 | 26 | public DataBaseHelper(Context context) { 27 | super(context, DB_NAME, null, 1);// 1? its Database Version 28 | DB_PATH = "/data/data/" + context.getPackageName() + "/databases/"; 29 | this.mContext = context; 30 | } 31 | 32 | public void createDataBase() throws IOException { 33 | //If database not exists copy it from the assets 34 | 35 | boolean mDataBaseExist = checkDataBase(); 36 | if (!mDataBaseExist) { 37 | this.getReadableDatabase(); 38 | this.close(); 39 | try { 40 | //Copy the database from assests 41 | copyDataBase(); 42 | Log.e("DB", "createDatabase database created"); 43 | } catch (IOException mIOException) { 44 | throw new Error("ErrorCopyingDataBase"); 45 | } 46 | } 47 | } 48 | 49 | //Check that the database exists here: /data/data/your package/databases/Da Name 50 | private boolean checkDataBase() { 51 | File dbFile = new File(DB_PATH + DB_NAME); 52 | return dbFile.exists(); 53 | } 54 | 55 | //Copy the database from assets 56 | private void copyDataBase() throws IOException { 57 | InputStream mInput = mContext.getAssets().open(DB_NAME); 58 | String outFileName = DB_PATH + DB_NAME; 59 | OutputStream mOutput = new FileOutputStream(outFileName); 60 | byte[] mBuffer = new byte[1024]; 61 | int mLength; 62 | while ((mLength = mInput.read(mBuffer)) > 0) { 63 | mOutput.write(mBuffer, 0, mLength); 64 | } 65 | mOutput.flush(); 66 | mOutput.close(); 67 | mInput.close(); 68 | } 69 | 70 | //Open the database, so we can query it 71 | public boolean openDataBase() throws SQLException { 72 | String mPath = DB_PATH + DB_NAME; 73 | mDataBase = SQLiteDatabase.openDatabase(mPath, null, SQLiteDatabase.CREATE_IF_NECESSARY); 74 | return mDataBase != null; 75 | } 76 | 77 | @Override 78 | public synchronized void close() { 79 | if (mDataBase != null) 80 | mDataBase.close(); 81 | super.close(); 82 | } 83 | 84 | @Override 85 | public void onCreate(SQLiteDatabase database) { 86 | //database.execSQL(DATABASE_CREATE); 87 | } 88 | 89 | @Override 90 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 91 | // TODO Auto-generated method stub 92 | 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/DatabaseManager/DataBaseOperations.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.DatabaseManager; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.text.format.DateFormat; 6 | import android.widget.Toast; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Date; 10 | 11 | /** 12 | * Created by Kartik_ch on 8/29/2015. 13 | */ 14 | public class DataBaseOperations { 15 | //String title, url, body; 16 | Context context; 17 | ArrayList titleArrLst = new ArrayList<>(); 18 | ArrayList urlArrLst = new ArrayList<>(); 19 | ArrayList bodyArrLst = new ArrayList<>(); 20 | ArrayList dateArrLst = new ArrayList<>(); 21 | 22 | public DataBaseOperations(Context context) { 23 | this.context = context; 24 | } 25 | 26 | public void saveDataInDB(String title, String url, String body) { 27 | // ' (single apostrophe) doesn't work with sqlite database in insertion, instead of it, use ''(double apostrophe). tldr : store ' as '' otherwise it won't work 28 | title=title.replace("'","''"); 29 | body=body.replace("'","''"); 30 | Date date = new Date(); 31 | CharSequence initTime = DateFormat.format("yyyy-MM-dd hh:mm:ss", date.getTime()); 32 | String time = initTime.toString(); 33 | DataBaseAdapter dbAdapter = new DataBaseAdapter(context); 34 | dbAdapter.createDatabase(); 35 | dbAdapter.open(); 36 | String query = "INSERT INTO webpage (title, url, desc, date) " + 37 | "VALUES ('" + title + "', '" + url + "', '" + body + "', '" + time + "')"; 38 | dbAdapter.executeQuery(query); 39 | dbAdapter.close(); 40 | Toast.makeText(context, "Data saved successfully", Toast.LENGTH_SHORT).show(); 41 | } 42 | 43 | public void retrieveFromDB() { 44 | DataBaseAdapter dbAdapter = new DataBaseAdapter(context); 45 | dbAdapter.createDatabase(); 46 | dbAdapter.open(); 47 | String query = "SELECT * FROM webpage"; 48 | Cursor cursor = dbAdapter.selectQuery(query); 49 | if (cursor != null && cursor.getCount() != 0) { 50 | if (cursor.moveToFirst()) { 51 | do { 52 | titleArrLst.add(cursor.getString(cursor.getColumnIndex("title"))); 53 | urlArrLst.add(cursor.getString(cursor.getColumnIndex("url"))); 54 | bodyArrLst.add(cursor.getString(cursor.getColumnIndex("desc"))); 55 | dateArrLst.add(cursor.getString(cursor.getColumnIndex("date"))); 56 | } while (cursor.moveToNext()); 57 | } 58 | } 59 | dbAdapter.close(); 60 | Toast.makeText(context, "Data retrieved successfully", Toast.LENGTH_SHORT).show(); 61 | } 62 | 63 | public void deleteFromDB(String selectedUrl){ 64 | DataBaseAdapter dbAdapter = new DataBaseAdapter(context); 65 | dbAdapter.createDatabase(); 66 | dbAdapter.open(); 67 | String query = "DELETE FROM webpage " + 68 | "WHERE url='"+selectedUrl+"'"; 69 | dbAdapter.executeQuery(query); 70 | dbAdapter.close(); 71 | Toast.makeText(context, "Data deleted successfully", Toast.LENGTH_SHORT).show(); 72 | } 73 | 74 | public void deleteAllFromDB(){ 75 | DataBaseAdapter dbAdapter=new DataBaseAdapter(context); 76 | dbAdapter.createDatabase(); 77 | dbAdapter.open(); 78 | String query="DELETE FROM webpage"; 79 | dbAdapter.executeQuery(query); 80 | dbAdapter.close(); 81 | Toast.makeText(context, "Database deleted successfully", Toast.LENGTH_SHORT).show(); 82 | } 83 | 84 | public ArrayList getTitleArrLst() { 85 | return titleArrLst; 86 | } 87 | 88 | public ArrayList getUrlArrLst() { 89 | return urlArrLst; 90 | } 91 | 92 | public ArrayList getBodyArrLst() { 93 | return bodyArrLst; 94 | } 95 | 96 | public ArrayList getDateArrLst() { 97 | return dateArrLst; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/ErrorActivity.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | 8 | 9 | public class ErrorActivity extends ActionBarActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_error); 15 | } 16 | 17 | @Override 18 | public boolean onCreateOptionsMenu(Menu menu) { 19 | // Inflate the menu; this adds items to the action bar if it is present. 20 | getMenuInflater().inflate(R.menu.menu_error, menu); 21 | return true; 22 | } 23 | 24 | @Override 25 | public boolean onOptionsItemSelected(MenuItem item) { 26 | // Handle action bar item clicks here. The action bar will 27 | // automatically handle clicks on the Home/Up button, so long 28 | // as you specify a parent activity in AndroidManifest.xml. 29 | int id = item.getItemId(); 30 | 31 | //noinspection SimplifiableIfStatement 32 | if (id == R.id.action_settings) { 33 | return true; 34 | } 35 | 36 | return super.onOptionsItemSelected(item); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/FadeAnimation.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.view.animation.AlphaAnimation; 7 | import android.view.animation.Animation; 8 | import android.view.animation.AnimationUtils; 9 | 10 | /** 11 | * Created by Kartik_ch on 8/17/2015. 12 | */ 13 | public class FadeAnimation { 14 | 15 | Context context; 16 | 17 | public FadeAnimation(Context context) { 18 | this.context = context; 19 | } 20 | 21 | public void fadeInLeft(View view) { 22 | view.setVisibility(View.INVISIBLE); 23 | Animation fadeInAnim = AnimationUtils.makeInAnimation(context, true); 24 | view.startAnimation(fadeInAnim); 25 | view.setVisibility(View.VISIBLE); 26 | Log.d("fadeIn", "true"); 27 | } 28 | 29 | public void fadeOutRight(View view) { 30 | Animation fadeOutAnim = AnimationUtils.makeOutAnimation(context, true); 31 | view.startAnimation(fadeOutAnim); 32 | view.setVisibility(View.INVISIBLE); 33 | Log.d("fadeOut", "true"); 34 | } 35 | 36 | public void fadeInAlpha(View view){ 37 | view.setVisibility(View.INVISIBLE); 38 | AlphaAnimation alphaAnimation=new AlphaAnimation(0f, 1.0f); 39 | alphaAnimation.setDuration(500); 40 | view.startAnimation(alphaAnimation); 41 | view.setVisibility(View.VISIBLE); 42 | } 43 | 44 | public void fadeOutAlpha(View view){ 45 | view.setVisibility(View.VISIBLE); 46 | AlphaAnimation alphaAnimation=new AlphaAnimation(1.0f, 0f); 47 | alphaAnimation.setDuration(500); 48 | view.startAnimation(alphaAnimation); 49 | view.setVisibility(View.GONE); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | 11 | import com.balysv.materialripple.MaterialRippleLayout; 12 | 13 | import butterknife.ButterKnife; 14 | 15 | /** 16 | * Created by Kartik_ch on 8/15/2015. 17 | */ 18 | public class HomeFragment extends Fragment { 19 | 20 | String search_url, title, body; 21 | MainActivity mainActivity; 22 | 23 | @Nullable 24 | @Override 25 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 26 | //Log.d("test","true"); 27 | ButterKnife.bind(getActivity()); 28 | mainActivity = (MainActivity) getActivity(); 29 | search_url = mainActivity.getSearchTxt(); 30 | return inflater.inflate(R.layout.fragment_home, container, false); 31 | } 32 | 33 | @Override 34 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 35 | super.onActivityCreated(savedInstanceState); 36 | LoadWebData loadWebData = new LoadWebData(search_url, getActivity()); 37 | if (!search_url.equals("")) { 38 | //Toast.makeText(getActivity(), search_url, Toast.LENGTH_SHORT).show(); 39 | loadWebData.execute(); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/InitActivity.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.os.Handler; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.os.Bundle; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.view.Menu; 12 | import android.view.MenuItem; 13 | 14 | 15 | public class InitActivity extends Activity { 16 | 17 | private SharedPreferences mSharedPreferences; 18 | private String mSharedPref="APP_INIT"; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_init); 24 | if(checkIfNewInstall()){ 25 | runIntent(SplashActivity.class); 26 | }else{ 27 | new SettingsPreferences(InitActivity.this).resetPINTemp(); 28 | runIntent(MainActivity.class); 29 | //removed this because its irritating 30 | /*Handler handler=new Handler(); 31 | handler.postDelayed(new Runnable() { 32 | @Override 33 | public void run() { 34 | new SettingsPreferences(InitActivity.this).resetPINTemp(); 35 | runIntent(MainActivity.class); 36 | } 37 | }, 1000);*/ 38 | } 39 | } 40 | 41 | private void runIntent(Class activityClass) { 42 | Intent intent=new Intent(InitActivity.this, activityClass); 43 | startActivity(intent); 44 | finish(); 45 | } 46 | 47 | private boolean checkIfNewInstall() { 48 | try { 49 | mSharedPreferences = getSharedPreferences(mSharedPref, Context.MODE_PRIVATE); 50 | if(mSharedPreferences.getString("install_success", null).equals("true")){ 51 | return false; 52 | } 53 | }catch (Exception e){ 54 | e.printStackTrace(); 55 | } 56 | return true; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/LibraryListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.BaseAdapter; 10 | 11 | import com.balysv.materialripple.MaterialRippleLayout; 12 | import com.github.leonardoxh.customfont.FontText; 13 | 14 | /** 15 | * Created by Kartik_ch on 8/28/2015. 16 | */ 17 | public class LibraryListAdapter extends BaseAdapter{ 18 | Context context; 19 | LayoutInflater layoutInflater; 20 | String[] libraryName, libraryDesc, libraryUrl; 21 | public LibraryListAdapter(Context context) { 22 | this.context=context; 23 | layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 24 | libraryName=context.getResources().getStringArray(R.array.library_name); 25 | libraryDesc=context.getResources().getStringArray(R.array.library_desc); 26 | libraryUrl=context.getResources().getStringArray(R.array.library_url); 27 | } 28 | 29 | @Override 30 | public int getCount() { 31 | return libraryName.length; 32 | } 33 | 34 | @Override 35 | public Object getItem(int position) { 36 | return null; 37 | } 38 | 39 | @Override 40 | public long getItemId(int position) { 41 | return position; 42 | } 43 | 44 | @Override 45 | public View getView(final int position, View convertView, ViewGroup parent) { 46 | View view; 47 | view=layoutInflater.inflate(R.layout.custom_list_single_item, null); 48 | MaterialRippleLayout ripple=(MaterialRippleLayout)view.findViewById(R.id.ripple); 49 | FontText libraryOwnerTxt=(FontText)view.findViewById(R.id.library_name_txt); 50 | FontText libraryDescTxt=(FontText)view.findViewById(R.id.library_desc_txt); 51 | libraryOwnerTxt.setText("\n"+libraryName[position]); 52 | libraryDescTxt.setText(libraryDesc[position] + "\n"); 53 | ripple.setOnClickListener(new View.OnClickListener() { 54 | @Override 55 | public void onClick(View v) { 56 | //Toast.makeText(context, libraryName[position], Toast.LENGTH_SHORT).show(); 57 | Intent intent=new Intent(Intent.ACTION_VIEW); 58 | intent.setData(Uri.parse(libraryUrl[position])); 59 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 60 | context.startActivity(intent); 61 | } 62 | }); 63 | return view; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/LoadWebData.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.AsyncTask; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.util.TypedValue; 8 | import android.view.View; 9 | import android.view.inputmethod.InputMethodManager; 10 | import android.widget.Button; 11 | import android.widget.Toast; 12 | 13 | import com.afollestad.materialdialogs.MaterialDialog; 14 | import com.chdev.ks.minx.DatabaseManager.DataBaseAdapter; 15 | import com.github.leonardoxh.customfont.FontText; 16 | import com.pnikosis.materialishprogress.ProgressWheel; 17 | 18 | import org.jsoup.Jsoup; 19 | import org.jsoup.nodes.Document; 20 | import org.jsoup.select.Elements; 21 | 22 | import java.io.IOException; 23 | import java.util.ArrayList; 24 | 25 | /** 26 | * Created by Kartik_ch on 8/15/2015. 27 | */ 28 | public class LoadWebData extends AsyncTask { 29 | String search_url, title, body, link; 30 | String[] linkArr; 31 | String sharedPrefs; 32 | Elements paragraphs; 33 | Elements links; 34 | Document document; 35 | FragmentActivity activity; 36 | ProgressWheel progressViewLoading; 37 | FontText title_txt, body_txt; 38 | Button btn_view_links; 39 | MainActivity mainActivity; 40 | SharedPreferences sharedPreferences; 41 | SharedPreferences.Editor editor; 42 | 43 | public LoadWebData(String search_url, FragmentActivity activity) { 44 | super(); 45 | this.search_url = search_url; 46 | this.activity = activity; 47 | progressViewLoading = (ProgressWheel) (activity).findViewById(R.id.progressViewLoading); 48 | title_txt = (FontText) (activity).findViewById(R.id.title_txt); 49 | body_txt = (FontText) (activity).findViewById(R.id.body_txt); 50 | btn_view_links = (Button) (activity).findViewById(R.id.btn_view_links); 51 | mainActivity=(MainActivity)activity; 52 | sharedPrefs=activity.getResources().getString(R.string.sharedPrefs); 53 | sharedPreferences=activity.getSharedPreferences(sharedPrefs, Context.MODE_PRIVATE); 54 | editor=sharedPreferences.edit(); 55 | } 56 | 57 | @Override 58 | protected String doInBackground(Void... params) { 59 | try { 60 | document = Jsoup.connect(search_url).get(); 61 | title = document.title(); 62 | paragraphs = document.select("p"); 63 | links = document.select("a[href]"); 64 | body = convertParagraphsToString(); 65 | link = convertLinksToString(); 66 | linkArr = convertLinksToStringArr(); 67 | } catch (IOException e) { 68 | e.printStackTrace(); 69 | } catch (Exception e){ 70 | e.printStackTrace(); 71 | Toast.makeText(activity, "Error : "+e.toString(), Toast.LENGTH_LONG).show(); 72 | } 73 | return null; 74 | } 75 | 76 | @Override 77 | protected void onPreExecute() { 78 | super.onPreExecute(); 79 | progressViewLoading.setVisibility(View.VISIBLE); 80 | btn_view_links.setVisibility(View.INVISIBLE); 81 | title_txt.setText(""); 82 | body_txt.setText(""); 83 | clearSharedPrefs(); 84 | } 85 | 86 | @Override 87 | protected void onPostExecute(String s) { 88 | super.onPostExecute(s); 89 | try { 90 | progressViewLoading.setVisibility(View.INVISIBLE); 91 | btn_view_links.setVisibility(View.VISIBLE); 92 | setLoadedValues(); 93 | } catch (Exception e) { 94 | e.printStackTrace(); 95 | Toast.makeText(activity, activity.getResources().getString(R.string.error), Toast.LENGTH_SHORT).show(); 96 | //Toast.makeText(activity, "Error : "+e.toString(), Toast.LENGTH_LONG).show(); 97 | } 98 | } 99 | 100 | private void setLoadedValues() { 101 | setFontSize(); 102 | title_txt.setText(title); 103 | body_txt.setText(body); 104 | //links_txt.setText(link); 105 | showTitleBody(title_txt, body_txt); 106 | loadLinks(); 107 | setDataIntoSharedPrefs(search_url, title, body); 108 | title = ""; 109 | body = ""; 110 | } 111 | 112 | private void setFontSize() { 113 | //setting title font 114 | SettingsPreferences settingsPreferencesTitle=new SettingsPreferences(activity, "title"); 115 | String titleFont=settingsPreferencesTitle.retrieveFontPreferences(); 116 | title_txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(titleFont)); 117 | //setting body font 118 | SettingsPreferences settingsPreferencesBody=new SettingsPreferences(activity, "body"); 119 | String bodyFont=settingsPreferencesBody.retrieveFontPreferences(); 120 | body_txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(bodyFont)); 121 | } 122 | 123 | private void loadLinks() { 124 | btn_view_links.setOnClickListener(new View.OnClickListener() { 125 | @Override 126 | public void onClick(View v) { 127 | new MaterialDialog.Builder(activity) 128 | .title(R.string.dialog_link_title) 129 | .items(linkArr) 130 | .itemsCallback(new MaterialDialog.ListCallback() { 131 | @Override 132 | public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 133 | String[] linkSingle = text.toString().split("http:"); 134 | String linkFinal="http:"+linkSingle[1]; 135 | //linkSingle[1] 136 | //Toast.makeText(activity, "http:"+linkSingle[1].trim(), Toast.LENGTH_SHORT).show(); 137 | LoadWebData loadWebData=new LoadWebData(linkFinal, activity); 138 | //change search text field with new url 139 | mainActivity.search_txt.setText(linkFinal); 140 | if(!search_url.equals("")) { 141 | //Toast.makeText(getActivity(), search_url, Toast.LENGTH_SHORT).show(); 142 | loadWebData.execute(); 143 | } 144 | } 145 | }) 146 | .show(); 147 | } 148 | }); 149 | } 150 | 151 | private String convertParagraphsToString() { 152 | String para = ""; 153 | for (int i = 0; i < paragraphs.size(); i++) { 154 | para += paragraphs.get(i).text().trim() + "\n\n"; 155 | } 156 | return para; 157 | } 158 | 159 | private String convertLinksToString() { 160 | String allLinks = ""; 161 | for (int i = 0; i < links.size(); i++) { 162 | if (links.get(i).text().trim().isEmpty()) { 163 | allLinks += links.get(i).attr("abs:href") + "\n\n"; 164 | } else { 165 | allLinks += links.get(i).text() + " : " + links.get(i).attr("abs:href") + "\n\n"; 166 | } 167 | } 168 | return allLinks; 169 | } 170 | 171 | private String[] convertLinksToStringArr() { 172 | ArrayList arrLst = new ArrayList(); 173 | for (int i = 0; i < links.size(); i++) { 174 | if (links.get(i).text().trim().isEmpty()) { 175 | arrLst.add(links.get(i).attr("abs:href")); 176 | } else { 177 | arrLst.add("\n" + links.get(i).text() + "\n" + links.get(i).attr("abs:href") + "\n"); 178 | } 179 | } 180 | String[] stringArray = arrLst.toArray(new String[arrLst.size()]); 181 | return stringArray; 182 | } 183 | 184 | @Override 185 | protected void onProgressUpdate(Void... values) { 186 | super.onProgressUpdate(values); 187 | } 188 | 189 | private void showTitleBody(final FontText title_txt, final FontText body_txt) { 190 | FadeAnimation fadeAnimation = new FadeAnimation(activity); 191 | //fadeAnimation.fadeInLeft(title_txt); 192 | //fadeAnimation.fadeInLeft(body_txt); 193 | fadeAnimation.fadeInAlpha(title_txt); 194 | fadeAnimation.fadeInAlpha(body_txt); 195 | } 196 | 197 | private void setDataIntoSharedPrefs(String url, String title, String body){ 198 | editor.putString("url", url); 199 | editor.putString("title", title); 200 | editor.putString("body", body); 201 | editor.commit(); 202 | } 203 | 204 | private void clearSharedPrefs(){ 205 | editor.clear().commit(); 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.net.Uri; 7 | import android.os.Bundle; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.app.FragmentTransaction; 10 | import android.support.v7.app.ActionBar; 11 | import android.support.v7.app.ActionBarActivity; 12 | import android.support.v7.widget.Toolbar; 13 | import android.view.KeyEvent; 14 | import android.view.Menu; 15 | import android.view.MenuItem; 16 | import android.view.View; 17 | import android.view.inputmethod.InputMethodManager; 18 | import android.widget.AdapterView; 19 | import android.widget.EditText; 20 | import android.widget.FrameLayout; 21 | import android.widget.ImageView; 22 | import android.widget.Toast; 23 | 24 | import com.afollestad.materialdialogs.MaterialDialog; 25 | import com.chdev.ks.minx.DatabaseManager.DataBaseOperations; 26 | import com.mikepenz.materialdrawer.Drawer; 27 | import com.mikepenz.materialdrawer.DrawerBuilder; 28 | import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; 29 | import com.mikepenz.materialdrawer.accountswitcher.AccountHeaderBuilder; 30 | import com.mikepenz.materialdrawer.model.DividerDrawerItem; 31 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; 32 | import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; 33 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; 34 | 35 | import java.net.URI; 36 | 37 | import butterknife.Bind; 38 | import butterknife.ButterKnife; 39 | 40 | 41 | public class MainActivity extends ActionBarActivity { 42 | 43 | Boolean actionItem = true; 44 | 45 | @Bind(R.id.toolbar) 46 | Toolbar toolbar; 47 | @Bind(R.id.search_txt) 48 | EditText search_txt; 49 | @Bind(R.id.fragment_frame) 50 | FrameLayout frameLayout; 51 | Drawer result; 52 | SharedPreferences sharedPreferences; 53 | SharedPreferences.Editor editor; 54 | EditText save_title_txt, save_url_txt; 55 | /*@Bind(R.id.saved_title_txt) 56 | EditText save_title_txt; 57 | @Bind(R.id.saved_url_txt) 58 | EditText save_url_txt;*/ 59 | private String search_str, cancel_str, exit_dialog_title_str, exit_dialog_yes_str, exit_dialog_cancel_str, finTitle, finUrl, finBody; 60 | private int loadSearchType = 0; 61 | 62 | @Override 63 | protected void onCreate(Bundle savedInstanceState) { 64 | super.onCreate(savedInstanceState); 65 | 66 | //ErrorActivity.install(this); 67 | 68 | setContentView(R.layout.activity_main); 69 | ButterKnife.bind(this); 70 | 71 | search_str = getResources().getString(R.string.action_search); 72 | cancel_str = getResources().getString(R.string.action_cancel); 73 | exit_dialog_title_str = getResources().getString(R.string.exit_dialog_title); 74 | exit_dialog_yes_str = getResources().getString(R.string.exit_dialog_yes); 75 | exit_dialog_cancel_str = getResources().getString(R.string.exit_dialog_cancel); 76 | 77 | clearSharedPrefs(); 78 | getPublicIntent(); 79 | loadFragment(-1); 80 | setUpToolbar(); 81 | setUpDrawer(); 82 | 83 | search_txt.setOnKeyListener(new View.OnKeyListener() { 84 | @Override 85 | public boolean onKey(View v, int keyCode, KeyEvent event) { 86 | if (event.getAction() != KeyEvent.ACTION_DOWN) { 87 | //to stop this goddamn function from running twice 88 | if (testInput()) { 89 | loadFragment(0); 90 | } 91 | hideKeyboard(); 92 | return false; 93 | } 94 | return false; 95 | } 96 | }); 97 | } 98 | 99 | private boolean testInput() { 100 | String urlValue = search_txt.getText().toString(); 101 | if (!urlValue.contains("://")) { 102 | //Toast.makeText(MainActivity.this, "Invalid url, please add http:// or https:// before your url", Toast.LENGTH_SHORT).show(); 103 | urlValue = "http://" + urlValue; 104 | } 105 | try { 106 | URI.create(urlValue); 107 | search_txt.setText(urlValue); 108 | return true; 109 | } catch (IllegalArgumentException e) { 110 | Toast.makeText(MainActivity.this, "Invalid url", Toast.LENGTH_SHORT).show(); 111 | } 112 | return false; 113 | } 114 | 115 | public void hideKeyboard() { 116 | View view = MainActivity.this.getCurrentFocus(); 117 | if (view != null) { 118 | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 119 | inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); 120 | } 121 | } 122 | 123 | @Override 124 | protected void onResume() { 125 | super.onResume(); 126 | } 127 | 128 | private void setUpToolbar() { 129 | setSupportActionBar(toolbar); 130 | final ActionBar actionBar = getSupportActionBar(); 131 | actionBar.setTitle(""); 132 | } 133 | 134 | private void setUpDrawer() { 135 | 136 | AccountHeader accountHeader = new AccountHeaderBuilder() 137 | .withActivity(MainActivity.this) 138 | .withHeaderBackground(R.drawable.minx_small) 139 | .withHeaderBackgroundScaleType(ImageView.ScaleType.FIT_CENTER) 140 | .withHeightDp(200) 141 | .build(); 142 | 143 | result = new DrawerBuilder() 144 | .withHeaderDivider(true) 145 | .withActivity(this) 146 | .withAccountHeader(accountHeader) 147 | .withToolbar(toolbar) 148 | .addDrawerItems( 149 | new PrimaryDrawerItem().withName(R.string.drawer_item_home), 150 | new DividerDrawerItem(), 151 | new SecondaryDrawerItem().withName(R.string.drawer_item_saved), 152 | new SecondaryDrawerItem().withName(R.string.drawer_item_share), 153 | new SecondaryDrawerItem().withName(R.string.drawer_item_settings), 154 | new SecondaryDrawerItem().withName(R.string.drawer_item_about) 155 | ) 156 | .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 157 | @Override 158 | public boolean onItemClick(AdapterView parent, View view, int position, long id, IDrawerItem drawerItem) { 159 | // do something with the clicked item :D 160 | Toast.makeText(MainActivity.this, "You clicked on item : " + position, Toast.LENGTH_SHORT).show(); 161 | loadFragment(position); 162 | return false; 163 | } 164 | }) 165 | .build(); 166 | getSupportActionBar().setDisplayHomeAsUpEnabled(false); 167 | result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true); 168 | 169 | } 170 | 171 | private void loadFragment(int position) { 172 | Boolean switchFragment = true; 173 | Fragment fragment = new MainFragment(); 174 | switch (position) { 175 | case 0: 176 | if (search_txt.getText().toString().isEmpty()) { 177 | fragment = new MainFragment(); 178 | } else { 179 | fragment = new HomeFragment(); 180 | } 181 | break; 182 | case 2: 183 | fragment = new SavedFragment(); 184 | break; 185 | case 3: 186 | switchFragment = false; 187 | shareData(); 188 | break; 189 | case 4: 190 | fragment = new SettingsFragment(); 191 | break; 192 | case 5: 193 | fragment = new AboutFragment(); 194 | break; 195 | } 196 | if (switchFragment) { 197 | frameLayout.removeAllViews(); 198 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 199 | fragmentTransaction.add(R.id.fragment_frame, fragment).commit(); 200 | } 201 | } 202 | 203 | private void shareData() { 204 | getSharedPrefs(); 205 | Intent shareIntent = new Intent(); 206 | shareIntent.setAction(Intent.ACTION_SEND); 207 | shareIntent.putExtra(Intent.EXTRA_SUBJECT, finTitle); 208 | shareIntent.putExtra(Intent.EXTRA_TEXT, finBody); 209 | shareIntent.setType("text/plain"); 210 | startActivity(shareIntent); 211 | } 212 | 213 | private void hideSearchTxt() { 214 | //Hide edittext with keyboard 215 | //search_txt.setVisibility(View.GONE); 216 | FadeAnimation fadeAnimation = new FadeAnimation(MainActivity.this); 217 | fadeAnimation.fadeOutRight(search_txt); 218 | View view = this.getCurrentFocus(); 219 | if (view != null) { 220 | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 221 | inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); 222 | } 223 | //search_txt.setFocusable(false); 224 | } 225 | 226 | private void showSearchTxt() { 227 | if (loadSearchType == 1) { 228 | search_txt.setVisibility(View.VISIBLE); 229 | search_txt.setFocusable(true); 230 | search_txt.requestFocus(); 231 | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 232 | inputMethodManager.showSoftInput(search_txt, InputMethodManager.SHOW_IMPLICIT); 233 | } else { 234 | //Show edittext with keyboard and request focus on edittext 235 | FadeAnimation fadeAnimation = new FadeAnimation(MainActivity.this); 236 | fadeAnimation.fadeInLeft(search_txt); 237 | //search_txt.setVisibility(View.VISIBLE); 238 | //search_txt.setFocusable(true); 239 | search_txt.requestFocus(); 240 | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 241 | inputMethodManager.showSoftInput(search_txt, InputMethodManager.SHOW_IMPLICIT); 242 | } 243 | } 244 | 245 | @Override 246 | public boolean onCreateOptionsMenu(Menu menu) { 247 | // Inflate the menu; this adds items to the action bar if it is present. 248 | getMenuInflater().inflate(R.menu.menu_main, menu); 249 | return true; 250 | } 251 | 252 | @Override 253 | public boolean onOptionsItemSelected(MenuItem item) { 254 | // Handle action bar item clicks here. The action bar will 255 | // automatically handle clicks on the Home/Up button, so long 256 | // as you specify a parent activity in AndroidManifest.xml. 257 | int id = item.getItemId(); 258 | 259 | //noinspection SimplifiableIfStatement 260 | if (id == R.id.action_item) { 261 | if (actionItem) { 262 | showSearchTxt(); 263 | item.setIcon(R.drawable.ic_action_navigation_close); 264 | item.setTitle(cancel_str); 265 | actionItem = false; 266 | } else { 267 | hideSearchTxt(); 268 | item.setIcon(R.drawable.ic_action_action_search); 269 | item.setTitle(search_str); 270 | actionItem = true; 271 | } 272 | return true; 273 | } 274 | 275 | if (id == R.id.action_save) { 276 | if (sharedPrefsStatus()) { 277 | promptSaveData(); 278 | Toast.makeText(MainActivity.this, "save", Toast.LENGTH_SHORT).show(); 279 | } else { 280 | Toast.makeText(MainActivity.this, "No webpage loaded", Toast.LENGTH_SHORT).show(); 281 | } 282 | } 283 | 284 | return super.onOptionsItemSelected(item); 285 | } 286 | 287 | private void promptSaveData() { 288 | getSharedPrefs(); 289 | MaterialDialog materialDialog = new MaterialDialog.Builder(MainActivity.this) 290 | .title(R.string.dialog_save_title) 291 | .customView(R.layout.save_dialog, true) 292 | .positiveText(R.string.dialog_save) 293 | .negativeText(R.string.exit_dialog_cancel) 294 | .callback(new MaterialDialog.ButtonCallback() { 295 | @Override 296 | public void onPositive(MaterialDialog dialog) { 297 | super.onPositive(dialog); 298 | new DataBaseOperations(MainActivity.this).saveDataInDB(save_title_txt.getText().toString(), save_url_txt.getText().toString(), finBody); 299 | Toast.makeText(MainActivity.this, save_title_txt.getText().toString() + "\n" + save_url_txt.getText().toString(), Toast.LENGTH_SHORT).show(); 300 | } 301 | 302 | @Override 303 | public void onNegative(MaterialDialog dialog) { 304 | super.onNegative(dialog); 305 | } 306 | }).build(); 307 | save_title_txt = (EditText) materialDialog.getView().findViewById(R.id.saved_title_txt); 308 | save_url_txt = (EditText) materialDialog.getView().findViewById(R.id.saved_url_txt); 309 | save_title_txt.setText(finTitle); 310 | save_url_txt.setText(finUrl); 311 | materialDialog.show(); 312 | } 313 | 314 | private Boolean sharedPrefsStatus() { 315 | try { 316 | sharedPreferences = getSharedPreferences(getResources().getString(R.string.sharedPrefs), Context.MODE_PRIVATE); 317 | if (sharedPreferences.getString("url", null).equals("")) { 318 | return false; 319 | } else { 320 | return true; 321 | } 322 | } catch (Exception e) { 323 | e.printStackTrace(); 324 | return false; 325 | } 326 | } 327 | 328 | private void getSharedPrefs() { 329 | sharedPreferences = getSharedPreferences(getResources().getString(R.string.sharedPrefs), Context.MODE_PRIVATE); 330 | finTitle = sharedPreferences.getString("title", null); 331 | finUrl = sharedPreferences.getString("url", null); 332 | finBody = sharedPreferences.getString("body", null); 333 | } 334 | 335 | private void clearSharedPrefs() { 336 | try { 337 | sharedPreferences = getSharedPreferences(getResources().getString(R.string.sharedPrefs), Context.MODE_PRIVATE); 338 | editor = sharedPreferences.edit(); 339 | editor.clear().commit(); 340 | } catch (Exception e) { 341 | e.printStackTrace(); 342 | } 343 | } 344 | 345 | 346 | public String getSearchTxt() { 347 | return search_txt.getText().toString(); 348 | } 349 | 350 | //For some reason this reloads the fragment again and again, will fix this later 351 | /*@Override 352 | public void onBackPressed() { 353 | //Don't use super.onBackPressed() if you want to override the default back button(h/w) completely 354 | //super.onBackPressed(); 355 | showExitPrompt(); 356 | } 357 | 358 | private void showExitPrompt() { 359 | 360 | }*/ 361 | 362 | public void getPublicIntent() { 363 | String url = null; 364 | Intent intent = getIntent(); 365 | try { 366 | if (intent != null) { 367 | Uri data = intent.getData(); 368 | String scheme = data.getScheme(); 369 | String fullPath = data.getEncodedSchemeSpecificPart(); 370 | fullPath = fullPath.replace("//", ""); 371 | url = scheme + "://" + fullPath; 372 | } 373 | if (url != null) { 374 | loadSearchType = 1; 375 | search_txt.setText(url); 376 | showSearchTxt(); 377 | } else { 378 | Toast.makeText(MainActivity.this, "Invalid Url", Toast.LENGTH_SHORT).show(); 379 | } 380 | } catch (NullPointerException e) { 381 | e.printStackTrace(); 382 | } 383 | } 384 | 385 | public String getTextFromIntent(Intent intent) { 386 | return intent.getStringExtra(Intent.EXTRA_TEXT); 387 | } 388 | } 389 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/MainFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.Fragment; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.ImageView; 13 | import android.widget.LinearLayout; 14 | 15 | import com.github.leonardoxh.customfont.FontText; 16 | 17 | /** 18 | * Created by Kartik_ch on 8/28/2015. 19 | */ 20 | public class MainFragment extends Fragment { 21 | 22 | FontText welcome_title_txt, welcome_body_txt, network_txt; 23 | LinearLayout imageLayout; 24 | ImageView imageFace; 25 | 26 | @Nullable 27 | @Override 28 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 29 | return inflater.inflate(R.layout.fragment_main, container, false); 30 | } 31 | 32 | @Override 33 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 34 | super.onActivityCreated(savedInstanceState); 35 | welcome_title_txt= (FontText) getView().findViewById(R.id.welcome_title_txt); 36 | welcome_body_txt= (FontText) getView().findViewById(R.id.welcome_body_txt); 37 | network_txt= (FontText) getView().findViewById(R.id.network_txt); 38 | imageLayout= (LinearLayout) getView().findViewById(R.id.imageLayout); 39 | imageFace= (ImageView) getView().findViewById(R.id.imageFace); 40 | testNetworkAvailability(); 41 | } 42 | 43 | private void testNetworkAvailability() { 44 | //To check if internet connection is available or not 45 | Boolean connection = false; 46 | ConnectivityManager connectivityManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); 47 | if (connectivityManager != null) { 48 | NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo(); 49 | if (networkInfos != null) { 50 | for (int i = 0; i < networkInfos.length; i++) { 51 | if (networkInfos[i].getState() == NetworkInfo.State.CONNECTED) { 52 | connection = true; 53 | } 54 | } 55 | } 56 | } 57 | if (!connection) { 58 | imageFace.setImageResource(R.drawable.sad_face); 59 | network_txt.setVisibility(View.VISIBLE); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SavedExtndActivity.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.ActionBar; 5 | import android.support.v7.app.ActionBarActivity; 6 | import android.os.Bundle; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.TypedValue; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | import android.widget.Toast; 12 | 13 | import com.afollestad.materialdialogs.MaterialDialog; 14 | import com.chdev.ks.minx.DatabaseManager.DataBaseOperations; 15 | import com.github.leonardoxh.customfont.FontText; 16 | 17 | import butterknife.Bind; 18 | import butterknife.ButterKnife; 19 | 20 | 21 | public class SavedExtndActivity extends ActionBarActivity { 22 | 23 | @Bind(R.id.saved_extnd_toolbar) 24 | Toolbar toolbar; 25 | @Bind(R.id.saved_extnd_title_txt) 26 | FontText saved_extnd_title_txt; 27 | @Bind(R.id.saved_extnd_url_txt) 28 | FontText saved_extnd_url_txt; 29 | @Bind(R.id.saved_extnd_body_txt) 30 | FontText saved_extnd_body_txt; 31 | String title, url, body; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_saved_extnd); 37 | ButterKnife.bind(this); 38 | setUpToolbar(); 39 | displayInfo(); 40 | } 41 | 42 | private void setUpToolbar() { 43 | setSupportActionBar(toolbar); 44 | final ActionBar actionBar=getSupportActionBar(); 45 | actionBar.setDisplayHomeAsUpEnabled(true); 46 | actionBar.setDisplayShowHomeEnabled(true); 47 | actionBar.setTitle(""); 48 | } 49 | 50 | private void displayInfo() { 51 | getExtraFromIntent(); 52 | setFontSize(); 53 | saved_extnd_title_txt.setText(title); 54 | saved_extnd_url_txt.setText(url); 55 | saved_extnd_body_txt.setText(body); 56 | } 57 | 58 | private void getExtraFromIntent() { 59 | Bundle bundle=getIntent().getExtras(); 60 | title=bundle.getString("saved_extnd_title"); 61 | url=bundle.getString("saved_extnd_url"); 62 | body=bundle.getString("saved_extnd_body"); 63 | } 64 | 65 | private void setFontSize() { 66 | //setting title font 67 | SettingsPreferences settingsPreferencesTitle=new SettingsPreferences(SavedExtndActivity.this, "title"); 68 | String titleFont=settingsPreferencesTitle.retrieveFontPreferences(); 69 | saved_extnd_title_txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(titleFont)); 70 | //setting body font 71 | SettingsPreferences settingsPreferencesBody=new SettingsPreferences(SavedExtndActivity.this, "body"); 72 | String bodyFont=settingsPreferencesBody.retrieveFontPreferences(); 73 | saved_extnd_body_txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(bodyFont)); 74 | } 75 | 76 | @Override 77 | public boolean onCreateOptionsMenu(Menu menu) { 78 | // Inflate the menu; this adds items to the action bar if it is present. 79 | getMenuInflater().inflate(R.menu.menu_saved_extnd, menu); 80 | return true; 81 | } 82 | 83 | @Override 84 | public boolean onOptionsItemSelected(MenuItem item) { 85 | // Handle action bar item clicks here. The action bar will 86 | // automatically handle clicks on the Home/Up button, so long 87 | // as you specify a parent activity in AndroidManifest.xml. 88 | int id = item.getItemId(); 89 | 90 | //noinspection SimplifiableIfStatement 91 | /*if (id == R.id.homeAsUp) { 92 | onBackPressed(); 93 | return true; 94 | }*/ 95 | 96 | if(id==R.id.action_delete){ 97 | promptDelete(); 98 | return true; 99 | } 100 | 101 | if(id==R.id.action_share){ 102 | shareData(); 103 | return true; 104 | } 105 | 106 | return super.onOptionsItemSelected(item); 107 | } 108 | 109 | private void promptDelete() { 110 | new MaterialDialog.Builder(SavedExtndActivity.this) 111 | .title(R.string.are_you_sure) 112 | .positiveText(R.string.exit_dialog_yes) 113 | .negativeText(R.string.exit_dialog_cancel) 114 | .callback(new MaterialDialog.ButtonCallback() { 115 | @Override 116 | public void onPositive(MaterialDialog dialog) { 117 | super.onPositive(dialog); 118 | new DataBaseOperations(SavedExtndActivity.this).deleteFromDB(url); 119 | Toast.makeText(SavedExtndActivity.this, "Deleted succesfully", Toast.LENGTH_SHORT).show(); 120 | startActivity(new Intent(SavedExtndActivity.this, MainActivity.class)); 121 | finish(); 122 | } 123 | }).show(); 124 | } 125 | 126 | private void shareData() { 127 | getExtraFromIntent(); 128 | Intent shareIntent = new Intent(); 129 | shareIntent.setAction(Intent.ACTION_SEND); 130 | shareIntent.putExtra(Intent.EXTRA_SUBJECT, title); 131 | shareIntent.putExtra(Intent.EXTRA_TEXT, body); 132 | shareIntent.setType("text/plain"); 133 | startActivity(shareIntent); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SavedFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.Button; 12 | import android.widget.EditText; 13 | import android.widget.ListView; 14 | import android.widget.Toast; 15 | 16 | import com.chdev.ks.minx.DatabaseManager.DataBaseOperations; 17 | import com.github.leonardoxh.customfont.FontText; 18 | 19 | import java.util.ArrayList; 20 | 21 | /** 22 | * Created by Kartik_ch on 8/29/2015. 23 | */ 24 | public class SavedFragment extends Fragment { 25 | 26 | FontText enterPinTxt; 27 | EditText userArchivePinTxt; 28 | Button btnRetrieveArchive; 29 | ListView listViewSaved; 30 | int pinValue; 31 | SettingsPreferences settingsPreferences; 32 | ArrayList titleArrLst = new ArrayList<>(); 33 | ArrayList urlArrLst = new ArrayList<>(); 34 | ArrayList bodyArrLst = new ArrayList<>(); 35 | ArrayList dateArrLst = new ArrayList<>(); 36 | 37 | @Nullable 38 | @Override 39 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 40 | return inflater.inflate(R.layout.fragment_saved, container, false); 41 | } 42 | 43 | @Override 44 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 45 | super.onActivityCreated(savedInstanceState); 46 | 47 | enterPinTxt = (FontText) getView().findViewById(R.id.enter_pin_txt); 48 | userArchivePinTxt = (EditText) getView().findViewById(R.id.userArchivePinTxt); 49 | btnRetrieveArchive = (Button) getView().findViewById(R.id.btnRetrieveArchive); 50 | listViewSaved = (ListView) getView().findViewById(R.id.saved_list); 51 | 52 | if(checkPINEnabled()){ 53 | enterPinTxt.setVisibility(View.GONE); 54 | userArchivePinTxt.setVisibility(View.GONE); 55 | btnRetrieveArchive.setVisibility(View.GONE); 56 | loadSavedData(); 57 | }else{ 58 | settingsPreferences = new SettingsPreferences(getActivity()); 59 | if(!settingsPreferences.retrievePINTemp()){ 60 | loadPIN(); 61 | }else{ 62 | enterPinTxt.setVisibility(View.GONE); 63 | userArchivePinTxt.setVisibility(View.GONE); 64 | btnRetrieveArchive.setVisibility(View.GONE); 65 | loadSavedData(); 66 | } 67 | } 68 | } 69 | 70 | private void loadPIN(){ 71 | btnRetrieveArchive.setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | if (!userArchivePinTxt.getText().toString().equals("")) { 75 | pinValue = Integer.parseInt(userArchivePinTxt.getText().toString()); 76 | } else { 77 | pinValue = -1; 78 | } 79 | settingsPreferences = new SettingsPreferences(getActivity()); 80 | if (settingsPreferences.retrievePINPreferences() == pinValue) { 81 | settingsPreferences.setPINTemp(); 82 | hideTxt(); 83 | loadSavedData(); 84 | } else { 85 | Toast.makeText(getActivity(), "Invalid PIN", Toast.LENGTH_SHORT).show(); 86 | } 87 | } 88 | }); 89 | } 90 | 91 | private Boolean checkPINEnabled(){ 92 | try{ 93 | SettingsPreferences settingsPreferences = new SettingsPreferences(getActivity()); 94 | //simply check if pin was entered in tutorial screen 95 | if(settingsPreferences.retrievePINPreferences()==-2){ 96 | return true; 97 | } 98 | }catch (Exception e){ 99 | e.printStackTrace(); 100 | } 101 | return false; 102 | } 103 | 104 | private void hideTxt() { 105 | FadeAnimation fadeAnimation = new FadeAnimation(getActivity()); 106 | fadeAnimation.fadeOutAlpha(enterPinTxt); 107 | fadeAnimation.fadeOutAlpha(userArchivePinTxt); 108 | fadeAnimation.fadeOutAlpha(btnRetrieveArchive); 109 | } 110 | 111 | private void loadSavedData() { 112 | FadeAnimation fadeAnimation = new FadeAnimation(getActivity()); 113 | fadeAnimation.fadeInAlpha(listViewSaved); 114 | 115 | DataBaseOperations dbOperations = new DataBaseOperations(getActivity().getApplicationContext()); 116 | 117 | dbOperations.retrieveFromDB(); 118 | titleArrLst = dbOperations.getTitleArrLst(); 119 | urlArrLst = dbOperations.getUrlArrLst(); 120 | bodyArrLst = dbOperations.getBodyArrLst(); 121 | dateArrLst = dbOperations.getDateArrLst(); 122 | 123 | if(urlArrLst.isEmpty()){ 124 | Toast.makeText(getActivity(), "Database is empty", Toast.LENGTH_SHORT).show(); 125 | } 126 | 127 | /*for(int i=0; i titleArrLst = new ArrayList<>(); 25 | ArrayList urlArrLst = new ArrayList<>(); 26 | ArrayList bodyArrLst = new ArrayList<>(); 27 | ArrayList dateArrLst = new ArrayList<>(); 28 | public SavedListAdapter(Context context, ArrayList titleArrLst, ArrayList urlArrLst, ArrayList bodyArrLst, ArrayList dateArrLst) { 29 | this.context=context; 30 | layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 31 | this.titleArrLst=titleArrLst; 32 | this.urlArrLst=urlArrLst; 33 | this.bodyArrLst=bodyArrLst; 34 | this.dateArrLst=dateArrLst; 35 | } 36 | 37 | @Override 38 | public int getCount() { 39 | return urlArrLst.size(); 40 | } 41 | 42 | @Override 43 | public Object getItem(int position) { 44 | return null; 45 | } 46 | 47 | @Override 48 | public long getItemId(int position) { 49 | return position; 50 | } 51 | 52 | @Override 53 | public View getView(final int position, View convertView, ViewGroup parent) { 54 | View view; 55 | view=layoutInflater.inflate(R.layout.custom_list_single_item, null); 56 | MaterialRippleLayout ripple=(MaterialRippleLayout)view.findViewById(R.id.ripple); 57 | final FontText titleTxt=(FontText)view.findViewById(R.id.library_name_txt); 58 | FontText bodyTxt=(FontText)view.findViewById(R.id.library_desc_txt); 59 | titleTxt.setText("\n"+titleArrLst.get(position).trim()); 60 | bodyTxt.setText(urlArrLst.get(position)+ "\n"); 61 | ripple.setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | Toast.makeText(context, titleArrLst.get(position).trim(), Toast.LENGTH_SHORT).show(); 65 | Intent intent=new Intent(context, SavedExtndActivity.class); 66 | intent.putExtra("saved_extnd_title", titleArrLst.get(position)); 67 | intent.putExtra("saved_extnd_url", urlArrLst.get(position)); 68 | intent.putExtra("saved_extnd_body", bodyArrLst.get(position)); 69 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 70 | context.startActivity(intent); 71 | } 72 | }); 73 | return view; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.util.TypedValue; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.AdapterView; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.EditText; 13 | import android.widget.Toast; 14 | 15 | import com.afollestad.materialdialogs.MaterialDialog; 16 | import com.balysv.materialripple.MaterialRippleLayout; 17 | import com.chdev.ks.minx.DatabaseManager.DataBaseOperations; 18 | import com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner; 19 | 20 | /** 21 | * Created by Kartik_ch on 9/6/2015. 22 | */ 23 | public class SettingsFragment extends Fragment { 24 | 25 | MaterialRippleLayout rippleResetDbBtn, rippleResetPinBtn; 26 | MaterialBetterSpinner titleSpinner, bodySpinner; 27 | String[] title_items, body_items; 28 | ArrayAdapter arrayAdapterTitle, arrayAdapterBody; 29 | EditText resetDbPIN, oldPIN, newPIN; 30 | SettingsPreferences settingsPreferences; 31 | 32 | @Nullable 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 35 | return inflater.inflate(R.layout.fragment_settings, container, false); 36 | } 37 | 38 | @Override 39 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 40 | super.onActivityCreated(savedInstanceState); 41 | titleSpinner= (MaterialBetterSpinner) getView().findViewById(R.id.titleFontSizeSpinnerMain); 42 | bodySpinner= (MaterialBetterSpinner) getView().findViewById(R.id.bodyFontSizeSpinnerMain); 43 | rippleResetDbBtn= (MaterialRippleLayout) getView().findViewById(R.id.rippleResetDbBtn); 44 | rippleResetPinBtn= (MaterialRippleLayout) getView().findViewById(R.id.rippleResetPinBtn); 45 | 46 | title_items=getActivity().getResources().getStringArray(R.array.splash_title_entries); 47 | body_items=getActivity().getResources().getStringArray(R.array.splash_body_entries); 48 | arrayAdapterTitle=new ArrayAdapter(getActivity(), android.R.layout.simple_dropdown_item_1line, title_items); 49 | arrayAdapterBody=new ArrayAdapter(getActivity(), android.R.layout.simple_dropdown_item_1line, body_items); 50 | titleSpinner.setAdapter(arrayAdapterTitle); 51 | bodySpinner.setAdapter(arrayAdapterBody); 52 | 53 | titleSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() { 54 | @Override 55 | public void onItemClick(AdapterView parent, View view, int position, long id) { 56 | setFontSize("title", title_items[position]); 57 | } 58 | }); 59 | bodySpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() { 60 | @Override 61 | public void onItemClick(AdapterView parent, View view, int position, long id) { 62 | setFontSize("body", body_items[position]); 63 | } 64 | }); 65 | 66 | rippleResetDbBtn.setOnClickListener(new View.OnClickListener() { 67 | @Override 68 | public void onClick(View v) { 69 | promptResetDB(); 70 | } 71 | }); 72 | 73 | rippleResetPinBtn.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | promptResetPIN(); 77 | } 78 | }); 79 | } 80 | 81 | private void setFontSize(String type, String fontSize) { 82 | if(type.equals("title")){ 83 | SettingsPreferences settingsPreferences=new SettingsPreferences(getActivity(), "title"); 84 | settingsPreferences.setSettingsPreferences(fontSize); 85 | }else{ 86 | if(type.equals("body")){ 87 | SettingsPreferences settingsPreferences=new SettingsPreferences(getActivity(), "body"); 88 | settingsPreferences.setSettingsPreferences(fontSize); 89 | } 90 | } 91 | } 92 | 93 | private void promptResetDB() { 94 | if(checkPINEnabled()){ 95 | MaterialDialog materialDialog=new MaterialDialog.Builder(getActivity()) 96 | .title(R.string.exit_dialog_title) 97 | .positiveText(R.string.exit_dialog_yes) 98 | .negativeText(R.string.exit_dialog_cancel) 99 | .callback(new MaterialDialog.ButtonCallback() { 100 | @Override 101 | public void onPositive(MaterialDialog dialog) { 102 | super.onPositive(dialog); 103 | new DataBaseOperations(getActivity()).deleteAllFromDB(); 104 | } 105 | }) 106 | .build(); 107 | materialDialog.show(); 108 | }else{ 109 | MaterialDialog materialDialog=new MaterialDialog.Builder(getActivity()) 110 | .title(R.string.exit_dialog_title) 111 | .customView(R.layout.reset_db_dialog, true) 112 | .positiveText(R.string.exit_dialog_yes) 113 | .negativeText(R.string.exit_dialog_cancel) 114 | .callback(new MaterialDialog.ButtonCallback() { 115 | @Override 116 | public void onPositive(MaterialDialog dialog) { 117 | super.onPositive(dialog); 118 | settingsPreferences = new SettingsPreferences(getActivity()); 119 | if (Integer.parseInt(resetDbPIN.getText().toString()) == settingsPreferences.retrievePINPreferences()) { 120 | new DataBaseOperations(getActivity()).deleteAllFromDB(); 121 | } else { 122 | Toast.makeText(getActivity(), "Invalid PIN", Toast.LENGTH_SHORT).show(); 123 | } 124 | } 125 | }) 126 | .build(); 127 | resetDbPIN = (EditText) materialDialog.getView().findViewById(R.id.confirm_pin_txt); 128 | materialDialog.show(); 129 | } 130 | } 131 | 132 | private void promptResetPIN() { 133 | if(checkPINEnabled()){ 134 | MaterialDialog materialDialog=new MaterialDialog.Builder(getActivity()) 135 | .title(R.string.new_pin_dialog_title) 136 | .customView(R.layout.new_pin_dialog, true) 137 | .positiveText(R.string.exit_dialog_yes) 138 | .negativeText(R.string.exit_dialog_cancel) 139 | .callback(new MaterialDialog.ButtonCallback() { 140 | @Override 141 | public void onPositive(MaterialDialog dialog) { 142 | super.onPositive(dialog); 143 | settingsPreferences = new SettingsPreferences(getActivity()); 144 | if (newPIN.getText().toString().length()==4) { 145 | settingsPreferences.setSettingsPreferences(Integer.parseInt(newPIN.getText().toString())); 146 | } else { 147 | Toast.makeText(getActivity(), "Invalid PIN", Toast.LENGTH_SHORT).show(); 148 | } 149 | } 150 | }) 151 | .build(); 152 | newPIN = (EditText) materialDialog.getView().findViewById(R.id.new_user_pin_txt); 153 | materialDialog.show(); 154 | }else { 155 | MaterialDialog materialDialog = new MaterialDialog.Builder(getActivity()) 156 | .title(R.string.exit_dialog_title) 157 | .customView(R.layout.reset_pin_dialog, true) 158 | .positiveText(R.string.exit_dialog_yes) 159 | .negativeText(R.string.exit_dialog_cancel) 160 | .callback(new MaterialDialog.ButtonCallback() { 161 | @Override 162 | public void onPositive(MaterialDialog dialog) { 163 | super.onPositive(dialog); 164 | settingsPreferences = new SettingsPreferences(getActivity()); 165 | if (Integer.parseInt(oldPIN.getText().toString()) == settingsPreferences.retrievePINPreferences()) { 166 | if (newPIN.getText().toString().length() == 4) { 167 | settingsPreferences.setSettingsPreferences(Integer.parseInt(newPIN.getText().toString())); 168 | } else { 169 | Toast.makeText(getActivity(), "Invalid new PIN", Toast.LENGTH_SHORT).show(); 170 | } 171 | } else { 172 | Toast.makeText(getActivity(), "Invalid PIN", Toast.LENGTH_SHORT).show(); 173 | } 174 | } 175 | }) 176 | .build(); 177 | oldPIN = (EditText) materialDialog.getView().findViewById(R.id.old_pin_txt); 178 | newPIN = (EditText) materialDialog.getView().findViewById(R.id.new_pin_txt); 179 | materialDialog.show(); 180 | } 181 | } 182 | 183 | private Boolean checkPINEnabled(){ 184 | try{ 185 | SettingsPreferences settingsPreferences = new SettingsPreferences(getActivity()); 186 | if(settingsPreferences.retrievePINPreferences()==-2){ 187 | return true; 188 | } 189 | }catch (Exception e){ 190 | e.printStackTrace(); 191 | } 192 | return false; 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SettingsPreferences.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.util.Base64; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /** 10 | * Created by Kartik_ch on 9/5/2015. 11 | */ 12 | public class SettingsPreferences { 13 | String type, fontSize, pin, sharedPref; 14 | SharedPreferences sharedPreferences; 15 | SharedPreferences.Editor editor; 16 | Context context; 17 | 18 | public SettingsPreferences(Context context, String type) { 19 | this.context=context; 20 | this.type = type; 21 | sharedPref="SETTINGS_PREF"; 22 | } 23 | 24 | public SettingsPreferences(Context context){ 25 | this.context=context; 26 | } 27 | 28 | public void setSettingsPreferences(String fontSize){ 29 | sharedPreferences=context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 30 | editor=sharedPreferences.edit(); 31 | editor.putString(type+"Size", fontSize); 32 | editor.commit(); 33 | } 34 | 35 | public void setSettingsPreferences(int pin){ 36 | try { 37 | this.pin = String.valueOf(pin); 38 | byte[] pinData = this.pin.getBytes("UTF-8"); 39 | String encodedPIN = Base64.encodeToString(pinData, Base64.DEFAULT); 40 | sharedPreferences=context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 41 | editor=sharedPreferences.edit(); 42 | editor.putString("PIN", encodedPIN); 43 | editor.commit(); 44 | } catch (UnsupportedEncodingException e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | public void setPINTemp(){ 50 | sharedPreferences=context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 51 | editor=sharedPreferences.edit(); 52 | editor.putBoolean("PIN_entered", true); 53 | editor.commit(); 54 | } 55 | 56 | public void resetPINTemp(){ 57 | sharedPreferences=context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 58 | editor=sharedPreferences.edit(); 59 | editor.putBoolean("PIN_entered", false); 60 | editor.commit(); 61 | } 62 | 63 | public Boolean retrievePINTemp(){ 64 | sharedPreferences=context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 65 | return sharedPreferences.getBoolean("PIN_entered", false); 66 | } 67 | 68 | public String retrieveFontPreferences(){ 69 | try { 70 | sharedPreferences = context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 71 | fontSize = sharedPreferences.getString(type + "Size", null); 72 | return fontSize; 73 | }catch (Exception e){ 74 | e.printStackTrace(); 75 | } 76 | return "nil"; 77 | } 78 | 79 | public int retrievePINPreferences(){ 80 | try { 81 | sharedPreferences = context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE); 82 | pin = sharedPreferences.getString("PIN", null); 83 | byte[] pinData = Base64.decode(pin, Base64.DEFAULT); 84 | pin = new String(pinData, "UTF-8"); 85 | return Integer.parseInt(pin); 86 | } catch (UnsupportedEncodingException e) { 87 | e.printStackTrace(); 88 | } 89 | return 0; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.support.v4.app.FragmentActivity; 8 | import android.support.v4.view.ViewPager; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | 12 | import com.balysv.materialripple.MaterialRippleLayout; 13 | 14 | import butterknife.Bind; 15 | import butterknife.ButterKnife; 16 | 17 | 18 | public class SplashActivity extends FragmentActivity implements ViewPager.OnPageChangeListener { 19 | 20 | //Extending this class with FragmentActivity because Fullscreen(in manifest theme) doesn't work with ActionBarActivity/AppCompat 21 | @Bind(R.id.splashViewPager) 22 | ViewPager splashViewPager; 23 | @Bind(R.id.ripplePrev) 24 | MaterialRippleLayout ripplePrev; 25 | @Bind(R.id.rippleNext) 26 | MaterialRippleLayout rippleNext; 27 | @Bind(R.id.rippleOk) 28 | MaterialRippleLayout rippleOk; 29 | @Bind(R.id.indicator) 30 | ImageView indicator; 31 | private int mPosition = 0; 32 | private SharedPreferences mSharedPreferences; 33 | private SharedPreferences.Editor mEditor; 34 | private String mSharedPref="APP_INIT"; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_splash); 40 | ButterKnife.bind(this); 41 | splashViewPager.setAdapter(new SplashViewPagerAdapter(getSupportFragmentManager())); 42 | splashViewPager.setOnPageChangeListener(this); 43 | splashViewPager.setOffscreenPageLimit(4); 44 | 45 | ripplePrev.setVisibility(View.GONE); 46 | rippleNext.setVisibility(View.VISIBLE); 47 | 48 | rippleNext.setOnClickListener(new View.OnClickListener() { 49 | @Override 50 | public void onClick(View v) { 51 | splashViewPager.setCurrentItem(mPosition + 1, true); 52 | } 53 | }); 54 | ripplePrev.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | splashViewPager.setCurrentItem(mPosition - 1, true); 58 | } 59 | }); 60 | rippleOk.setOnClickListener(new View.OnClickListener() { 61 | @Override 62 | public void onClick(View v) { 63 | mSharedPreferences = getSharedPreferences(mSharedPref, Context.MODE_PRIVATE); 64 | mEditor=mSharedPreferences.edit(); 65 | mEditor.putString("install_success", "true"); 66 | mEditor.commit(); 67 | Intent intent=new Intent(SplashActivity.this, MainActivity.class); 68 | startActivity(intent); 69 | finish(); 70 | } 71 | }); 72 | } 73 | 74 | @Override 75 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 76 | 77 | } 78 | 79 | @Override 80 | public void onPageSelected(int position) { 81 | try { 82 | mPosition = position; 83 | switch (position){ 84 | case 0:indicator.setImageResource(R.drawable.indicator_1); 85 | ripplePrev.setVisibility(View.GONE); 86 | rippleNext.setVisibility(View.VISIBLE); 87 | rippleOk.setVisibility(View.GONE); 88 | break; 89 | case 1:indicator.setImageResource(R.drawable.indicator_2); 90 | ripplePrev.setVisibility(View.VISIBLE); 91 | rippleNext.setVisibility(View.VISIBLE); 92 | rippleOk.setVisibility(View.GONE); 93 | break; 94 | case 2:indicator.setImageResource(R.drawable.indicator_3); 95 | ripplePrev.setVisibility(View.VISIBLE); 96 | rippleNext.setVisibility(View.VISIBLE); 97 | rippleOk.setVisibility(View.GONE); 98 | break; 99 | case 3:indicator.setImageResource(R.drawable.indicator_4); 100 | ripplePrev.setVisibility(View.VISIBLE); 101 | rippleNext.setVisibility(View.GONE); 102 | rippleOk.setVisibility(View.VISIBLE); 103 | break; 104 | } 105 | } catch (Exception e) { 106 | 107 | } 108 | } 109 | 110 | @Override 111 | public void onPageScrollStateChanged(int state) { 112 | 113 | } 114 | 115 | /*@Override 116 | public boolean onCreateOptionsMenu(Menu menu) { 117 | // Inflate the menu; this adds items to the action bar if it is present. 118 | getMenuInflater().inflate(R.menu.menu_splash, menu); 119 | return true; 120 | } 121 | 122 | @Override 123 | public boolean onOptionsItemSelected(MenuItem item) { 124 | // Handle action bar item clicks here. The action bar will 125 | // automatically handle clicks on the Home/Up button, so long 126 | // as you specify a parent activity in AndroidManifest.xml. 127 | int id = item.getItemId(); 128 | 129 | //noinspection SimplifiableIfStatement 130 | if (id == R.id.action_settings) { 131 | return true; 132 | } 133 | 134 | return super.onOptionsItemSelected(item); 135 | }*/ 136 | } 137 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashFragments/SplashIntroFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.SplashFragments; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.RelativeLayout; 10 | 11 | import com.chdev.ks.minx.FadeAnimation; 12 | import com.chdev.ks.minx.R; 13 | 14 | /** 15 | * Created by Kartik_ch on 9/1/2015. 16 | */ 17 | public class SplashIntroFragment extends Fragment{ 18 | 19 | @Nullable 20 | @Override 21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 22 | return inflater.inflate(R.layout.fragment_splash_intro, container, false); 23 | } 24 | 25 | @Override 26 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 27 | super.onActivityCreated(savedInstanceState); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashFragments/SplashPinFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.SplashFragments; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | import android.widget.EditText; 11 | import android.widget.Toast; 12 | 13 | import com.chdev.ks.minx.R; 14 | import com.chdev.ks.minx.SettingsPreferences; 15 | 16 | /** 17 | * Created by Kartik_ch on 9/5/2015. 18 | */ 19 | public class SplashPinFragment extends Fragment { 20 | 21 | EditText txtPIN; 22 | Button btnSavePin; 23 | String pinValue; 24 | 25 | @Nullable 26 | @Override 27 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 28 | return inflater.inflate(R.layout.fragment_splash_pin, container, false); 29 | } 30 | 31 | @Override 32 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 33 | super.onActivityCreated(savedInstanceState); 34 | txtPIN= (EditText) getView().findViewById(R.id.userPinTxt); 35 | btnSavePin= (Button) getView().findViewById(R.id.btnSavePin); 36 | btnSavePin.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | pinValue=txtPIN.getText().toString(); 40 | if(pinValue.length()==4){ 41 | new SettingsPreferences(getActivity()).setSettingsPreferences(Integer.parseInt(pinValue)); 42 | Toast.makeText(getActivity(), "PIN Saved", Toast.LENGTH_SHORT).show(); 43 | }else{ 44 | Toast.makeText(getActivity(), "Invalid Pin", Toast.LENGTH_SHORT).show(); 45 | } 46 | } 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashFragments/SplashSettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.SplashFragments; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.util.TypedValue; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.AdapterView; 11 | import android.widget.ArrayAdapter; 12 | 13 | import com.chdev.ks.minx.R; 14 | import com.chdev.ks.minx.SettingsPreferences; 15 | import com.github.leonardoxh.customfont.FontText; 16 | import com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner; 17 | 18 | /** 19 | * Created by Kartik_ch on 9/4/2015. 20 | */ 21 | public class SplashSettingsFragment extends Fragment { 22 | 23 | FontText title, body; 24 | MaterialBetterSpinner titleSpinner, bodySpinner; 25 | String[] title_items, body_items; 26 | ArrayAdapter arrayAdapterTitle, arrayAdapterBody; 27 | 28 | @Nullable 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 31 | return inflater.inflate(R.layout.fragment_splash_settings, container, false); 32 | } 33 | 34 | @Override 35 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 36 | super.onActivityCreated(savedInstanceState); 37 | title= (FontText) getView().findViewById(R.id.tutorial_splash_title); 38 | body= (FontText) getView().findViewById(R.id.tutorial_splash_body); 39 | titleSpinner= (MaterialBetterSpinner) getView().findViewById(R.id.titleFontSizeSpinner); 40 | bodySpinner= (MaterialBetterSpinner) getView().findViewById(R.id.bodyFontSizeSpinner); 41 | title_items=getActivity().getResources().getStringArray(R.array.splash_title_entries); 42 | body_items=getActivity().getResources().getStringArray(R.array.splash_body_entries); 43 | arrayAdapterTitle=new ArrayAdapter(getActivity(), android.R.layout.simple_dropdown_item_1line, title_items); 44 | arrayAdapterBody=new ArrayAdapter(getActivity(), android.R.layout.simple_dropdown_item_1line, body_items); 45 | titleSpinner.setAdapter(arrayAdapterTitle); 46 | bodySpinner.setAdapter(arrayAdapterBody); 47 | setDefaultValues(); 48 | titleSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() { 49 | @Override 50 | public void onItemClick(AdapterView parent, View view, int position, long id) { 51 | setFontSize("title", title_items[position]); 52 | } 53 | }); 54 | bodySpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() { 55 | @Override 56 | public void onItemClick(AdapterView parent, View view, int position, long id) { 57 | setFontSize("body", body_items[position]); 58 | } 59 | }); 60 | } 61 | 62 | private void setDefaultValues() { 63 | new SettingsPreferences(getActivity(), "title").setSettingsPreferences("30"); 64 | new SettingsPreferences(getActivity(), "body").setSettingsPreferences("20"); 65 | new SettingsPreferences(getActivity()).setSettingsPreferences(-2); 66 | new SettingsPreferences(getActivity()).resetPINTemp(); 67 | } 68 | 69 | private void setFontSize(String type, String fontSize){ 70 | if(type.equals("title")){ 71 | SettingsPreferences settingsPreferences=new SettingsPreferences(getActivity(), "title"); 72 | settingsPreferences.setSettingsPreferences(fontSize); 73 | title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(fontSize)); 74 | }else{ 75 | if(type.equals("body")){ 76 | SettingsPreferences settingsPreferences=new SettingsPreferences(getActivity(), "body"); 77 | settingsPreferences.setSettingsPreferences(fontSize); 78 | body.setTextSize(TypedValue.COMPLEX_UNIT_SP, Float.parseFloat(fontSize)); 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashFragments/SplashTutorialFragment.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx.SplashFragments; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.RelativeLayout; 10 | 11 | import com.chdev.ks.minx.FadeAnimation; 12 | import com.chdev.ks.minx.R; 13 | 14 | /** 15 | * Created by Kartik_ch on 9/3/2015. 16 | */ 17 | public class SplashTutorialFragment extends Fragment { 18 | @Nullable 19 | @Override 20 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 21 | return inflater.inflate(R.layout.fragment_splash_tutorial, container, false); 22 | } 23 | 24 | @Override 25 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 26 | super.onActivityCreated(savedInstanceState); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/chdev/ks/minx/SplashViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chdev.ks.minx; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | import android.support.v4.view.PagerAdapter; 7 | 8 | import com.chdev.ks.minx.SplashFragments.SplashIntroFragment; 9 | import com.chdev.ks.minx.SplashFragments.SplashPinFragment; 10 | import com.chdev.ks.minx.SplashFragments.SplashSettingsFragment; 11 | import com.chdev.ks.minx.SplashFragments.SplashTutorialFragment; 12 | 13 | /** 14 | * Created by Kartik_ch on 9/1/2015. 15 | */ 16 | public class SplashViewPagerAdapter extends FragmentPagerAdapter { 17 | 18 | public SplashViewPagerAdapter(FragmentManager fm) { 19 | super(fm); 20 | } 21 | 22 | @Override 23 | public Fragment getItem(int position) { 24 | switch (position){ 25 | case 0:return new SplashIntroFragment(); 26 | case 1:return new SplashTutorialFragment(); 27 | case 2:return new SplashSettingsFragment(); 28 | case 3:return new SplashPinFragment(); 29 | default:return new SplashIntroFragment(); 30 | } 31 | } 32 | 33 | @Override 34 | public int getCount() { 35 | return 4; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_action_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-hdpi/ic_action_action_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-hdpi/ic_action_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_action_turned_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-hdpi/ic_action_action_turned_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_navigation_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-hdpi/ic_action_navigation_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-hdpi/ic_action_social_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_action_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-mdpi/ic_action_action_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-mdpi/ic_action_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_action_turned_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-mdpi/ic_action_action_turned_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_navigation_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-mdpi/ic_action_navigation_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-mdpi/ic_action_social_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_action_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xhdpi/ic_action_action_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xhdpi/ic_action_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_action_turned_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xhdpi/ic_action_action_turned_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_navigation_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xhdpi/ic_action_navigation_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xhdpi/ic_action_social_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_action_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxhdpi/ic_action_action_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxhdpi/ic_action_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_action_turned_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxhdpi/ic_action_action_turned_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_navigation_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxhdpi/ic_action_navigation_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxhdpi/ic_action_social_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_action_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxxhdpi/ic_action_action_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxxhdpi/ic_action_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_action_turned_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxxhdpi/ic_action_action_turned_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_navigation_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxxhdpi/ic_action_navigation_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable-xxxhdpi/ic_action_social_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/error_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/error_face.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/happy_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/happy_face.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/indicator_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/indicator_1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/indicator_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/indicator_2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/indicator_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/indicator_3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/indicator_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/indicator_4.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/minx_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/minx_small.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/sad_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/sad_face.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/search_tutorial_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/search_tutorial_small.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/share_tutorial_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyhitty/minx/ddcaedd628cb843dbce49c4354ab31e448f85f62/app/src/main/res/drawable/share_tutorial_small.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_error.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 19 | 20 | 29 | 30 | 42 | 43 | 44 | 50 | 51 | 57 | 58 |