package com.farcore.videoplayer;
import android.os.storage.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import com.subtitleparser.*;
import com.subtitleview.SubtitleView;
import android.content.Context;
import com.farcore.playerservice.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.provider.Settings.System;
import android.database.Cursor;
import android.provider.MediaStore;
import android.util.Log;
import android.view.*;
import android.widget.*;
public class playermenu extends Activity {
private static String TAG = "playermenu";
private static String codec_mips = null;
private static String InputFile = "/sys/class/audiodsp/codec_mips";
private static String OutputFile = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq";
/** Called when the activity is first created. */
private int totaltime = 0;
private int curtime = 0;
private int playPosition = 0;
private int cur_audio_stream = 0;
private int total_audio_num = 0;
private boolean backToFileList = false;
private boolean progressSliding = false;
private boolean INITOK = false;
private boolean FF_FLAG = false;
private boolean NOT_FIRSTTIME = false;
private static final int MID_FREESCALE = 0x10001;
//for repeat mode;
private static int m_playmode = 1;
private static final int REPEATLIST = 1;
private static final int REPEATONE = 2;
private SeekBar myProgressBar = null;
private ImageButton play = null;
private ImageButton fastforword = null;
private ImageButton fastreverse = null;
private TextView cur_time = null;
private TextView total_time = null;
private LinearLayout infobar = null;
private LinearLayout morbar = null;
private LinearLayout subbar = null;
private LinearLayout otherbar = null;
private AlertDialog confirm_dialog = null;
private BroadcastReceiver mReceiver = null;
Timer timer = new Timer();
Toast toast = null;
public MediaInfo bMediaInfo = null;
private static int PRE_NEXT_FLAG = 0;
private int resumeSecond = 8;
private int player_status = VideoInfo.PLAYER_UNKNOWN;
//for subtitle
private SubtitleUtils subMange = null;
private SubtitleView subTitleView = null;
private subview_set sub_para = null;
private int sub_switch_state = 0;
private int sub_font_state = 0;
private int sub_color_state = 0;
private TextView t_subswitch =null ;
private TextView t_subsfont=null ;
private TextView t_subscolor=null ;
private TextView morebar_tileText =null;
private String[] m_brightness= {"1","2","3","4"};
private static final String ACTION_HDMISWITCH_MODE_CHANGED =
"com.amlogic.HdmiSwitch.HDMISWITCH_MODE_CHANGED";
private boolean mSuspendFlag = false;
PowerManager.WakeLock mScreenLock = null;
private void videobar() {
setContentView(R.layout.layout_morebar);
subTitleView = (SubtitleView) findViewById(R.id.subTitle_more);
subTitleView.setTextColor(sub_para.color);
subTitleView.setTextSize(sub_para.font);
openFile(sub_para.sub_id);
subbar = (LinearLayout)findViewById(R.id.LinearLayout_sub);
subbar.setVisibility(View.GONE);
otherbar = (LinearLayout)findViewById(R.id.LinearLayout_other);
morebar_tileText = (TextView)findViewById(R.id.more_title);
otherbar.setVisibility(View.GONE);
morbar = (LinearLayout)findViewById(R.id.morebarLayout);
if (SettingsVP.display_mode.equals("480p"))
{
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) morbar.getLayoutParams();
linearParams.width = 710;
linearParams.bottomMargin = 15;
morbar.setLayoutParams(linearParams);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
morbar.requestFocus();
ImageButton resume = (ImageButton) findViewById(R.id.ImageButton01);
resume.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
otherbar.setVisibility(View.VISIBLE);
morbar.setVisibility(View.GONE);
morebar_tileText.setText(R.string.setting_resume);
ListView listView = (ListView)findViewById(R.id.AudioListView);
String[] m_resume= {
playermenu.this.getResources().getString(R.string.str_on),
playermenu.this.getResources().getString(R.string.str_off)
};
listView.setAdapter(new ArrayAdapter<String>(playermenu.this,
R.layout.list_row, m_resume));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
if (position == 0)
SettingsVP.putParaBoolean("ResumeMode", true);
else if (position == 1)
SettingsVP.putParaBoolean("ResumeMode", false);
otherbar.setVisibility(View.GONE);
morbar.setVisibility(View.VISIBLE);
}
});
otherbar.requestFocus();
}
});
ImageButton playmode = (ImageButton) findViewById(R.id.ImageButton02);
playmode.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
otherbar.setVisibility(View.VISIBLE);
morbar.setVisibility(View.GONE);
morebar_tileText.setText(R.string.setting_playmode);
ListView listView = (ListView)findViewById(R.id.AudioListView);
String[] m_repeat= {
playermenu.this.getResources().getString(R.string.setting_playmode_repeatall),
playermenu.this.getResources().getString(R.string.setting_playmode_repeatone)
};
listView.setAdapter(new ArrayAdapter<String>(playermenu.this,
R.layout.list_row,m_repeat));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
if (position == 0)
m_playmode = REPEATLIST;
else if (position == 1)
m_playmode = REPEATONE;
otherbar.setVisibility(View.GONE);
morbar.setVisibility(View.VISIBLE);
}
});
otherbar.requestFocus();
}
});
ImageButton audiotrack = (ImageButton) findViewById(R.id.ImageButton03);
audiotrack.setOnClickListener(new View.OnClickListener()