Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.iran.sunni.time;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.Locale;
- import java.util.Timer;
- import java.util.TimerTask;
- import android.app.Activity;
- import android.app.AlarmManager;
- import android.app.Dialog;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Typeface;
- import android.graphics.drawable.ColorDrawable;
- import android.os.Bundle;
- import android.view.KeyEvent;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.Window;
- import android.view.WindowManager;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.RadioButton;
- import android.widget.ScrollView;
- import android.widget.Spinner;
- import android.widget.TextView;
- import com.google.android.gms.ads.AdListener;
- import com.google.android.gms.ads.AdRequest;
- import com.google.android.gms.ads.AdView;
- public class PrayerTimeActivity extends Activity {
- TextView fajarTime, ishraTime, zuharTime, asarTime, margibTime, ishaTime,
- dateText, timeText,
- countryText, // qiblaDirection,//cityText,
- diffText, fajarText, zuharText, asarText, magribText, ishaText,
- sunRiseText, islmaicTimeText;
- private ScrollView scrollView;
- Spinner citySpinner;
- String hijriMonthName[];
- int notificationId = 1;
- NotificationManager notificationManager;
- public MyDailoag customDialog = new MyDailoag(this);
- LinearLayout fajarLayout, sunRiseLayout, zuharLayout, asarLayout,
- magribLayout, ishaLayout, prayerLayout, qiblaLayout, settingLayout;
- ImageView imgPrayer, imgQibla, imgSettings;// imgCalendar,imgMore;
- private final String DEV_HASH = "5725V9X2K1PEBJZK4HMN3YRUYS5WB";
- public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
- public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
- public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
- public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
- public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;
- private static int adNo = 0;
- public Country countryData = new Country(this);
- public static ArrayList<String> paryerData = null;
- public ArrayList<String> paryerData1 = null;
- public String fajaralarm = "true", zuharAlarm = "true",
- asarAlarm = "true", magribAlarm = "true", ishaAlarm = "true";
- ImageView fajarAudio, sunRiseAudio, zuharAudio, asarAudio, magribAudio,
- ishaAudio;
- int i = 3;
- boolean fajarCheck = true, sunRiseCheck = true, zuharCheck = true,
- asarCheck = true, magribCheck = true, ishaCheck = true,
- showDialog = true;
- Timer timer = new Timer();
- TimerTask timer1;
- // LinearLayout ltcountry;
- public String calMethod = "3";
- String[] calMethods;
- public static Context context;
- public static ArrayList<String> getData = new ArrayList<String>();
- public static ArrayList<String> country = new ArrayList<String>();
- public static ArrayList<String> cites = new ArrayList<String>();
- public static ArrayList<String> latitude = new ArrayList<String>();
- public static ArrayList<String> timeZone = new ArrayList<String>();
- public static ArrayList<String> longitude = new ArrayList<String>();
- RadioButton hanfi, shafi;
- public static String lati, longi, qibla, currentCounty, currentCity,
- timezone;
- String firka = "Shafi";
- // ListView menu_dialog;
- public PrayerTimeActivity() {
- context = this;
- }
- public void setAlarmImage() {
- if (Settings.storeData.getTextData("audio").equals("")) {
- //////////// On all prayer times
- fajaralarm = "true";
- fajarCheck = false;
- setAlarm(paryerData.get(0), 0);
- fajarAudio.setImageResource(R.drawable.sound_on);
- zuharAlarm = "true";
- zuharCheck = false;
- setAlarm(paryerData.get(2), 2);
- zuharAudio.setImageResource(R.drawable.sound_on);
- asarAlarm = "true";
- asarCheck = false;
- setAlarm(paryerData.get(3), 3);
- asarAudio.setImageResource(R.drawable.sound_on);
- magribAlarm = "true";
- magribCheck = false;
- setAlarm(paryerData.get(4), 4);
- magribAudio.setImageResource(R.drawable.sound_on);
- ishaAlarm = "true";
- ishaCheck = false;
- setAlarm(paryerData.get(5), 5);
- ishaAudio.setImageResource(R.drawable.sound_on);
- } else {
- String[] highlight = Settings.storeData.getTextData("audio").split(
- ",");
- if (highlight[0].equals("true")) {
- fajaralarm = "true";
- fajarCheck = false;
- setAlarm(paryerData.get(0), 0);
- fajarAudio.setImageResource(R.drawable.sound_on);
- } else {
- fajaralarm = "false";
- fajarCheck = true;
- removeAlarm(paryerData.get(0), 0);
- fajarAudio.setImageResource(R.drawable.sound_off);
- }
- if (highlight[1].equals("true")) {
- zuharAlarm = "true";
- zuharCheck = false;
- setAlarm(paryerData.get(2), 2);
- zuharAudio.setImageResource(R.drawable.sound_on);
- } else {
- zuharAlarm = "false";
- zuharCheck = true;
- removeAlarm(paryerData.get(2), 2);
- zuharAudio.setImageResource(R.drawable.sound_off);
- }
- if (highlight[2].equals("true")) {
- asarAlarm = "true";
- asarCheck = false;
- setAlarm(paryerData.get(3), 3);
- asarAudio.setImageResource(R.drawable.sound_on);
- } else {
- asarAlarm = "false";
- asarCheck = true;
- removeAlarm(paryerData.get(3), 3);
- asarAudio.setImageResource(R.drawable.sound_off);
- }
- if (highlight[3].equals("true")) {
- magribAlarm = "true";
- magribCheck = false;
- setAlarm(paryerData.get(4), 4);
- magribAudio.setImageResource(R.drawable.sound_on);
- } else {
- magribAlarm = "false";
- magribCheck = true;
- removeAlarm(paryerData.get(4), 4);
- magribAudio.setImageResource(R.drawable.sound_off);
- }
- if (highlight[4].equals("true")) {
- ishaAlarm = "true";
- ishaCheck = false;
- setAlarm(paryerData.get(5), 5);
- ishaAudio.setImageResource(R.drawable.sound_on);
- } else {
- ishaAlarm = "false";
- ishaCheck = true;
- removeAlarm(paryerData.get(5), 5);
- ishaAudio.setImageResource(R.drawable.sound_off);
- }
- }
- }
- public void readFile()
- {
- getData.clear();
- country.clear();
- cites.clear();
- latitude.clear();
- longitude.clear();
- timeZone.clear();
- try
- {
- countryData.getAllCountires();
- int index = 0;
- if (Settings.storeData.getTextData("text").equals("")) {
- ArrayList<ArrayList<String>> value = countryData
- .getAllDataCities("Iran");
- country = countryData.myCountries;
- cites = value.get(0);
- latitude = value.get(1);
- longitude = value.get(2);
- timeZone = value.get(4);
- calMethod = "3";
- } else {
- String value = Settings.storeData.getTextData("text");
- String[] str = Settings.storeData.getTextData("text").split(",");
- int countyCode = countryData.myCountries.indexOf("Iran");
- ArrayList<ArrayList<String>> list = countryData
- .getAllDataCities(str[0]);
- cites = list.get(0);
- latitude = list.get(1);
- longitude = list.get(2);
- timeZone = list.get(4);
- calMethod = "" + Integer.parseInt((str[7]));
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- if (!hasFocus) {
- String saveString = fajaralarm + "," + zuharAlarm + "," + asarAlarm
- + "," + magribAlarm + "," + ishaAlarm;
- Settings.storeData.saveTextData("audio", saveString);
- /*
- * if(imgPrayer!=null) {
- * imgPrayer.setImageResource(R.drawable.prayertab_on);
- * imgQibla.setImageResource(R.drawable.qiblahtab_off);
- * imgSettings.setImageResource(R.drawable.settingtab_off);
- * //imgMore.setImageResource(R.drawable.moretab_off);
- * //imgCalendar.setImageResource(R.drawable.calendertab_off); }
- */} else if (!showDialog) {
- showDialog = false;
- showMenu();
- }
- }
- public void setNotification(String time) {
- String serName = Context.NOTIFICATION_SERVICE;
- notificationManager = (NotificationManager) getSystemService(serName);
- // define notification using: icon, text, and timing.
- int icon = R.drawable.ic_launcher;
- String tickerText = "1. My Notification TickerText";
- long when = System.currentTimeMillis();
- Notification notification = new Notification(icon, tickerText, when);
- // configure appearance of the notification
- String extendedTitle = getString(R.string.app_name);
- String extendedText = "It's " + time + " Prayer Time";
- // set a Pending Activity to take care of the potential request the user
- // may have by clicking on the notification asking for more explanations
- Intent intent = new Intent(getApplicationContext(),
- PrayerTimeActivity.class);
- intent.putExtra("extendedText", extendedText);
- intent.putExtra("extendedTitle", extendedTitle);
- PendingIntent launchIntent = PendingIntent.getActivity(
- getApplicationContext(), 0, intent, 0);
- notification.setLatestEventInfo(getApplicationContext(), extendedTitle,
- extendedText, launchIntent);
- // trigger notification
- notificationId = 1;
- notificationManager.notify(notificationId, notification);
- }
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.main);
- initGui();
- calMethods = new String[] { getResources().getString(R.string.ummal_qura_makkah),
- getResources().getString(R.string.university_of_islamic_science_karachi), getResources().getString(R.string.muslim_world_league),
- getResources().getString(R.string.muslim_world_league_iran),getResources().getString(R.string.egypton_general_authority_of_survey),
- getResources().getString(R.string.islamic_society_of_north_america) };
- hijriMonthName = new String[] { getString(R.string.muharram), getString(R.string.Safar), getString(R.string.rabiulawal),
- getString(R.string.rabiulsani), getString(R.string.jamadiulawal), getString(R.string.jamadiulakhir), getString(R.string.Rajab),
- getString(R.string.shaban), getString(R.string.ramadan), getString(R.string.shawal), getString(R.string.zeqad),
- getString(R.string.zilhajj) };
- setListener();
- readFile();
- selectCountryAndValues();
- calculateParyerTime();
- setIslamicDate();
- setAlarmImage();
- startTimer();
- }
- public void setIslamicDate() {
- Date date = new Date();
- islmaicTimeText.setText(""
- + getIslamicTime(date.getYear() + 1900, date.getMonth() + 1,
- date.getDate()));
- }
- public void selectCountryAndValues() {
- if (Settings.storeData.getTextData("text").equals("")) {
- countryText.setText(cites.get(cites.indexOf("Tehran")) + ", "
- + country.get(country.indexOf("Iran")));
- currentCounty = country.get(country.indexOf("Iran"));
- // cityText.setText(cites.get(0));
- currentCity = cites.get(cites.indexOf("Tehran"));
- timezone = timeZone.get(cites.indexOf("Tehran"));
- lati = latitude.get(cites.indexOf("Tehran"));
- longi = longitude.get(cites.indexOf("Tehran"));
- firka = getString(R.string.shafi);
- } else {
- String[] values = Settings.storeData.getTextData("text").split(",");
- countryText.setText(values[1] + ", " + values[0]);
- currentCounty = values[0];
- // cityText.setText(values[1]);
- currentCity = values[1];
- lati = values[2];
- longi = values[3];
- qibla = values[4];
- firka = values[5];
- timezone = values[6];
- }
- }
- public String getDayFromDate(int year, int month, int day)
- throws ParseException {
- String dateString = String.format("%d-%d-%d", year, month, day);
- Date date = new SimpleDateFormat("yyyy-M-d").parse(dateString);
- // Then get the day of week from the Date based on specific locale.
- String dayOfWeek = new SimpleDateFormat("EEEE", Locale.ENGLISH)
- .format(date);
- String monthName = new SimpleDateFormat("MMM").format(date);
- return dayOfWeek;
- }
- public String getMonthFromDate(int year, int month, int day)
- throws ParseException {
- String dateString = String.format("%d-%d-%d", year, month, day);
- Date date = new SimpleDateFormat("yyyy-M-d").parse(dateString);
- // Then get the day of week from the Date based on specific locale.
- ;
- String monthName = new SimpleDateFormat("MMM").format(date);
- return monthName;
- }
- public void calculateParyerTime() {
- // calcuate current System time
- PrayTime pt = new PrayTime(this);
- Calendar cal = Calendar.getInstance();
- DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd/hh/mm/a");
- Date date = new Date();
- int hour = date.getHours();
- int min = date.getMinutes();
- String yourDate = dateFormat.format(cal.getTime());
- // calculate paryer Times
- String[] time = yourDate.split("/");
- int currenthourTime = 0;
- int currentminTime = 0;
- try {
- String dayName = getDayFromDate(Integer.parseInt(time[0]),
- Integer.parseInt(time[1]), Integer.parseInt(time[2]));
- String monthName = getMonthFromDate(Integer.parseInt(time[0]),
- Integer.parseInt(time[1]), Integer.parseInt(time[2]));
- dateText.setText(dayName.substring(0, 3) + ", " + time[2] + " "
- + monthName);
- String text = time[3] + ":" + time[4] + " " + time[5];
- //Typeface type = Typeface.createFromAsset(getAssets(),
- // "fonts/DS-DIGIT.TTF");
- //timeText.setTypeface(type);
- String ampm="";
- if (time[5].equals("pm")) {
- ampm = ""+ getString(R.string.pm);
- } else {
- ampm = ""+ getString(R.string.am);
- }
- timeText.setText(time[3] + ":" + time[4] + " " + ampm);
- currenthourTime = Integer.parseInt(time[3]);
- currentminTime = Integer.parseInt(time[4]);
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (firka.equals(getString(R.string.hanfi))) {
- pt.setAsrJuristic(pt.Hanafi);
- pt.getHanafi();
- } else {
- pt.setAsrJuristic(pt.Shafii);
- pt.getShafii();
- }
- calculasMethod(pt);
- pt.setAdjustHighLats(pt.AngleBased);
- int[] offsets = { 0, 0, 0, 0, 0, 0, 0 }; // {Fajr,Sunrise,Dhuhr,Asr,Sunset,Maghrib,Isha}
- pt.tune(offsets);
- double valuee = adjustLatitude(lati);
- double value1 = adjustLongitude(longi);
- // getQiblaDriectionFromLatiLongi(valuee+"", value1+"");
- paryerData = pt.getDatePrayerTimes(Integer.parseInt(time[0]),
- Integer.parseInt(time[1]), Integer.parseInt(time[2]),
- adjustLatitude(lati), adjustLongitude(longi),
- Double.parseDouble(timezone));
- paryerData.remove(paryerData.size() - 2);
- ArrayList<String> am_pmList;
- applyDayNightSetting();
- ajustTime();
- /////////Add hour in prayer times//////
- paryerData1 = paryerData;
- adjustOneHourTime();
- String setDuration = getTimeDiff(paryerData, Integer.parseInt(time[3]),
- Integer.parseInt(time[4]), time[5]);
- String[] value = setDuration.split(":");
- hightlistParyerTime(Integer.parseInt(value[2]));
- if (Integer.parseInt(value[0]) == 0) {
- if (Integer.parseInt(value[1]) != 0) {
- diffText.setText(pt.timeNames.get(Integer.parseInt(value[2]))
- + " "+getString(R.string.after)+" " + value[1] + " "+getString(R.string.mins));
- } else {
- diffText.setText(getString(R.string.time) +" "+getString(R.string.namaz) +" "+
- pt.timeNames.get(Integer.parseInt(value[2])));
- }
- } else {
- diffText.setText(pt.timeNames.get(Integer.parseInt(value[2]))
- + " "+getString(R.string.after)+" " + value[0] + " "+getString(R.string.hour)+" "+getString(R.string.and)
- +" " + value[1] + " "+getString(R.string.mins));
- }
- // pt.setTimeFormat(pt.Time12);
- am_pmList = setFormate(paryerData);
- fajarTime.setText(setTimeFormat(paryerData.get(0)) + " "
- + am_pmList.get(0));
- ishraTime.setText(setTimeFormat(paryerData.get(1)) + " "
- + am_pmList.get(1));
- zuharTime.setText(setTimeFormat(paryerData.get(2)) + " "
- + am_pmList.get(2));
- asarTime.setText(setTimeFormat(paryerData.get(3)) + " "
- + am_pmList.get(3));
- margibTime.setText(setTimeFormat(paryerData.get(4)) + " "
- + am_pmList.get(4));
- ishaTime.setText(setTimeFormat(paryerData.get(5)) + " "
- + am_pmList.get(5));
- }
- public void getQiblaDriectionFromLatiLongi(String lati, String longi) {
- double direction = QiblaDirectionCalculator.getQiblaDirectionFromNorth(
- Double.parseDouble(lati), Double.parseDouble(longi)) + 10;
- // qiblaDirection.setText("Qiblah: "+new
- // DecimalFormat("###.####").format(direction) + " clockwise");
- }
- public Double adjustLatitude(String lati) {
- Double laty = Double.parseDouble(lati);
- if (!lati.contains(".")) {
- laty = laty / 10000;
- } else {
- laty = Double.parseDouble(lati);
- }
- return laty;
- }
- public Double adjustLongitude(String longi) {
- Double longy = Double.parseDouble(longi);
- if (!longi.contains(".")) {
- longy = longy / 10000;
- } else {
- longy = Double.parseDouble(longi);
- }
- return longy;
- }
- public void ajustTime() {
- {
- String dtFajarSetting = Settings.storeData.getTextData("At0");
- if (!dtFajarSetting.equals("")) {
- String[] dnValue = dtFajarSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- // ----------------------------------
- {
- String dtSunRiseSetting = Settings.storeData.getTextData("At1");
- if (!dtSunRiseSetting.equals("")) {
- String[] dnValue = dtSunRiseSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- // ---------------------------
- {
- String dtZuharSetting = Settings.storeData.getTextData("At2");
- if (!dtZuharSetting.equals("")) {
- String[] dnValue = dtZuharSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- // ---------------------------------------
- {
- String dtAsarSetting = Settings.storeData.getTextData("At3");
- if (!dtAsarSetting.equals("")) {
- String[] dnValue = dtAsarSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- {
- String dtMagribSetting = Settings.storeData.getTextData("At4");
- if (!dtMagribSetting.equals("")) {
- String[] dnValue = dtMagribSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- {
- String dtIshaSetting = Settings.storeData.getTextData("At5");
- if (!dtIshaSetting.equals("")) {
- String[] dnValue = dtIshaSetting.split(",");
- int index = Integer.parseInt(dnValue[0]);
- int totalMin = Integer.parseInt(dnValue[1]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- }
- }
- }
- public void adjustOneHourTime() {
- int index = 0;
- int totalMin;
- {
- String dtFajarSetting = Settings.storeData.getTextData("At0");
- //if (!dtFajarSetting.equals("")) {
- String[] dnValue = dtFajarSetting.split(",");
- totalMin = 60;
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- // ----------------------------------
- index++;
- {
- String dtSunRiseSetting = Settings.storeData.getTextData("At1");
- //if (!dtSunRiseSetting.equals("")) {
- // String[] dnValue = dtSunRiseSetting.split(",");
- //int index = Integer.parseInt(dnValue[0]);
- totalMin = 60;
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- // ---------------------------
- index++;
- {
- String dtZuharSetting = Settings.storeData.getTextData("At2");
- //if (!dtZuharSetting.equals("")) {
- //String[] dnValue = dtZuharSetting.split(",");
- //int index = Integer.parseInt(dnValue[0]);
- totalMin = 60;
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- // ---------------------------------------
- index++;
- {
- /*if (firka.equals(getString(R.string.shafi))) {
- totalMin = -19;
- } else {
- totalMin = 57;
- }*/
- totalMin = 60;
- String dtAsarSetting = Settings.storeData.getTextData("At3");
- //if (!dtAsarSetting.equals("")) {
- //String[] dnValue = dtAsarSetting.split(",");
- //int index = Integer.parseInt(dnValue[0]);
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- index++;
- {
- String dtMagribSetting = Settings.storeData.getTextData("At4");
- //if (!dtMagribSetting.equals("")) {
- //String[] dnValue = dtMagribSetting.split(",");
- //int index = Integer.parseInt(dnValue[0]);
- totalMin = 60;
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- index++;
- {
- String dtIshaSetting = Settings.storeData.getTextData("At5");
- // if (!dtIshaSetting.equals("")) {
- // String[] dnValue = dtIshaSetting.split(",");
- //int index = Integer.parseInt(dnValue[0]);
- totalMin = 60;
- paryerData.add(index, addMin(totalMin, paryerData.get(index)));
- paryerData.remove(index + 1);
- //}
- }
- }
- public void applyDayNightSetting() {
- String dnSetting = Settings.storeData.getTextData("dn");
- if (dnSetting.equals(""))
- return;
- String[] dnValue = dnSetting.split(",");
- int totalMin = Integer.parseInt(dnValue[1]);
- if (dnValue[0].equals("true")) {
- for (int i = 0; i < paryerData.size(); i++) {
- paryerData
- .add(i,
- set24HourFormate(
- addMin(totalMin, paryerData.get(i)), i));
- paryerData.remove(i + 1);
- }
- }
- }
- public void SetAlarm(Context context) {
- // AlarmManager
- // am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
- // Intent intent = new Intent(context, AlarmActivity.class);
- // PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);
- // After after 30 seconds
- // am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
- // 1000 , pi);
- }
- public void calculasMethod(PrayTime pt) {
- if (calMethod.equals("0")) {
- pt.setCalcMethod(pt.Makkah);
- }
- if (calMethod.equals("1")) {
- pt.setCalcMethod(pt.Karachi);
- }
- if (calMethod.equals("2")) {
- pt.setCalcMethod(pt.MWL);
- }
- if (calMethod.equals("3")) {
- pt.setCalcMethod(pt.MWL);
- }
- if (calMethod.equals("4")) {
- pt.setCalcMethod(pt.Egypt);
- }
- if (calMethod.equals("5")) {
- pt.setCalcMethod(pt.ISNA);
- }
- }
- public String set24HourFormate(String prayerMin, int index) {
- String[] str = prayerMin.split(":");
- int hour = Integer.parseInt(str[0]);
- int min = Integer.parseInt(str[1]);
- if (index > 1) {
- hour = hour + 12;
- }
- return hour + ":" + min + "";
- }
- public static String applyAlermelay(String time, int index) {
- int totalMin = Integer.parseInt(time);
- String value = addMin(totalMin, paryerData.get(index));
- return addDelayMin(totalMin, paryerData.get(index));
- }
- public static String addMin(int mins, String prayerMin) {
- String[] str = prayerMin.split(":");
- int hour = Integer.parseInt(str[0]);
- int min = Integer.parseInt(str[1]);
- min = min + mins;
- if (min >= 60) {
- int h = (int) min / 60;
- hour += h;
- int m = (int) min % 60;
- min = m;
- }
- if (min < 0) {
- int h = (int) min / 60;
- hour = hour + (h - 1);
- int m = 60 + (int) min % 60;
- min = m;
- }
- return hour + ":" + min + "";
- }
- public static String addDelayMin(int mins, String prayerMin) {
- String[] str = prayerMin.split(":");
- int hour = Integer.parseInt(str[0]);
- int min = Integer.parseInt(str[1]);
- min = min + mins;
- if (min >= 60) {
- hour = (hour + (int) min / 60);
- if (hour == 0)
- hour = 1;
- min = min % 60;
- } else {
- hour = hour % 12;
- if (hour == 0)
- hour = 12;
- min = min % 60;
- }
- return hour + ":" + min + "";
- }
- public static String getTimeDiff(ArrayList<String> paryer,
- int currenthourTime, int currentminTime, String formate) {
- String[] getMin = paryer.get(1).split(" ");
- String diff = "";
- ArrayList<String> resultTime = new ArrayList<String>();
- String time1 = "", time2 = "", resultHour = "", resultMin = "0";
- Date date = null;
- // if(formate.equals(getMin[1].toUpperCase()))
- date = new Date("12/12/11 " + currenthourTime + ":" + currentminTime
- + ":" + "00 " + formate);
- time1 = new SimpleDateFormat("HH").format(date);
- time2 = new SimpleDateFormat("mm").format(date);
- int paryerH = 0, currentH = 0;
- String[] times = null;
- for (int i = 0; i < paryer.size(); i++) {
- // if (i == 4)
- // continue;
- times = paryer.get(i).split(":");
- paryerH = Integer.parseInt(times[0]);
- currentH = Integer.parseInt(time1);
- if (paryerH >= currentH) {
- resultHour = ""
- + (Integer.parseInt(times[0]) - Integer.parseInt(time1));
- if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
- int remainMin = 60 - Integer.parseInt(time2);
- int remainHour = (Integer.parseInt(resultHour));
- if (remainHour <= 0) {
- resultMin = Integer.parseInt(time2)
- - Integer.parseInt(times[1]) + "";
- continue;
- }
- remainHour--;
- remainMin = remainMin + (Integer.parseInt(times[1]));
- resultHour = "" + remainHour;
- resultMin = "" + remainMin;
- } else {
- resultMin = ""
- + (Integer.parseInt(times[1]) - Integer
- .parseInt(time2));
- }
- resultTime.add(resultHour + ":" + resultMin + ":" + i);
- }
- }
- if (resultTime.size() < 1) {
- if (currentH > 18) {
- times = paryer.get(0).split(":");
- paryerH = Integer.parseInt(times[0]);
- currentH = Integer.parseInt(time1);
- int time = 24 - currentH;
- int totalHour = time + paryerH;
- resultHour = "" + totalHour;
- if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
- int remainMin = 60 - Integer.parseInt(time2);
- int remainHour = (Integer.parseInt(resultHour));
- remainHour--;
- remainMin = remainMin + (Integer.parseInt(times[1]));
- resultHour = "" + remainHour;
- resultMin = "" + remainMin;
- } else {
- resultMin = ""
- + (Integer.parseInt(times[1]) - Integer
- .parseInt(time2));
- }
- resultTime.add(resultHour + ":" + resultMin + ":" + 0);
- } else {
- resultHour = "" + (currentH - paryerH);
- if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
- int remainMin = 60 - Integer.parseInt(time2);
- int remainHour = (Integer.parseInt(resultHour));
- remainHour--;
- remainMin = remainMin + (Integer.parseInt(times[1]));
- resultHour = "" + remainHour;
- resultMin = "" + remainMin;
- } else {
- resultMin = ""
- + (Integer.parseInt(times[1]) - Integer
- .parseInt(time2));
- }
- resultTime.add(resultHour + ":" + resultMin + ":" + 0);
- }
- }
- String mytime = resultTime.get(0);
- return mytime;
- }
- public void hightlistParyerTime(int index) {
- if (index == 0) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- fajarText.setTextColor(getResources().getColor(R.color.pressed));
- fajarTime.setTextColor(getResources().getColor(R.color.pressed));
- sunRiseText.setTextColor(getResources().getColor(R.color.norm));
- ishraTime.setTextColor(getResources().getColor(R.color.norm));
- zuharText.setTextColor(getResources().getColor(R.color.norm));
- zuharTime.setTextColor(getResources().getColor(R.color.norm));
- asarText.setTextColor(getResources().getColor(R.color.norm));
- asarTime.setTextColor(getResources().getColor(R.color.norm));
- magribText.setTextColor(getResources().getColor(R.color.norm));
- margibTime.setTextColor(getResources().getColor(R.color.norm));
- ishaText.setTextColor(getResources().getColor(R.color.norm));
- ishaTime.setTextColor(getResources().getColor(R.color.norm));
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- }
- if (index == 1) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- sunRiseText.setTextColor(getResources().getColor(R.color.pressed));
- ishraTime.setTextColor(getResources().getColor(R.color.pressed));
- fajarText.setTextColor(getResources().getColor(R.color.norm));
- fajarTime.setTextColor(getResources().getColor(R.color.norm));
- zuharText.setTextColor(getResources().getColor(R.color.norm));
- zuharTime.setTextColor(getResources().getColor(R.color.norm));
- asarText.setTextColor(getResources().getColor(R.color.norm));
- asarTime.setTextColor(getResources().getColor(R.color.norm));
- magribText.setTextColor(getResources().getColor(R.color.norm));
- margibTime.setTextColor(getResources().getColor(R.color.norm));
- ishaText.setTextColor(getResources().getColor(R.color.norm));
- ishaTime.setTextColor(getResources().getColor(R.color.norm));
- zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- }
- if (index == 2) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- zuharLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- zuharText.setTextColor(getResources().getColor(R.color.pressed));
- zuharTime.setTextColor(getResources().getColor(R.color.pressed));
- fajarText.setTextColor(getResources().getColor(R.color.norm));
- fajarTime.setTextColor(getResources().getColor(R.color.norm));
- sunRiseText.setTextColor(getResources().getColor(R.color.norm));
- ishraTime.setTextColor(getResources().getColor(R.color.norm));
- asarText.setTextColor(getResources().getColor(R.color.norm));
- asarTime.setTextColor(getResources().getColor(R.color.norm));
- magribText.setTextColor(getResources().getColor(R.color.norm));
- margibTime.setTextColor(getResources().getColor(R.color.norm));
- ishaText.setTextColor(getResources().getColor(R.color.norm));
- ishaTime.setTextColor(getResources().getColor(R.color.norm));
- asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- }
- if (index == 3) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- asarLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- asarText.setTextColor(getResources().getColor(R.color.pressed));
- asarTime.setTextColor(getResources().getColor(R.color.pressed));
- fajarText.setTextColor(getResources().getColor(R.color.norm));
- fajarTime.setTextColor(getResources().getColor(R.color.norm));
- sunRiseText.setTextColor(getResources().getColor(R.color.norm));
- ishraTime.setTextColor(getResources().getColor(R.color.norm));
- zuharText.setTextColor(getResources().getColor(R.color.norm));
- zuharTime.setTextColor(getResources().getColor(R.color.norm));
- magribText.setTextColor(getResources().getColor(R.color.norm));
- margibTime.setTextColor(getResources().getColor(R.color.norm));
- ishaText.setTextColor(getResources().getColor(R.color.norm));
- ishaTime.setTextColor(getResources().getColor(R.color.norm));
- magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- }
- if (index == 4) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- magribLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- magribText.setTextColor(getResources().getColor(R.color.pressed));
- margibTime.setTextColor(getResources().getColor(R.color.pressed));
- fajarText.setTextColor(getResources().getColor(R.color.norm));
- fajarTime.setTextColor(getResources().getColor(R.color.norm));
- sunRiseText.setTextColor(getResources().getColor(R.color.norm));
- ishraTime.setTextColor(getResources().getColor(R.color.norm));
- zuharText.setTextColor(getResources().getColor(R.color.norm));
- zuharTime.setTextColor(getResources().getColor(R.color.norm));
- asarText.setTextColor(getResources().getColor(R.color.norm));
- asarTime.setTextColor(getResources().getColor(R.color.norm));
- ishaText.setTextColor(getResources().getColor(R.color.norm));
- ishaTime.setTextColor(getResources().getColor(R.color.norm));
- ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- }
- if (index == 5) {
- fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
- ishaLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
- ishaText.setTextColor(getResources().getColor(R.color.pressed));
- ishaTime.setTextColor(getResources().getColor(R.color.pressed));
- fajarText.setTextColor(getResources().getColor(R.color.norm));
- fajarTime.setTextColor(getResources().getColor(R.color.norm));
- sunRiseText.setTextColor(getResources().getColor(R.color.norm));
- ishraTime.setTextColor(getResources().getColor(R.color.norm));
- zuharText.setTextColor(getResources().getColor(R.color.norm));
- zuharTime.setTextColor(getResources().getColor(R.color.norm));
- asarText.setTextColor(getResources().getColor(R.color.norm));
- asarTime.setTextColor(getResources().getColor(R.color.norm));
- magribText.setTextColor(getResources().getColor(R.color.norm));
- margibTime.setTextColor(getResources().getColor(R.color.norm));
- }
- }
- public static String setTimeFormat(String time) {
- String newTime = "";
- String formate = "";
- String[] mytime = time.split(":");
- int hour = Integer.parseInt(mytime[0]);
- int hourTime = (hour % 12);
- if (hourTime == 0)
- hourTime = 12;
- newTime = setformate(hourTime + "") + ":" + setformate(mytime[1]);
- return newTime;
- }
- public ArrayList<String> setFormate(ArrayList<String> times) {
- String formate;
- ArrayList<String> str = new ArrayList<String>();
- try {
- for (int i = 0; i < times.size(); i++) {
- String time = times.get(i);
- String[] mytime = time.split(":");
- int hour = Integer.parseInt(mytime[0]);
- if (hour >= 12) {
- formate = ""+ getString(R.string.pm);
- } else {
- formate = ""+ getString(R.string.am);
- }
- str.add(formate);
- }
- } catch (Exception e) {
- }
- return str;
- }
- public static String setformate(String str) {
- if (Integer.parseInt(str) < 10) {
- if (str.length() == 1)
- str = "0" + str;
- }
- return str;
- }
- public void startTimer() {
- timer.scheduleAtFixedRate(new TimerTask() {
- public void run() {
- runOnUiThread(new Runnable() {
- public void run() {
- calculateParyerTime();
- }
- });
- }
- }, 0, 500);
- }
- public void setAlarm(String alarmTime, int alarmId) {
- SetAlarm(this);
- //
- Date date = new Date();
- String[] alram = alarmTime.split(":");
- int hour = Integer.parseInt(alram[0]);
- int min = Integer.parseInt(alram[1]);
- //
- AlarmManager objAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
- //
- Calendar now = Calendar.getInstance();
- Calendar objCalendar = Calendar.getInstance();
- int a = objCalendar.get(Calendar.YEAR);
- int b = objCalendar.get(Calendar.MONTH);
- int c = objCalendar.get(Calendar.DAY_OF_MONTH);
- objCalendar.set(a, b, c, hour, min);
- now.setTime(date);
- if (objCalendar.before(now)) {
- objCalendar.set(Calendar.DATE, c + 1);
- // objCalendar.add(Calendar.DATE, 1); //Add 1 day if time selected
- // before now
- }
- Intent alamShowIntent = new Intent(this, AlarmActivity.class);
- alamShowIntent.putExtra("AlramId", "" + alarmId);
- alamShowIntent.putExtra("name", PrayTime.timeNames.get(alarmId));
- alamShowIntent.putExtra("lati", lati);
- alamShowIntent.putExtra("longi", longi);
- alamShowIntent.putExtra("timeZone", timezone);
- alamShowIntent.putExtra("firka", firka);
- PendingIntent alarmPendingIntent = PendingIntent.getActivity(this,
- alarmId, alamShowIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- objAlarmManager.set(AlarmManager.RTC_WAKEUP,
- objCalendar.getTimeInMillis(),
- // objCalendar.getTimeInMillis(),
- alarmPendingIntent);
- }
- public void removeAlarm(String alarmTime, int alarmId) {
- AlarmManager objAlarmManager = (AlarmManager) this
- .getSystemService(Context.ALARM_SERVICE);
- Intent alamShowIntent = new Intent(this, AlarmActivity.class);
- PendingIntent alarmPendingIntent = PendingIntent.getActivity(this,
- alarmId, alamShowIntent, 0);
- objAlarmManager.cancel(alarmPendingIntent);
- }
- public void setListener() {
- /*
- * qiblaLayout.setOnClickListener(new OnClickListener() {
- *
- * public void onClick(View v) { startActivity(new
- * Intent(PrayerTimeActivity.this,QiblaCompass.class)); } });
- *
- *
- * ltcountry.setOnClickListener(new OnClickListener() {
- *
- * public void onClick(View v) { if(!showDialog) { showDialog=true; //
- * menu_dialog.setVisibility(View.GONE); //
- * menu_dialog.setAnimation(upAnimation()); return; } } });
- */
- fajarAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- int alaramId = 0;
- if (fajarCheck || fajaralarm == "false") {
- fajaralarm = "true";
- String alarmtime = paryerData.get(0);
- setAlarm(alarmtime, 0);
- fajarAudio.setImageResource(R.drawable.sound_on);
- fajarCheck = false;
- } else {
- fajaralarm = "false";
- removeAlarm(paryerData.get(0), 0);
- fajarAudio.setImageResource(R.drawable.sound_off);
- fajarCheck = true;
- }
- }
- });
- sunRiseAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- }
- });
- zuharAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- if (zuharCheck || zuharAlarm == "false") {
- zuharAlarm = "true";
- String alarmtime = paryerData.get(2);
- setAlarm(alarmtime, 2);
- zuharAudio.setImageResource(R.drawable.sound_on);
- zuharCheck = false;
- } else {
- zuharAlarm = "false";
- removeAlarm(paryerData.get(2), 2);
- zuharAudio.setImageResource(R.drawable.sound_off);
- zuharCheck = true;
- }
- }
- });
- asarAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- if (asarCheck || asarAlarm == "false") {
- asarAlarm = "true";
- String alarmtime = paryerData.get(3);
- setAlarm(alarmtime, 3);
- asarAudio.setImageResource(R.drawable.sound_on);
- asarCheck = false;
- } else {
- asarAlarm = "false";
- removeAlarm(paryerData.get(3), 3);
- asarAudio.setImageResource(R.drawable.sound_off);
- asarCheck = true;
- }
- }
- });
- magribAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- if (magribCheck || magribAlarm == "false") {
- magribAlarm = "true";
- String alarmtime = paryerData.get(4);
- setAlarm(alarmtime, 4);
- magribAudio.setImageResource(R.drawable.sound_on);
- magribCheck = false;
- } else {
- magribAlarm = "false";
- removeAlarm(paryerData.get(4), 4);
- magribAudio.setImageResource(R.drawable.sound_off);
- magribCheck = true;
- }
- }
- });
- ishaAudio.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- if (ishaCheck || ishaAlarm == "false") {
- ishaAlarm = "true";
- String alarmtime = paryerData.get(5);
- setAlarm(alarmtime, 5);
- ishaAudio.setImageResource(R.drawable.sound_on);
- ishaCheck = false;
- } else {
- ishaAlarm = "false";
- removeAlarm(paryerData.get(5), 5);
- ishaAudio.setImageResource(R.drawable.sound_off);
- ishaCheck = true;
- }
- }
- });
- fajarLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.fajar));
- // startActivity(new
- // Intent(PrayerTimeActivity.this,AlarmActivity.class));
- }
- });
- sunRiseLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.sunrise));
- }
- });
- zuharLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.zuhar));
- }
- });
- asarLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.asar));
- }
- });
- magribLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // /menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.maghrib));
- }
- });
- ishaLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- return;
- }
- ;
- customDialog.showDialog(getString(R.string.isha));
- }
- });
- imgPrayer.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- return;
- }
- prayerLayout
- .setBackgroundResource(R.drawable.footer_tab_select_line);
- qiblaLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- settingLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- }
- });
- imgQibla.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- return;
- }
- prayerLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- qiblaLayout
- .setBackgroundResource(R.drawable.footer_tab_select_line);
- settingLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- PrayerTimeActivity.this.finish();
- startActivity(new Intent(PrayerTimeActivity.this,
- QiblaCompass.class));
- }
- });
- imgSettings.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if (!showDialog) {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- return;
- }
- prayerLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- qiblaLayout
- .setBackgroundResource(R.drawable.footer_tab_unselect_line);
- settingLayout
- .setBackgroundResource(R.drawable.footer_tab_select_line);
- PrayerTimeActivity.this.finish();
- startActivity(new Intent(getApplicationContext(),
- Settings.class));
- }
- });
- }
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- // ShowRateDialog();
- // Widget.pushWidgetUpdate(getApplicationContext());
- exitDialog();
- return false;
- }
- if (keyCode == KeyEvent.KEYCODE_MENU) {
- showMenu();
- }
- return super.onKeyDown(keyCode, event);
- }
- public void showMenu() {
- if (showDialog) {
- showDialog = false;
- // menu_dialog.setVisibility(View.VISIBLE);
- // menu_dialog.setAnimation(downAnimation());
- } else {
- showDialog = true;
- // menu_dialog.setVisibility(View.GONE);
- // menu_dialog.setAnimation(upAnimation());
- }
- }
- private void exitDialog() {
- final Dialog exitDialog = new Dialog(this);
- exitDialog.setCancelable(false);
- exitDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- exitDialog.setContentView(R.layout.exitdialog);
- exitDialog.getWindow().setBackgroundDrawable(
- new ColorDrawable(android.graphics.Color.TRANSPARENT));
- TextView laterbtn = (TextView) exitDialog.findViewById(R.id.ok);
- TextView likebtn = (TextView) exitDialog.findViewById(R.id.Cancel);
- laterbtn.setOnClickListener(new OnClickListener() {
- public void onClick(View arg0) {
- PrayerTimeActivity.this.finish();
- exitDialog.cancel();
- exitDialog.dismiss();
- }
- });
- likebtn.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- exitDialog.cancel();
- exitDialog.dismiss();
- }
- });
- exitDialog.show();
- }
- public String getIslamicTime(int g_y, int g_m, int g_d) {
- int year, month, day;
- int zyr;
- int zd;
- int zm;
- int zy;
- float zjd;
- int zl;
- int zn;
- int zj;
- year = g_y;
- month = g_m;
- day = g_d;
- zyr = year;
- zd = day;
- zm = month;
- zy = zyr;
- if ((zy > 1582) || ((zy == 1582) && (zm > 10))
- || ((zy == 1582) && (zm == 10) && (zd > 14))) {
- zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4)
- + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12)
- - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd
- - 32075;
- } else {
- zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4)
- + ((275 * zm) / 9) + zd + 1729777;
- }
- zl = (int) (zjd - 1948440 + 10632);
- zn = ((zl - 1) / 10631);
- zl = zl - 10631 * zn + 354;
- zj = (((10985 - zl) / 5316)) * ((int) ((50 * zl) / 17719))
- + ((zl / 5670)) * ((int) ((43 * zl) / 15238));
- zl = zl - (((30 - zj) / 15)) * (((17719 * zj) / 50)) - ((zj / 16))
- * (((15238 * zj) / 43)) + 29;
- zm = ((24 * zl) / 709);
- zd = zl - ((709 * zm) / 24);
- zy = 30 * zn + zj - 30;
- return "" + zd + " " + hijriMonthName[zm - 1] + " " + zy;
- }
- public void initGui() {
- // qiblaLayout=(LinearLayout) findViewById(R.id.qiblaLayout);
- // qiblaDirection = (TextView) findViewById(R.id.qiblaDireation);
- // qiblaDirection.setSelected(true);
- fajarTime = (TextView) findViewById(R.id.fajarTime);
- ishraTime = (TextView) findViewById(R.id.IshraTime);
- zuharTime = (TextView) findViewById(R.id.zuharTime);
- asarTime = (TextView) findViewById(R.id.asarTime);
- islmaicTimeText = (TextView) findViewById(R.id.islmaicTime);
- margibTime = (TextView) findViewById(R.id.magribTime);
- ishaTime = (TextView) findViewById(R.id.IshaTime);
- countryText = (TextView) findViewById(R.id.conturyText);
- countryText.setSelected(true);
- // cityText = (TextView) findViewById(R.id.cityText);
- // cityText.setSelected(true);
- dateText = (TextView) findViewById(R.id.dateText);// citySpinner=(Spinner)findViewById(R.id.citySpinner);
- timeText = (TextView) findViewById(R.id.timeText);//
- // ltcountry = (LinearLayout) findViewById(R.id.ltcountry);
- diffText = (TextView) findViewById(R.id.diffText);
- fajarText = (TextView) findViewById(R.id.fajarText);
- sunRiseText = (TextView) findViewById(R.id.IshraText);
- zuharText = (TextView) findViewById(R.id.zuharText);
- asarText = (TextView) findViewById(R.id.asarText);
- magribText = (TextView) findViewById(R.id.magribText);
- ishaText = (TextView) findViewById(R.id.IshaText);
- fajarAudio = (ImageView) findViewById(R.id.audiofajar);
- sunRiseAudio = (ImageView) findViewById(R.id.audiosunRise);
- zuharAudio = (ImageView) findViewById(R.id.audioZuhar);
- asarAudio = (ImageView) findViewById(R.id.audioAsar);
- magribAudio = (ImageView) findViewById(R.id.audioMagrib);
- ishaAudio = (ImageView) findViewById(R.id.audioIsha);
- fajarLayout = (LinearLayout) findViewById(R.id.fajarLayout);
- sunRiseLayout = (LinearLayout) findViewById(R.id.sunRiseLayout);
- zuharLayout = (LinearLayout) findViewById(R.id.zuharLayout);
- asarLayout = (LinearLayout) findViewById(R.id.asarLayout);
- magribLayout = (LinearLayout) findViewById(R.id.magribLayout);
- ishaLayout = (LinearLayout) findViewById(R.id.ishaLayout);
- prayerLayout = (LinearLayout) findViewById(R.id.LayoutImagePrayer);
- qiblaLayout = (LinearLayout) findViewById(R.id.LayoutImageQibla);
- settingLayout = (LinearLayout) findViewById(R.id.LayoutImageSettings);
- imgPrayer = (ImageView) findViewById(R.id.imgPrayer);
- imgQibla = (ImageView) findViewById(R.id.imgQibla);
- imgSettings = (ImageView) findViewById(R.id.imgSettings);
- scrollView = (ScrollView) findViewById(R.id.scrollView);
- // imgCalendar = (ImageView)findViewById(R.id.imgCalendar);
- // imgMore = (ImageView)findViewById(R.id.imgMore);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement