Керемет идея! Төменде файл аттарын БҰЗБАЙ, қосымша...

Erstellt am: 24. Oktober 2025

Beantwortet mit GPT-5 Thinking von Chat01

Frage

Керемет идея! Төменде файл аттарын БҰЗБАЙ, қосымшаны “Алматы City Guide (қала гиді)” тақырыбына бейімдеп бердім. Тек мәтіндер мен логиканың мағынасы өзгертілді; класс/файл атаулары сол күйі қалады. Код үзінділерін өз файлдарыңызға жай ғана алмастырып қойыңыз.


1) AndroidManifest.xml

(Тек түсініктеме мен қажет болса COARSE рұқсатын қостым – аттары өзгермейді.)

xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapplication67"> <!-- 🌐 Интернет пен хабарлама/геолокация --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Қажет болса: --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.Material3.DayNight.NoActionBar"> <!-- 🏙️ Басты бет (қала гиді) --> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- 📲 Қосымша беттер (экстра функциялар) --> <activity android:name=".ToolsActivity" android:exported="true" /> <!-- ⏰ Тур еске салғыш --> <receiver android:name=".ReminderReceiver" android:exported="false" /> <!-- 🌤️ Ауа райы хабарламасы --> <receiver android:name=".WeatherReceiver" android:exported="false" /> </application> </manifest>

2) com.example.myapplication67.MainActivity

(Студент тақырыбынан – қала қонағын қарсы алатын гидке ауыстырдық. Маршрут/санат логикасы сол Map арқылы жұмыс істейді.)

java
package com.example.myapplication67; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.*; import androidx.appcompat.app.AppCompatActivity; import java.text.SimpleDateFormat; import java.util.*; public class MainActivity extends AppCompatActivity { EditText etName, etGroup; // etGroup енді "Санат" ретінде қолданылады (FOOD/MUSEUM/NATURE) TextView tvOutput, tvSchedule, tvTime; Button btnSave, btnDelete, btnLocation, btnLink, btnTools; WebView webView; Map<String, String> scheduleMap = new HashMap<>(); Handler handler = new Handler(); long startTime; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("Almaty City Guide"); etName = findViewById(R.id.etName); etGroup = findViewById(R.id.etGroup); tvOutput = findViewById(R.id.tvOutput); tvSchedule = findViewById(R.id.tvSchedule); tvTime = findViewById(R.id.tvTime); btnSave = findViewById(R.id.btnSave); btnDelete = findViewById(R.id.btnDelete); btnLocation = findViewById(R.id.btnLocation); btnLink = findViewById(R.id.btnLink); btnTools = findViewById(R.id.btnTools); webView = findViewById(R.id.webView); initSchedules(); startTime = System.currentTimeMillis(); startTimer(); btnSave.setOnClickListener(v -> { String name = etName.getText().toString().trim(); String group = etGroup.getText().toString().trim().toUpperCase(); // FOOD/MUSEUM/NATURE if (name.isEmpty() || group.isEmpty()) { Toast.makeText(this, "⚠️ Атыңыз бен санатты енгізіңіз!", Toast.LENGTH_SHORT).show(); return; } tvOutput.setText("🧑‍💼 Қонақ: " + name + "\n🗂️ Санат: " + group); if (scheduleMap.containsKey(group)) { tvSchedule.setText("🗺️ Ұсынылған маршрут:\n\n" + scheduleMap.get(group)); } else { tvSchedule.setText("❌ Бұл санат үшін маршрут табылмады. Мысалы: FOOD, MUSEUM, NATURE"); } Toast.makeText(this, "✅ Сапар ақпараты сақталды", Toast.LENGTH_SHORT).show(); }); btnDelete.setOnClickListener(v -> { etName.setText(""); etGroup.setText(""); tvOutput.setText(""); tvSchedule.setText(""); webView.loadUrl("about:blank"); Toast.makeText(this, "🗑️ Деректер тазаланды", Toast.LENGTH_SHORT).show(); }); btnLocation.setOnClickListener(v -> { // Көк-Төбе координаттары try { Uri gmmIntentUri = Uri.parse("geo:43.23022,76.95417?q=Kok+Tobe+(Алматы+көрікті+жері)"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); Toast.makeText(this, "📍 Көк-Төбе картасы ашылды", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://2gis.kz/almaty/search/%D0%9A%D0%BE%D0%BA-%D0%A2%D0%BE%D0%B1%D0%B5")); startActivity(browserIntent); } }); btnLink.setOnClickListener(v -> { webView.setWebViewClient(new WebViewClient()); webView.loadUrl("https://visitalmaty.kz/"); }); btnTools.setOnClickListener(v -> { Intent intent = new Intent(MainActivity.this, ToolsActivity.class); startActivity(intent); }); } private void startTimer() { handler.postDelayed(new Runnable() { @Override public void run() { long now = System.currentTimeMillis(); long elapsed = now - startTime; SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); String currentTime = sdf.format(new Date()); long seconds = elapsed / 1000; long minutes = seconds / 60; long hours = minutes / 60; seconds %= 60; minutes %= 60; String elapsedStr = String.format(Locale.getDefault(), "%02d:%02d:%02d", hours, minutes, seconds); tvTime.setText("🕓 Ағымдағы уақыт: " + currentTime + "\n⏱️ Қолданба ашылғаннан бері: " + elapsedStr); handler.postDelayed(this, 1000); } }, 1000); } private void initSchedules() { // Категория бойынша жеңіл маршруттар (үлгі) scheduleMap.put("FOOD", "09:00 – Таңғы ас: Navat\n" + "13:00 – Түскі ас: Kaganat\n" + "19:00 – Кешкі ас: Line Brew\n" + "20:30 – Арбат бойымен серуен"); scheduleMap.put("MUSEUM", "10:00 – ҚР Орталық музейі\n" + "12:00 – ҚазҰУ музейі (кампус)\n" + "15:00 – «Ә.Қастеев атындағы өнер музейі»\n" + "18:00 – Панорамалар үшін Көк-Төбе"); scheduleMap.put("NATURE", "08:30 – Көлсай/Қайыңды (1 күндік тур)\n" + "10:00 – Немесе Медеу – Шымбұлақ бағыты\n" + "17:30 – Шағын треккинг\n" + "20:00 – Қалаға оралу"); } }

3) com.example.lab7.MainActivity (Kotlin)

(“Жақын туристік нысанды” табатын етіп мәтіндерін өзгерттім. Логика сол қалпында.)

kotlin
package com.example.lab7 // ... imports сол қалпында ... class MainActivity : AppCompatActivity() { // id/логика өзгермейді // Тек көрсетілетін мәтіндер қала гидіне бейімделді // ... onCreate т.б. сол қалпында ... private fun updateNearest() { val loc = bestCurrentLocation() ?: run { tvNearestResult.text = "📍 Ағымдағы орын анықталмады" return } if (places.isEmpty()) { tvNearestResult.text = "ℹ️ Туристік нысандар базасы бос" return } var best: ServicePlace? = null var bestDist = Double.MAX_VALUE for (p in places) { val d = haversineKm(loc.latitude, loc.longitude, p.lat, p.lon) if (d < bestDist) { bestDist = d best = p } } best?.let { tvNearestResult.text = "Ең жақын: «${it.name}» (${it.type}) — %.2f км\n%s".format(bestDist, it.address ?: "") } } // ... қалғаны өзгеріссіз ... }

assets/places.json файлыңызға “музей”, “кафе”, “көрікті жер” сияқты нысандарды енгізсеңіз болды (төменде үлгісі бар).


4) ReminderReceiver.java

(“Сабақ” → “Тур/серуен” еске салғышы.)

java
package com.example.myapplication67; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; public class ReminderReceiver extends BroadcastReceiver { private static final String CHANNEL_ID = "reminder_channel"; @Override public void onReceive(Context context, Intent intent) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( CHANNEL_ID, "Reminder Notifications", NotificationManager.IMPORTANCE_HIGH ); channel.setDescription("Серуен/тур еске салғыш хабарламалары"); NotificationManager manager = context.getSystemService(NotificationManager.class); if (manager != null) manager.createNotificationChannel(channel); } NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(android.R.drawable.ic_popup_reminder) .setContentTitle("⏰ Еске салғыш") .setContentText("Серуеніңіз басталуға жақын! 🗺️") .setPriority(NotificationCompat.PRIORITY_HIGH) .setAutoCancel(true); NotificationManagerCompat nm = NotificationManagerCompat.from(context); if (androidx.core.content.ContextCompat.checkSelfPermission( context, android.Manifest.permission.POST_NOTIFICATIONS) == android.content.pm.PackageManager.PERMISSION_GRANTED) { nm.notify(1, builder.build()); } } }

5) WeatherReceiver.java

(Ауа райын “Алматы туры” контекстінде көрсетеді. Каналды шақыруды қостым.)

java
package com.example.myapplication67; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import org.json.JSONObject; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class WeatherReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Каналды бірден тіркейміз createWeatherNotificationChannel(context); new Thread(() -> { try { String apiKey = "2d3fd51b9caaad1f31e2b19b020d0f1f"; // prod-та қауіпсіз сақтаңыз String urlString = "https://api.openweathermap.org/data/2.5/weather?q=Almaty&appid=" + apiKey + "&units=metric&lang=ru"; URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder response = new StringBuilder(); String line; while ((line = reader.readLine()) != null) response.append(line); reader.close(); JSONObject json = new JSONObject(response.toString()); JSONObject main = json.getJSONObject("main"); JSONObject weather = json.getJSONArray("weather").getJSONObject(0); double temp = main.getDouble("temp"); String desc = weather.getString("description"); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "weather_channel") .setSmallIcon(android.R.drawable.ic_menu_compass) .setContentTitle("🌤️ Алматы ауа райы") .setContentText(String.format("Серуенге қолайлы ма? %.1f°C — %s", temp, desc)) .setPriority(NotificationCompat.PRIORITY_HIGH) .setAutoCancel(true); NotificationManagerCompat.from(context).notify(2, builder.build()); } catch (Exception e) { e.printStackTrace(); } }).start(); } public static void createWeatherNotificationChannel(Context context) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( "weather_channel", "Weather Channel", NotificationManager.IMPORTANCE_HIGH ); channel.setDescription("Ауа райы туралы хабарламалар"); NotificationManager manager = context.getSystemService(NotificationManager.class); if (manager != null) manager.createNotificationChannel(channel); } } }

6) res/layout/activity_main.xml

(Бет тақырыбы/батырмалар – туризмге лайықталды. Id-лер өзгермейді.)

xml
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F5FAFF" android:padding="20dp"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"> <TextView android:text="🗺️ Almaty City Guide" android:textSize="24sp" android:textStyle="bold" android:textColor="#1565C0" android:letterSpacing="0.05" android:layout_marginBottom="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <EditText android:id="@+id/etName" android:hint="Есіміңіз" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp" android:background="@drawable/edittext_bg_blue" android:textColor="#0D47A1" android:textSize="16sp" android:layout_marginBottom="12dp" /> <EditText android:id="@+id/etGroup" android:hint="Санат (FOOD / MUSEUM / NATURE)" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp" android:background="@drawable/edittext_bg_blue" android:textColor="#0D47A1" android:textSize="16sp" android:layout_marginBottom="18dp" /> <Button android:id="@+id/btnSave" android:text="💾 Маршрут ұсыну" android:textSize="16sp" android:textColor="#FFF" android:backgroundTint="#1565C0" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnDelete" android:text="🗑️ Тазалау" android:textSize="16sp" android:textColor="#FFF" android:backgroundTint="#1E88E5" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnLocation" android:text="🗺️ Көк-Төбені картадан ашу" android:textSize="16sp" android:textColor="#FFF" android:backgroundTint="#42A5F5" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnLink" android:text="🔗 Visit Almaty сайты" android:textSize="16sp" android:textColor="#FFF" android:backgroundTint="#64B5F6" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnTools" android:text="📱 Экстра мүмкіндіктер" android:textSize="16sp" android:textColor="#FFF" android:backgroundTint="#1565C0" android:layout_marginBottom="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvOutput" android:text="🧾 Қонақ ақпараты:" android:textColor="#0D47A1" android:textSize="17sp" android:textStyle="bold" android:layout_marginTop="12dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvSchedule" android:text="🗺️ Маршрут осы жерде шығады." android:textColor="#1A237E" android:textSize="15sp" android:background="#FFFFFF" android:padding="14dp" android:elevation="3dp" android:layout_marginTop="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="400dp" android:layout_marginTop="20dp" android:background="#FFFFFF" android:elevation="2dp" android:padding="4dp" /> <TextView android:id="@+id/tvTime" android:text="⏰ Уақыт есептелуде..." android:textSize="16sp" android:textColor="#0D47A1" android:gravity="center" android:layout_marginTop="16dp" android:padding="10dp" android:background="#E3F2FD" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="2dp" /> </LinearLayout> </ScrollView>

7) res/layout/<tools экраны>.xml

(Екінші ScrollView — экстра функцияларды туризмге бейімдедім. Id-лер сол күйі.)

xml
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F4F9FF" android:padding="18dp"> <LinearLayout android:orientation="vertical" android:gravity="center_horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/btnWeather" android:text="🌤️ Ауа райын тексеру (Алматы)" android:backgroundTint="#1565C0" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnDistance" android:text="📍 Көк-Төбеге дейінгі қашықтық" android:backgroundTint="#1E88E5" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvDistance" android:text="Қашықтық: анықталмады" android:textColor="#0D47A1" android:textSize="16sp" android:layout_marginTop="6dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:text="💸 Күндік шығынды есептеу (4 сан енгізіңіз)" android:textStyle="bold" android:textSize="18sp" android:textColor="#0D47A1" android:layout_marginTop="16dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:orientation="horizontal" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp"> <EditText android:id="@+id/etGrade1" android:hint="Шығын 1" android:inputType="numberDecimal" android:layout_weight="1" android:layout_margin="4dp" android:padding="10dp" android:background="@drawable/edittext_bg_blue" android:layout_width="0dp" android:layout_height="wrap_content" /> <EditText android:id="@+id/etGrade2" android:hint="Шығын 2" android:inputType="numberDecimal" android:layout_weight="1" android:layout_margin="4dp" android:padding="10dp" android:background="@drawable/edittext_bg_blue" android:layout_width="0dp" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="4dp"> <EditText android:id="@+id/etGrade3" android:hint="Шығын 3" android:inputType="numberDecimal" android:layout_weight="1" android:layout_margin="4dp" android:padding="10dp" android:background="@drawable/edittext_bg_blue" android:layout_width="0dp" android:layout_height="wrap_content" /> <EditText android:id="@+id/etGrade4" android:hint="Шығын 4" android:inputType="numberDecimal" android:layout_weight="1" android:layout_margin="4dp" android:padding="10dp" android:background="@drawable/edittext_bg_blue" android:layout_width="0dp" android:layout_height="wrap_content" /> </LinearLayout> <Button android:id="@+id/btnGpa" android:text="📘 Орташа күндік шығынды есептеу" android:backgroundTint="#42A5F5" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvGpaResult" android:text="📊 Нәтиже мұнда шығады" android:textSize="16sp" android:textColor="#0D47A1" android:layout_marginTop="6dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnReminder" android:text="⏰ Серуен еске салғышын қою" android:backgroundTint="#64B5F6" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="12dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:text="📄 Туристік PDF сілтемесін енгіз:" android:textColor="#1565C0" android:textSize="17sp" android:layout_marginTop="12dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <EditText android:id="@+id/etPdfUrl" android:hint="https://.../almaty_guide.pdf" android:layout_marginTop="4dp" android:inputType="textUri" android:padding="10dp" android:background="@drawable/edittext_bg_blue" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnPdf" android:text="📘 PDF ашу" android:backgroundTint="#1E88E5" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnDarkMode" android:text="🌙 Түнгі режим" android:backgroundTint="#0D47A1" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="12dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btnBack" android:text="↩️ Артқа қайту" android:backgroundTint="#90CAF9" android:textColor="#FFFFFF" android:textSize="16sp" android:layout_marginTop="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvWeather" android:text="🌤️ Ауа райы мұнда көрсетіледі" android:textSize="17sp" android:textColor="#0D47A1" android:gravity="center" android:layout_marginTop="12dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </ScrollView>

Ескерту: ToolsActivity ішіндегі calculateGPA() функциясы атауын өзгертпей-ақ қолдануға болады — ол енді 4 мәннің орташа күндік шығынын есептейді (мәтіндері ғана өзгертілді). Сол сияқты setReminder(), openPdfFromInternet(), toggleDarkMode() туризм контекстіне лайықталды.


8) res/drawable/edittext_bg_blue.xml

(Өзгеріссіз қалды – тек әдемі қоршау.)


9) assets/places.json (үлгі)

(Котлин бөлігі “ең жақын нысанды” табады. Файл аты/орны сол.)

json
[ {"name": "Көк-Төбе", "type": "sight", "lat": 43.23022, "lon": 76.95417, "address": "Көк-Төбе паркі"}, {"name": "Медеу", "type": "nature", "lat": 43.1975, "lon": 77.0546, "address": "Медеу мұз айдыны"}, {"name": "Қастеев музейі", "type": "museum", "lat": 43.2389, "lon": 76.9150, "address": "Көктем-3"}, {"name": "Arbat жаяу жүргіншілер көшесі", "type": "walk", "lat": 43.2586, "lon": 76.9457, "address": "Жібек жолы"} ]

Осы код негізінде drowio - файлы ретінде блок схема және URL диаграмма құрып жібер

Gedanke

Thought for 35s

Antwort

Тамаша! Екі draw.io (diagrams.net) диаграммасын жасадым:

Екеуі де .drawio форматында, diagrams.net ішінде бірден ашылады (көп бет емес, әр файлда бір бет). Егер қосымша бет, стиль не белгілеулер (icons, swimlane т.б.) керек болса — айтыңыз, реттеп берем.

Diesen Q&A teilen