forked from recloudstream/cloudstream
		
	added logcat
This commit is contained in:
		
							parent
							
								
									e90862235a
								
							
						
					
					
						commit
						a14aef8418
					
				
					 9 changed files with 205 additions and 24 deletions
				
			
		|  | @ -577,6 +577,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | ||||||
|             createISO() |             createISO() | ||||||
|         }*/ |         }*/ | ||||||
| 
 | 
 | ||||||
|  |         if (BuildConfig.DEBUG) { | ||||||
|             var providersAndroidManifestString = "Current androidmanifest should be:\n" |             var providersAndroidManifestString = "Current androidmanifest should be:\n" | ||||||
|             for (api in allProviders) { |             for (api in allProviders) { | ||||||
|                 providersAndroidManifestString += "<data android:scheme=\"https\" android:host=\"${ |                 providersAndroidManifestString += "<data android:scheme=\"https\" android:host=\"${ | ||||||
|  | @ -587,6 +588,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             println(providersAndroidManifestString) |             println(providersAndroidManifestString) | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         handleAppIntent(intent) |         handleAppIntent(intent) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -699,27 +699,21 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio | ||||||
| 
 | 
 | ||||||
|             media_route_button?.alpha = if (chromecastSupport) 1f else 0.3f |             media_route_button?.alpha = if (chromecastSupport) 1f else 0.3f | ||||||
|             if (!chromecastSupport) { |             if (!chromecastSupport) { | ||||||
|                 media_route_button.setOnClickListener { |                 media_route_button?.setOnClickListener { | ||||||
|                     showToast(activity, R.string.no_chromecast_support_toast, Toast.LENGTH_LONG) |                     showToast(activity, R.string.no_chromecast_support_toast, Toast.LENGTH_LONG) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             activity?.let { |             activity?.let { act -> | ||||||
|                 if (it.isCastApiAvailable()) { |                 if (act.isCastApiAvailable()) { | ||||||
|                     try { |                     try { | ||||||
|                         CastButtonFactory.setUpMediaRouteButton(it, media_route_button) |                         CastButtonFactory.setUpMediaRouteButton(act, media_route_button) | ||||||
|                         val castContext = CastContext.getSharedInstance(it.applicationContext) |                         val castContext = CastContext.getSharedInstance(act.applicationContext) | ||||||
|  | 
 | ||||||
|  |                         media_route_button?.isGone = castContext.castState == CastState.NO_DEVICES_AVAILABLE | ||||||
| 
 | 
 | ||||||
|                         if (castContext.castState != CastState.NO_DEVICES_AVAILABLE) media_route_button.visibility = |  | ||||||
|                             VISIBLE |  | ||||||
|                         castContext.addCastStateListener { state -> |                         castContext.addCastStateListener { state -> | ||||||
|                             if (media_route_button != null) { |                             media_route_button?.isGone = state == CastState.NO_DEVICES_AVAILABLE | ||||||
|                                 if (state == CastState.NO_DEVICES_AVAILABLE) media_route_button.visibility = |  | ||||||
|                                     GONE else { |  | ||||||
|                                     if (media_route_button.visibility == GONE) media_route_button.visibility = |  | ||||||
|                                         VISIBLE |  | ||||||
|                                 } |  | ||||||
|                             } |  | ||||||
|                         } |                         } | ||||||
|                     } catch (e: Exception) { |                     } catch (e: Exception) { | ||||||
|                         logError(e) |                         logError(e) | ||||||
|  |  | ||||||
|  | @ -194,6 +194,8 @@ class SyncViewModel : ViewModel() { | ||||||
|                                 Log.i(TAG, "modifyData ${repo.name} => $newData") |                                 Log.i(TAG, "modifyData ${repo.name} => $newData") | ||||||
|                                 repo.score(id, newData) |                                 repo.score(id, newData) | ||||||
|                             } |                             } | ||||||
|  |                         } else if (result is Resource.Failure){ | ||||||
|  |                             Log.e(TAG, "modifyData getStatus error ${result.errorString}") | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  | @ -212,6 +214,7 @@ class SyncViewModel : ViewModel() { | ||||||
|                         _userDataResponse.postValue(result) |                         _userDataResponse.postValue(result) | ||||||
|                         return@launch |                         return@launch | ||||||
|                     } else if (result is Resource.Failure) { |                     } else if (result is Resource.Failure) { | ||||||
|  |                         Log.e(TAG, "updateUserData error ${result.errorString}") | ||||||
|                         lastError = result |                         lastError = result | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  | @ -233,6 +236,7 @@ class SyncViewModel : ViewModel() { | ||||||
|                         _metaResponse.postValue(result) |                         _metaResponse.postValue(result) | ||||||
|                         return@launch |                         return@launch | ||||||
|                     } else if (result is Resource.Failure) { |                     } else if (result is Resource.Failure) { | ||||||
|  |                         Log.e(TAG, "updateMetadata error ${result.errorString}") | ||||||
|                         lastError = result |                         lastError = result | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,8 @@ package com.lagradost.cloudstream3.ui.settings | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| import android.app.UiModeManager | import android.app.UiModeManager | ||||||
|  | import android.content.ClipData | ||||||
|  | import android.content.ClipboardManager | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
| import android.content.res.Configuration | import android.content.res.Configuration | ||||||
|  | @ -51,9 +53,15 @@ import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso | ||||||
| import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe | import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe | ||||||
| import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard | import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard | ||||||
| import com.lagradost.cloudstream3.utils.UIHelper.setImage | import com.lagradost.cloudstream3.utils.UIHelper.setImage | ||||||
|  | import com.lagradost.cloudstream3.utils.VideoDownloadManager | ||||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath | import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath | ||||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager.getDownloadDir | import com.lagradost.cloudstream3.utils.VideoDownloadManager.getDownloadDir | ||||||
|  | import kotlinx.android.synthetic.main.logcat.* | ||||||
|  | import okhttp3.internal.closeQuietly | ||||||
|  | import java.io.BufferedReader | ||||||
| import java.io.File | import java.io.File | ||||||
|  | import java.io.InputStreamReader | ||||||
|  | import java.io.OutputStream | ||||||
| import kotlin.concurrent.thread | import kotlin.concurrent.thread | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -500,6 +508,69 @@ class SettingsFragment : PreferenceFragmentCompat() { | ||||||
|             return@setOnPreferenceClickListener true |             return@setOnPreferenceClickListener true | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         getPref(R.string.show_logcat_key)?.setOnPreferenceClickListener { pref -> | ||||||
|  |             val builder = | ||||||
|  |                 AlertDialog.Builder(pref.context, R.style.AlertDialogCustom) | ||||||
|  |                     .setView(R.layout.logcat) | ||||||
|  | 
 | ||||||
|  |             val dialog = builder.create() | ||||||
|  |             dialog.show() | ||||||
|  |             val log = StringBuilder() | ||||||
|  |             try { | ||||||
|  |                 //https://developer.android.com/studio/command-line/logcat | ||||||
|  |                 val process = Runtime.getRuntime().exec("logcat -d") | ||||||
|  |                 val bufferedReader = BufferedReader( | ||||||
|  |                     InputStreamReader(process.inputStream) | ||||||
|  |                 ) | ||||||
|  | 
 | ||||||
|  |                 var line: String? | ||||||
|  |                 while (bufferedReader.readLine().also { line = it } != null) { | ||||||
|  |                     log.append(line) | ||||||
|  |                 } | ||||||
|  |             } catch (e: Exception) { | ||||||
|  |                 logError(e) // kinda ironic | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             val text = log.toString() | ||||||
|  |             dialog.text1?.text = text | ||||||
|  | 
 | ||||||
|  |             dialog.copy_btt?.setOnClickListener { | ||||||
|  |                 val serviceClipboard = | ||||||
|  |                     (activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager?) | ||||||
|  |                         ?: return@setOnClickListener | ||||||
|  |                 val clip = ClipData.newPlainText("logcat", text) | ||||||
|  |                 serviceClipboard.setPrimaryClip(clip) | ||||||
|  |                 dialog.dismissSafe(activity) | ||||||
|  |             } | ||||||
|  |             dialog.clear_btt?.setOnClickListener { | ||||||
|  |                 Runtime.getRuntime().exec("logcat -c") | ||||||
|  |                 dialog.dismissSafe(activity) | ||||||
|  |             } | ||||||
|  |             dialog.save_btt?.setOnClickListener { | ||||||
|  |                 var fileStream: OutputStream? = null | ||||||
|  |                 try { | ||||||
|  |                     fileStream = | ||||||
|  |                         VideoDownloadManager.setupStream( | ||||||
|  |                             it.context, | ||||||
|  |                             "logcat", | ||||||
|  |                             null, | ||||||
|  |                             "txt", | ||||||
|  |                             false | ||||||
|  |                         ).fileStream | ||||||
|  |                     fileStream?.writer()?.write(text) | ||||||
|  |                 } catch (e: Exception) { | ||||||
|  |                     logError(e) | ||||||
|  |                 } finally { | ||||||
|  |                     fileStream?.closeQuietly() | ||||||
|  |                     dialog.dismissSafe(activity) | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             dialog.close_btt?.setOnClickListener { | ||||||
|  |                 dialog.dismissSafe(activity) | ||||||
|  |             } | ||||||
|  |             return@setOnPreferenceClickListener true | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         getPref(R.string.app_layout_key)?.setOnPreferenceClickListener { |         getPref(R.string.app_layout_key)?.setOnPreferenceClickListener { | ||||||
|             val prefNames = resources.getStringArray(R.array.app_layout) |             val prefNames = resources.getStringArray(R.array.app_layout) | ||||||
|             val prefValues = resources.getIntArray(R.array.app_layout_values) |             val prefValues = resources.getIntArray(R.array.app_layout_values) | ||||||
|  |  | ||||||
|  | @ -581,7 +581,7 @@ object VideoDownloadManager { | ||||||
|      * Sets up the appropriate file and creates a data stream from the file. |      * Sets up the appropriate file and creates a data stream from the file. | ||||||
|      * Used for initializing downloads. |      * Used for initializing downloads. | ||||||
|      * */ |      * */ | ||||||
|     private fun setupStream( |     fun setupStream( | ||||||
|         context: Context, |         context: Context, | ||||||
|         name: String, |         name: String, | ||||||
|         folder: String?, |         folder: String?, | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								app/src/main/res/drawable/baseline_description_24.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/src/main/res/drawable/baseline_description_24.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     android:width="24dp" | ||||||
|  |     android:height="24dp" | ||||||
|  |     android:viewportWidth="24" | ||||||
|  |     android:viewportHeight="24" | ||||||
|  |     android:tint="?attr/white"> | ||||||
|  |   <path | ||||||
|  |       android:fillColor="@android:color/white" | ||||||
|  |       android:pathData="M14,2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6zM16,18L8,18v-2h8v2zM16,14L8,14v-2h8v2zM13,9L13,3.5L18.5,9L13,9z"/> | ||||||
|  | </vector> | ||||||
							
								
								
									
										79
									
								
								app/src/main/res/layout/logcat.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								app/src/main/res/layout/logcat.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,79 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |         xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |         android:orientation="vertical" | ||||||
|  |         android:layout_width="match_parent" | ||||||
|  |         android:layout_height="match_parent"> | ||||||
|  | 
 | ||||||
|  |     <ScrollView | ||||||
|  |             android:layout_marginBottom="60dp" | ||||||
|  |             android:layout_width="match_parent" | ||||||
|  |             android:layout_height="match_parent"> | ||||||
|  | 
 | ||||||
|  |         <TextView | ||||||
|  |                 android:id="@+id/text1" | ||||||
|  |                 android:padding="15dp" | ||||||
|  | 
 | ||||||
|  |                 android:textSize="15sp" | ||||||
|  |                 android:textColor="?attr/textColor" | ||||||
|  |                 android:layout_width="match_parent" | ||||||
|  |                 android:layout_rowWeight="1" | ||||||
|  |                 tools:text="Test" | ||||||
|  |                 android:layout_height="wrap_content" /> | ||||||
|  |     </ScrollView> | ||||||
|  | 
 | ||||||
|  |     <HorizontalScrollView | ||||||
|  |             android:id="@+id/apply_btt_holder" | ||||||
|  |             android:layout_gravity="bottom" | ||||||
|  |             android:gravity="bottom|end" | ||||||
|  |             android:layout_marginTop="-60dp" | ||||||
|  |             android:layout_width="match_parent" | ||||||
|  |             android:layout_height="60dp"> | ||||||
|  | 
 | ||||||
|  |         <LinearLayout | ||||||
|  |                 android:layout_width="wrap_content" | ||||||
|  |                 android:layout_height="match_parent" | ||||||
|  |                 android:orientation="horizontal"> | ||||||
|  | 
 | ||||||
|  |             <com.google.android.material.button.MaterialButton | ||||||
|  |                     android:nextFocusRight="@id/copy_btt" | ||||||
|  |                     android:id="@+id/save_btt" | ||||||
|  | 
 | ||||||
|  |                     style="@style/WhiteButton" | ||||||
|  |                     android:layout_gravity="center_vertical|end" | ||||||
|  |                     android:text="@string/sort_save" | ||||||
|  |                     android:layout_width="wrap_content" /> | ||||||
|  | 
 | ||||||
|  |             <com.google.android.material.button.MaterialButton | ||||||
|  |                     android:nextFocusLeft="@id/save_btt" | ||||||
|  |                     android:nextFocusRight="@id/clear_btt" | ||||||
|  |                     android:id="@+id/copy_btt" | ||||||
|  | 
 | ||||||
|  |                     style="@style/BlackButton" | ||||||
|  |                     android:layout_gravity="center_vertical|end" | ||||||
|  |                     android:text="@string/sort_copy" | ||||||
|  |                     android:layout_width="wrap_content" /> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |             <com.google.android.material.button.MaterialButton | ||||||
|  |                     android:nextFocusRight="@id/close_btt" | ||||||
|  |                     android:nextFocusLeft="@id/copy_btt" | ||||||
|  | 
 | ||||||
|  |                     style="@style/BlackButton" | ||||||
|  |                     android:layout_gravity="center_vertical|end" | ||||||
|  |                     android:text="@string/sort_clear" | ||||||
|  |                     android:id="@+id/clear_btt" | ||||||
|  |                     android:layout_width="wrap_content" /> | ||||||
|  | 
 | ||||||
|  |             <com.google.android.material.button.MaterialButton | ||||||
|  |                     android:nextFocusLeft="@id/clear_btt" | ||||||
|  |                     android:id="@+id/close_btt" | ||||||
|  | 
 | ||||||
|  |                     style="@style/BlackButton" | ||||||
|  |                     android:layout_gravity="center_vertical|end" | ||||||
|  |                     android:text="@string/sort_close" | ||||||
|  |                     android:layout_width="wrap_content" /> | ||||||
|  |         </LinearLayout> | ||||||
|  |     </HorizontalScrollView> | ||||||
|  | 
 | ||||||
|  | </LinearLayout> | ||||||
|  | @ -40,6 +40,8 @@ | ||||||
|     <string name="prefer_media_type_key" translatable="false">prefer_media_type_key</string> |     <string name="prefer_media_type_key" translatable="false">prefer_media_type_key</string> | ||||||
|     <string name="app_theme_key" translatable="false">app_theme_key</string> |     <string name="app_theme_key" translatable="false">app_theme_key</string> | ||||||
|     <string name="episode_sync_enabled_key" translatable="false">episode_sync_enabled_key</string> |     <string name="episode_sync_enabled_key" translatable="false">episode_sync_enabled_key</string> | ||||||
|  |     <string name="log_enabled_key" translatable="false">log_enabled_key</string> | ||||||
|  |     <string name="show_logcat_key" translatable="false">show_logcat_key</string> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     <!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG --> |     <!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG --> | ||||||
|  | @ -142,6 +144,11 @@ | ||||||
|     <string name="action_add_to_bookmarks">Set watch status</string> |     <string name="action_add_to_bookmarks">Set watch status</string> | ||||||
|     <string name="sort_apply">Apply</string> |     <string name="sort_apply">Apply</string> | ||||||
|     <string name="sort_cancel">Cancel</string> |     <string name="sort_cancel">Cancel</string> | ||||||
|  |     <string name="sort_copy">Copy</string> | ||||||
|  |     <string name="sort_close">Close</string> | ||||||
|  |     <string name="sort_clear">Clear</string> | ||||||
|  |     <string name="sort_save">Save</string> | ||||||
|  | 
 | ||||||
|     <string name="player_speed">Player Speed</string> |     <string name="player_speed">Player Speed</string> | ||||||
| 
 | 
 | ||||||
|     <string name="subtitles_settings">Subtitle Settings</string> |     <string name="subtitles_settings">Subtitle Settings</string> | ||||||
|  | @ -178,6 +185,8 @@ | ||||||
|     <string name="normal_no_plot">No Plot Found</string> |     <string name="normal_no_plot">No Plot Found</string> | ||||||
|     <string name="torrent_no_plot">No Description Found</string> |     <string name="torrent_no_plot">No Description Found</string> | ||||||
| 
 | 
 | ||||||
|  |     <string name="show_log_cat">Show logcat</string> | ||||||
|  | 
 | ||||||
|     <string name="picture_in_picture">Picture-in-picture</string> |     <string name="picture_in_picture">Picture-in-picture</string> | ||||||
|     <string name="picture_in_picture_des">Continues playback in a miniature player on top of other apps</string> |     <string name="picture_in_picture_des">Continues playback in a miniature player on top of other apps</string> | ||||||
|     <string name="player_size_settings">Player resize button</string> |     <string name="player_size_settings">Player resize button</string> | ||||||
|  |  | ||||||
|  | @ -206,6 +206,18 @@ | ||||||
|                 android:key="@string/restore_key" |                 android:key="@string/restore_key" | ||||||
|                 android:title="@string/restore_settings" /> |                 android:title="@string/restore_settings" /> | ||||||
| 
 | 
 | ||||||
|  |         <Preference | ||||||
|  |                 android:key="@string/show_logcat_key" | ||||||
|  |                 android:title="@string/show_log_cat" | ||||||
|  |                 android:icon="@drawable/baseline_description_24" /> | ||||||
|  | 
 | ||||||
|  |         <!--<SwitchPreference | ||||||
|  |                 android:defaultValue="false" | ||||||
|  |                 android:key="@string/log_enabled_key" | ||||||
|  |                 android:title="@string/toggle_logcat" | ||||||
|  |                 android:summary="@string/toggle_logcat_des" | ||||||
|  |                 android:icon="@drawable/baseline_description_24" />--> | ||||||
|  | 
 | ||||||
|         <SwitchPreference |         <SwitchPreference | ||||||
|                 android:icon="@drawable/netflix_download" |                 android:icon="@drawable/netflix_download" | ||||||
|                 android:key="@string/killswitch_key" |                 android:key="@string/killswitch_key" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue