move cache location
This commit is contained in:
parent
6c83a96491
commit
ce28a53de7
5 changed files with 48 additions and 7 deletions
|
@ -11,10 +11,16 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider;
|
||||||
|
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
||||||
|
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import asgardius.page.s3manager.databinding.ActivitySettingsBinding;
|
import asgardius.page.s3manager.databinding.ActivitySettingsBinding;
|
||||||
|
|
||||||
public class Settings extends AppCompatActivity {
|
public class Settings extends AppCompatActivity {
|
||||||
|
@ -24,13 +30,13 @@ public class Settings extends AppCompatActivity {
|
||||||
SQLiteDatabase db;
|
SQLiteDatabase db;
|
||||||
String videocache, videotime, buffersize, playlisttime;
|
String videocache, videotime, buffersize, playlisttime;
|
||||||
EditText vcachepick, vtimepick, bsizepick, ptimepick;
|
EditText vcachepick, vtimepick, bsizepick, ptimepick;
|
||||||
Button saveprefs, about;
|
Button saveprefs, about, clearcache;
|
||||||
SwitchMaterial isplaylist;
|
SwitchMaterial isplaylist;
|
||||||
|
StandaloneDatabaseProvider standaloneDatabaseProvider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
vcachepick = (EditText)findViewById(R.id.videocache);
|
vcachepick = (EditText)findViewById(R.id.videocache);
|
||||||
|
@ -73,6 +79,7 @@ public class Settings extends AppCompatActivity {
|
||||||
playlisttime = (cursor.getString(0));
|
playlisttime = (cursor.getString(0));
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
@ -100,6 +107,25 @@ public class Settings extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
getprefs.start();
|
getprefs.start();
|
||||||
|
|
||||||
|
clearcache = (Button)findViewById(R.id.clearcache);
|
||||||
|
clearcache.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//buttonaction
|
||||||
|
try {
|
||||||
|
standaloneDatabaseProvider = new StandaloneDatabaseProvider(getApplicationContext());
|
||||||
|
SimpleCache.delete(new File(getApplicationContext().getFilesDir(), "media"), standaloneDatabaseProvider);
|
||||||
|
standaloneDatabaseProvider.close();
|
||||||
|
Toast.makeText(getApplicationContext(),getResources().getString(R.string.clearcache_ok), Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
//This launch account add screen
|
||||||
|
//addaccount(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//This is to add new user account
|
//This is to add new user account
|
||||||
saveprefs = (Button)findViewById(R.id.saveprefs);
|
saveprefs = (Button)findViewById(R.id.saveprefs);
|
||||||
saveprefs.setOnClickListener(new View.OnClickListener(){
|
saveprefs.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@ -153,6 +179,12 @@ public class Settings extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private void aboutPage () {
|
private void aboutPage () {
|
||||||
|
|
||||||
Intent intent = new Intent(this, WebBrowser.class);
|
Intent intent = new Intent(this, WebBrowser.class);
|
||||||
|
@ -163,7 +195,6 @@ public class Settings extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mainmenu() {
|
private void mainmenu() {
|
||||||
|
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
intent.putExtra("EXIT", true);
|
intent.putExtra("EXIT", true);
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
mediaSession.setActive(true);
|
mediaSession.setActive(true);
|
||||||
evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
|
evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
|
||||||
simpleCache = new SimpleCache(
|
simpleCache = new SimpleCache(
|
||||||
new File(this.getCacheDir(), "media"),
|
new File(this.getFilesDir(), "media"),
|
||||||
evictor,
|
evictor,
|
||||||
standaloneDatabaseProvider);
|
standaloneDatabaseProvider);
|
||||||
playerView.setPlayer(player);
|
playerView.setPlayer(player);
|
||||||
|
@ -338,7 +338,7 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
//System.out.println("WakeLock acquired");
|
//System.out.println("WakeLock acquired");
|
||||||
}
|
}
|
||||||
mediaSessionConnector.setPlayer(null);
|
mediaSessionConnector.setPlayer(null);
|
||||||
deleteCache(this, standaloneDatabaseProvider);
|
//deleteCache(this, standaloneDatabaseProvider);
|
||||||
mediaSession.setActive(false);
|
mediaSession.setActive(false);
|
||||||
playerNotificationManager.setPlayer(null);
|
playerNotificationManager.setPlayer(null);
|
||||||
player.release();
|
player.release();
|
||||||
|
@ -429,9 +429,9 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleteCache(Context context, StandaloneDatabaseProvider database) {
|
/*static void deleteCache(Context context, StandaloneDatabaseProvider database) {
|
||||||
SimpleCache.delete(new File(context.getCacheDir(), "media"), database);
|
SimpleCache.delete(new File(context.getCacheDir(), "media"), database);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:textColorHint="?attr/colorOnSecondary"/>
|
android:textColorHint="?attr/colorOnSecondary"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/clearcache"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="70dp"
|
||||||
|
android:text="@string/clearcache" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -125,4 +125,6 @@
|
||||||
<string name="set_private">Establecer como privado</string>
|
<string name="set_private">Establecer como privado</string>
|
||||||
<string name="parent_policy">Política establecida por carpeta padre</string>
|
<string name="parent_policy">Política establecida por carpeta padre</string>
|
||||||
<string name="expiration_not_required">Fecha de expiración no requerida</string>
|
<string name="expiration_not_required">Fecha de expiración no requerida</string>
|
||||||
|
<string name="clearcache">Limpiar Cache de Video</string>
|
||||||
|
<string name="clearcache_ok">Cache limpiada exitosamente</string>
|
||||||
</resources>
|
</resources>
|
|
@ -129,4 +129,6 @@
|
||||||
<string name="set_private">Set as private</string>
|
<string name="set_private">Set as private</string>
|
||||||
<string name="parent_policy">Policy set by parent folder</string>
|
<string name="parent_policy">Policy set by parent folder</string>
|
||||||
<string name="expiration_not_required">Expiration date not required</string>
|
<string name="expiration_not_required">Expiration date not required</string>
|
||||||
|
<string name="clearcache">Clear Video Cache</string>
|
||||||
|
<string name="clearcache_ok">Cache clean successfully</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue