plagin4pda's People
Forkers
snowvolfplagin4pda's Issues
Code Update
Нужно поправить код. Добавь меня в fork.
Это MainActivity.java
package com.trablone.plagin.forpda;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class MainActivity extends Activity
{
/* Called when the activity is first created. */
Uri mUri;
private String patch;
private String fileout = "/mnt/sdcard/data/4pdaclient/styles/";
private String plusFileOut = "mnt/sdcard/Android/data/org.softeg.slartus.forpdaplus/files/styles/";
private String[] filesOut= {fileout, plusFileOut };
private String nameFile;
private String style;
private String errorOpen = "Ошибка открытия стиля!";
private String error = "Ошибка сохранения! Стиль удален или перемещен";
private String saveOk = "Стиль успешно сохранен!";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.plagin);
final TextView light = (TextView)findViewById(R.id.textLight);
final TextView black = (TextView)findViewById(R.id.textBlack);
final TextView dark = (TextView)findViewById(R.id.textDark);
//final TextView white = (TextView)findViewById(R.id.textWhite);
Intent i = getIntent();
String action = i.getAction();
String type = i.getType();
if (Intent.ACTION_VIEW.equals(action))
{
mUri = getIntent().getData();
patch = mUri.getPath();
if (patch != null)
openNamedFile(patch);
}
light.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
if (nameFile != null)
{
copyLight();
}
else
{
toastShow(error);
finish();
}
}
{
// TODO: Implement this method
}
});
black.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
if (nameFile != null)
{
copyBlack();
}
else
{
toastShow(error);
finish();
}
}
});
dark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
if (nameFile != null)
{
copyDark();
}
else
{
toastShow(error);
finish();
}
}
});
}
private void copyLight(){
style = "light";
copyFile(style);
}
private void copyBlack(){
style = "black";
copyFile(style);
}
private void copyDark(){
style = "dark";
copyFile(style);
}
private void deleteOriginal()
{
File file = new File(patch);
if (file.exists())
{
boolean deleted = file.delete();
}
}
private void copyFile(final String style){
findViewById(R.id.plaginLinearLayout).setVisibility(View.GONE);
findViewById(R.id.plaginProgressBar).setVisibility(View.VISIBLE);
Handler handler = new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run()
{
File in = new File(patch);
for(String file : filesOut){
File out = new File(file + style);
com.trablone.plagin.forpda.EIfile.exportStyle(in, out, nameFile);
}
deleteOriginal();
finish();
toastShow(saveOk);
}
}, 500);
}
protected void openNamedFile(String patch)
{
try
{
File f = new File(patch);
FileInputStream fis = new FileInputStream(f);
long size = f.length();
nameFile = f.getName();
DataInputStream dis = new DataInputStream(fis);
byte[] b = new byte[(int) size];
int length = dis.read(b, 0, (int) size);
dis.close();
fis.close();
String ttt = new String(b, 0, length, "UTF-8");
if(nameFile.indexOf("light") >= 0){
copyLight();
}
if(nameFile.indexOf("black") >= 0){
copyBlack();
}
if(nameFile.indexOf("dark") >= 0){
copyDark();
}
}
catch (FileNotFoundException e)
{
toastShow(errorOpen);
}
catch (IOException e)
{
toastShow(errorOpen);
}
}
{
// TODO: Implement this method
}
private void toastShow(String toastText)
{
Toast toast = Toast.makeText
(this, toastText, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.