├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── LICENSE ├── README.md ├── WP_News ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── ghasemi │ │ └── abbas │ │ └── wordpress │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── fonts │ │ │ └── sans.ttf │ ├── java │ │ └── ghasemi │ │ │ └── abbas │ │ │ └── wordpress │ │ │ ├── Application.java │ │ │ ├── BuildApp.java │ │ │ ├── api │ │ │ ├── ApiSeivice.java │ │ │ ├── CheckNetworkStatus.java │ │ │ ├── ConnectionManager.java │ │ │ ├── KeepRequestQueue.java │ │ │ └── ResultListener.java │ │ │ ├── general │ │ │ ├── SaveModel.java │ │ │ └── TinyData.java │ │ │ ├── support │ │ │ └── customtabs │ │ │ │ ├── CustomTabsCallback.java │ │ │ │ ├── CustomTabsClient.java │ │ │ │ ├── CustomTabsIntent.java │ │ │ │ ├── CustomTabsService.java │ │ │ │ ├── CustomTabsServiceConnection.java │ │ │ │ ├── CustomTabsSession.java │ │ │ │ ├── CustomTabsSessionToken.java │ │ │ │ ├── ICustomTabsCallback.java │ │ │ │ └── ICustomTabsService.java │ │ │ └── ui │ │ │ ├── LauncherActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── PhotoEditActivity.java │ │ │ ├── adapter │ │ │ ├── Holder.java │ │ │ ├── OnClickListener.java │ │ │ └── PostsAdapter.java │ │ │ └── fragment │ │ │ ├── AboutUs.java │ │ │ ├── BaseFragment.java │ │ │ ├── BookMark.java │ │ │ ├── Category.java │ │ │ ├── Comments.java │ │ │ ├── FinishListener.java │ │ │ ├── Home.java │ │ │ ├── Menu.java │ │ │ ├── Page.java │ │ │ ├── PostView.java │ │ │ ├── Search.java │ │ │ └── ShowCategory.java │ └── res │ │ ├── anim │ │ ├── fade_in.xml │ │ ├── fade_in_to_left.xml │ │ └── fade_out.xml │ │ ├── color │ │ └── bottom_nav_color.xml │ │ ├── drawable-hdpi │ │ ├── a.png │ │ ├── eraser.png │ │ ├── marker_pen.png │ │ ├── pen.png │ │ ├── redo.png │ │ ├── undo.png │ │ └── without_internet.png │ │ ├── drawable-night-xhdpi │ │ ├── msg_in.9.png │ │ └── msg_out.9.png │ │ ├── drawable-night-xxhdpi │ │ ├── msg_in.9.png │ │ └── msg_out.9.png │ │ ├── drawable-xhdpi │ │ ├── msg_in.9.png │ │ └── msg_out.9.png │ │ ├── drawable-xxhdpi │ │ ├── msg_in.9.png │ │ └── msg_out.9.png │ │ ├── drawable │ │ ├── alert_dialog_bg.xml │ │ ├── back_color.xml │ │ ├── back_row_main_2.xml │ │ ├── back_writer_post_row_main_2.xml │ │ ├── color.xml │ │ ├── dialog_sheet_bg.xml │ │ ├── ic_ac_unit.xml │ │ ├── ic_arrow_back.xml │ │ ├── ic_call.xml │ │ ├── ic_close.xml │ │ ├── ic_comment.xml │ │ ├── ic_done.xml │ │ ├── ic_folder.xml │ │ ├── ic_home.xml │ │ ├── ic_info_outline.xml │ │ ├── ic_insert_invitation.xml │ │ ├── ic_mail.xml │ │ ├── ic_menu.xml │ │ ├── ic_menu_share.xml │ │ ├── ic_mic.xml │ │ ├── ic_screen_share.xml │ │ ├── ic_search.xml │ │ ├── ic_storage.xml │ │ ├── ic_turned.xml │ │ ├── ic_turned_not.xml │ │ ├── ic_web.xml │ │ └── sad.png │ │ ├── font │ │ └── sans.ttf │ │ ├── layout │ │ ├── activity_luancher.xml │ │ ├── activity_photo_edit.xml │ │ ├── activity_splash.xml │ │ ├── dialog_select_night_mode.xml │ │ ├── fragment_about_us.xml │ │ ├── fragment_base_list.xml │ │ ├── fragment_comment.xml │ │ ├── fragment_list_main.xml │ │ ├── fragment_menu.xml │ │ ├── fragment_search.xml │ │ ├── fragment_show_post.xml │ │ ├── row_arshiv.xml │ │ ├── row_category.xml │ │ ├── row_comment_admin.xml │ │ ├── row_comment_user.xml │ │ ├── row_main_1.xml │ │ ├── row_main_2.xml │ │ └── row_main_3.xml │ │ ├── menu │ │ └── navigation.xml │ │ ├── mipmap │ │ └── ic_launcher.png │ │ ├── values-night-v21 │ │ └── styles.xml │ │ ├── values-night │ │ ├── colors.xml │ │ └── styles.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ ├── network_security_config.xml │ │ └── provider_paths.xml │ └── test │ └── java │ └── ghasemi │ └── abbas │ └── wordpress │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── media └── screenshot.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | Display your ***wordpress*** site as an application. 3 | 4 | ![](media/screenshot.gif) 5 | 6 | ## Getting started 7 | 8 | ### Setting up 9 | 10 | 0. Support for wordpress version 5.8 and above. 11 | 1. Add your site address in the build.gradle file that is relatad to the WP_News folder 12 | that is the end. 13 | 2. For more changes and personalising go to this path and edit BuildApp file ```ghasemi.abbas.wordpress```. 14 | 3. You are ready to compile application. 15 | 16 | ## Author & support 17 | This project was created by [Abbas Ghasemi](https://farasource.com/). 18 | > You can help us to keep my open source projects up to date! 19 | -------------------------------------------------------------------------------- /WP_News/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /WP_News/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | def api = 'https://blog.iranserver.com/' // YOUR SITE 6 | def packageName = "ghasemi.abbas.wordpress" 7 | def code = 41 8 | def name = "4.1" 9 | 10 | android { 11 | compileSdk 34 12 | 13 | defaultConfig { 14 | applicationId packageName 15 | versionCode code 16 | versionName name 17 | minSdk 24 18 | targetSdk 34 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled true 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | 29 | buildTypes.each { 30 | it.buildConfigField 'String', 'API', '\"' + api + '\"' 31 | } 32 | } 33 | 34 | compileOptions{ 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | sourceCompatibility JavaVersion.VERSION_1_8 37 | } 38 | buildToolsVersion '33.0.0' 39 | } 40 | 41 | dependencies { 42 | implementation fileTree(dir: 'libs', include: ['*.jar']) 43 | androidTestImplementation 'androidx.test.ext:junit:1.1.5' 44 | androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1') 45 | testImplementation 'junit:junit:4.13.2' 46 | implementation(platform('org.jetbrains.kotlin:kotlin-bom:1.9.10')) 47 | implementation 'androidx.appcompat:appcompat:1.6.1' 48 | implementation 'com.google.android.material:material:1.9.0' 49 | implementation 'androidx.cardview:cardview:1.0.0' 50 | implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' 51 | implementation 'com.github.Guilherme-HRamos:Easy-Save:1.2.1' 52 | implementation 'com.burhanrashid52:photoeditor:3.0.1' 53 | implementation 'com.android.volley:volley:1.2.1' 54 | implementation 'com.github.bumptech.glide:glide:4.16.0' 55 | annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0' 56 | } -------------------------------------------------------------------------------- /WP_News/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\HiCell\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 | 19 | -keep public class * implements com.bumptech.glide.module.GlideModule 20 | -keep class * extends com.bumptech.glide.module.AppGlideModule { 21 | (...); 22 | } 23 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { 24 | **[] $VALUES; 25 | public *; 26 | } 27 | -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { 28 | *** rewind(); 29 | } 30 | 31 | # Uncomment for DexGuard only 32 | #-keepresourcexmlelements manifest/application/meta-data@value=GlideModule 33 | 34 | -------------------------------------------------------------------------------- /WP_News/src/androidTest/java/ghasemi/abbas/wordpress/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package ghasemi.abbas.wordpress; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | assertEquals("ghasemi.abbas.wordpress", appContext.getPackageName()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /WP_News/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 40 | 41 | 46 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /WP_News/src/main/assets/fonts/sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/assets/fonts/sans.ttf -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress; 6 | 7 | import android.annotation.SuppressLint; 8 | import android.content.Context; 9 | 10 | import androidx.appcompat.app.AppCompatDelegate; 11 | import br.vince.easysave.EasySave; 12 | import ghasemi.abbas.wordpress.general.TinyData; 13 | 14 | public class Application extends android.app.Application { 15 | 16 | @SuppressLint("StaticFieldLeak") 17 | public static Context context; 18 | @SuppressLint("StaticFieldLeak") 19 | public static EasySave easySave; 20 | 21 | @Override 22 | public void onCreate() { 23 | super.onCreate(); 24 | 25 | context = getApplicationContext(); 26 | easySave = new EasySave(context); 27 | 28 | checkNightMode(); 29 | 30 | distoryCashe(); 31 | } 32 | 33 | private void checkNightMode() { 34 | String nightMode = TinyData.getInstance().getString("nightMode", "system"); 35 | if (nightMode.equals("system")) { 36 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); 37 | } else if (nightMode.equals("off")) { 38 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); 39 | } else { 40 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); 41 | } 42 | } 43 | 44 | private void distoryCashe() { 45 | long timeNow = System.currentTimeMillis(); 46 | String keys = TinyData.getInstance().getString("cashe_info"); 47 | if (keys.isEmpty()) { 48 | return; 49 | } 50 | long timer = BuildApp.timeDistoryCashe * 30 * 1000; 51 | String[] data = keys.split("::"); 52 | StringBuilder newKeys = new StringBuilder(); 53 | for (String key : data) { 54 | key = key.replace(":", ""); 55 | String time = TinyData.getInstance().getString("time_last_" + key); 56 | if (timeNow - Long.parseLong(time) >= timer) { 57 | easySave.saveModel(key, null); 58 | } else { 59 | newKeys.append(":").append(key).append(":"); 60 | } 61 | } 62 | TinyData.getInstance().putString("cashe_info", newKeys.toString()); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/BuildApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress; 6 | 7 | import android.app.Activity; 8 | import android.content.Intent; 9 | import android.net.Uri; 10 | 11 | import androidx.appcompat.app.AlertDialog; 12 | 13 | import android.util.DisplayMetrics; 14 | 15 | import java.util.HashMap; 16 | 17 | import ghasemi.abbas.wordpress.general.SaveModel; 18 | import ghasemi.abbas.wordpress.ui.MainActivity; 19 | import ghasemi.abbas.wordpress.support.customtabs.CustomTabsIntent; 20 | 21 | public class BuildApp { 22 | 23 | public static String authorName = "abbas ghasemi"; 24 | public static String mail = ""; 25 | public static String phone = ""; 26 | public static String telegram = "https://t.me/telegram"; // می تونی آدرس پیامرسان یا سایت های دیگری مثل آپارات ، سایت خودتون و ... را قرار دهی. 27 | public static String instagram = "https://instagram.com/p/instagram";// می تونی آدرس پیامرسان یا سایت های دیگری مثل آپارات ، سایت خودتون و ... را قرار دهی 28 | public static String fontName = "sans"; 29 | public static String download = "https://cafebazaar.ir/app/" + Application.context.getPackageName(); 30 | public static String siteName = "کافه بازار"; // متناسب با linkDownload تغییر نماید. 31 | public static int showType = 2; // 1 or 2 or 3 32 | public static boolean showSplash = true; // true or false 33 | public static int splashTime = 1; // Second ,example 1 - 4 34 | public static boolean doubleClickForExit = true; // true or false 35 | public static boolean divider = false; // true or false 36 | public static int limitPage = 10; // 10 37 | public static int timeout = 12; // second 38 | public static int timeDistoryCashe = 5; // 5 minute 39 | public static boolean enablePage = true; 40 | 41 | ///////// Don't Change ///////// 42 | public static void Share() { 43 | try { 44 | Intent intent = new Intent(Intent.ACTION_SEND); 45 | intent.putExtra(Intent.EXTRA_TEXT, "اپلیکیشن " + MainActivity.activity.getResources().getString(R.string.app_name) + " رو از " + BuildApp.siteName + " دانلود کن:\n" + BuildApp.download); 46 | intent.setType("text/*"); 47 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 48 | MainActivity.activity.startActivity(Intent.createChooser(intent, "برنامه ای را جهت ارسال انتخاب نمائید")); 49 | } catch (Exception e) { 50 | // 51 | } 52 | } 53 | 54 | public static void setViewSite(Activity activity, String url) { 55 | Uri uri = Uri.parse(url); 56 | CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder(); 57 | intentBuilder.setToolbarColor(activity.getTheme().getResources().getColor( R.color.colorPrimary)); 58 | intentBuilder.setSecondaryToolbarColor(activity.getTheme().getResources().getColor(R.color.colorPrimaryDark)); 59 | intentBuilder.setStartAnimations(activity, R.anim.fade_in, R.anim.fade_out); 60 | CustomTabsIntent customTabsIntent = intentBuilder.build(); 61 | customTabsIntent.launchUrl(activity, uri); 62 | } 63 | 64 | public static void addBookMark(SaveModel saveModel) { 65 | SaveModel newSaveModel = Application.easySave.retrieveModel("book_mark_info", SaveModel.class); 66 | if (newSaveModel != null) { 67 | saveModel.hashMapList.addAll(newSaveModel.hashMapList); 68 | } 69 | Application.easySave.saveModel("book_mark_info", saveModel); 70 | } 71 | 72 | public static void removeBookMark(String id) { 73 | SaveModel saveModel = Application.easySave.retrieveModel("book_mark_info", SaveModel.class); 74 | if (saveModel != null) { 75 | SaveModel newSaveModel = new SaveModel(); 76 | for (HashMap hashMap : saveModel.hashMapList) { 77 | if (!hashMap.get("id").equals(id)) { 78 | newSaveModel.hashMapList.add(hashMap); 79 | } 80 | } 81 | Application.easySave.saveModel("book_mark_info", newSaveModel.hashMapList.isEmpty() ? null : newSaveModel); 82 | } 83 | } 84 | 85 | public static boolean hasID(String id) { 86 | SaveModel saveModel = Application.easySave.retrieveModel("book_mark_info", SaveModel.class); 87 | if (saveModel != null) { 88 | for (HashMap hashMap : saveModel.hashMapList) { 89 | if (hashMap.get("id").equals(id)) { 90 | return true; 91 | } 92 | } 93 | } 94 | return false; 95 | } 96 | 97 | public static int getCountPx() { 98 | DisplayMetrics displayMetrics = Application.context.getResources().getDisplayMetrics(); 99 | return (int) (displayMetrics.widthPixels / displayMetrics.density / 140); 100 | } 101 | 102 | public static void setCustomDialog(AlertDialog alertDialog) { 103 | alertDialog.getWindow().setBackgroundDrawableResource(R.drawable.alert_dialog_bg); 104 | } 105 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/api/ApiSeivice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.api; 6 | 7 | import ghasemi.abbas.wordpress.BuildConfig; 8 | import ghasemi.abbas.wordpress.BuildApp; 9 | 10 | public class ApiSeivice { 11 | 12 | private final static String api; 13 | 14 | static { 15 | if (BuildConfig.API.endsWith("/")) { 16 | api = BuildConfig.API + "wp-json/wp/v2/"; 17 | } else { 18 | api = BuildConfig.API + "/wp-json/wp/v2/"; 19 | } 20 | } 21 | 22 | public static String getCategoryPosts(String id, String page) { 23 | return api + "posts?" + "categories=" + id + "&per_page=" + BuildApp.limitPage + "&page=" + page; 24 | } 25 | 26 | public static String getCategoryIndex() { 27 | return api + "categories?per_page=100"; 28 | } 29 | 30 | public static String getPageIndex() { 31 | return api + "pages?per_page=100"; 32 | } 33 | 34 | public static String getSearchResults(String search, String page) { 35 | return api + "search?" + "per_page=" + BuildApp.limitPage + "&search=" + search + "&page=" + page; 36 | } 37 | 38 | public static String getPost(String post) { 39 | return api + "posts/" + post; 40 | } 41 | 42 | public static String getPosts(String page) { 43 | return api + "posts?" + "per_page=" + BuildApp.limitPage + "&page=" + page; 44 | } 45 | 46 | public static String getComments(String id, String page) { 47 | return api + "comments?" + "post=" + id + "&per_page=" + /*BuildApp.LimitPage*/ 100 + "&page=" + page; 48 | } 49 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/api/CheckNetworkStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.api; 6 | 7 | import android.content.Context; 8 | import android.net.ConnectivityManager; 9 | import android.net.NetworkInfo; 10 | 11 | import ghasemi.abbas.wordpress.Application; 12 | 13 | public class CheckNetworkStatus { 14 | 15 | public static boolean isOnline() { 16 | 17 | ConnectivityManager connectivityManager = (ConnectivityManager) Application.context.getSystemService(Context.CONNECTIVITY_SERVICE); 18 | if (connectivityManager == null) { 19 | return false; 20 | } 21 | boolean wifi = false, network = false; 22 | NetworkInfo _network = connectivityManager.getActiveNetworkInfo(); 23 | if (_network != null) { 24 | network = _network.isConnectedOrConnecting(); 25 | 26 | } 27 | NetworkInfo _wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 28 | if (_wifi != null) { 29 | wifi = _wifi.isConnectedOrConnecting(); 30 | } 31 | NetworkInfo _mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); 32 | if (_mobile != null) { 33 | network = _mobile.isConnectedOrConnecting(); 34 | } 35 | return network || wifi; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/api/ConnectionManager.java: -------------------------------------------------------------------------------- 1 | package ghasemi.abbas.wordpress.api; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.android.volley.DefaultRetryPolicy; 6 | import com.android.volley.toolbox.StringRequest; 7 | 8 | import org.json.JSONArray; 9 | import org.json.JSONException; 10 | 11 | import java.io.UnsupportedEncodingException; 12 | import java.net.URLEncoder; 13 | 14 | 15 | import ghasemi.abbas.wordpress.ui.MainActivity; 16 | import ghasemi.abbas.wordpress.BuildApp; 17 | 18 | public class ConnectionManager { 19 | 20 | private String url; 21 | private String params; 22 | private int timeOut = BuildApp.timeout * 1000; 23 | 24 | private ConnectionManager() { 25 | } 26 | 27 | public static class Builder { 28 | private ConnectionManager connectionManager; 29 | 30 | public Builder() { 31 | connectionManager = new ConnectionManager(); 32 | } 33 | 34 | public Builder setURL(String url) { 35 | connectionManager.url = url; 36 | return this; 37 | } 38 | 39 | public Builder addParams(String key, Object value) { 40 | if (TextUtils.isEmpty(connectionManager.params)) { 41 | connectionManager.params = "?" + key + "=" + connectionManager.encodeUrl(value.toString()); 42 | } else { 43 | connectionManager.params += "&" + key + "=" + connectionManager.encodeUrl(value.toString()); 44 | } 45 | return this; 46 | } 47 | 48 | public void request(ResultConnection resultConnection) { 49 | if (!TextUtils.isEmpty(connectionManager.params)) { 50 | connectionManager.url += connectionManager.params; 51 | } 52 | connectionManager.stringRequest(resultConnection); 53 | } 54 | } 55 | 56 | private void stringRequest(ResultConnection resultConnection) { 57 | StringRequest stringRequest = new StringRequest(0, url, response -> MainActivity.activity.runOnUiThread(() -> { 58 | try { 59 | String object = response.trim(); 60 | if (object.startsWith("{")) { 61 | object = "[" + object + "]"; 62 | } 63 | resultConnection.onSuccess(new JSONArray(object)); 64 | } catch (JSONException e) { 65 | resultConnection.onFail(e.toString()); 66 | } 67 | }), error -> MainActivity.activity.runOnUiThread(() -> resultConnection.onFail(error.toString()))); 68 | stringRequest.setRetryPolicy(new DefaultRetryPolicy(timeOut, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); 69 | KeepRequestQueue.newKeepRequestQueue(MainActivity.activity.getApplicationContext()).add(stringRequest); 70 | } 71 | 72 | 73 | private String encodeUrl(String data) { 74 | try { 75 | return URLEncoder.encode(data, "utf-8"); 76 | } catch (UnsupportedEncodingException e) { 77 | return ""; 78 | } 79 | } 80 | 81 | public interface ResultConnection { 82 | void onSuccess(JSONArray jsonArray) throws JSONException; 83 | 84 | void onFail(String error); 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/api/KeepRequestQueue.java: -------------------------------------------------------------------------------- 1 | package ghasemi.abbas.wordpress.api; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | 6 | import com.android.volley.Request; 7 | import com.android.volley.RequestQueue; 8 | import com.android.volley.toolbox.Volley; 9 | 10 | public class KeepRequestQueue { 11 | 12 | private RequestQueue requestQueue; 13 | @SuppressLint("StaticFieldLeak") 14 | private static KeepRequestQueue keepRequestQueue; 15 | private Context context; 16 | 17 | private KeepRequestQueue(Context context) { 18 | this.context = context; 19 | } 20 | 21 | public static synchronized KeepRequestQueue newKeepRequestQueue(Context context) { 22 | if (keepRequestQueue == null) { 23 | keepRequestQueue = new KeepRequestQueue(context); 24 | } 25 | return keepRequestQueue; 26 | } 27 | 28 | private RequestQueue getRequestQueue() { 29 | if (requestQueue == null) { 30 | requestQueue = Volley.newRequestQueue(context); 31 | } 32 | return requestQueue; 33 | } 34 | 35 | public Request add(Request request) { 36 | return getRequestQueue().add(request); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/api/ResultListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.api; 6 | 7 | import org.json.JSONArray; 8 | 9 | public interface ResultListener { 10 | void onResult(boolean isSuccess, String msg, JSONArray jsonArray,int id); 11 | } 12 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/general/SaveModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.general; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | 11 | public class SaveModel { 12 | 13 | public List> hashMapList = new ArrayList<>(); 14 | public int page = 1; 15 | public boolean hasNext = false; 16 | 17 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/general/TinyData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.general; 6 | 7 | import android.content.Context; 8 | import android.content.SharedPreferences; 9 | import android.preference.PreferenceManager; 10 | 11 | import ghasemi.abbas.wordpress.Application; 12 | 13 | public class TinyData { 14 | 15 | private static TinyData tinyData; 16 | private SharedPreferences sharedPreferences; 17 | 18 | public static TinyData getInstance() { 19 | if (tinyData == null) { 20 | tinyData = new TinyData(Application.context); 21 | } 22 | return tinyData; 23 | } 24 | 25 | private TinyData(Context context) { 26 | sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 27 | } 28 | 29 | public void putString(String key, String v) { 30 | sharedPreferences.edit().putString(key, v).apply(); 31 | } 32 | 33 | public void putStringCashe(String key) { 34 | String data = getString("cashe_info"); 35 | if (!data.contains(key)) { 36 | String k = data + ":" + key + ":"; 37 | putString("cashe_info", k); 38 | } 39 | putString("time_last_" + key, String.valueOf(System.currentTimeMillis())); 40 | } 41 | 42 | public String getString(String key) { 43 | return getString(key, ""); 44 | } 45 | 46 | public String getString(String key, String value) { 47 | return sharedPreferences.getString(key, value); 48 | } 49 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.os.Bundle; 20 | 21 | /** 22 | * A callback class for custom tabs client to get messages regarding events in their custom tabs. 23 | */ 24 | public class CustomTabsCallback { 25 | public static final int NAVIGATION_STARTED = 1; 26 | public static final int NAVIGATION_FINISHED = 2; 27 | public static final int NAVIGATION_FAILED = 3; 28 | public static final int NAVIGATION_ABORTED = 4; 29 | public static final int TAB_SHOWN = 5; 30 | public static final int TAB_HIDDEN = 6; 31 | 32 | public CustomTabsCallback() { 33 | } 34 | 35 | public void onNavigationEvent(int navigationEvent, Bundle extras) { 36 | } 37 | 38 | public void extraCallback(String callbackName, Bundle args) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.content.ComponentName; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.os.Bundle; 23 | import android.os.RemoteException; 24 | import android.text.TextUtils; 25 | 26 | public class CustomTabsClient { 27 | private final ICustomTabsService mService; 28 | private final ComponentName mServiceComponentName; 29 | 30 | CustomTabsClient(ICustomTabsService service, ComponentName componentName) { 31 | this.mService = service; 32 | this.mServiceComponentName = componentName; 33 | } 34 | 35 | public static boolean bindCustomTabsService(Context context, String packageName, CustomTabsServiceConnection connection) { 36 | Intent intent = new Intent("android.support.customtabs.action.CustomTabsService"); 37 | if (!TextUtils.isEmpty(packageName)) { 38 | intent.setPackage(packageName); 39 | } 40 | 41 | return context.bindService(intent, connection, 33); 42 | } 43 | 44 | public boolean warmup(long flags) { 45 | try { 46 | return this.mService.warmup(flags); 47 | } catch (RemoteException var4) { 48 | return false; 49 | } 50 | } 51 | 52 | public CustomTabsSession newSession(final CustomTabsCallback callback) { 53 | ICustomTabsCallback.Stub wrapper = new ICustomTabsCallback.Stub() { 54 | public void onNavigationEvent(int navigationEvent, Bundle extras) { 55 | if (callback != null) { 56 | callback.onNavigationEvent(navigationEvent, extras); 57 | } 58 | 59 | } 60 | 61 | public void extraCallback(String callbackName, Bundle args) throws RemoteException { 62 | if (callback != null) { 63 | callback.extraCallback(callbackName, args); 64 | } 65 | 66 | } 67 | }; 68 | 69 | try { 70 | if (!this.mService.newSession(wrapper)) { 71 | return null; 72 | } 73 | } catch (RemoteException var4) { 74 | return null; 75 | } 76 | 77 | return new CustomTabsSession(this.mService, wrapper, this.mServiceComponentName); 78 | } 79 | 80 | public Bundle extraCommand(String commandName, Bundle args) { 81 | try { 82 | return this.mService.extraCommand(commandName, args); 83 | } catch (RemoteException var4) { 84 | return null; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.app.Service; 20 | import android.content.Intent; 21 | import android.net.Uri; 22 | import android.os.Bundle; 23 | import android.os.IBinder; 24 | import android.os.IBinder.DeathRecipient; 25 | import android.os.RemoteException; 26 | import androidx.collection.ArrayMap; 27 | 28 | import java.util.List; 29 | import java.util.Map; 30 | import java.util.NoSuchElementException; 31 | 32 | public abstract class CustomTabsService extends Service { 33 | public static final String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService"; 34 | public static final String KEY_URL = "android.support.customtabs.otherurls.URL"; 35 | private final Map mDeathRecipientMap = new ArrayMap(); 36 | private ICustomTabsService.Stub mBinder = new ICustomTabsService.Stub() { 37 | public boolean warmup(long flags) { 38 | return CustomTabsService.this.warmup(flags); 39 | } 40 | 41 | public boolean newSession(ICustomTabsCallback callback) { 42 | final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback); 43 | 44 | try { 45 | DeathRecipient e = new DeathRecipient() { 46 | public void binderDied() { 47 | CustomTabsService.this.cleanUpSession(sessionToken); 48 | } 49 | }; 50 | synchronized (CustomTabsService.this.mDeathRecipientMap) { 51 | callback.asBinder().linkToDeath(e, 0); 52 | CustomTabsService.this.mDeathRecipientMap.put(callback.asBinder(), e); 53 | } 54 | 55 | return CustomTabsService.this.newSession(sessionToken); 56 | } catch (RemoteException var7) { 57 | return false; 58 | } 59 | } 60 | 61 | public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List otherLikelyBundles) { 62 | return CustomTabsService.this.mayLaunchUrl(new CustomTabsSessionToken(callback), url, extras, otherLikelyBundles); 63 | } 64 | 65 | public Bundle extraCommand(String commandName, Bundle args) { 66 | return CustomTabsService.this.extraCommand(commandName, args); 67 | } 68 | 69 | public boolean updateVisuals(ICustomTabsCallback callback, Bundle bundle) { 70 | return CustomTabsService.this.updateVisuals(new CustomTabsSessionToken(callback), bundle); 71 | } 72 | }; 73 | 74 | public CustomTabsService() { 75 | } 76 | 77 | public IBinder onBind(Intent intent) { 78 | return this.mBinder; 79 | } 80 | 81 | protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) { 82 | try { 83 | Map e = this.mDeathRecipientMap; 84 | synchronized (this.mDeathRecipientMap) { 85 | IBinder binder = sessionToken.getCallbackBinder(); 86 | DeathRecipient deathRecipient = this.mDeathRecipientMap.get(binder); 87 | binder.unlinkToDeath(deathRecipient, 0); 88 | this.mDeathRecipientMap.remove(binder); 89 | return true; 90 | } 91 | } catch (NoSuchElementException var7) { 92 | return false; 93 | } 94 | } 95 | 96 | protected abstract boolean warmup(long var1); 97 | 98 | protected abstract boolean newSession(CustomTabsSessionToken var1); 99 | 100 | protected abstract boolean mayLaunchUrl(CustomTabsSessionToken var1, Uri var2, Bundle var3, List var4); 101 | 102 | protected abstract Bundle extraCommand(String var1, Bundle var2); 103 | 104 | protected abstract boolean updateVisuals(CustomTabsSessionToken var1, Bundle var2); 105 | } 106 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsServiceConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.content.ComponentName; 20 | import android.content.ServiceConnection; 21 | import android.os.IBinder; 22 | 23 | public abstract class CustomTabsServiceConnection implements ServiceConnection { 24 | public CustomTabsServiceConnection() { 25 | } 26 | 27 | public final void onServiceConnected(final ComponentName name, IBinder service) { 28 | this.onCustomTabsServiceConnected(name, new CustomTabsClient(ICustomTabsService.Stub.asInterface(service), name) { 29 | }); 30 | } 31 | 32 | public abstract void onCustomTabsServiceConnected(ComponentName var1, CustomTabsClient var2); 33 | } 34 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.content.ComponentName; 20 | import android.graphics.Bitmap; 21 | import android.net.Uri; 22 | import android.os.Bundle; 23 | import android.os.IBinder; 24 | import android.os.RemoteException; 25 | import androidx.annotation.NonNull; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * A class to be used for Custom Tabs related communication. Clients that want to launch Custom Tabs 31 | * can use this class exclusively to handle all related communication. 32 | */ 33 | public final class CustomTabsSession { 34 | private static final String TAG = "CustomTabsSession"; 35 | private final ICustomTabsService mService; 36 | private final ICustomTabsCallback mCallback; 37 | private final ComponentName mComponentName; 38 | 39 | CustomTabsSession(ICustomTabsService service, ICustomTabsCallback callback, ComponentName componentName) { 40 | this.mService = service; 41 | this.mCallback = callback; 42 | this.mComponentName = componentName; 43 | } 44 | 45 | public boolean mayLaunchUrl(Uri url, Bundle extras, List otherLikelyBundles) { 46 | try { 47 | return this.mService.mayLaunchUrl(this.mCallback, url, extras, otherLikelyBundles); 48 | } catch (RemoteException var5) { 49 | return false; 50 | } 51 | } 52 | 53 | public boolean setActionButton(@NonNull Bitmap icon, @NonNull String description) { 54 | return this.setToolbarItem(0, icon, description); 55 | } 56 | 57 | public boolean setToolbarItem(int id, @NonNull Bitmap icon, @NonNull String description) { 58 | Bundle bundle = new Bundle(); 59 | bundle.putInt("android.support.customtabs.customaction.ID", id); 60 | bundle.putParcelable("android.support.customtabs.customaction.ICON", icon); 61 | bundle.putString("android.support.customtabs.customaction.DESCRIPTION", description); 62 | Bundle metaBundle = new Bundle(); 63 | metaBundle.putBundle("android.support.customtabs.extra.ACTION_BUTTON_BUNDLE", bundle); 64 | 65 | try { 66 | return this.mService.updateVisuals(this.mCallback, metaBundle); 67 | } catch (RemoteException var7) { 68 | return false; 69 | } 70 | } 71 | 72 | IBinder getBinder() { 73 | return this.mCallback.asBinder(); 74 | } 75 | 76 | ComponentName getComponentName() { 77 | return this.mComponentName; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/CustomTabsSessionToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | import android.os.IBinder; 22 | import android.os.RemoteException; 23 | import androidx.core.app.BundleCompat; 24 | import android.util.Log; 25 | 26 | /** 27 | * Wrapper class that can be used as a unique identifier for a session. Also contains an accessor 28 | * for the {@link CustomTabsCallback} for the session if there was any. 29 | */ 30 | public class CustomTabsSessionToken { 31 | private static final String TAG = "CustomTabsSessionToken"; 32 | private final ICustomTabsCallback mCallbackBinder; 33 | private final CustomTabsCallback mCallback; 34 | 35 | public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) { 36 | Bundle b = intent.getExtras(); 37 | IBinder binder = BundleCompat.getBinder(b, "android.support.customtabs.extra.SESSION"); 38 | return binder == null ? null : new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder)); 39 | } 40 | 41 | CustomTabsSessionToken(ICustomTabsCallback callbackBinder) { 42 | this.mCallbackBinder = callbackBinder; 43 | this.mCallback = new CustomTabsCallback() { 44 | public void onNavigationEvent(int navigationEvent, Bundle extras) { 45 | try { 46 | CustomTabsSessionToken.this.mCallbackBinder.onNavigationEvent(navigationEvent, extras); 47 | } catch (RemoteException var4) { 48 | Log.e("CustomTabsSessionToken", "RemoteException during ICustomTabsCallback transaction"); 49 | } 50 | 51 | } 52 | }; 53 | } 54 | 55 | IBinder getCallbackBinder() { 56 | return this.mCallbackBinder.asBinder(); 57 | } 58 | 59 | public int hashCode() { 60 | return this.getCallbackBinder().hashCode(); 61 | } 62 | 63 | public boolean equals(Object o) { 64 | if (!(o instanceof CustomTabsSessionToken)) { 65 | return false; 66 | } else { 67 | CustomTabsSessionToken token = (CustomTabsSessionToken) o; 68 | return token.getCallbackBinder().equals(this.mCallbackBinder.asBinder()); 69 | } 70 | } 71 | 72 | public CustomTabsCallback getCallback() { 73 | return this.mCallback; 74 | } 75 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/support/customtabs/ICustomTabsCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ghasemi.abbas.wordpress.support.customtabs; 18 | 19 | import android.os.Binder; 20 | import android.os.Bundle; 21 | import android.os.IBinder; 22 | import android.os.IInterface; 23 | import android.os.Parcel; 24 | import android.os.RemoteException; 25 | 26 | public interface ICustomTabsCallback extends IInterface { 27 | void onNavigationEvent(int var1, Bundle var2) throws RemoteException; 28 | 29 | void extraCallback(String var1, Bundle var2) throws RemoteException; 30 | 31 | abstract class Stub extends Binder implements ICustomTabsCallback { 32 | private static final String DESCRIPTOR = "android.support.customtabs.ICustomTabsCallback"; 33 | static final int TRANSACTION_onNavigationEvent = 2; 34 | static final int TRANSACTION_extraCallback = 3; 35 | 36 | public Stub() { 37 | this.attachInterface(this, "android.support.customtabs.ICustomTabsCallback"); 38 | } 39 | 40 | public static ICustomTabsCallback asInterface(IBinder obj) { 41 | if (obj == null) { 42 | return null; 43 | } else { 44 | IInterface iin = obj.queryLocalInterface("android.support.customtabs.ICustomTabsCallback"); 45 | return (iin != null && iin instanceof ICustomTabsCallback ? (ICustomTabsCallback) iin : new Proxy(obj)); 46 | } 47 | } 48 | 49 | public IBinder asBinder() { 50 | return this; 51 | } 52 | 53 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { 54 | Bundle _arg1; 55 | switch (code) { 56 | case 2: 57 | data.enforceInterface("android.support.customtabs.ICustomTabsCallback"); 58 | int _arg01 = data.readInt(); 59 | if (0 != data.readInt()) { 60 | _arg1 = Bundle.CREATOR.createFromParcel(data); 61 | } else { 62 | _arg1 = null; 63 | } 64 | 65 | this.onNavigationEvent(_arg01, _arg1); 66 | return true; 67 | case 3: 68 | data.enforceInterface("android.support.customtabs.ICustomTabsCallback"); 69 | String _arg0 = data.readString(); 70 | if (0 != data.readInt()) { 71 | _arg1 = Bundle.CREATOR.createFromParcel(data); 72 | } else { 73 | _arg1 = null; 74 | } 75 | 76 | this.extraCallback(_arg0, _arg1); 77 | return true; 78 | case 1598968902: 79 | reply.writeString("android.support.customtabs.ICustomTabsCallback"); 80 | return true; 81 | default: 82 | return super.onTransact(code, data, reply, flags); 83 | } 84 | } 85 | 86 | private static class Proxy implements ICustomTabsCallback { 87 | private IBinder mRemote; 88 | 89 | Proxy(IBinder remote) { 90 | this.mRemote = remote; 91 | } 92 | 93 | public IBinder asBinder() { 94 | return this.mRemote; 95 | } 96 | 97 | public String getInterfaceDescriptor() { 98 | return "android.support.customtabs.ICustomTabsCallback"; 99 | } 100 | 101 | public void onNavigationEvent(int navigationEvent, Bundle extras) throws RemoteException { 102 | Parcel _data = Parcel.obtain(); 103 | 104 | try { 105 | _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); 106 | _data.writeInt(navigationEvent); 107 | if (extras != null) { 108 | _data.writeInt(1); 109 | extras.writeToParcel(_data, 0); 110 | } else { 111 | _data.writeInt(0); 112 | } 113 | 114 | this.mRemote.transact(2, _data, null, 1); 115 | } finally { 116 | _data.recycle(); 117 | } 118 | 119 | } 120 | 121 | public void extraCallback(String callbackName, Bundle args) throws RemoteException { 122 | Parcel _data = Parcel.obtain(); 123 | 124 | try { 125 | _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); 126 | _data.writeString(callbackName); 127 | if (args != null) { 128 | _data.writeInt(1); 129 | args.writeToParcel(_data, 0); 130 | } else { 131 | _data.writeInt(0); 132 | } 133 | 134 | this.mRemote.transact(3, _data, null, 1); 135 | } finally { 136 | _data.recycle(); 137 | } 138 | 139 | } 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/LauncherActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui; 6 | 7 | import android.content.Intent; 8 | import android.os.Bundle; 9 | import android.os.Handler; 10 | 11 | import androidx.appcompat.app.AppCompatActivity; 12 | 13 | import android.os.Looper; 14 | import android.widget.Toast; 15 | 16 | import ghasemi.abbas.wordpress.R; 17 | import ghasemi.abbas.wordpress.api.CheckNetworkStatus; 18 | 19 | import static ghasemi.abbas.wordpress.BuildApp.showSplash; 20 | import static ghasemi.abbas.wordpress.BuildApp.splashTime; 21 | 22 | public class LauncherActivity extends AppCompatActivity { 23 | 24 | @Override 25 | protected void onCreate(Bundle superSave) { 26 | super.onCreate(superSave); 27 | 28 | if (!showSplash) { 29 | main(); 30 | return; 31 | } 32 | 33 | setContentView(R.layout.activity_splash); 34 | if (!CheckNetworkStatus.isOnline()) 35 | Toast.makeText(this, "شبکه در دسترس نیست!", Toast.LENGTH_SHORT).show(); 36 | new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { 37 | @Override 38 | public void run() { 39 | main(); 40 | } 41 | }, splashTime * 1000); 42 | } 43 | 44 | private void main() { 45 | if (isFinishing()) { 46 | return; 47 | } 48 | startActivity(new Intent(LauncherActivity.this, MainActivity.class)); 49 | overridePendingTransition(R.anim.fade_in, R.anim.fade_out); 50 | finish(); 51 | } 52 | 53 | @Override 54 | public void onBackPressed() { 55 | finish(); 56 | } 57 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui; 6 | 7 | import android.annotation.SuppressLint; 8 | import android.content.DialogInterface; 9 | import android.os.Bundle; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.fragment.app.Fragment; 13 | import androidx.appcompat.app.AlertDialog; 14 | import androidx.appcompat.app.AppCompatActivity; 15 | 16 | import android.view.MenuItem; 17 | import android.view.View; 18 | import android.widget.ImageView; 19 | import android.widget.LinearLayout; 20 | import android.widget.Toast; 21 | 22 | import com.google.android.material.bottomnavigation.BottomNavigationView; 23 | import com.google.android.material.navigation.NavigationBarView; 24 | 25 | import java.util.Date; 26 | 27 | import androidx.viewpager2.adapter.FragmentStateAdapter; 28 | import androidx.viewpager2.widget.ViewPager2; 29 | 30 | import ghasemi.abbas.wordpress.R; 31 | import ghasemi.abbas.wordpress.ui.fragment.BaseFragment; 32 | import ghasemi.abbas.wordpress.ui.fragment.BookMark; 33 | import ghasemi.abbas.wordpress.ui.fragment.Category; 34 | import ghasemi.abbas.wordpress.ui.fragment.Home; 35 | import ghasemi.abbas.wordpress.ui.fragment.Menu; 36 | import ghasemi.abbas.wordpress.ui.fragment.Search; 37 | import ghasemi.abbas.wordpress.ui.fragment.FinishListener; 38 | import ghasemi.abbas.wordpress.ui.adapter.OnClickListener; 39 | 40 | import static ghasemi.abbas.wordpress.BuildApp.doubleClickForExit; 41 | 42 | public class MainActivity extends AppCompatActivity { 43 | @SuppressLint("StaticFieldLeak") 44 | public static MainActivity activity; 45 | ViewPager2 viewPager; 46 | long preTime; 47 | BottomNavigationView bottomBar; 48 | LinearLayout bottomBarPost; 49 | ImageView share, screen, comments, fav, web; 50 | OnClickListener onClickListener; 51 | BaseFragment[] baseFragments = new BaseFragment[5]; 52 | FinishListener finishListener; 53 | 54 | @Override 55 | protected void onCreate(Bundle superSave) { 56 | super.onCreate(superSave); 57 | activity = this; 58 | init(); 59 | } 60 | 61 | private void init() { 62 | setContentView(R.layout.activity_luancher); 63 | viewPager = findViewById(R.id.contentContainer); 64 | viewPager.setOffscreenPageLimit(4); 65 | viewPager.setUserInputEnabled(false); 66 | viewPager.setAdapter(new FragmentStateAdapter(this) { 67 | 68 | @Override 69 | public Fragment createFragment(int position) { 70 | switch (position) { 71 | case 0: 72 | baseFragments[0] = new Home(); 73 | return baseFragments[0]; 74 | case 1: 75 | baseFragments[1] = new Category(); 76 | return baseFragments[1]; 77 | case 2: 78 | baseFragments[2] = new Search(); 79 | return baseFragments[2]; 80 | case 3: 81 | baseFragments[3] = new BookMark(); 82 | return baseFragments[3]; 83 | default: 84 | baseFragments[4] = new Menu(); 85 | return baseFragments[4]; 86 | } 87 | } 88 | 89 | @Override 90 | public int getItemCount() { 91 | return 5; 92 | } 93 | }); 94 | bottomBarPost = findViewById(R.id.bottomBarPost); 95 | share = findViewById(R.id.share); 96 | share.setOnClickListener(new BottomBarPost()); 97 | screen = findViewById(R.id.screen); 98 | screen.setOnClickListener(new BottomBarPost()); 99 | comments = findViewById(R.id.comments); 100 | comments.setOnClickListener(new BottomBarPost()); 101 | fav = findViewById(R.id.fav); 102 | fav.setOnClickListener(new BottomBarPost()); 103 | web = findViewById(R.id.web); 104 | web.setOnClickListener(new BottomBarPost()); 105 | bottomBar = findViewById(R.id.bottomBar); 106 | bottomBar.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() { 107 | @Override 108 | public boolean onNavigationItemSelected(@NonNull MenuItem item) { 109 | int id; 110 | switch (item.getItemId()) { 111 | case R.id.tab_home: 112 | id = 0; 113 | break; 114 | case R.id.tab_categories: 115 | id = 1; 116 | break; 117 | case R.id.tab_search: 118 | id = 2; 119 | break; 120 | case R.id.tab_favorites: 121 | id = 3; 122 | break; 123 | case R.id.tab_menu: 124 | id = 4; 125 | break; 126 | default: 127 | throw new RuntimeException("bottomBar:: tabId not found!."); 128 | } 129 | viewPager.setCurrentItem(id); 130 | if (baseFragments[id] != null) 131 | finishListener = baseFragments[id].getFinishFragment(); 132 | return true; 133 | } 134 | }); 135 | 136 | bottomBar.setOnItemReselectedListener(new NavigationBarView.OnItemReselectedListener() { 137 | @Override 138 | public void onNavigationItemReselected(@NonNull MenuItem item) { 139 | if (finishListener != null) { 140 | finishListener.finishFragment(); 141 | } 142 | } 143 | }); 144 | } 145 | 146 | public void showBottomBarPost(boolean show, boolean showComment, boolean isMark, OnClickListener onClickListener) { 147 | if (showComment) { 148 | comments.setVisibility(View.VISIBLE); 149 | } else { 150 | comments.setVisibility(View.GONE); 151 | } 152 | if (isMark) { 153 | fav.setImageResource(R.drawable.ic_turned); 154 | } else { 155 | fav.setImageResource(R.drawable.ic_turned_not); 156 | } 157 | showBottomBarPost(show); 158 | this.onClickListener = onClickListener; 159 | } 160 | 161 | public void showBottomBarPost(boolean show) { 162 | if (show) { 163 | bottomBar.setVisibility(View.INVISIBLE); 164 | this.bottomBarPost.setVisibility(View.VISIBLE); 165 | web.setColorFilter(getResources().getColor(R.color.inActiveTabColor)); 166 | } else { 167 | bottomBar.setVisibility(View.VISIBLE); 168 | this.bottomBarPost.setVisibility(View.GONE); 169 | } 170 | } 171 | 172 | public void setStatus(boolean showWeb, boolean isMark) { 173 | if (showWeb) { 174 | web.setColorFilter(getTheme().getResources().getColor(R.color.colorAccent)); 175 | } 176 | if (isMark) { 177 | fav.setImageResource(R.drawable.ic_turned); 178 | } 179 | } 180 | 181 | @Override 182 | public void onBackPressed() { 183 | if (finishListener != null && finishListener.finishFragment()) { 184 | return; 185 | } 186 | if (doubleClickForExit) { 187 | long currentTime = new Date().getTime(); 188 | if ((currentTime - preTime) > 2000) { 189 | Toast.makeText(MainActivity.this, "جهت خروج مجددا کلیک کنید ...", Toast.LENGTH_SHORT).show(); 190 | preTime = currentTime; 191 | } else { 192 | MainActivity.this.finish(); 193 | } 194 | } else { 195 | new AlertDialog.Builder(this) 196 | .setTitle("خروج از برنامه") 197 | .setMessage("آیا می خواهید از برنامه خارج شوید؟") 198 | .setPositiveButton("خیر", null) 199 | .setNeutralButton("بله", new DialogInterface.OnClickListener() { 200 | @Override 201 | public void onClick(DialogInterface dialog, int which) { 202 | MainActivity.this.finish(); 203 | } 204 | }) 205 | .show(); 206 | } 207 | } 208 | 209 | @Override 210 | protected void onResume() { 211 | super.onResume(); 212 | } 213 | 214 | public class BottomBarPost implements View.OnClickListener { 215 | 216 | @Override 217 | public void onClick(View v) { 218 | if (onClickListener == null) { 219 | return; 220 | } 221 | onClickListener.onClick(v, 0); 222 | } 223 | } 224 | 225 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/adapter/Holder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.adapter; 6 | 7 | import androidx.recyclerview.widget.RecyclerView; 8 | import android.view.View; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import ghasemi.abbas.wordpress.R; 13 | import ghasemi.abbas.wordpress.BuildApp; 14 | 15 | class Holder extends RecyclerView.ViewHolder { 16 | ImageView imgPost; 17 | View card; 18 | TextView titlePost, contextPost, authorPost, datePost; 19 | 20 | 21 | Holder(View itemView) { 22 | super(itemView); 23 | imgPost = itemView.findViewById(R.id.imgPost); 24 | titlePost = itemView.findViewById(R.id.titlePost); 25 | authorPost = itemView.findViewById(R.id.writerPost); 26 | if (BuildApp.showType == 1) { 27 | contextPost = itemView.findViewById(R.id.contextPost); 28 | } 29 | if (BuildApp.showType != 2) { 30 | datePost = itemView.findViewById(R.id.timePost); 31 | card = itemView.findViewById(R.id.card_view); 32 | } else { 33 | card = itemView; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/adapter/OnClickListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.adapter; 6 | 7 | import android.view.View; 8 | 9 | public interface OnClickListener { 10 | void onClick(View view,int position); 11 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/adapter/PostsAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.adapter; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.recyclerview.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | 13 | import com.bumptech.glide.Glide; 14 | 15 | import java.util.HashMap; 16 | import java.util.List; 17 | 18 | import ghasemi.abbas.wordpress.R; 19 | import ghasemi.abbas.wordpress.BuildApp; 20 | 21 | public class PostsAdapter extends RecyclerView.Adapter { 22 | private List> date; 23 | private OnClickListener onClickListener; 24 | 25 | public void setOnClickListener(OnClickListener onClickListener) { 26 | this.onClickListener = onClickListener; 27 | } 28 | 29 | public List> getDate() { 30 | return date; 31 | } 32 | 33 | public void setDate(List> date) { 34 | this.date = date; 35 | } 36 | 37 | @NonNull 38 | @Override 39 | public Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { 40 | View view; 41 | switch (BuildApp.showType) { 42 | case 1: 43 | view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_main_1, viewGroup, false); 44 | break; 45 | case 2: 46 | view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_main_2, viewGroup, false); 47 | break; 48 | default: 49 | view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_main_3, viewGroup, false); 50 | break; 51 | } 52 | return new Holder(view); 53 | } 54 | 55 | @Override 56 | public void onBindViewHolder(@NonNull final Holder holder, final int position) { 57 | final HashMap hash_get = date.get(position); 58 | holder.titlePost.setText(hash_get.get("title").toString()); 59 | 60 | holder.authorPost.setText(String.format("نویسنده: %s", BuildApp.authorName)); 61 | 62 | String url_image = hash_get.get("url_image").toString(); 63 | 64 | if (!url_image.equals("")) { 65 | holder.imgPost.setVisibility(View.VISIBLE); 66 | Glide.with(holder.card).load(url_image).into(holder.imgPost); 67 | } else 68 | holder.imgPost.setVisibility(View.GONE); 69 | holder.card.setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | onClickListener.onClick(v, position); 73 | } 74 | }); 75 | 76 | if (BuildApp.showType == 1) { 77 | String s = hash_get.get("excerpt").toString(); 78 | holder.contextPost.setText(s); 79 | } 80 | if (BuildApp.showType != 2) { 81 | holder.datePost.setText(hash_get.get("date").toString()); 82 | } 83 | } 84 | 85 | @Override 86 | public int getItemCount() { 87 | return date.size(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/AboutUs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import androidx.annotation.LayoutRes; 8 | import androidx.annotation.NonNull; 9 | import android.view.View; 10 | import android.widget.TextView; 11 | 12 | import ghasemi.abbas.wordpress.BuildConfig; 13 | import ghasemi.abbas.wordpress.R; 14 | 15 | 16 | public class AboutUs extends BaseFragment { 17 | 18 | @Override 19 | public void onCreateView(@NonNull BaseFragment baseFragment,@LayoutRes int id) { 20 | super.onCreateView(baseFragment, R.layout.fragment_about_us); 21 | findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | finishFragment(); 25 | } 26 | }); 27 | TextView textView = findViewById(R.id.about_text); 28 | textView.setText(getResources().getString(R.string.msg_about)); 29 | TextView version = findViewById(R.id.version); 30 | version.setText(String.format("%s نسخه %s", getResources().getString(R.string.app_name), BuildConfig.VERSION_NAME)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/BaseFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import android.content.Intent; 8 | import android.os.Bundle; 9 | 10 | import androidx.annotation.CallSuper; 11 | import androidx.annotation.IdRes; 12 | import androidx.annotation.LayoutRes; 13 | import androidx.annotation.NonNull; 14 | import androidx.annotation.Nullable; 15 | import androidx.fragment.app.Fragment; 16 | import androidx.appcompat.app.AppCompatActivity; 17 | 18 | import android.view.LayoutInflater; 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.widget.FrameLayout; 22 | import android.widget.TextView; 23 | 24 | import java.util.ArrayList; 25 | import java.util.HashMap; 26 | 27 | import ghasemi.abbas.wordpress.ui.MainActivity; 28 | import ghasemi.abbas.wordpress.R; 29 | import ghasemi.abbas.wordpress.ui.adapter.OnClickListener; 30 | 31 | public class BaseFragment extends Fragment { 32 | 33 | protected FrameLayout frameLayout; 34 | private ArrayList baseFragments; 35 | private View view; 36 | private HashMap hashMap; 37 | private boolean isShowBottomBarPost; 38 | 39 | 40 | protected final void setTitle(String title) { 41 | TextView t = findViewById(R.id.title); 42 | if (t == null) { 43 | return; 44 | } 45 | t.setText(title); 46 | } 47 | 48 | @Nullable 49 | public T findViewById(@IdRes int id) { 50 | if (view == null) { 51 | if (frameLayout == null) { 52 | return null; 53 | } 54 | return frameLayout.findViewById(id); 55 | } 56 | return view.findViewById(id); 57 | } 58 | 59 | @Override 60 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 61 | frameLayout = new FrameLayout(getContext()); 62 | baseFragments = new ArrayList<>(); 63 | onCreateView(inflater); 64 | return frameLayout; 65 | } 66 | 67 | public void onCreateView(@NonNull LayoutInflater layoutInflater) { 68 | 69 | } 70 | 71 | @CallSuper 72 | public void onCreateView(@NonNull BaseFragment baseFragment, @LayoutRes int id) { 73 | view = getContext().getLayoutInflater().inflate(id, null); 74 | baseFragment.frameLayout.addView(view); 75 | baseFragment.baseFragments.add(this); 76 | frameLayout = baseFragment.frameLayout; 77 | baseFragments = baseFragment.baseFragments; 78 | } 79 | 80 | @NonNull 81 | @Override 82 | public AppCompatActivity getContext() { 83 | return MainActivity.activity; 84 | } 85 | 86 | @Nullable 87 | @Override 88 | public View getView() { 89 | return frameLayout; 90 | } 91 | 92 | public void startFragment(BaseFragment baseFragment) { 93 | // if (isShowBottomBarPost) { 94 | // showBottomBarPost(false); 95 | // } 96 | baseFragment.onCreateView(this, -1); 97 | } 98 | 99 | 100 | @CallSuper 101 | public boolean finishFragment() { 102 | if (frameLayout.getChildCount() > 1) { 103 | if (baseFragments.get(baseFragments.size() - 1).isShowBottomBarPost) { 104 | showBottomBarPost(false); 105 | } 106 | frameLayout.removeViewAt(frameLayout.getChildCount() - 1); 107 | baseFragments.remove(baseFragments.size() - 1); 108 | if (view == null && baseFragments.isEmpty()) { 109 | onResumeFragment(); // not good 110 | } else if (!baseFragments.isEmpty()) { 111 | baseFragments.get(baseFragments.size() - 1).onResumeFragment(); 112 | } 113 | return true; 114 | } 115 | return false; 116 | } 117 | 118 | public HashMap getDataArguments() { 119 | return hashMap; 120 | } 121 | 122 | public void addDataArguments(HashMap data) { 123 | this.hashMap = new HashMap<>(); 124 | this.hashMap.putAll(data); 125 | } 126 | 127 | public void startActivity(Intent intent) { 128 | getContext().startActivity(intent); 129 | } 130 | 131 | public void showBottomBarPost(boolean show, boolean showComment, boolean isMark) { 132 | ((MainActivity) getContext()).showBottomBarPost(show, showComment, isMark, show ? new OnClickListener() { 133 | @Override 134 | public void onClick(View view, int i) { 135 | baseFragments.get(baseFragments.size() - 1).onClickBottomBarPost(view); 136 | } 137 | } : null); 138 | baseFragments.get(baseFragments.size() - 1).isShowBottomBarPost = show; 139 | } 140 | 141 | public void showBottomBarPost(boolean show) { 142 | ((MainActivity) getContext()).showBottomBarPost(show); 143 | } 144 | 145 | public void onClickBottomBarPost(View view) { 146 | 147 | } 148 | 149 | public FinishListener getFinishFragment() { 150 | if (baseFragments != null && !baseFragments.isEmpty()) { 151 | baseFragments.get(baseFragments.size() - 1).onResumeFragment(); 152 | } else { 153 | onResumeFragment(); 154 | } 155 | return new FinishListener() { 156 | @Override 157 | public boolean finishFragment() { 158 | return BaseFragment.this.finishFragment(); 159 | } 160 | }; 161 | } 162 | 163 | public void setButtonBarPostStatus(boolean showWeb, boolean isMark) { 164 | ((MainActivity) getContext()).setStatus(showWeb, isMark); 165 | } 166 | 167 | public void onResumeFragment() { 168 | 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/BookMark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.recyclerview.widget.DividerItemDecoration; 9 | import androidx.recyclerview.widget.RecyclerView; 10 | import androidx.recyclerview.widget.StaggeredGridLayoutManager; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.widget.ImageView; 14 | import android.widget.LinearLayout; 15 | import android.widget.TextView; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | 20 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 21 | import ghasemi.abbas.wordpress.Application; 22 | import ghasemi.abbas.wordpress.R; 23 | import ghasemi.abbas.wordpress.ui.adapter.PostsAdapter; 24 | import ghasemi.abbas.wordpress.BuildApp; 25 | import ghasemi.abbas.wordpress.general.SaveModel; 26 | import ghasemi.abbas.wordpress.ui.adapter.OnClickListener; 27 | 28 | import static ghasemi.abbas.wordpress.BuildApp.divider; 29 | 30 | public class BookMark extends BaseFragment { 31 | 32 | private PostsAdapter postsAdapter; 33 | private LinearLayout errorNet; 34 | 35 | @Override 36 | public void onCreateView(@NonNull LayoutInflater inflater) { 37 | frameLayout.addView(inflater.inflate(R.layout.fragment_list_main, null)); 38 | setTitle(getResources().getString(R.string.mark_name)); 39 | findViewById(R.id.progressBar).setVisibility(View.GONE); 40 | SwipeRefreshLayout pullRefreshLayout = findViewById(R.id.pull); 41 | errorNet = findViewById(R.id.error_net); 42 | ((ImageView)findViewById(R.id.image)).setImageResource(R.drawable.sad); 43 | ((TextView)findViewById(R.id.check)).setText(getResources().getString(R.string.empty)); 44 | pullRefreshLayout.setEnabled(false); 45 | pullRefreshLayout.setRefreshing(false); 46 | postsAdapter = new PostsAdapter(); 47 | RecyclerView recView = findViewById(R.id.recycler_view); 48 | recView.setLayoutManager(new StaggeredGridLayoutManager(BuildApp.showType == 3 ? BuildApp.getCountPx() : 1, StaggeredGridLayoutManager.VERTICAL)); 49 | postsAdapter.setDate(new ArrayList>()); 50 | postsAdapter.setOnClickListener(new OnClickListener() { 51 | @Override 52 | public void onClick(View view, int position) { 53 | PostView baseFragment = new PostView(); 54 | baseFragment.addDataArguments(postsAdapter.getDate().get(position)); 55 | startFragment(baseFragment); 56 | } 57 | }); 58 | recView.setAdapter(postsAdapter); 59 | if (divider) { 60 | DividerItemDecoration itemDecor = new DividerItemDecoration(getContext(), 1); 61 | recView.addItemDecoration(itemDecor); 62 | } 63 | } 64 | 65 | @Override 66 | public void onResumeFragment() { 67 | postsAdapter.getDate().clear(); 68 | SaveModel saveModel = Application.easySave.retrieveModel("book_mark_info", SaveModel.class); 69 | if (saveModel != null) { 70 | errorNet.setVisibility(View.GONE); 71 | postsAdapter.getDate().addAll(saveModel.hashMapList); 72 | }else { 73 | errorNet.setVisibility(View.VISIBLE); 74 | } 75 | postsAdapter.notifyDataSetChanged(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import android.os.Bundle; 8 | import android.os.Handler; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.LinearLayoutManager; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import android.os.Looper; 15 | import android.view.LayoutInflater; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.ImageView; 19 | import android.widget.LinearLayout; 20 | import android.widget.ProgressBar; 21 | import android.widget.TextView; 22 | 23 | import org.json.JSONArray; 24 | import org.json.JSONException; 25 | import org.json.JSONObject; 26 | 27 | import java.util.ArrayList; 28 | import java.util.HashMap; 29 | import java.util.List; 30 | 31 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 32 | import ghasemi.abbas.wordpress.Application; 33 | import ghasemi.abbas.wordpress.R; 34 | import ghasemi.abbas.wordpress.api.ApiSeivice; 35 | import ghasemi.abbas.wordpress.api.CheckNetworkStatus; 36 | import ghasemi.abbas.wordpress.api.ConnectionManager; 37 | import ghasemi.abbas.wordpress.general.SaveModel; 38 | import ghasemi.abbas.wordpress.general.TinyData; 39 | 40 | public class Category extends BaseFragment { 41 | private String status = ""; 42 | private List> hash; 43 | private ProgressBar progressBar; 44 | private TextView check; 45 | private LinearLayout net; 46 | private CategoryAdaper categoryAdaper; 47 | private boolean isLoading; 48 | private SwipeRefreshLayout refreshLayout; 49 | 50 | @Override 51 | public void onCreateView(@NonNull LayoutInflater inflater) { 52 | frameLayout.addView(inflater.inflate(R.layout.fragment_list_main, null)); 53 | setTitle(getResources().getString(R.string.boxs)); 54 | progressBar = findViewById(R.id.progressBar); 55 | hash = new ArrayList<>(); 56 | check = findViewById(R.id.check); 57 | net = findViewById(R.id.error_net); 58 | RecyclerView recyclerView = findViewById(R.id.recycler_view); 59 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 60 | categoryAdaper = new CategoryAdaper(); 61 | recyclerView.setAdapter(categoryAdaper); 62 | final SaveModel saveModel = Application.easySave.retrieveModel("Category", SaveModel.class); 63 | if (saveModel != null) { 64 | isLoading = true; 65 | new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { 66 | @Override 67 | public void run() { 68 | hash.addAll(saveModel.hashMapList); 69 | progressBar.setVisibility(View.GONE); 70 | categoryAdaper.notifyDataSetChanged(); 71 | isLoading = false; 72 | } 73 | }, 500); 74 | } else { 75 | getCategory(); 76 | } 77 | check.setOnClickListener(new View.OnClickListener() { 78 | @Override 79 | public void onClick(View v) { 80 | net.setVisibility(View.GONE); 81 | progressBar.setVisibility(View.VISIBLE); 82 | getCategory(); 83 | } 84 | }); 85 | 86 | refreshLayout = findViewById(R.id.pull); 87 | refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 88 | @Override 89 | public void onRefresh() { 90 | if (isLoading) { 91 | return; 92 | } 93 | getCategory(); 94 | } 95 | }); 96 | } 97 | 98 | private void getCategory() { 99 | if (isLoading) { 100 | return; 101 | } 102 | hash.clear(); 103 | categoryAdaper.notifyDataSetChanged(); 104 | isLoading = true; 105 | new ConnectionManager.Builder() 106 | .setURL(ApiSeivice.getCategoryIndex()) 107 | .request(new ConnectionManager.ResultConnection() { 108 | @Override 109 | public void onSuccess(JSONArray jsonArray) throws JSONException { 110 | if (jsonArray.length() == 0) { 111 | ((ImageView) findViewById(R.id.image)).setImageResource(R.drawable.sad); 112 | net.setVisibility(View.VISIBLE); 113 | check.setText(getResources().getString(R.string.empty)); 114 | check.setOnClickListener(null); 115 | check.setClickable(false); 116 | } else { 117 | for (int i = 0; i < jsonArray.length(); i++) { 118 | JSONObject object = jsonArray.getJSONObject(i); 119 | HashMap add = new HashMap<>(); 120 | add.put("id", object.getString("id")); 121 | add.put("slug", object.getString("slug")); 122 | add.put("title", object.getString("name")); 123 | add.put("count", object.getString("count")); 124 | hash.add(add); 125 | } 126 | if (hash.isEmpty()) { 127 | ((ImageView) findViewById(R.id.image)).setImageResource(R.drawable.sad); 128 | net.setVisibility(View.VISIBLE); 129 | check.setText(getResources().getString(R.string.empty)); 130 | check.setOnClickListener(null); 131 | check.setClickable(false); 132 | } else { 133 | SaveModel saveModel = new SaveModel(); 134 | saveModel.hashMapList.addAll(hash); 135 | Application.easySave.saveModel("Category", saveModel); 136 | TinyData.getInstance().putStringCashe("Category"); 137 | categoryAdaper.notifyDataSetChanged(); 138 | } 139 | } 140 | progressBar.setVisibility(View.GONE); 141 | if (refreshLayout.isRefreshing()) { 142 | refreshLayout.setRefreshing(false); 143 | } 144 | isLoading = false; 145 | } 146 | 147 | @Override 148 | public void onFail(String error) { 149 | if (CheckNetworkStatus.isOnline()) 150 | getCategory(); 151 | else { 152 | progressBar.setVisibility(View.GONE); 153 | net.setVisibility(View.VISIBLE); 154 | if (refreshLayout.isRefreshing()) { 155 | refreshLayout.setRefreshing(false); 156 | } 157 | } 158 | isLoading = false; 159 | } 160 | }); 161 | } 162 | 163 | public class CategoryAdaper extends RecyclerView.Adapter { 164 | 165 | @NonNull 166 | @Override 167 | public CategoryAdaper.Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { 168 | return new CategoryAdaper.Holder(LayoutInflater.from(getContext()).inflate(R.layout.row_category, null)); 169 | } 170 | 171 | @Override 172 | public void onBindViewHolder(@NonNull CategoryAdaper.Holder holder, final int i) { 173 | holder.title.setText(hash.get(i).get("title").toString()); 174 | holder.title.setOnClickListener(new View.OnClickListener() { 175 | @Override 176 | public void onClick(View v) { 177 | ShowCategory baseFragment = new ShowCategory(); 178 | baseFragment.addDataArguments(hash.get(i)); 179 | Bundle bundle = new Bundle(); 180 | bundle.putString("id", hash.get(i).get("id").toString()); 181 | baseFragment.setArguments(bundle); 182 | startFragment(baseFragment); 183 | } 184 | }); 185 | } 186 | 187 | @Override 188 | public int getItemCount() { 189 | return hash.size(); 190 | } 191 | 192 | class Holder extends RecyclerView.ViewHolder { 193 | TextView title; 194 | 195 | Holder(@NonNull View itemView) { 196 | super(itemView); 197 | title = itemView.findViewById(R.id.title); 198 | } 199 | } 200 | } 201 | 202 | } 203 | 204 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/Comments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.recyclerview.widget.LinearLayoutManager; 9 | import androidx.recyclerview.widget.RecyclerView; 10 | 11 | import android.text.Html; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.TextView; 16 | import android.widget.Toast; 17 | 18 | import org.json.JSONArray; 19 | import org.json.JSONException; 20 | import org.json.JSONObject; 21 | 22 | import java.util.ArrayList; 23 | import java.util.HashMap; 24 | import java.util.List; 25 | 26 | import ghasemi.abbas.wordpress.R; 27 | import ghasemi.abbas.wordpress.api.ApiSeivice; 28 | import ghasemi.abbas.wordpress.api.ConnectionManager; 29 | import ghasemi.abbas.wordpress.BuildApp; 30 | 31 | public class Comments extends BaseFragment { 32 | private List> hash; 33 | private boolean isLoading; 34 | private int page = 1; 35 | private boolean hasNext; 36 | private AdapterComments adapterComments; 37 | 38 | @Override 39 | public void onCreateView(@NonNull BaseFragment baseFragment, int id) { 40 | super.onCreateView(baseFragment, R.layout.fragment_comment); 41 | RecyclerView recView = findViewById(R.id.recycler_comment); 42 | 43 | findViewById(R.id.back_comment).setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | finishFragment(); 47 | } 48 | }); 49 | 50 | hash = new ArrayList<>(); 51 | adapterComments = new AdapterComments(); 52 | recView.setLayoutManager(new LinearLayoutManager(getContext())); 53 | recView.setAdapter(adapterComments); 54 | getComments(); 55 | } 56 | 57 | private void getComments() { 58 | findViewById(R.id.progressBar).setVisibility(View.VISIBLE); 59 | if (isLoading) { 60 | return; 61 | } 62 | isLoading = true; 63 | new ConnectionManager.Builder() 64 | .setURL(ApiSeivice.getComments(getArguments().getString("post"), String.valueOf(page))) 65 | .request(new ConnectionManager.ResultConnection() { 66 | @Override 67 | public void onSuccess(JSONArray jsonArray) throws JSONException { 68 | for (int i = 0; i < jsonArray.length(); i++) { 69 | JSONObject object = jsonArray.getJSONObject(i); 70 | HashMap add = new HashMap<>(); 71 | add.put("name", object.getString("author_name")); 72 | add.put("date", object.getString("date").replace("T", " ")); 73 | add.put("content", Html.fromHtml(object.getJSONObject("content").getString("rendered"))); 74 | boolean author = object.getString("author").equals(getArguments().getString("author")); 75 | add.put("type", author ? 1 : 0); 76 | hash.add(add); 77 | } 78 | hasNext = jsonArray.length() == BuildApp.limitPage; 79 | isLoading = false; 80 | adapterComments.notifyDataSetChanged(); 81 | findViewById(R.id.progressBar).setVisibility(View.GONE); 82 | if (jsonArray.length() == 0) { 83 | findViewById(R.id.no_comment).setVisibility(View.VISIBLE); 84 | } 85 | } 86 | 87 | @Override 88 | public void onFail(String error) { 89 | findViewById(R.id.progressBar).setVisibility(View.GONE); 90 | isLoading = false; 91 | finishFragment(); 92 | Toast.makeText(getContext(), "شبکه در دسترس نیست!", Toast.LENGTH_SHORT).show(); 93 | } 94 | }); 95 | } 96 | 97 | class AdapterComments extends RecyclerView.Adapter { 98 | 99 | @NonNull 100 | @Override 101 | public contentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 102 | View view = LayoutInflater.from(parent.getContext()).inflate(viewType == 0 ? 103 | R.layout.row_comment_user : 104 | R.layout.row_comment_admin, parent, false); 105 | return new contentViewHolder(view); 106 | } 107 | 108 | @Override 109 | public void onBindViewHolder(contentViewHolder holder, int position) { 110 | final HashMap hash_get = hash.get(position); 111 | String c = hash_get.get("name").toString() + " میگه: \n" + hash_get.get("content").toString().trim(); 112 | holder.msg.setText(c); 113 | holder.date.setText(hash_get.get("date").toString()); 114 | } 115 | 116 | @Override 117 | public int getItemCount() { 118 | return hash.size(); 119 | } 120 | 121 | @Override 122 | public int getItemViewType(int position) { 123 | return (int) hash.get(position).get("type"); 124 | } 125 | 126 | class contentViewHolder extends RecyclerView.ViewHolder { 127 | TextView msg, date; 128 | 129 | contentViewHolder(View itemView) { 130 | super(itemView); 131 | msg = itemView.findViewById(R.id.msg); 132 | date = itemView.findViewById(R.id.date); 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/FinishListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | public interface FinishListener { 8 | boolean finishFragment(); 9 | } -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/Menu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import android.content.ActivityNotFoundException; 8 | import android.content.DialogInterface; 9 | import android.content.Intent; 10 | import android.net.Uri; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.appcompat.app.AlertDialog; 14 | import androidx.appcompat.app.AppCompatDelegate; 15 | 16 | import android.text.TextUtils; 17 | import android.view.LayoutInflater; 18 | import android.view.View; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import com.google.android.material.bottomsheet.BottomSheetDialog; 23 | 24 | import ghasemi.abbas.wordpress.BuildConfig; 25 | import ghasemi.abbas.wordpress.R; 26 | import ghasemi.abbas.wordpress.BuildApp; 27 | import ghasemi.abbas.wordpress.general.TinyData; 28 | 29 | public class Menu extends BaseFragment { 30 | private BottomSheetDialog bottomSheetDialog; 31 | private TextView nightType; 32 | 33 | @Override 34 | public void onCreateView(@NonNull LayoutInflater inflater) { 35 | frameLayout.addView(inflater.inflate(R.layout.fragment_menu, null)); 36 | if (!BuildApp.enablePage) { 37 | findViewById(R.id.pages).setVisibility(View.GONE); 38 | findViewById(R.id.pages_divider).setVisibility(View.GONE); 39 | } 40 | findViewById(R.id.pages).setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | startFragment(new Page()); 44 | } 45 | }); 46 | findViewById(R.id.share).setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View v) { 49 | BuildApp.Share(); 50 | } 51 | }); 52 | 53 | if (TextUtils.isEmpty(BuildApp.phone)) { 54 | findViewById(R.id.call).setVisibility(View.GONE); 55 | findViewById(R.id.call_divider).setVisibility(View.GONE); 56 | } 57 | findViewById(R.id.call).setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | try { 61 | Intent intent = new Intent(Intent.ACTION_DIAL); 62 | intent.setData(Uri.parse("tel:" + BuildApp.phone)); 63 | startActivity(intent); 64 | } catch (Exception e) { 65 | Toast.makeText(getContext(), "هیچ برنامه ای نمی تواند این کار را انجام دهد.", Toast.LENGTH_SHORT).show(); 66 | } 67 | } 68 | }); 69 | findViewById(R.id.email).setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | Intent i = new Intent(Intent.ACTION_SEND); 73 | i.setType("message/rfc822"); 74 | i.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildApp.mail}); 75 | i.putExtra(Intent.EXTRA_SUBJECT, "V:" + BuildConfig.VERSION_NAME + " " + getResources().getString(R.string.app_name)); 76 | i.putExtra(Intent.EXTRA_TEXT, ""); 77 | try { 78 | startActivity(i); 79 | } catch (android.content.ActivityNotFoundException ex) { 80 | Toast.makeText(getContext(), "هیچ برنامه ای نمی تواند این کار را انجام دهد.", Toast.LENGTH_SHORT).show(); 81 | } 82 | } 83 | }); 84 | findViewById(R.id.telegram).setOnClickListener(new View.OnClickListener() { 85 | @Override 86 | public void onClick(View v) { 87 | try { 88 | Intent intent = new Intent(Intent.ACTION_VIEW); 89 | intent.setData(Uri.parse(BuildApp.telegram)); 90 | startActivity(intent); 91 | } catch (ActivityNotFoundException e) { 92 | Toast.makeText(getContext(), "هیچ برنامه ای نمی تواند این کار را انجام دهد.", Toast.LENGTH_SHORT).show(); 93 | } 94 | } 95 | }); 96 | findViewById(R.id.instagram).setOnClickListener(new View.OnClickListener() { 97 | @Override 98 | public void onClick(View v) { 99 | try { 100 | Intent intent = new Intent(Intent.ACTION_VIEW); 101 | intent.setData(Uri.parse(BuildApp.instagram)); 102 | startActivity(intent); 103 | } catch (ActivityNotFoundException e) { 104 | Toast.makeText(getContext(), "هیچ برنامه ای نمی تواند این کار را انجام دهد.", Toast.LENGTH_SHORT).show(); 105 | } 106 | } 107 | }); 108 | findViewById(R.id.service).setOnClickListener(new View.OnClickListener() { 109 | @Override 110 | public void onClick(View v) { 111 | BuildApp.setCustomDialog(new AlertDialog.Builder(getContext()) 112 | .setTitle(getString(R.string.app_name)) 113 | .setMessage(getString(R.string.msg_service)) 114 | .setNegativeButton("لغو", null) 115 | .show()); 116 | } 117 | }); 118 | findViewById(R.id.about).setOnClickListener(new View.OnClickListener() { 119 | @Override 120 | public void onClick(View v) { 121 | startFragment(new AboutUs()); 122 | } 123 | }); 124 | 125 | 126 | nightType = findViewById(R.id.night_type); 127 | String nightMode = TinyData.getInstance().getString("nightMode", "system"); 128 | if (nightMode.equals("system")) { 129 | nightType.setText("پیشفرض سیستم"); 130 | } else if (nightMode.equals("off")) { 131 | nightType.setText("غیر فعال"); 132 | } 133 | findViewById(R.id.l_theme).setOnClickListener(new View.OnClickListener() { 134 | @Override 135 | public void onClick(View v) { 136 | if (bottomSheetDialog != null) { 137 | return; 138 | } 139 | bottomSheetDialog = new BottomSheetDialog(getContext(), R.style.BottomSheetDialogTheme); 140 | bottomSheetDialog.setContentView(getLayoutInflater().inflate(R.layout.dialog_select_night_mode, null)); 141 | bottomSheetDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { 142 | @Override 143 | public void onCancel(DialogInterface dialog) { 144 | bottomSheetDialog = null; 145 | } 146 | }); 147 | bottomSheetDialog.show(); 148 | bottomSheetDialog.findViewById(R.id.night_system).setOnClickListener(new View.OnClickListener() { 149 | @Override 150 | public void onClick(View v) { 151 | bottomSheetDialog.dismiss(); 152 | bottomSheetDialog = null; 153 | String nightMode = TinyData.getInstance().getString("nightMode", "system"); 154 | if (!nightMode.equals("system")) { 155 | TinyData.getInstance().putString("nightMode", "system"); 156 | nightType.setText("پیشفرض سیستم"); 157 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); 158 | } 159 | } 160 | }); 161 | bottomSheetDialog.findViewById(R.id.night_off).setOnClickListener(new View.OnClickListener() { 162 | @Override 163 | public void onClick(View v) { 164 | bottomSheetDialog.dismiss(); 165 | bottomSheetDialog = null; 166 | String nightMode = TinyData.getInstance().getString("nightMode", "system"); 167 | if (!nightMode.equals("off")) { 168 | TinyData.getInstance().putString("nightMode", "off"); 169 | nightType.setText("غیر فعال"); 170 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); 171 | } 172 | } 173 | }); 174 | bottomSheetDialog.findViewById(R.id.night_on).setOnClickListener(new View.OnClickListener() { 175 | @Override 176 | public void onClick(View v) { 177 | bottomSheetDialog.dismiss(); 178 | bottomSheetDialog = null; 179 | String nightMode = TinyData.getInstance().getString("nightMode", "system"); 180 | if (!nightMode.equals("on")) { 181 | TinyData.getInstance().putString("nightMode", "on"); 182 | nightType.setText("فعال"); 183 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); 184 | } 185 | } 186 | }); 187 | } 188 | }); 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /WP_News/src/main/java/ghasemi/abbas/wordpress/ui/fragment/Page.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 All rights reserved for FaraSource (ABBAS GHASEMI) 3 | * https://farasource.com 4 | */ 5 | package ghasemi.abbas.wordpress.ui.fragment; 6 | 7 | import android.os.Handler; 8 | 9 | import androidx.annotation.NonNull; 10 | import androidx.recyclerview.widget.DividerItemDecoration; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | import androidx.recyclerview.widget.StaggeredGridLayoutManager; 13 | 14 | import android.os.Looper; 15 | import android.text.Html; 16 | import android.view.View; 17 | import android.widget.LinearLayout; 18 | import android.widget.ProgressBar; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import org.json.JSONArray; 23 | import org.json.JSONException; 24 | import org.json.JSONObject; 25 | 26 | import java.util.ArrayList; 27 | import java.util.HashMap; 28 | import java.util.regex.Matcher; 29 | import java.util.regex.Pattern; 30 | 31 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 32 | import ghasemi.abbas.wordpress.Application; 33 | import ghasemi.abbas.wordpress.R; 34 | import ghasemi.abbas.wordpress.ui.adapter.PostsAdapter; 35 | import ghasemi.abbas.wordpress.api.ApiSeivice; 36 | import ghasemi.abbas.wordpress.BuildApp; 37 | import ghasemi.abbas.wordpress.api.CheckNetworkStatus; 38 | import ghasemi.abbas.wordpress.api.ConnectionManager; 39 | import ghasemi.abbas.wordpress.general.SaveModel; 40 | import ghasemi.abbas.wordpress.general.TinyData; 41 | import ghasemi.abbas.wordpress.ui.adapter.OnClickListener; 42 | 43 | import static ghasemi.abbas.wordpress.BuildApp.divider; 44 | 45 | public class Page extends BaseFragment { 46 | private PostsAdapter postsAdapter; 47 | private ProgressBar progress; 48 | private String status = ""; 49 | private SwipeRefreshLayout pullRefreshLayout; 50 | private LinearLayout net; 51 | private boolean isLoading; 52 | 53 | @Override 54 | public void onCreateView(@NonNull BaseFragment baseFragment, int id) { 55 | super.onCreateView(baseFragment, R.layout.fragment_base_list); 56 | setTitle(getResources().getString(R.string.page_name)); 57 | 58 | findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | finishFragment(); 62 | } 63 | }); 64 | 65 | pullRefreshLayout = findViewById(R.id.pull); 66 | RecyclerView recView = findViewById(R.id.recycler_view); 67 | TextView check = findViewById(R.id.check); 68 | net = findViewById(R.id.error_net); 69 | progress = findViewById(R.id.progressBar); 70 | postsAdapter = new PostsAdapter(); 71 | postsAdapter.setDate(new ArrayList<>()); 72 | postsAdapter.setOnClickListener(new OnClickListener() { 73 | @Override 74 | public void onClick(View view, int position) { 75 | PostView baseFragment = new PostView(); 76 | baseFragment.addDataArguments(postsAdapter.getDate().get(position)); 77 | startFragment(baseFragment); 78 | } 79 | }); 80 | recView.setLayoutManager(new StaggeredGridLayoutManager(BuildApp.showType == 3 ? BuildApp.getCountPx() : 1, StaggeredGridLayoutManager.VERTICAL)); 81 | recView.setAdapter(postsAdapter); 82 | if (divider) { 83 | DividerItemDecoration itemDecor = new DividerItemDecoration(getContext(), 1); 84 | recView.addItemDecoration(itemDecor); 85 | } 86 | 87 | SaveModel saveModel = Application.easySave.retrieveModel("Page", SaveModel.class); 88 | if (saveModel != null) { 89 | postsAdapter.getDate().addAll(saveModel.hashMapList); 90 | progress.setVisibility(View.GONE); 91 | } else { 92 | getPage(); 93 | } 94 | 95 | pullRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 96 | @Override 97 | public void onRefresh() { 98 | if (isLoading) { 99 | return; 100 | } 101 | Application.easySave.saveModel("Page", null); 102 | postsAdapter.getDate().clear(); 103 | postsAdapter.notifyDataSetChanged(); 104 | progress.setVisibility(View.VISIBLE); 105 | new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { 106 | @Override 107 | public void run() { 108 | pullRefreshLayout.setRefreshing(false); 109 | } 110 | }, 500); 111 | getPage(); 112 | } 113 | }); 114 | check.setOnClickListener(new View.OnClickListener() { 115 | @Override 116 | public void onClick(View v) { 117 | net.setVisibility(View.GONE); 118 | progress.setVisibility(View.VISIBLE); 119 | getPage(); 120 | } 121 | }); 122 | } 123 | 124 | 125 | private void getPage() { 126 | if (isLoading) { 127 | return; 128 | } 129 | isLoading = true; 130 | new ConnectionManager.Builder() 131 | .setURL(ApiSeivice.getPageIndex()) 132 | .request(new ConnectionManager.ResultConnection() { 133 | @Override 134 | public void onSuccess(JSONArray jsonArray) throws JSONException { 135 | if (jsonArray.length() > 0) { 136 | for (int i = 0; i < jsonArray.length(); i++) { 137 | JSONObject object = jsonArray.getJSONObject(i); 138 | HashMap add = new HashMap<>(); 139 | add.put("id", object.getString("id")); 140 | add.put("url", object.getString("link")); 141 | add.put("title", object.getJSONObject("title").getString("rendered")); 142 | add.put("content", object.getJSONObject("content").getString("rendered")); 143 | String excerpt = String.valueOf(Html.fromHtml(object.getJSONObject("excerpt").getString("rendered"))); 144 | add.put("excerpt", excerpt); 145 | add.put("date", object.getString("date").replace("T", " ")); 146 | add.put("author", object.getString("author")); 147 | if (object.has("yoast_head_json") && object.getJSONObject("yoast_head_json").has("og_image")) { 148 | JSONArray array = object.getJSONObject("yoast_head_json").getJSONArray("og_image"); 149 | add.put("url_image", array.getJSONObject(array.length() - 1).getString("url")); 150 | } else if (object.has("yoast_head")) { 151 | String head = object.getString("yoast_head"); 152 | Pattern pattern = Pattern.compile("property=\"og:image\" content=\"(.*)\""); 153 | Matcher matcher = pattern.matcher(head); 154 | if (matcher.find()) { 155 | head = matcher.group(); 156 | add.put("url_image", head.substring(29, head.length() - 1)); 157 | } else { 158 | add.put("url_image", ""); 159 | } 160 | } else { 161 | add.put("url_image", ""); 162 | } 163 | postsAdapter.getDate().add(add); 164 | } 165 | SaveModel saveModel = new SaveModel(); 166 | saveModel.hashMapList.addAll(postsAdapter.getDate()); 167 | Application.easySave.saveModel("Page", saveModel); 168 | postsAdapter.notifyDataSetChanged(); 169 | TinyData.getInstance().putStringCashe("Page"); 170 | } else { 171 | Toast.makeText(getContext(), "موردی موجود نیست!", Toast.LENGTH_LONG).show(); 172 | finishFragment(); 173 | } 174 | progress.setVisibility(View.GONE); 175 | if (pullRefreshLayout.isRefreshing()) { 176 | pullRefreshLayout.setRefreshing(false); 177 | } 178 | isLoading = false; 179 | } 180 | 181 | @Override 182 | public void onFail(String error) { 183 | isLoading = false; 184 | if (CheckNetworkStatus.isOnline()) 185 | getPage(); 186 | else { 187 | progress.setVisibility(View.GONE); 188 | net.setVisibility(View.VISIBLE); 189 | } 190 | } 191 | }); 192 | } 193 | } -------------------------------------------------------------------------------- /WP_News/src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/anim/fade_in_to_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /WP_News/src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /WP_News/src/main/res/color/bottom_nav_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/a.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/eraser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/eraser.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/marker_pen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/marker_pen.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/pen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/pen.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/redo.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/undo.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-hdpi/without_internet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-hdpi/without_internet.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-night-xhdpi/msg_in.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-night-xhdpi/msg_in.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-night-xhdpi/msg_out.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-night-xhdpi/msg_out.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-night-xxhdpi/msg_in.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-night-xxhdpi/msg_in.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-night-xxhdpi/msg_out.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-night-xxhdpi/msg_out.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-xhdpi/msg_in.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-xhdpi/msg_in.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-xhdpi/msg_out.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-xhdpi/msg_out.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-xxhdpi/msg_in.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-xxhdpi/msg_in.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable-xxhdpi/msg_out.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable-xxhdpi/msg_out.9.png -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/alert_dialog_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/back_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/back_row_main_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/back_writer_post_row_main_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/dialog_sheet_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_ac_unit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_arrow_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_call.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_close.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_comment.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_done.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_folder.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_home.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_info_outline.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_insert_invitation.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_mail.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_mic.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_screen_share.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_storage.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_turned.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_turned_not.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/ic_web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/main/res/drawable/sad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/drawable/sad.png -------------------------------------------------------------------------------- /WP_News/src/main/res/font/sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/font/sans.ttf -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/activity_luancher.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | 26 | 27 | 38 | 39 | 48 | 49 | 59 | 60 | 70 | 71 | 81 | 82 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 28 | 29 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/dialog_select_night_mode.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | 25 | 26 | 36 | 37 | 47 | 48 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_about_us.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 25 | 26 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 46 | 47 | 54 | 55 | 64 | 65 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_base_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 24 | 25 | 32 | 33 | 34 | 39 | 40 | 44 | 45 | 46 | 47 | 55 | 56 | 65 | 66 | 74 | 75 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_comment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | 25 | 32 | 33 | 34 | 40 | 41 | 49 | 50 | 58 | 59 | 66 | 67 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_list_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 26 | 27 | 31 | 32 | 33 | 34 | 42 | 43 | 52 | 53 | 61 | 62 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 23 | 24 | 28 | 29 | 39 | 40 | 47 | 48 | 58 | 59 | 60 | 61 | 67 | 68 | 79 | 80 | 87 | 88 | 99 | 100 | 106 | 107 | 118 | 119 | 125 | 126 | 137 | 138 | 145 | 146 | 157 | 158 | 164 | 165 | 176 | 177 | 183 | 184 | 195 | 196 | 202 | 203 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/fragment_show_post.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 24 | 25 | 33 | 34 | 50 | 51 | 52 | 53 | 57 | 58 | 62 | 63 | 68 | 69 | 74 | 75 | 81 | 82 | 94 | 95 | 108 | 109 | 115 | 116 | 123 | 124 | 125 | 126 | 127 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_arshiv.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 24 | 25 | 30 | 31 | 32 | 41 | 42 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_category.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 24 | 25 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_comment_admin.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 16 | 17 | 29 | 30 | 34 | 35 | 36 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_comment_user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 16 | 17 | 29 | 30 | 34 | 35 | 36 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_main_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 20 | 21 | 27 | 28 | 33 | 34 | 45 | 46 | 57 | 58 | 62 | 63 | 69 | 70 | 71 | 80 | 81 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_main_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 19 | 20 | 24 | 25 | 36 | 37 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /WP_News/src/main/res/layout/row_main_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 18 | 19 | 25 | 26 | 37 | 38 | 43 | 44 | 48 | 49 | 56 | 57 | 58 | 67 | 68 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /WP_News/src/main/res/menu/navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 13 | 14 | 18 | 19 | 23 | 27 | -------------------------------------------------------------------------------- /WP_News/src/main/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/WP_News/src/main/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /WP_News/src/main/res/values-night-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #25292c 4 | #1E2123 5 | #FFFFFF 6 | #F4F4F4 7 | #E4E4E4 8 | #E4E4E4 9 | #40FFFFFF 10 | #393939 11 | #202020 12 | #282C30 13 | #3A3E42 14 | #1AFFFFFF 15 | #000 16 | #1d2122 17 | #B7C2C7 18 | #23384C 19 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 17 | 20 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFFFF 4 | #1E88E5 5 | #1E88E5 6 | #cc000000 7 | #5A5A5A 8 | #E4E4E4 9 | #e2e2e2 10 | #393939 11 | #202020 12 | #fff 13 | #fff 14 | #ced7db 15 | #e2e2e2 16 | #fff 17 | @color/colorAccent 18 | #B7C2C7 19 | #000 20 | #59a70f 21 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | اپلیکیشن خبری 4 | 5 | 6 | abbas ghasemi 7 | دسته بندی مطالب 8 | دیدگاه های پست 9 | برگه ها 10 | نشانه ها 11 | موردی برای نمایش وجود ندارد. 12 | موردی برای نمایش پیدا نشد!. 13 | جستجو 14 | 15 | 16 | دیدگاه ها 17 | باز کردن در مرورگر 18 | ارسال متن 19 | کپی متن 20 | اشتراک لینک 21 | کپی لینک 22 | 23 | 24 | منو 25 | خانه 26 | دسته ها 27 | اشتراک برنامه 28 | درباره ما 29 | ویژگی های برنامه 30 | نشان شده ها 31 | 32 | اینستاگرام 33 | تلگرام 34 | شرایط استفاده 35 | 36 | تمامی حقوق این اپلیکیشن متعلق به عباس قاسمی می باشد. 37 | \n\n 38 | Copy Right 2019 39 | \n 40 | برنامه نویس: عباس قاسمی 41 | 42 | 43 | تمامی حقوق این اپلیکیشن متعلق به عباس قاسمی می باشد. 44 | \n\n 45 | Copy Right 2019 46 | \n 47 | برنامه نویس: عباس قاسمی 48 | 49 | 50 | Open navigation drawer 51 | Close navigation drawer 52 | بررسی مجدد 53 | 54 | -------------------------------------------------------------------------------- /WP_News/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 18 | 19 | 23 | 24 | -------------------------------------------------------------------------------- /WP_News/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WP_News/src/main/res/xml/provider_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WP_News/src/test/java/ghasemi/abbas/wordpress/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package ghasemi.abbas.wordpress; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id 'com.android.application' version '7.4.2' apply false 4 | id 'com.android.library' version '7.4.2' apply false 5 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 28 16:37:06 IRST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /media/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasghasemi/wordpress/d5d77aa8c23a912cbdcc46dc8f0d9632fd768713/media/screenshot.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | maven { url 'https://jitpack.io' } 14 | } 15 | } 16 | rootProject.name = "wordpress" 17 | include ':WP_News' 18 | --------------------------------------------------------------------------------